eww/examples/data-structures/eww.yuck
2024-08-25 16:24:31 +02:00

73 lines
1.2 KiB
Text

(defvar stringArray `[
"🦝",
"🐱",
"🐵",
"🦁",
"🐹",
"🦊"
]`)
(defvar object `{
"🦝": "racoon",
"🐱": "cat",
"🐵": "ape",
"🦁": "lion",
"🐹": "hamster",
"🦊": "fox"
}`)
; You could also create an array of objects:
; (defvar objectArray `[{ "emoji": "🦝", "name": "racoon" }, { "emoji": "🦊", "name": "fox" }]`)
(defvar selected `🦝`)
(defwidget animalButton [emoji]
(box
:class "animalLayout"
(eventbox
:class `animal ${selected == emoji ? "selected" : ""}`
:cursor "pointer"
:onhover "eww update selected=${emoji}"
emoji
)
)
)
(defwidget animalRow []
(box
:class "animals"
:orientation "horizontal"
:halign "center"
(for animal in stringArray
(animalButton
:emoji animal
)
)
)
)
(defwidget currentAnimal []
(box
`${object[selected]} ${selected}`
)
)
(defwidget layout []
(box
:class "layout"
:orientation "vertical"
:halign "center"
(animalRow)
(currentAnimal)
)
)
(defwindow data-structures
:monitor 0
:exclusive false
:focusable false
:geometry (geometry
:anchor "center"
)
(layout)
)