deno.land / x / fresh@1.1.1 / www / islands / Counter.tsx

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { useState } from "preact/hooks";import { IS_BROWSER } from "$fresh/runtime.ts";import { RoundedButton } from "../components/Button.tsx";import { IconMinus, IconPlus } from "../components/Icons.tsx";
interface CounterProps { start: number;}
export default function Counter(props: CounterProps) { const [count, setCount] = useState(props.start); return ( <div class="bg-gray-100 p-4 border border-gray-200 flex items-center justify-around"> <RoundedButton title="Subtract 1" onClick={() => setCount(count - 1)} disabled={!IS_BROWSER || count <= 0} > <IconMinus /> </RoundedButton> <div class="text-3xl tabular-nums">{count}</div> <RoundedButton title="Add 1" onClick={() => setCount(count + 1)} disabled={!IS_BROWSER} > <IconPlus /> </RoundedButton> </div> );}
fresh

Version Info

Tagged at
a year ago