dreamstack/examples/streaming-mood.ds

34 lines
926 B
Text
Raw Permalink Normal View History

-- DreamStack Streaming Mood
-- Interactive mood and energy tracker.
-- Only mood, energy, color are exposed (clicks is internal).
--
-- Run with:
-- dreamstack stream examples/streaming-mood.ds --port 3004
let mood = "neutral"
let energy = 50
let color = "gray"
let clicks = 0
stream mood_tracker on "ws://localhost:9100/peer/mood" {
mode: signal,
output: mood, energy, color
}
view mood_tracker =
column [
text "😊 Mood Tracker"
text "Mood: {mood}"
text "Energy: {energy}%"
text "Color: {color}"
row [
button "😄 Happy" { click: mood = "happy"; color = "green"; energy += 10 }
button "😐 Neutral" { click: mood = "neutral"; color = "gray" }
button "😤 Angry" { click: mood = "angry"; color = "red"; energy -= 10 }
]
row [
button "☕ Caffeine" { click: energy += 25; clicks += 1 }
button "😴 Rest" { click: energy -= 15; clicks += 1 }
]
]