feat: a new "island" based architechture (#97)

This commit is contained in:
Luca Casonato
2022-03-04 19:49:27 +01:00
committed by GitHub
parent d441bf2489
commit 8daa280862
70 changed files with 820 additions and 972 deletions
+34
View File
@@ -0,0 +1,34 @@
/** @jsx h */
import { h, IS_BROWSER, tw, useState } from "../client_deps.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={tw
`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}
>
<IconMinus />
</RoundedButton>
<div class={tw`text-3xl`}>{count}</div>
<RoundedButton
title="Add 1"
onClick={() => setCount(count + 1)}
disabled={!IS_BROWSER}
>
<IconPlus />
</RoundedButton>
</div>
);
}