mirror of
https://github.com/penpot/penpot.git
synced 2025-07-25 15:47:18 +02:00
🚧 UI to support switching to system theme
This commit is contained in:
parent
2650eccd09
commit
ee022e225c
7 changed files with 40 additions and 10 deletions
|
@ -160,8 +160,10 @@
|
|||
(update [_ state]
|
||||
(update-in state [:profile :theme]
|
||||
(fn [current]
|
||||
(if (= current "default")
|
||||
"light"
|
||||
(case current
|
||||
"dark" "light"
|
||||
"light" "system"
|
||||
"system" "dark"
|
||||
"default"))))
|
||||
|
||||
ptk/WatchEvent
|
||||
|
|
|
@ -358,7 +358,10 @@
|
|||
(let [route (mf/deref refs/route)
|
||||
edata (mf/deref refs/exception)
|
||||
profile (mf/deref refs/profile)
|
||||
theme (or (:theme profile) "default")]
|
||||
theme (case (:theme profile)
|
||||
"system" (dom/get-system-theme)
|
||||
"default" "dark"
|
||||
(:theme profile))]
|
||||
|
||||
(mf/with-effect [theme]
|
||||
(dom/set-html-theme-color theme))
|
||||
|
|
|
@ -59,8 +59,9 @@
|
|||
[:& fm/select {:label (tr "dashboard.select-ui-theme")
|
||||
:name :theme
|
||||
:default "default"
|
||||
:options [{:label "Penpot Dark (default)" :value "default"}
|
||||
{:label "Penpot Light" :value "light"}]
|
||||
:options [{:label (tr "dashboard.select-ui-theme.dark") :value "dark"}
|
||||
{:label (tr "dashboard.select-ui-theme.light") :value "light"}
|
||||
{:label (tr "dashboard.select-ui-theme.system") :value "system"}]
|
||||
:data-testid "setting-theme"}]]
|
||||
|
||||
[:> fm/submit-button*
|
||||
|
|
|
@ -280,9 +280,11 @@
|
|||
:data-testid "toggle-theme"
|
||||
:id "file-menu-toggle-theme"}
|
||||
[:span {:class (stl/css :item-name)}
|
||||
(if (= (:theme profile) "default")
|
||||
(tr "workspace.header.menu.toggle-light-theme")
|
||||
(tr "workspace.header.menu.toggle-dark-theme"))]
|
||||
(case (:theme profile) ;; default = dark -> light -> system -> dark and so on
|
||||
"default" (tr "workspace.header.menu.toggle-light-theme")
|
||||
"light" (tr "workspace.header.menu.toggle-system-theme")
|
||||
"system" (tr "workspace.header.menu.toggle-dark-theme")
|
||||
(tr "workspace.header.menu.toggle-light-theme"))]
|
||||
[:span {:class (stl/css :shortcut)}
|
||||
(for [sc (scd/split-sc (sc/get-tooltip :toggle-theme))]
|
||||
[:span {:class (stl/css :shortcut-key) :key sc} sc])]]]))
|
||||
|
|
|
@ -76,9 +76,10 @@
|
|||
|
||||
(defn set-html-theme-color
|
||||
[^string color]
|
||||
(let [node (.querySelector js/document "body")]
|
||||
(let [node (.querySelector js/document "body")
|
||||
class (if (= color "dark") "default" "light")]
|
||||
(.removeAttribute node "class")
|
||||
(.add ^js (.-classList ^js node) color)))
|
||||
(.add ^js (.-classList ^js node) class)))
|
||||
|
||||
(defn set-page-style!
|
||||
[styles]
|
||||
|
|
|
@ -923,6 +923,15 @@ msgstr "Select UI language"
|
|||
msgid "dashboard.select-ui-theme"
|
||||
msgstr "Select theme"
|
||||
|
||||
msgid "dashboard.select-ui-theme.dark"
|
||||
msgstr "Penpot Dark (default)"
|
||||
|
||||
msgid "dashboard.select-ui-theme.light"
|
||||
msgstr "Penpot Light"
|
||||
|
||||
msgid "dashboard.select-ui-theme.system"
|
||||
msgstr "System theme"
|
||||
|
||||
#: src/app/main/ui/settings/notifications.cljs:57
|
||||
msgid "dashboard.settings.notifications.dashboard-comments.all"
|
||||
msgstr "All comments, mentions and replies"
|
||||
|
@ -5166,6 +5175,9 @@ msgstr "Switch to dark theme"
|
|||
msgid "workspace.header.menu.toggle-light-theme"
|
||||
msgstr "Switch to light theme"
|
||||
|
||||
msgid "workspace.header.menu.toggle-system-theme"
|
||||
msgstr "Switch to system theme"
|
||||
|
||||
#: src/app/main/ui/workspace/main_menu.cljs:457
|
||||
msgid "workspace.header.menu.undo"
|
||||
msgstr "Undo"
|
||||
|
|
|
@ -935,6 +935,15 @@ msgstr "Cambiar el idioma de la interfaz"
|
|||
msgid "dashboard.select-ui-theme"
|
||||
msgstr "Selecciona un tema"
|
||||
|
||||
msgid "dashboard.select-ui-theme.dark"
|
||||
msgstr "Penpot Dark (por defecto)"
|
||||
|
||||
msgid "dashboard.select-ui-theme.light"
|
||||
msgstr "Penpot Light"
|
||||
|
||||
msgid "dashboard.select-ui-theme.system"
|
||||
msgstr "Sistema"
|
||||
|
||||
#: src/app/main/ui/settings/notifications.cljs:57
|
||||
msgid "dashboard.settings.notifications.dashboard-comments.all"
|
||||
msgstr "Todos los comentarios, menciones y respuestas"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue