diff options
Diffstat (limited to 'examples/container-with-vitest/src')
6 files changed, 74 insertions, 0 deletions
diff --git a/examples/container-with-vitest/src/components/Card.astro b/examples/container-with-vitest/src/components/Card.astro new file mode 100644 index 000000000..a7e49f41c --- /dev/null +++ b/examples/container-with-vitest/src/components/Card.astro @@ -0,0 +1,8 @@ +--- + +--- + +<div> + This is a card + <slot /> +</div> diff --git a/examples/container-with-vitest/src/components/Counter.jsx b/examples/container-with-vitest/src/components/Counter.jsx new file mode 100644 index 000000000..2148bf3d8 --- /dev/null +++ b/examples/container-with-vitest/src/components/Counter.jsx @@ -0,0 +1,14 @@ +import { useState } from 'react'; + +export default function({ initialCount }) { + const [count, setCount] = useState(initialCount || 0); + return ( + <div className="rounded-t-lg overflow-hidden border-t border-l border-r border-gray-400 text-center p-4"> + <h2 className="font-semibold text-lg">Counter</h2> + <h3 className="font-medium text-lg">Count: {count}</h3> + <button + className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded" + onClick={() => setCount(count + 1)}>Increment</button> + </div> + ) +} diff --git a/examples/container-with-vitest/src/components/ReactWrapper.astro b/examples/container-with-vitest/src/components/ReactWrapper.astro new file mode 100644 index 000000000..73ac6baeb --- /dev/null +++ b/examples/container-with-vitest/src/components/ReactWrapper.astro @@ -0,0 +1,5 @@ +--- +import Counter from './Counter.jsx'; +--- + +<Counter initialCount={5} /> diff --git a/examples/container-with-vitest/src/pages/[locale].astro b/examples/container-with-vitest/src/pages/[locale].astro new file mode 100644 index 000000000..b76d36d39 --- /dev/null +++ b/examples/container-with-vitest/src/pages/[locale].astro @@ -0,0 +1,20 @@ +--- +export function getStaticPaths() { + return [{ params: { locale: 'en' } }]; +} +const { locale } = Astro.params; +--- + +<html lang="en"> + <head> + <meta charset="utf-8" /> + <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> + <meta name="viewport" content="width=device-width" /> + <meta name="generator" content={Astro.generator} /> + <title>Astro</title> + </head> + <body> + <h1>Astro</h1> + <p>Locale: {locale}</p> + </body> +</html> diff --git a/examples/container-with-vitest/src/pages/api.ts b/examples/container-with-vitest/src/pages/api.ts new file mode 100644 index 000000000..c30def5bb --- /dev/null +++ b/examples/container-with-vitest/src/pages/api.ts @@ -0,0 +1,11 @@ +export function GET() { + const json = { + foo: 'bar', + number: 1, + }; + return new Response(JSON.stringify(json), { + headers: { + 'content-type': 'application/json', + }, + }); +} diff --git a/examples/container-with-vitest/src/pages/index.astro b/examples/container-with-vitest/src/pages/index.astro new file mode 100644 index 000000000..2d1410736 --- /dev/null +++ b/examples/container-with-vitest/src/pages/index.astro @@ -0,0 +1,16 @@ +--- + +--- + +<html lang="en"> + <head> + <meta charset="utf-8" /> + <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> + <meta name="viewport" content="width=device-width" /> + <meta name="generator" content={Astro.generator} /> + <title>Astro</title> + </head> + <body> + <h1>Astro</h1> + </body> +</html> |