0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Use currently active sets as sets for temporary theme

This commit is contained in:
Florian Schroedl 2024-09-26 15:24:02 +02:00
parent 29a2478bb5
commit 5f6a76dfce
2 changed files with 16 additions and 7 deletions

View file

@ -268,6 +268,7 @@
(token-theme-path hidden-token-theme-group hidden-token-theme-name))
(defprotocol ITokenTheme
(set-sets [_ set-names] "set the active token sets")
(toggle-set [_ set-name] "togle a set used / not used in the theme")
(theme-path [_] "get `token-theme-path` from theme")
(theme-matches-group-name [_ group name] "if a theme matches the given group & name")
@ -275,15 +276,19 @@
(defrecord TokenTheme [name group description is-source modified-at sets]
ITokenTheme
(toggle-set [_ set-name]
(set-sets [_ set-names]
(TokenTheme. name
group
description
is-source
(dt/now)
(if (sets set-name)
(disj sets set-name)
(conj sets set-name))))
set-names))
(toggle-set [this set-name]
(set-sets this (if (sets set-name)
(disj sets set-name)
(conj sets set-name))))
(theme-path [_]
(token-theme-path group name))

View file

@ -217,9 +217,13 @@
(watch [it state _]
(let [tokens-lib (get-tokens-lib state)
prev-theme (ctob/get-theme tokens-lib ctob/hidden-token-theme-group ctob/hidden-token-theme-name)
theme (-> (or prev-theme (ctob/make-token-theme
:group ctob/hidden-token-theme-group
:name ctob/hidden-token-theme-name))
active-token-set-names (ctob/get-active-themes-set-names tokens-lib)
theme (-> (or (some-> prev-theme
(ctob/set-sets active-token-set-names))
(ctob/make-token-theme
:group ctob/hidden-token-theme-group
:name ctob/hidden-token-theme-name
:sets active-token-set-names))
(ctob/toggle-set token-set-name))
prev-active-token-themes (ctob/get-active-theme-paths tokens-lib)
changes (-> (pcb/empty-changes it)