From e586d7d704d475afe3373a1de6ae20d504f79d6d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 5 Jun 2025 14:25:23 +0000 Subject: Sync from a8e1c0a7402940e0fc5beef669522b315052df1b --- .../framework-react/src/components/Counter.css | 11 +++++++ .../framework-react/src/components/Counter.tsx | 25 +++++++++++++++ examples/framework-react/src/pages/index.astro | 36 ++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 examples/framework-react/src/components/Counter.css create mode 100644 examples/framework-react/src/components/Counter.tsx create mode 100644 examples/framework-react/src/pages/index.astro (limited to 'examples/framework-react/src') diff --git a/examples/framework-react/src/components/Counter.css b/examples/framework-react/src/components/Counter.css new file mode 100644 index 000000000..fb21044d7 --- /dev/null +++ b/examples/framework-react/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/examples/framework-react/src/components/Counter.tsx b/examples/framework-react/src/components/Counter.tsx new file mode 100644 index 000000000..cc416d3f1 --- /dev/null +++ b/examples/framework-react/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}
+ +
+
{children}
+ + ); +} diff --git a/examples/framework-react/src/pages/index.astro b/examples/framework-react/src/pages/index.astro new file mode 100644 index 000000000..5bc1f8d36 --- /dev/null +++ b/examples/framework-react/src/pages/index.astro @@ -0,0 +1,36 @@ +--- +// Component Imports +import Counter from '../components/Counter'; +const someProps = { + count: 0, +}; + +// Full Astro Component Syntax: +// https://docs.astro.build/basics/astro-components/ +--- + + + + + + + + + + +
+ +

Hello, React!

+
+
+ + -- cgit v1.2.3