MCPcopy Create free account
hub / github.com/NativeScript/template-macos-solid / Counter

Function Counter

src/examples/counter.tsx:3–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1import { createSignal } from "npm:solid-js";
2
3export function Counter() {
4 const [count, setCount] = createSignal(0);
5
6 return (
7 <view
8 style={{
9 flexDirection: "row",
10 gap: 15,
11 alignItems: "center",
12 }}
13 >
14 <button
15 onClick={() => setCount(Math.max(count() - 1, 0))}
16 style={{
17 borderRadius: 5,
18 padding: 10,
19 fontSize: 20,
20 }}
21 bezelStyle={NSBezelStyle.TexturedSquare}
22 >
23 -
24 </button>
25
26 <text
27 style={{
28 fontSize: 24,
29 }}
30 >
31 {count()}
32 </text>
33
34 <button
35 onClick={() => setCount(count() + 1)}
36 style={{
37 borderRadius: 5,
38 padding: 10,
39 fontSize: 20,
40 }}
41 bezelStyle={NSBezelStyle.TexturedSquare}
42 >
43 +
44 </button>
45 </view>
46 );
47}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected