소스 검색

fix: theme

Tienson Qin 4 달 전
부모
커밋
dbf46ed303
2개의 변경된 파일13개의 추가작업 그리고 2개의 파일을 삭제
  1. 13 1
      src/main/capacitor/components/app.cljs
  2. 0 1
      src/main/frontend/mobile/action_bar.cljs

+ 13 - 1
src/main/capacitor/components/app.cljs

@@ -210,8 +210,20 @@
      (shui-popup/install-popups))))
 
 (rum/defc main []
-  (let [current-repo (frum/use-atom-in fstate/state :git/current-repo)]
+  (let [current-repo (frum/use-atom-in fstate/state :git/current-repo)
+        ;; TODO: support dark theme
+        theme "light"]
     ;; global
+    (hooks/use-effect!
+     #(let [^js doc js/document.documentElement
+            ^js cls (.-classList doc)
+            ^js cls-body (.-classList js/document.body)]
+        (.setAttribute doc "data-theme" theme)
+        (if (= theme "dark") ;; for tailwind dark mode
+          (do (.add cls "dark") (doto cls-body (.remove "light-theme") (.add "dark-theme")))
+          (do (.remove cls "dark") (doto cls-body (.remove "dark-theme") (.add "light-theme")))))
+     [theme])
+
     ;; why need this
     (hooks/use-effect!
      (fn []

+ 0 - 1
src/main/frontend/mobile/action_bar.cljs

@@ -38,7 +38,6 @@
      [:div.action-bar-commands
       (action-command "copy" "Copy" #(editor-handler/copy-selection-blocks false))
       (action-command "cut" "Cut" #(editor-handler/cut-selection-blocks true))
-      (action-command "trash" "Delete" #(editor-handler/cut-selection-blocks false))
       (action-command "registered" "Copy ref"
                       (fn [_event] (editor-handler/copy-block-refs)))
       (action-command "link" "Copy url"