mirror of
https://github.com/penpot/penpot.git
synced 2025-04-08 21:11:22 -05:00
Remove unused
This commit is contained in:
parent
3843253a5d
commit
c8494c9931
2 changed files with 0 additions and 81 deletions
|
@ -497,12 +497,6 @@
|
|||
(l/derived #(some-> % ctob/get-active-themes-set-tokens) tokens-lib))
|
||||
|
||||
(dm/legacy
|
||||
(def workspace-temp-theme-id
|
||||
(l/derived wtts/get-temp-theme-id st/state))
|
||||
|
||||
(def workspace-ordered-token-sets-tokens
|
||||
(l/derived wtts/get-workspace-ordered-sets-tokens st/state =))
|
||||
|
||||
(def workspace-selected-token-set-tokens
|
||||
(l/derived
|
||||
(fn [data]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
(ns app.main.ui.workspace.tokens.token-set
|
||||
(:require
|
||||
[app.common.data :refer [ordered-map]]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.types.tokens-lib :as ctob]
|
||||
[app.main.ui.workspace.tokens.token :as wtt]
|
||||
[clojure.set :as set]))
|
||||
|
@ -14,29 +13,12 @@
|
|||
(defn get-workspace-themes [state]
|
||||
(get-in state [:workspace-data :token-themes] []))
|
||||
|
||||
(defn get-workspace-theme [id state]
|
||||
(get-in state [:workspace-data :token-themes-index id]))
|
||||
|
||||
(defn get-workspace-themes-index [state]
|
||||
(get-in state [:workspace-data :token-themes-index] {}))
|
||||
|
||||
(defn get-workspace-theme-groups [state]
|
||||
(reduce
|
||||
(fn [acc {:keys [group]}]
|
||||
(if group
|
||||
(conj acc group)
|
||||
acc))
|
||||
#{} (vals (get-workspace-themes-index state))))
|
||||
|
||||
(defn get-workspace-token-set-groups [state]
|
||||
(get-in state [:workspace-data :token-set-groups]))
|
||||
|
||||
(defn get-workspace-ordered-themes [state]
|
||||
(let [themes (get-workspace-themes state)
|
||||
themes-index (get-workspace-themes-index state)]
|
||||
(->> (map #(get themes-index %) themes)
|
||||
(group-by :group))))
|
||||
|
||||
(defn get-active-theme-ids [state]
|
||||
(get-in state [:workspace-data :token-active-themes] #{}))
|
||||
|
||||
|
@ -66,40 +48,6 @@
|
|||
token-set-groups (get-workspace-token-set-groups state)]
|
||||
(filter active-set-ids token-set-groups)))
|
||||
|
||||
(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)
|
||||
theme-group (get-in themes [theme-id :group])
|
||||
same-group-theme-ids (->> themes
|
||||
(eduction
|
||||
(map val)
|
||||
(filter #(= (:group %) theme-group))
|
||||
(map :id))
|
||||
(into #{}))]
|
||||
same-group-theme-ids))
|
||||
|
||||
(defn toggle-active-theme-id
|
||||
"Toggle a `theme-id` by checking `:token-active-themes`.
|
||||
Deactivate 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 #{}))
|
||||
active-theme-ids (get-active-theme-ids state)
|
||||
add? (not (get active-theme-ids theme-id))
|
||||
;; Deactivate themes with the same group when activating a theme
|
||||
same-group-ids (when add? (theme-ids-with-group theme-id state))
|
||||
theme-ids-without-same-group (set/difference active-theme-ids
|
||||
same-group-ids
|
||||
temp-theme-id-set)
|
||||
new-themes (if add?
|
||||
(conj theme-ids-without-same-group theme-id)
|
||||
(disj theme-ids-without-same-group theme-id))]
|
||||
(if (empty? new-themes)
|
||||
(or temp-theme-id-set #{})
|
||||
new-themes)))
|
||||
|
||||
(defn update-theme-id
|
||||
[state]
|
||||
(let [active-themes (get-active-theme-ids state)
|
||||
|
@ -115,34 +63,11 @@
|
|||
(defn add-token-set-to-token-theme [token-set-id token-theme]
|
||||
(update token-theme :sets conj token-set-id))
|
||||
|
||||
(defn toggle-token-set-to-token-theme [token-set-id token-theme]
|
||||
(update token-theme :sets #(if (get % token-set-id)
|
||||
(disj % token-set-id)
|
||||
(conj % token-set-id))))
|
||||
|
||||
;; Sets ------------------------------------------------------------------------
|
||||
|
||||
(defn get-workspace-sets [state]
|
||||
(get-in state [:workspace-data :token-sets-index]))
|
||||
|
||||
(defn get-workspace-ordered-sets [state]
|
||||
;; TODO Include groups
|
||||
(let [top-level-set-ids (get-in state [:workspace-data :token-set-groups])
|
||||
token-sets (get-workspace-sets state)]
|
||||
(->> (map (fn [id] [id (get token-sets id)]) top-level-set-ids)
|
||||
(into (ordered-map)))))
|
||||
|
||||
(defn get-workspace-ordered-sets-tokens [state]
|
||||
(let [sets (get-workspace-ordered-sets state)]
|
||||
(reduce
|
||||
(fn [acc [_ {:keys [tokens] :as sets}]]
|
||||
(reduce (fn [acc' token-id]
|
||||
(if-let [token (wtt/get-workspace-token token-id state)]
|
||||
(assoc acc' (wtt/token-identifier token) token)
|
||||
acc'))
|
||||
acc tokens))
|
||||
{} sets)))
|
||||
|
||||
(defn get-token-set [set-id state]
|
||||
(some-> (get-workspace-sets state)
|
||||
(get set-id)))
|
||||
|
|
Loading…
Add table
Reference in a new issue