|
| 1 | +// oxlint-disable bombshell-dev/exported-function-async -- Solid components render synchronously. |
| 2 | +import { fixed, grow, percent } from '@bomb.sh/tty'; |
| 3 | +import { type JSXElement, rgba } from '@clack/ui-solid'; |
| 4 | +import { createSignal } from 'solid-js'; |
| 5 | + |
| 6 | +/** Render the interactive hello-world example. */ |
| 7 | +export function HelloWorld(): JSXElement { |
| 8 | + const [say, setSay] = createSignal('Hello'); |
| 9 | + const [to, setTo] = createSignal('World'); |
| 10 | + |
| 11 | + return ( |
| 12 | + <box |
| 13 | + layout={{ |
| 14 | + direction: 'ttb', |
| 15 | + gap: 1, |
| 16 | + padding: { top: 1, bottom: 1, left: 2, right: 2 }, |
| 17 | + width: fixed(40), |
| 18 | + }} |
| 19 | + border={{ color: blue, top: 1, right: 1, bottom: 1, left: 1 }} |
| 20 | + > |
| 21 | + <text color={cyan}> |
| 22 | + {say()}, {to()}! |
| 23 | + </text> |
| 24 | + <box layout={{ direction: 'ttb', width: grow() }}> |
| 25 | + <box layout={{ direction: 'ltr', gap: 1, width: grow() }}> |
| 26 | + <box layout={{ width: percent(0.3) }}> |
| 27 | + <text color={gray}>say:</text> |
| 28 | + </box> |
| 29 | + <box layout={{ width: percent(0.3) }}> |
| 30 | + <text color={gray}>to:</text> |
| 31 | + </box> |
| 32 | + </box> |
| 33 | + <box layout={{ direction: 'ltr', gap: 1, width: grow() }}> |
| 34 | + <input onInput={(event) => setSay(event.value)} /> |
| 35 | + <input onInput={(event) => setTo(event.value)} /> |
| 36 | + </box> |
| 37 | + </box> |
| 38 | + </box> |
| 39 | + ); |
| 40 | +} |
| 41 | + |
| 42 | +const blue = rgba(0, 0, 238); |
| 43 | +const cyan = rgba(0, 205, 205); |
| 44 | +const gray = rgba(127, 127, 127); |
0 commit comments