homeman-deno/islands/Counter.tsx

17 lines
437 B
TypeScript
Raw Normal View History

2024-01-05 13:22:56 -06:00
import type { Signal } from '@preact/signals'
import { Button } from '../components/Button.tsx'
interface CounterProps {
count: Signal<number>
}
export default function Counter(props: CounterProps) {
return (
<div class='flex gap-8 py-6'>
<Button onClick={() => props.count.value -= 1}>-1</Button>
<p class='text-3xl tabular-nums'>{props.count}</p>
<Button onClick={() => props.count.value += 1}>+1</Button>
</div>
)
}