Skip to content

Commit

Permalink
Making excalidraw follow the theme of logseq. (basic 'dark' 'light' t…
Browse files Browse the repository at this point in the history
…heming)
  • Loading branch information
andrewzhurov authored and tiensonqin committed Jun 13, 2022
1 parent de9ab5e commit 1c87fd2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main/frontend/extensions/excalidraw.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
(recur (.-parentNode el))))
state))

(defn excalidraw-theme [ui-theme]
;; One of these constants are meant to be used as a 'theme' argument for escalidraw:
;; https://github.com/excalidraw/excalidraw/blob/master/src/constants.ts#L75
;; But they are missing from the prod build of excalidraw we're using.
;; They map to "light" and "dark", happens that :ui/theme uses same values, so we are safe to pass it directly, for now.
;; Escalidraw may migrate to different values for these constants in future versions,
;; so, in order to not watch out for it every time we bump a new version we better migrate to constants as soon as they appear in a prod build.
ui-theme)

(rum/defcs draw-inner < rum/reactive
(rum/local 800 ::draw-width)
(rum/local true ::zen-mode?)
Expand Down Expand Up @@ -105,7 +114,8 @@
:zen-mode-enabled @*zen-mode?
:view-mode-enabled @*view-mode?
:grid-mode-enabled @*grid-mode?
:initial-data data}))]])))
:initial-data data
:theme (excalidraw-theme (state/sub :ui/theme))}))]])))

(rum/defcs draw-container < rum/reactive
{:init (fn [state]
Expand Down

0 comments on commit 1c87fd2

Please sign in to comment.