mirror of
https://github.com/kennethnym/jrx.git
synced 2026-03-20 20:01:19 +00:00
- Fix increment button: custom action handler instead of no-op setState - Toggle visibility on Show/Hide Details button via $cond - Input uses $bindState + useBoundProp for two-way binding - Add shiki syntax highlighting (catppuccin-latte/mocha dual theme) - Dark mode via prefers-color-scheme with CSS variables - Layout: Live UI left, JSX Source + JSON Output stacked right Co-authored-by: Ona <no-reply@ona.com>
71 lines
1.5 KiB
TypeScript
71 lines
1.5 KiB
TypeScript
/** @jsxImportSource jrx */
|
|
import { render } from "jrx";
|
|
import { Stack, Card, Text, Button, Input } from "../components";
|
|
|
|
export const fullSpec = render(
|
|
<Stack>
|
|
<Card title="Counter">
|
|
<Text content={{ $state: "/count" }} />
|
|
<Button
|
|
label="Increment"
|
|
on={{
|
|
press: {
|
|
action: "increment",
|
|
params: { statePath: "/count" },
|
|
},
|
|
}}
|
|
/>
|
|
</Card>
|
|
|
|
<Card title="Toggle Details">
|
|
<Button
|
|
label={{
|
|
$cond: { $state: "/showDetails", eq: true },
|
|
$then: "Hide Details",
|
|
$else: "Show Details",
|
|
}}
|
|
on={{
|
|
press: {
|
|
action: "setState",
|
|
params: {
|
|
statePath: "/showDetails",
|
|
value: {
|
|
$cond: { $state: "/showDetails", eq: true },
|
|
$then: false,
|
|
$else: true,
|
|
},
|
|
},
|
|
},
|
|
}}
|
|
/>
|
|
<Text
|
|
content="These are the hidden details!"
|
|
visible={{ $state: "/showDetails", eq: true }}
|
|
/>
|
|
</Card>
|
|
|
|
<Card title="Watched Input">
|
|
<Input
|
|
placeholder="Type a country..."
|
|
value={{ $bindState: "/country" }}
|
|
/>
|
|
<Text
|
|
content={{ $state: "/country" }}
|
|
watch={{
|
|
"/country": {
|
|
action: "logCountry",
|
|
params: { country: { $state: "/country" } },
|
|
},
|
|
}}
|
|
/>
|
|
</Card>
|
|
</Stack>,
|
|
{
|
|
state: {
|
|
count: 0,
|
|
showDetails: false,
|
|
country: "",
|
|
},
|
|
}
|
|
);
|