diff --git a/experimental/chatproto3/.gitignore b/experimental/chatproto3/.gitignore new file mode 100644 index 0000000..16d54bb --- /dev/null +++ b/experimental/chatproto3/.gitignore @@ -0,0 +1,24 @@ +# build output +dist/ +# generated types +.astro/ + +# dependencies +node_modules/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* + + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store + +# jetbrains setting folder +.idea/ diff --git a/experimental/chatproto3/.vscode/extensions.json b/experimental/chatproto3/.vscode/extensions.json new file mode 100644 index 0000000..22a1505 --- /dev/null +++ b/experimental/chatproto3/.vscode/extensions.json @@ -0,0 +1,4 @@ +{ + "recommendations": ["astro-build.astro-vscode"], + "unwantedRecommendations": [] +} diff --git a/experimental/chatproto3/.vscode/launch.json b/experimental/chatproto3/.vscode/launch.json new file mode 100644 index 0000000..d642209 --- /dev/null +++ b/experimental/chatproto3/.vscode/launch.json @@ -0,0 +1,11 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "command": "./node_modules/.bin/astro dev", + "name": "Development server", + "request": "launch", + "type": "node-terminal" + } + ] +} diff --git a/experimental/chatproto3/README.md b/experimental/chatproto3/README.md new file mode 100644 index 0000000..f036afa --- /dev/null +++ b/experimental/chatproto3/README.md @@ -0,0 +1,13 @@ +# Astro + React Example + +```sh +npm create astro@latest -- --template framework-react +``` + +[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/framework-react) +[](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/framework-react) +[](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/framework-react/devcontainer.json) + +This example showcases Astro working with [React](https://react.dev). + +Write your React components as `.jsx` or `.tsx` files in your project. diff --git a/experimental/chatproto3/astro.config.mjs b/experimental/chatproto3/astro.config.mjs new file mode 100644 index 0000000..b3294ee --- /dev/null +++ b/experimental/chatproto3/astro.config.mjs @@ -0,0 +1,10 @@ +// @ts-check + +import react from '@astrojs/react'; +import { defineConfig } from 'astro/config'; + +// https://astro.build/config +export default defineConfig({ + // Enable React to support React JSX components. + integrations: [react()], +}); diff --git a/experimental/chatproto3/package.json b/experimental/chatproto3/package.json new file mode 100644 index 0000000..6170e5a --- /dev/null +++ b/experimental/chatproto3/package.json @@ -0,0 +1,19 @@ +{ + "name": "", + "type": "module", + "version": "0.0.1", + "scripts": { + "dev": "astro dev", + "build": "astro build", + "preview": "astro preview", + "astro": "astro" + }, + "dependencies": { + "@astrojs/react": "^4.4.2", + "@types/react": "^18.3.27", + "@types/react-dom": "^18.3.7", + "astro": "^5.16.8", + "react": "^18.3.1", + "react-dom": "^18.3.1" + } +} \ No newline at end of file diff --git a/experimental/chatproto3/public/favicon.svg b/experimental/chatproto3/public/favicon.svg new file mode 100644 index 0000000..f157bd1 --- /dev/null +++ b/experimental/chatproto3/public/favicon.svg @@ -0,0 +1,9 @@ + diff --git a/experimental/chatproto3/src/components/Counter.css b/experimental/chatproto3/src/components/Counter.css new file mode 100644 index 0000000..fb21044 --- /dev/null +++ b/experimental/chatproto3/src/components/Counter.css @@ -0,0 +1,11 @@ +.counter { + display: grid; + font-size: 2em; + grid-template-columns: repeat(3, minmax(0, 1fr)); + margin-top: 2em; + place-items: center; +} + +.counter-message { + text-align: center; +} diff --git a/experimental/chatproto3/src/components/Counter.tsx b/experimental/chatproto3/src/components/Counter.tsx new file mode 100644 index 0000000..cc416d3 --- /dev/null +++ b/experimental/chatproto3/src/components/Counter.tsx @@ -0,0 +1,25 @@ +import { useState } from 'react'; +import './Counter.css'; + +export default function Counter({ + children, + count: initialCount, +}: { + children: JSX.Element; + count: number; +}) { + const [count, setCount] = useState(initialCount); + const add = () => setCount((i) => i + 1); + const subtract = () => setCount((i) => i - 1); + + return ( + <> +
{count}
+
+