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

Fix measures options

This commit is contained in:
Florian Schroedl 2024-10-02 10:46:55 +02:00
parent 028809f1d5
commit fdca6e4edf
5 changed files with 26 additions and 16 deletions

View file

@ -132,6 +132,13 @@
token))
(defn filter-by-type [token-type tokens]
(let [token-type? #(= token-type (:type %))]
(cond
(d/ordered-map? tokens) (into (d/ordered-map) (filter (comp token-type? val) tokens))
(map? tokens) (into {} (filter (comp token-type? val) tokens))
:else (filter token-type? tokens))))
;; === Token Set
(defprotocol ITokenSet

View file

@ -502,14 +502,6 @@
(def workspace-selected-token-set-tokens
(l/derived #(or (wtts/get-selected-token-set-tokens %) {}) st/state))
(dm/legacy
(def workspace-selected-token-set-tokens-OLD
(l/derived
(fn [data]
{})
st/state
=)))
;; ---- Viewer refs
(defn lookup-viewer-objects-by-id

View file

@ -27,16 +27,18 @@
[app.main.ui.formats :as fmt]
[app.main.ui.hooks :as h]
[app.main.ui.icons :as i]
[app.main.ui.workspace.tokens.changes :as wtch]
[app.main.ui.workspace.tokens.core :as wtc]
[app.main.ui.workspace.tokens.editable-select :refer [editable-select]]
[app.main.ui.workspace.tokens.style-dictionary :as sd]
[app.main.ui.workspace.tokens.token :as wtt]
[app.main.ui.workspace.tokens.changes :as wtch]
[app.main.ui.workspace.tokens.token-types :as wtty]
[app.util.dom :as dom]
[app.util.i18n :as i18n :refer [tr]]
[app.util.keyboard :as kbd]
[cuerdas.core :as str]
[rumext.v2 :as mf]))
[rumext.v2 :as mf]
[app.common.types.tokens-lib :as ctob]))
(defn- dir-icons-refactor
[val]
@ -856,8 +858,10 @@
shape (when-not multiple
(first (deref (refs/objects-by-id ids))))
tokens (mf/deref refs/workspace-selected-token-set-tokens-OLD)
spacing-tokens (mf/use-memo (mf/deps tokens) #(:spacing (wtc/group-tokens-by-type-OLD tokens)))
tokens (sd/use-active-theme-sets-tokens)
spacing-tokens (mf/use-memo
(mf/deps tokens)
#(ctob/filter-by-type :spacing tokens))
spacing-column-options (mf/use-memo
(mf/deps shape spacing-tokens)

View file

@ -108,21 +108,21 @@
border-radius-tokens (:border-radius tokens-by-type)
border-radius-options (mf/use-memo
(mf/deps shape border-radius-tokens)
#(wtc/tokens-name-map->select-options
#(wtc/tokens-name-map->select-options-OLD
{:shape shape
:tokens border-radius-tokens
:attributes (wtty/token-attributes :border-radius)}))
sizing-tokens (:sizing tokens-by-type)
width-options (mf/use-memo
(mf/deps shape sizing-tokens)
#(wtc/tokens-name-map->select-options
#(wtc/tokens-name-map->select-options-OLD
{:shape shape
:tokens sizing-tokens
:attributes (wtty/token-attributes :sizing)
:selected-attributes #{:width}}))
height-options (mf/use-memo
(mf/deps shape sizing-tokens)
#(wtc/tokens-name-map->select-options
#(wtc/tokens-name-map->select-options-OLD
{:shape shape
:tokens sizing-tokens
:attributes (wtty/token-attributes :sizing)

View file

@ -37,12 +37,19 @@
(->> (vals tokens)
(group-by :type))))
(defn tokens-name-map->select-options [{:keys [shape tokens attributes selected-attributes]}]
(defn tokens-name-map->select-options-OLD [{:keys [shape tokens attributes selected-attributes]}]
(->> (wtt/token-names-map tokens)
(map (fn [[_k {:keys [name] :as item}]]
(cond-> (assoc item :label name)
(wtt/token-applied? item shape (or selected-attributes attributes)) (assoc :selected? true))))))
(defn tokens-name-map->select-options [{:keys [shape tokens attributes selected-attributes]}]
(map
(fn [[_k {:keys [name] :as item}]]
(cond-> (assoc item :label name)
(wtt/token-applied? item shape (or selected-attributes attributes)) (assoc :selected? true)))
tokens))
;; JSON export functions -------------------------------------------------------
(defn encode-tokens