mirror of
https://github.com/penpot/penpot.git
synced 2025-02-01 11:59:17 -05:00
Fix border-radius and sizing panels
This commit is contained in:
parent
845de5d885
commit
93cc8214fa
3 changed files with 23 additions and 7 deletions
|
@ -132,6 +132,13 @@
|
||||||
|
|
||||||
token))
|
token))
|
||||||
|
|
||||||
|
(defn group-by-type [tokens]
|
||||||
|
(let [tokens' (if (or (map? tokens)
|
||||||
|
(d/ordered-map? tokens))
|
||||||
|
(vals tokens)
|
||||||
|
tokens)]
|
||||||
|
(group-by :type tokens')))
|
||||||
|
|
||||||
(defn filter-by-type [token-type tokens]
|
(defn filter-by-type [token-type tokens]
|
||||||
(let [token-type? #(= token-type (:type %))]
|
(let [token-type? #(= token-type (:type %))]
|
||||||
(cond
|
(cond
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
[app.util.dom :as dom]
|
[app.util.dom :as dom]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
[clojure.set :refer [rename-keys union]]
|
[clojure.set :refer [rename-keys union]]
|
||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]
|
||||||
|
[app.common.types.tokens-lib :as ctob]))
|
||||||
|
|
||||||
(def measure-attrs
|
(def measure-attrs
|
||||||
[:proportion-lock
|
[:proportion-lock
|
||||||
|
@ -101,28 +102,29 @@
|
||||||
selection-parents-ref (mf/use-memo (mf/deps ids) #(refs/parents-by-ids ids))
|
selection-parents-ref (mf/use-memo (mf/deps ids) #(refs/parents-by-ids ids))
|
||||||
selection-parents (mf/deref selection-parents-ref)
|
selection-parents (mf/deref selection-parents-ref)
|
||||||
|
|
||||||
tokens (-> (mf/deref refs/workspace-active-theme-sets-tokens)
|
tokens (sd/use-active-theme-sets-tokens)
|
||||||
(sd/use-resolved-tokens))
|
tokens-by-type (mf/use-memo
|
||||||
tokens-by-type (mf/use-memo (mf/deps tokens) #(wtc/group-tokens-by-type-OLD tokens))
|
(mf/deps tokens)
|
||||||
|
#(ctob/group-by-type tokens))
|
||||||
|
|
||||||
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-OLD
|
#(wtc/tokens->select-options
|
||||||
{: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-OLD
|
#(wtc/tokens->select-options
|
||||||
{: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-OLD
|
#(wtc/tokens->select-options
|
||||||
{:shape shape
|
{:shape shape
|
||||||
:tokens sizing-tokens
|
:tokens sizing-tokens
|
||||||
:attributes (wtty/token-attributes :sizing)
|
:attributes (wtty/token-attributes :sizing)
|
||||||
|
|
|
@ -43,6 +43,13 @@
|
||||||
(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->select-options [{:keys [shape tokens attributes selected-attributes]}]
|
||||||
|
(map
|
||||||
|
(fn [{:keys [name] :as item}]
|
||||||
|
(cond-> (assoc item :label name)
|
||||||
|
(wtt/token-applied? item shape (or selected-attributes attributes)) (assoc :selected? true)))
|
||||||
|
tokens))
|
||||||
|
|
||||||
(defn tokens-name-map->select-options [{:keys [shape tokens attributes selected-attributes]}]
|
(defn tokens-name-map->select-options [{:keys [shape tokens attributes selected-attributes]}]
|
||||||
(map
|
(map
|
||||||
(fn [[_k {:keys [name] :as item}]]
|
(fn [[_k {:keys [name] :as item}]]
|
||||||
|
|
Loading…
Add table
Reference in a new issue