Skip to content

Commit 48631a0

Browse files
committed
toggle bottom bar
1 parent 02e1e2d commit 48631a0

File tree

1 file changed

+50
-21
lines changed

1 file changed

+50
-21
lines changed

src/main/ui/render_comp/bottom_bar.cljs

Lines changed: 50 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,61 @@
22
(:require [applied-science.js-interop :as j]
33
["@blueprintjs/core" :as bp :refer [Checkbox Tooltip HTMLSelect Button ButtonGroup Card Slider Divider Menu MenuItem Popover MenuDivider]]
44
[ui.components.bottom-bar :as bcomp :refer [bottom-bar-buttons]]
5-
[ui.utils :refer [p]]
5+
[ui.utils :refer [p button-with-tooltip]]
6+
[reagent.core :as r]
67
[reagent.dom :as rd]))
78

89

9-
(defn bottom-bar []
10-
[:div.bottom-bar
11-
{:style {:display "flex"
12-
:flex-direction "row"
13-
:background-color "#eeebeb"
14-
:justify-content "center"
15-
:font-size "10px"
16-
:padding-right "11px"
17-
:align-items "center"
18-
:border "1px"}}
19-
[bottom-bar-buttons]])
10+
(defn bottom-bar [show?]
11+
(fn []
12+
(when @show?
13+
[:div.bottom-bar
14+
{:style {:display "flex"
15+
:flex-direction "row"
16+
:background-color "#eeebeb"
17+
:justify-content "center"
18+
:font-size "10px"
19+
:padding-right "11px"
20+
:align-items "center"
21+
:border "1px"}}
22+
[bottom-bar-buttons]])))
23+
24+
25+
(defn bottom-bar-toggle [toggle-atom]
26+
[:div.bottom-bar-toggle-button-div
27+
[button-with-tooltip
28+
"Toggle llm bottom bar."
29+
[:> Button
30+
{:class-name "bottom-bar-toggle-button"
31+
:icon "widget-footer"
32+
:minimal true
33+
:tabIndex 0
34+
:small true
35+
:on-click (fn []
36+
(do
37+
(swap! toggle-atom not)
38+
(println "toggle bottom bar")))}]]])
39+
2040

2141
(defn bottom-bar-main []
2242
(p "Creating bottom bar")
2343
(let [parent-el (.querySelector js/document ".roam-body")
2444
new-child (.createElement js/document "div")
25-
already-present? (.querySelector js/document ".llm-bottom-bar")]
26-
(set! (.-className new-child) "llm-bottom-bar")
27-
(.appendChild parent-el new-child)
28-
(rd/render [bottom-bar] new-child)
29-
(when (and
30-
(nil? already-present?)
31-
parent-el)
32-
(j/assoc-in! parent-el [:style :display] "flex")
33-
(j/assoc-in! parent-el [:style :flex-direction] "column"))))
45+
already-present? (.querySelector js/document ".llm-bottom-bar")
46+
show-bottom-bar? (r/atom true)
47+
48+
top-bar (.querySelector js/document ".rm-topbar")
49+
new-icon (.createElement js/document "div")]
50+
(println "show bottom bar" @show-bottom-bar?)
51+
(set! (.-className new-child) "llm-bottom-bar")
52+
(set! (.-className new-icon) "llm-bottom-bar-toggle")
53+
(.appendChild parent-el new-child)
54+
(.appendChild top-bar new-icon)
55+
(rd/render [bottom-bar show-bottom-bar?] new-child)
56+
(rd/render [bottom-bar-toggle show-bottom-bar?] new-icon)
57+
(when (and
58+
(nil? already-present?)
59+
parent-el)
60+
(j/assoc-in! parent-el [:style :display] "flex")
61+
(j/assoc-in! parent-el [:style :flex-direction] "column"))))
62+

0 commit comments

Comments
 (0)