-
-
Notifications
You must be signed in to change notification settings - Fork 401
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add example for data structures (#595)
- Loading branch information
1 parent
452cab7
commit 96529d3
Showing
5 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
* { | ||
all: unset; | ||
} | ||
|
||
.layout { | ||
padding: 8px; | ||
border: 1px solid black; | ||
border-radius: 4px; | ||
background-color: bisque; | ||
font-size: 16px; | ||
color: black; | ||
} | ||
|
||
.animalLayout { | ||
margin: 0 4px; | ||
} | ||
|
||
.animal { | ||
font-size: 24px; | ||
transition: 0.2s; | ||
border-radius: 4px; | ||
background-color: rgba(0, 0, 0, 0); | ||
border: 0 solid lightcoral; | ||
} | ||
|
||
.animal.selected { | ||
background-color: rgba(0, 0, 0, 0.2); | ||
border-width: 2px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
(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) | ||
) |