nandi/jolt-nativepublic Fork 0
789bb134c91bfdee346df2dc9656bf2e7f9bbd1a
Commits
Clone
git clone https://git.rickub.com/nandi/jolt-native.git
git clone ssh://git@rickub.com/nandi/jolt-native.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

counter.clj · 31 lines · 1.3 KBClojure Blame HistoryRaw
Paint glimmer with nothing under it f554a01 nandi 11d ago1(ns glimmer-gfx.counter
2 "The glimmer counter, rendered by gfx's own rasterizer.
3
4 Compare examples/ in glimmer-vidya: the component is the same shape, because
5 the component never knew which backend it had."
6 (:require [glimmer.ratom :as ra]
7 [glimmer.core :as ui]
8 [glimmer-gfx.core])) ; installs the backend
9
10(def state (ra/atom {:count 0 :volume 40 :loud? false}))
11
12(defn app []
13 (let [{:keys [count volume loud?]} (ra/deref state)]
14 [:page {:max-width 440}
15 [:card {:spacing 8}
16 [:title {:label "Counter"}]
17 [:label {:label (str "Count: " count)}]
18 [:hbox {:spacing 8}
19 [:button {:label "- 1" :on-click #(ra/swap! state update :count dec)}]
20 [:button {:label "+ 1" :kind :primary
21 :on-click #(ra/swap! state update :count inc)}]
22 [:button {:label "reset" :on-click #(ra/swap! state assoc :count 0)}]]
23 [:spacer {:size 6}]
24 [:label {:label "Volume" :dim true}]
25 [:slider {:value volume :min 0 :max 100
26 :on-change #(ra/swap! state assoc :volume (long %))}]
27 [:checkbox {:label "loud" :checked loud?
28 :on-click #(ra/swap! state update :loud? not)}]]]))
29
30(defn -main [& _]
31 (ui/run app :title "glimmer-gfx" :width 480 :height 340))