mirror of
https://github.com/penpot/penpot.git
synced 2025-07-28 00:17:29 +02:00
Fix measures options
This commit is contained in:
parent
028809f1d5
commit
fdca6e4edf
5 changed files with 26 additions and 16 deletions
|
@ -132,6 +132,13 @@
|
||||||
|
|
||||||
token))
|
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
|
;; === Token Set
|
||||||
|
|
||||||
(defprotocol ITokenSet
|
(defprotocol ITokenSet
|
||||||
|
|
|
@ -502,14 +502,6 @@
|
||||||
(def workspace-selected-token-set-tokens
|
(def workspace-selected-token-set-tokens
|
||||||
(l/derived #(or (wtts/get-selected-token-set-tokens %) {}) st/state))
|
(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
|
;; ---- Viewer refs
|
||||||
|
|
||||||
(defn lookup-viewer-objects-by-id
|
(defn lookup-viewer-objects-by-id
|
||||||
|
|
|
@ -27,16 +27,18 @@
|
||||||
[app.main.ui.formats :as fmt]
|
[app.main.ui.formats :as fmt]
|
||||||
[app.main.ui.hooks :as h]
|
[app.main.ui.hooks :as h]
|
||||||
[app.main.ui.icons :as i]
|
[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.core :as wtc]
|
||||||
[app.main.ui.workspace.tokens.editable-select :refer [editable-select]]
|
[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.token :as wtt]
|
||||||
[app.main.ui.workspace.tokens.changes :as wtch]
|
|
||||||
[app.main.ui.workspace.tokens.token-types :as wtty]
|
[app.main.ui.workspace.tokens.token-types :as wtty]
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[app.util.keyboard :as kbd]
|
[app.util.keyboard :as kbd]
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]
|
||||||
|
[app.common.types.tokens-lib :as ctob]))
|
||||||
|
|
||||||
(defn- dir-icons-refactor
|
(defn- dir-icons-refactor
|
||||||
[val]
|
[val]
|
||||||
|
@ -856,8 +858,10 @@
|
||||||
|
|
||||||
shape (when-not multiple
|
shape (when-not multiple
|
||||||
(first (deref (refs/objects-by-id ids))))
|
(first (deref (refs/objects-by-id ids))))
|
||||||
tokens (mf/deref refs/workspace-selected-token-set-tokens-OLD)
|
tokens (sd/use-active-theme-sets-tokens)
|
||||||
spacing-tokens (mf/use-memo (mf/deps tokens) #(:spacing (wtc/group-tokens-by-type-OLD tokens)))
|
spacing-tokens (mf/use-memo
|
||||||
|
(mf/deps tokens)
|
||||||
|
#(ctob/filter-by-type :spacing tokens))
|
||||||
|
|
||||||
spacing-column-options (mf/use-memo
|
spacing-column-options (mf/use-memo
|
||||||
(mf/deps shape spacing-tokens)
|
(mf/deps shape spacing-tokens)
|
||||||
|
|
|
@ -108,21 +108,21 @@
|
||||||
border-radius-tokens (:border-radius tokens-by-type)
|
border-radius-tokens (:border-radius tokens-by-type)
|
||||||
border-radius-options (mf/use-memo
|
border-radius-options (mf/use-memo
|
||||||
(mf/deps shape border-radius-tokens)
|
(mf/deps shape border-radius-tokens)
|
||||||
#(wtc/tokens-name-map->select-options
|
#(wtc/tokens-name-map->select-options-OLD
|
||||||
{:shape shape
|
{:shape shape
|
||||||
:tokens border-radius-tokens
|
:tokens border-radius-tokens
|
||||||
:attributes (wtty/token-attributes :border-radius)}))
|
:attributes (wtty/token-attributes :border-radius)}))
|
||||||
sizing-tokens (:sizing tokens-by-type)
|
sizing-tokens (:sizing tokens-by-type)
|
||||||
width-options (mf/use-memo
|
width-options (mf/use-memo
|
||||||
(mf/deps shape sizing-tokens)
|
(mf/deps shape sizing-tokens)
|
||||||
#(wtc/tokens-name-map->select-options
|
#(wtc/tokens-name-map->select-options-OLD
|
||||||
{:shape shape
|
{:shape shape
|
||||||
:tokens sizing-tokens
|
:tokens sizing-tokens
|
||||||
:attributes (wtty/token-attributes :sizing)
|
:attributes (wtty/token-attributes :sizing)
|
||||||
:selected-attributes #{:width}}))
|
:selected-attributes #{:width}}))
|
||||||
height-options (mf/use-memo
|
height-options (mf/use-memo
|
||||||
(mf/deps shape sizing-tokens)
|
(mf/deps shape sizing-tokens)
|
||||||
#(wtc/tokens-name-map->select-options
|
#(wtc/tokens-name-map->select-options-OLD
|
||||||
{:shape shape
|
{:shape shape
|
||||||
:tokens sizing-tokens
|
:tokens sizing-tokens
|
||||||
:attributes (wtty/token-attributes :sizing)
|
:attributes (wtty/token-attributes :sizing)
|
||||||
|
|
|
@ -37,12 +37,19 @@
|
||||||
(->> (vals tokens)
|
(->> (vals tokens)
|
||||||
(group-by :type))))
|
(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)
|
(->> (wtt/token-names-map tokens)
|
||||||
(map (fn [[_k {:keys [name] :as item}]]
|
(map (fn [[_k {:keys [name] :as item}]]
|
||||||
(cond-> (assoc item :label name)
|
(cond-> (assoc item :label name)
|
||||||
(wtt/token-applied? item shape (or selected-attributes attributes)) (assoc :selected? true))))))
|
(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 -------------------------------------------------------
|
;; JSON export functions -------------------------------------------------------
|
||||||
|
|
||||||
(defn encode-tokens
|
(defn encode-tokens
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue