diff options
| author | 2024-05-22 12:11:26 +0100 | |
|---|---|---|
| committer | 2024-05-22 12:11:26 +0100 | |
| commit | 12a1bccc818af292cdd2a8ed0f3e3c042b9819b4 (patch) | |
| tree | c031a014c1e68992aaf2419cb2f4355041b596cc /examples/container-with-vitest/src | |
| parent | a6916e4402bf5b7d74bab784a54eba63fd1d1179 (diff) | |
| download | astro-12a1bccc818af292cdd2a8ed0f3e3c042b9819b4.tar.gz astro-12a1bccc818af292cdd2a8ed0f3e3c042b9819b4.tar.zst astro-12a1bccc818af292cdd2a8ed0f3e3c042b9819b4.zip | |
feat: container APIs (#11051)
* feat: container APIs
* chore: handle runtime mode
* chore: render slots
* more prototyping
* Adding a changeset
* fix some weirdness around types
* feat: allow to inject the manifest
* feat: accept a manifest
* more APIs
* add `route` to the options
* chore
* fix component instance
* chore: document stuff
* remove commented code
* chore: add test for renderers and fixed its types
* fix: update name of the example
* fix regression inside tests
* use `experimental_`
* remove errors
* need to understand the types here
* remove some options that I don't deem necessary for this phase
* remove superfluous comments
* chore: remove useless `@ts-ignore` directive
* chore: address feedback
* fix regression and remove astro config
* chore: fix regression
* Apply suggestions from code review
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
* ooops
* restore changes
---------
Co-authored-by: Matthew Phillips <matthew@skypack.dev>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Diffstat (limited to '')
6 files changed, 75 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..776c82329 --- /dev/null +++ b/examples/container-with-vitest/src/components/Card.astro @@ -0,0 +1,7 @@ +--- + +--- +<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..55e5c186a --- /dev/null +++ b/examples/container-with-vitest/src/pages/[locale].astro @@ -0,0 +1,22 @@ +--- +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> | 
