0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-01 20:09:04 -05:00

Docstrings

This commit is contained in:
Florian Schroedl 2024-08-19 09:01:08 +02:00
parent e8bbb75008
commit 93a23c66ec

View file

@ -25,7 +25,10 @@
(defn get-temp-theme-id [state] (defn get-temp-theme-id [state]
(get-in state [:workspace-data :token-theme-temporary-id])) (get-in state [:workspace-data :token-theme-temporary-id]))
(defn theme-ids-with-group [theme-id state] (defn theme-ids-with-group
"Returns set of theme-ids that share the same `:group` property as the theme with `theme-id`.
Will also return matching theme-ids without a `:group` property."
[theme-id state]
(let [themes (get-workspace-themes-index state) (let [themes (get-workspace-themes-index state)
theme-group (get-in themes [theme-id :group]) theme-group (get-in themes [theme-id :group])
same-group-theme-ids (->> themes same-group-theme-ids (->> themes
@ -36,7 +39,11 @@
(into #{}))] (into #{}))]
same-group-theme-ids)) same-group-theme-ids))
(defn toggle-active-theme-id [theme-id state] (defn toggle-active-theme-id
"Toggle a `theme-id` by checking `:token-active-themes`.
De-activate all theme-ids that have the same group as `theme-id` when activating `theme-id`.
Ensures that the temporary theme id is selected when the resulting set is empty."
[theme-id state]
(let [temp-theme-id-set (some->> (get-temp-theme-id state) (conj #{})) (let [temp-theme-id-set (some->> (get-temp-theme-id state) (conj #{}))
active-theme-ids (get-active-theme-ids state) active-theme-ids (get-active-theme-ids state)
add? (not (get active-theme-ids theme-id)) add? (not (get active-theme-ids theme-id))