mirror of
https://github.com/logseq/logseq.git
synced 2026-04-25 22:54:48 +00:00
feat: custom theme switching (#4741)
* feat: custom theme switching Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * chore: handle reset-custom-theme Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * fix: unregisterTheme Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * fix: format with ts-standard Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * chore: reset extra formats Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * chore: simplify array types Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * Update lsplugin.core.js * fix: sync upstream Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * chore: add `no mode` themes into panel Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * fix: ci Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * fix: remove first <hr /> Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * fix: lockfile Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * chore: update Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * chore: set-theme! => set-theme-mode! Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * fix: selectTheme Signed-off-by: Yue Yang <g1enyy0ung@gmail.com> * perf: reduce unnecessary logic Signed-off-by: Yue Yang <g1enyy0ung@gmail.com>
This commit is contained in:
@@ -364,9 +364,7 @@
|
||||
[pid]
|
||||
(when-let [themes (get (group-by :pid (:plugin/installed-themes @state/state)) pid)]
|
||||
(when-let [theme (first themes)]
|
||||
(let [theme-mode (:mode theme)]
|
||||
(and theme-mode (state/set-theme! theme-mode))
|
||||
(js/LSPluginCore.selectTheme (bean/->js theme))))))
|
||||
(js/LSPluginCore.selectTheme (bean/->js theme)))))
|
||||
|
||||
(defn update-plugin-settings-state
|
||||
[id settings]
|
||||
@@ -599,12 +597,22 @@
|
||||
(swap! state/state assoc :plugin/installed-themes
|
||||
(vec (mapcat (fn [[pid vs]] (mapv #(assoc % :pid pid) (bean/->clj vs))) (bean/->clj themes))))))
|
||||
|
||||
(.on "theme-selected" (fn [^js opts]
|
||||
(let [opts (bean/->clj opts)
|
||||
url (:url opts)
|
||||
mode (:mode opts)]
|
||||
(when mode (state/set-theme! mode))
|
||||
(.on "theme-selected" (fn [^js theme]
|
||||
(let [theme (bean/->clj theme)
|
||||
url (:url theme)
|
||||
mode (:mode theme)]
|
||||
(when mode
|
||||
(state/set-custom-theme! mode theme)
|
||||
(state/set-theme-mode! mode))
|
||||
(state/set-state! :plugin/selected-theme url))))
|
||||
|
||||
(.on "reset-custom-theme" (fn [^js themes]
|
||||
(let [themes (bean/->clj themes)
|
||||
custom-theme (dissoc themes :mode)
|
||||
mode (:mode themes)]
|
||||
(state/set-custom-theme! {:light (if (nil? (:light custom-theme)) {:mode "light"} (:light custom-theme))
|
||||
:dark (if (nil? (:dark custom-theme)) {:mode "dark"} (:dark custom-theme))})
|
||||
(state/set-theme-mode! mode))))
|
||||
|
||||
(.on "settings-changed" (fn [id ^js settings]
|
||||
(let [id (keyword id)]
|
||||
|
||||
Reference in New Issue
Block a user