mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
Hide temporary token theme from user
This commit is contained in:
parent
e216d84484
commit
895f92e7c2
4 changed files with 27 additions and 13 deletions
|
@ -16,6 +16,14 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
#?(:clj [app.common.fressian :as fres])))
|
#?(:clj [app.common.fressian :as fres])))
|
||||||
|
|
||||||
|
;; === Constants
|
||||||
|
|
||||||
|
(def hidden-token-theme-group
|
||||||
|
"")
|
||||||
|
|
||||||
|
(def hidden-token-theme-name
|
||||||
|
"__PENPOT__HIDDEN__TOKEN__THEME__")
|
||||||
|
|
||||||
;; === Groups handling
|
;; === Groups handling
|
||||||
|
|
||||||
(def schema:groupable-item
|
(def schema:groupable-item
|
||||||
|
@ -257,7 +265,9 @@
|
||||||
|
|
||||||
(defprotocol ITokenTheme
|
(defprotocol ITokenTheme
|
||||||
(toggle-set [_ set-name] "togle a set used / not used in the theme")
|
(toggle-set [_ set-name] "togle a set used / not used in the theme")
|
||||||
(theme-path [_] "get `token-theme-path` from theme"))
|
(theme-path [_] "get `token-theme-path` from theme")
|
||||||
|
(theme-matches-group-name [_ group name] "if a theme matches the given group & name")
|
||||||
|
(hidden-temporary-theme? [_] "if a theme is the (from the user ui) hidden temporary theme"))
|
||||||
|
|
||||||
(defrecord TokenTheme [name group description is-source modified-at sets]
|
(defrecord TokenTheme [name group description is-source modified-at sets]
|
||||||
ITokenTheme
|
ITokenTheme
|
||||||
|
@ -271,7 +281,14 @@
|
||||||
(disj sets set-name)
|
(disj sets set-name)
|
||||||
(conj sets set-name))))
|
(conj sets set-name))))
|
||||||
(theme-path [_]
|
(theme-path [_]
|
||||||
(token-theme-path group name)))
|
(token-theme-path group name))
|
||||||
|
|
||||||
|
(theme-matches-group-name [this group name]
|
||||||
|
(and (= (:group this) group)
|
||||||
|
(= (:name this) name)))
|
||||||
|
|
||||||
|
(hidden-temporary-theme? [this]
|
||||||
|
(theme-matches-group-name this hidden-token-theme-group hidden-token-theme-name)))
|
||||||
|
|
||||||
(def schema:token-theme
|
(def schema:token-theme
|
||||||
[:and [:map {:title "TokenTheme"}
|
[:and [:map {:title "TokenTheme"}
|
||||||
|
|
|
@ -48,12 +48,6 @@
|
||||||
(defn get-tokens-lib [state]
|
(defn get-tokens-lib [state]
|
||||||
(get-in state [:workspace-data :tokens-lib]))
|
(get-in state [:workspace-data :tokens-lib]))
|
||||||
|
|
||||||
(def hidden-token-theme-group
|
|
||||||
"")
|
|
||||||
|
|
||||||
(def hidden-token-theme-name
|
|
||||||
"__PENPOT__HIDDEN__TOKEN__SET__")
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; TOKENS Actions
|
;; TOKENS Actions
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -222,14 +216,14 @@
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [it state _]
|
(watch [it state _]
|
||||||
(let [tokens-lib (get-tokens-lib state)
|
(let [tokens-lib (get-tokens-lib state)
|
||||||
prev-theme (ctob/get-theme tokens-lib hidden-token-theme-group hidden-token-theme-name)
|
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
|
theme (-> (or prev-theme (ctob/make-token-theme
|
||||||
:group hidden-token-theme-group
|
:group ctob/hidden-token-theme-group
|
||||||
:name hidden-token-theme-name))
|
:name ctob/hidden-token-theme-name))
|
||||||
(ctob/toggle-set token-set-name))
|
(ctob/toggle-set token-set-name))
|
||||||
prev-active-token-themes (ctob/get-active-theme-paths tokens-lib)
|
prev-active-token-themes (ctob/get-active-theme-paths tokens-lib)
|
||||||
changes (-> (pcb/empty-changes it)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/update-active-token-themes #{(ctob/token-theme-path hidden-token-theme-group hidden-token-theme-name)} prev-active-token-themes))
|
(pcb/update-active-token-themes #{(ctob/token-theme-path ctob/hidden-token-theme-group ctob/hidden-token-theme-name)} prev-active-token-themes))
|
||||||
changes' (if prev-theme
|
changes' (if prev-theme
|
||||||
(pcb/update-token-theme changes theme prev-theme)
|
(pcb/update-token-theme changes theme prev-theme)
|
||||||
(pcb/add-token-theme changes theme))]
|
(pcb/add-token-theme changes theme))]
|
||||||
|
|
|
@ -465,6 +465,9 @@
|
||||||
(def workspace-token-themes
|
(def workspace-token-themes
|
||||||
(l/derived #(or (some-> % ctob/get-themes) []) tokens-lib))
|
(l/derived #(or (some-> % ctob/get-themes) []) tokens-lib))
|
||||||
|
|
||||||
|
(def workspace-token-themes-no-hidden
|
||||||
|
(l/derived #(remove ctob/hidden-temporary-theme? %) workspace-token-themes))
|
||||||
|
|
||||||
(def workspace-selected-token-set-id
|
(def workspace-selected-token-set-id
|
||||||
(l/derived wtts/get-selected-token-set-id st/state))
|
(l/derived wtts/get-selected-token-set-id st/state))
|
||||||
|
|
||||||
|
|
|
@ -241,7 +241,7 @@
|
||||||
|
|
||||||
(mf/defc themes
|
(mf/defc themes
|
||||||
[_]
|
[_]
|
||||||
(let [themes (mf/deref refs/workspace-token-themes)
|
(let [themes (mf/deref refs/workspace-token-themes-no-hidden)
|
||||||
state (mf/use-state (if (empty? themes)
|
state (mf/use-state (if (empty? themes)
|
||||||
{:type :create-theme}
|
{:type :create-theme}
|
||||||
{:type :themes-overview}))
|
{:type :themes-overview}))
|
||||||
|
|
Loading…
Add table
Reference in a new issue