-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
page.cljs
52 lines (49 loc) · 1.99 KB
/
page.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
(ns frontend.page
(:require [rum.core :as rum]
[frontend.state :as state]
[frontend.ui :as ui]
[frontend.components.sidebar :as sidebar]
[frontend.context.i18n :as i18n]))
(rum/defc route-view
[view route-match]
(view route-match))
(rum/defc current-page < rum/reactive
{:did-mount (fn [state]
(state/set-root-component! (:rum/react-component state))
(state/setup-electron-updater!)
(ui/inject-document-devices-envs!)
(ui/inject-dynamic-style-node!)
(let [teardown-fn (comp (ui/setup-patch-ios-fixed-bottom-position!))]
(assoc state ::teardown teardown-fn)))
:will-unmount (fn [state]
(let [teardown (::teardown state)]
(when-not (nil? teardown)
(teardown))))}
[]
(when-let [route-match (state/sub :route-match)]
(i18n/tongue-provider
(let [route-name (get-in route-match [:data :name])]
(if-let [view (:view (:data route-match))]
(if (= :draw route-name)
(view route-match)
(sidebar/sidebar
route-match
(view route-match)))
;; FIXME: disable for now
;; (let [route-name (get-in route-match [:data :name])
;; no-animate? (contains? #{:repos :repo-add :file}
;; route-name)]
;; (when-let [view (:view (:data route-match))]
;; (sidebar/sidebar
;; route-match
;; (if no-animate?
;; (route-view view route-match)
;; (ui/transition-group
;; {:class-name "router-wrapper"}
;; (ui/css-transition
;; {:class-names "pageChange"
;; :key route-name
;; :timeout {:enter 300
;; :exit 200}}
;; (route-view view route-match)))))))
[:div "404 Page"])))))