-
-
Notifications
You must be signed in to change notification settings - Fork 81
/
viewer.cljs
74 lines (69 loc) · 2.24 KB
/
viewer.cljs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(ns portal-present.viewer
(:require [portal.colors :as c]
[portal.ui.api :as p]
[portal.ui.commands :as commands]
[portal.ui.icons :as icons]
[portal.ui.inspector :as ins]
[portal.ui.select :as select]
[portal.ui.state :as state]
[portal.ui.styled :as d]
[portal.ui.theme :as theme]
[reagent.core :as r]))
(commands/toggle-shell state/state)
(defn- button [{:keys [icon on-click]}]
(let [theme (theme/use-theme)]
[d/div
{:style
{:cursor :pointer
:padding (:padding theme)}
:style/hover {:color (::c/tag theme)}
:on-click (fn [e]
(.stopPropagation e)
(on-click))}
[icon]]))
(defn view-presentation []
(let [slide (r/atom 0)]
(fn [slides]
(let [theme (theme/use-theme)
background (ins/get-background)]
[d/div
{:style
{:background background
:padding (:padding theme)
:border-radius (:border-radius theme)
:border [1 :solid (::c/border theme)]}}
[d/div
{:style
{:padding-top 20
:min-height "50vh"}}
[select/with-position
{:row 0 :column 0}
[ins/with-key
@slide
[ins/dec-depth
[ins/inspector (nth (seq slides) @slide :no-slide)]]]]]
[d/div
{:style
{:display :flex
:align-items :center
:justify-content :space-between}}
[d/div
"Slide "
[d/span {:style {:color (::c/number theme)}} (inc @slide)]
" of "
[d/span {:style {:color (::c/number theme)}} (count slides)]]
[d/div
{:style {:display :flex}}
[button
{:icon icons/arrow-left
:on-click #(when (> @slide 0)
(swap! slide dec))}]
[button
{:icon icons/arrow-right
:on-click #(when (< (inc @slide) (count slides))
(swap! slide inc))}]]]]))))
(defn deck? [value] (and (coll? value) (not (map? value))))
(p/register-viewer!
{:name ::slides
:predicate deck?
:component view-presentation})