Skip to content

Commit 2676f74

Browse files
0.3.0
1 parent 80eb88c commit 2676f74

File tree

2 files changed

+39
-29
lines changed

2 files changed

+39
-29
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,9 @@ https://medium.com/@hebi_73682/fasttea-a-python-developers-quest-for-elegant-web
9595
**FastTEA: A Python Developer's Quest for Elegant Web Apps - Part 2**
9696
https://medium.com/@hebi_73682/fasttea-a-python-developers-quest-for-elegant-web-apps-part-2-a25fc77e09c3
9797

98+
**FastTEA: Behind the Scenes - Diving into JavaScript Integration - Part 3**
99+
https://medium.com/@hebi_73682/fasttea-behind-the-scenes-diving-into-javascript-integration-part-3-90f27d48b424
100+
98101
### Coming Soon!
99102

100103
We're constantly working to improve fastTEA and add new features. Here's a sneak peek at what's coming:

threejs_htmlbubble.py

+36-29
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
class CubeModel(Model):
99
color: str = "#ff0000" # Default red color
1010
rotation_speed: float = 1.0 # Default rotation speed
11+
first_time: bool = True # First time start
1112

1213

1314
# Initialize FastTEA app
@@ -148,22 +149,53 @@ def update(msg: Msg, model: CubeModel) -> tuple[CubeModel, Optional[Cmd]]:
148149
if msg.action == "changeColor":
149150
new_model = CubeModel(
150151
color=msg.value,
151-
rotation_speed=model.rotation_speed
152+
rotation_speed=model.rotation_speed,
153+
first_time=False
152154
)
153155
return new_model, Cmd(action="setColor", payload={"color": msg.value})
154156

155157
elif msg.action == "changeSpeed":
156158
speed = float(msg.value)
157159
new_model = CubeModel(
158160
color=model.color,
159-
rotation_speed=speed
161+
rotation_speed=speed,
162+
first_time=False
160163
)
161164
return new_model, Cmd(action="setSpeed", payload={"speed": speed})
162165

163166
return model, None
164167

165168

169+
166170
# View function
171+
def view_controlls(model: CubeModel) -> Element:
172+
# Controls card
173+
return card({"id":"view_controlls"}, [
174+
div({}, [
175+
label({"for": "colorPicker"}, "Cube Color:"),
176+
input_({
177+
"type": "color",
178+
"id": "colorPicker",
179+
"value": model.color,
180+
"onChange": "changeColor",
181+
"hx-target": "#view_controlls"
182+
}, [])
183+
]),
184+
div({"style": "margin-top: 1rem;"}, [
185+
label({"for": "speedSlider"}, f"Rotation Speed ({model.rotation_speed}x):"),
186+
input_({
187+
"type": "range",
188+
"id": "speedSlider",
189+
"min": "0",
190+
"max": "3",
191+
"step": "0.1",
192+
"value": str(model.rotation_speed),
193+
"onChange": "changeSpeed",
194+
"hx-target": "#view_controlls"
195+
""
196+
}, [])
197+
])
198+
])
167199
@app.view
168200
def view(model: CubeModel) -> Element:
169201
return container({}, [
@@ -180,33 +212,8 @@ def view(model: CubeModel) -> Element:
180212
}, [])
181213
])
182214
]),
183-
# Controls card
184-
card({}, [
185-
div({}, [
186-
label({"for": "colorPicker"}, "Cube Color:"),
187-
input_({
188-
"type": "color",
189-
"id": "colorPicker",
190-
"value": model.color,
191-
"onChange": "changeColor"
192-
}, [])
193-
]),
194-
div({"style": "margin-top: 1rem;"}, [
195-
label({"for": "speedSlider"}, f"Rotation Speed ({model.rotation_speed}x):"),
196-
input_({
197-
"type": "range",
198-
"id": "speedSlider",
199-
"min": "0",
200-
"max": "3",
201-
"step": "0.1",
202-
"value": str(model.rotation_speed),
203-
"onChange": "changeSpeed"
204-
}, [])
205-
])
206-
])
215+
view_controlls(model)
207216
])
208-
])
209-
210-
217+
]) if model.first_time else view_controlls(model)
211218

212219
app.run()

0 commit comments

Comments
 (0)