Skip to content

Commit 041b285

Browse files
committed
update unstyed
1 parent c388542 commit 041b285

File tree

16 files changed

+145
-12
lines changed

16 files changed

+145
-12
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.db
2+
*.py[cod]
3+
.web
4+
__pycache__/
15 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 13 additions & 0 deletions
Loading
Lines changed: 2 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# This file has been modified by the Nextpy Team in 2023 using AI tools and automation scripts.
2+
# We have rigorously tested these modifications to ensure reliability and performance. Based on successful test results, we are confident in the quality and stability of these changes.
3+
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import nextpy as xt
2+
3+
4+
class CounterState(xt.State):
5+
value: int = 0
6+
7+
def change_value(self, amount):
8+
self.value += amount
9+
10+
11+
def create_button(label, amount):
12+
return xt.unstyled.button(
13+
label,
14+
on_click=lambda: CounterState.change_value(amount)
15+
)
16+
17+
18+
def index() -> xt.Component:
19+
heading_color = xt.match(
20+
CounterState.value,
21+
(0, "red"),
22+
(4, "blue"),
23+
(8, "green"),
24+
(12, "orange"),
25+
(16, "lime"),
26+
(20, "orange"),
27+
"black"
28+
)
29+
30+
return xt.unstyled.flex(
31+
xt.unstyled.heading(
32+
CounterState.value,
33+
color="white",
34+
background_color=heading_color,
35+
as_="h2"
36+
),
37+
xt.unstyled.flex(
38+
create_button("decrement", -1),
39+
create_button("increment", 1),
40+
gap="2"
41+
),
42+
align_items="center",
43+
direction="column",
44+
gap="2"
45+
)
46+
47+
48+
# Global styles defined as a Python dictionary
49+
style = {
50+
"text_align": "center",
51+
}
52+
53+
app = xt.App(style=style)
54+
app.add_page(index)

0 commit comments

Comments
 (0)