mirror of
https://github.com/penpot/penpot.git
synced 2025-12-23 22:48:40 -05:00
wip
This commit is contained in:
@@ -32,13 +32,19 @@
|
|||||||
min-width: var(--sp-l);
|
min-width: var(--sp-l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Review if we need other type of button, so we don't need important here
|
||||||
.invisible-button {
|
.invisible-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 4px;
|
||||||
|
top: 4px;
|
||||||
opacity: var(--opacity-button);
|
opacity: var(--opacity-button);
|
||||||
|
background-color: var(--color-background-quaternary) !important;
|
||||||
&:hover {
|
&:hover {
|
||||||
|
background-color: var(--color-background-quaternary);
|
||||||
--opacity-button: 1;
|
--opacity-button: 1;
|
||||||
}
|
}
|
||||||
&:focus {
|
&:focus {
|
||||||
|
background-color: var(--color-background-quaternary);
|
||||||
--opacity-button: 1;
|
--opacity-button: 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
[:div {:class (stl/css :pill-dot)}])]]
|
[:div {:class (stl/css :pill-dot)}])]]
|
||||||
|
|
||||||
(when-not ^boolean disabled
|
(when-not ^boolean disabled
|
||||||
[:> icon-button* {:variant "action"
|
[:> icon-button* {:variant "ghost"
|
||||||
:class (stl/css :invisible-button)
|
:class (stl/css :invisible-button)
|
||||||
:icon i/broken-link
|
:icon i/broken-link
|
||||||
:ref token-detach-btn-ref
|
:ref token-detach-btn-ref
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
@use "ds/_sizes.scss" as *;
|
@use "ds/_sizes.scss" as *;
|
||||||
@use "ds/typography.scss" as t;
|
@use "ds/typography.scss" as t;
|
||||||
@use "ds/colors.scss" as *;
|
@use "ds/colors.scss" as *;
|
||||||
|
@use "ds/mixins.scss" as *;
|
||||||
|
|
||||||
.token-field {
|
.token-field {
|
||||||
--token-field-bg-color: var(--color-background-tertiary);
|
--token-field-bg-color: var(--color-background-tertiary);
|
||||||
@@ -16,9 +17,8 @@
|
|||||||
--token-field-outline-color: none;
|
--token-field-outline-color: none;
|
||||||
--token-field-height: var(--sp-xxxl);
|
--token-field-height: var(--sp-xxxl);
|
||||||
--token-field-margin: unset;
|
--token-field-margin: unset;
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr auto;
|
width: inherit;
|
||||||
column-gap: var(--sp-xs);
|
column-gap: var(--sp-xs);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
border-radius: $br-8;
|
border-radius: $br-8;
|
||||||
padding: var(--sp-xs);
|
padding: var(--sp-xs);
|
||||||
outline: $b-1 solid var(--token-field-outline-color);
|
outline: $b-1 solid var(--token-field-outline-color);
|
||||||
|
position: relative;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
--token-field-bg-color: var(--color-background-quaternary);
|
--token-field-bg-color: var(--color-background-quaternary);
|
||||||
@@ -39,7 +40,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.with-icon {
|
.with-icon {
|
||||||
grid-template-columns: auto 1fr auto;
|
grid-template-columns: auto 1fr;
|
||||||
}
|
}
|
||||||
|
|
||||||
.token-field-disabled {
|
.token-field-disabled {
|
||||||
@@ -57,6 +58,8 @@
|
|||||||
--pill-bg-color: var(--color-background-tertiary);
|
--pill-bg-color: var(--color-background-tertiary);
|
||||||
--pill-fg-color: var(--color-token-foreground);
|
--pill-fg-color: var(--color-token-foreground);
|
||||||
@include t.use-typography("code-font");
|
@include t.use-typography("code-font");
|
||||||
|
@include textEllipsis;
|
||||||
|
display: block;
|
||||||
height: var(--sp-xxl);
|
height: var(--sp-xxl);
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
background: var(--pill-bg-color);
|
background: var(--pill-bg-color);
|
||||||
@@ -65,6 +68,7 @@
|
|||||||
color: var(--pill-fg-color);
|
color: var(--pill-fg-color);
|
||||||
border-radius: $br-6;
|
border-radius: $br-6;
|
||||||
padding-inline: $sz-6;
|
padding-inline: $sz-6;
|
||||||
|
max-width: 100%;
|
||||||
&:hover {
|
&:hover {
|
||||||
--pill-bg-color: var(--color-token-background);
|
--pill-bg-color: var(--color-token-background);
|
||||||
--pill-fg-color: var(--color-foreground-primary);
|
--pill-fg-color: var(--color-foreground-primary);
|
||||||
@@ -115,6 +119,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.invisible-button {
|
.invisible-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
opacity: var(--opacity-button);
|
opacity: var(--opacity-button);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
@@ -159,4 +159,6 @@ $arrow-side: 12px;
|
|||||||
block-size: fit-content;
|
block-size: fit-content;
|
||||||
inline-size: fit-content;
|
inline-size: fit-content;
|
||||||
line-height: 0;
|
line-height: 0;
|
||||||
|
display: grid;
|
||||||
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,15 @@
|
|||||||
(:require
|
(:require
|
||||||
[app.common.data.macros :as dm]
|
[app.common.data.macros :as dm]
|
||||||
[app.common.types.shape.radius :as ctsr]
|
[app.common.types.shape.radius :as ctsr]
|
||||||
|
[app.common.types.token :as tk]
|
||||||
[app.main.data.workspace.shapes :as dwsh]
|
[app.main.data.workspace.shapes :as dwsh]
|
||||||
|
[app.main.data.workspace.tokens.application :as dwta]
|
||||||
|
[app.main.features :as features]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.components.numeric-input :as deprecated-input]
|
[app.main.ui.components.numeric-input :as deprecated-input]
|
||||||
|
[app.main.ui.context :as muc]
|
||||||
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
|
[app.main.ui.ds.buttons.icon-button :refer [icon-button*]]
|
||||||
|
[app.main.ui.ds.controls.numeric-input :refer [numeric-input*]]
|
||||||
[app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
|
[app.main.ui.ds.foundations.assets.icon :refer [icon*] :as i]
|
||||||
[app.main.ui.hooks :as hooks]
|
[app.main.ui.hooks :as hooks]
|
||||||
[app.util.i18n :as i18n :refer [tr]]
|
[app.util.i18n :as i18n :refer [tr]]
|
||||||
@@ -21,11 +26,15 @@
|
|||||||
(defn- check-border-radius-menu-props
|
(defn- check-border-radius-menu-props
|
||||||
[old-props new-props]
|
[old-props new-props]
|
||||||
(let [old-values (unchecked-get old-props "values")
|
(let [old-values (unchecked-get old-props "values")
|
||||||
new-values (unchecked-get new-props "values")]
|
new-values (unchecked-get new-props "values")
|
||||||
|
old-applied-tokens (unchecked-get old-props "applied-tokens")
|
||||||
|
new-applied-tokens (unchecked-get new-props "applied-tokens")]
|
||||||
(and (identical? (unchecked-get old-props "class")
|
(and (identical? (unchecked-get old-props "class")
|
||||||
(unchecked-get new-props "class"))
|
(unchecked-get new-props "class"))
|
||||||
(identical? (unchecked-get old-props "ids")
|
(identical? (unchecked-get old-props "ids")
|
||||||
(unchecked-get new-props "ids"))
|
(unchecked-get new-props "ids"))
|
||||||
|
(identical? old-applied-tokens
|
||||||
|
new-applied-tokens)
|
||||||
(identical? (get old-values :r1)
|
(identical? (get old-values :r1)
|
||||||
(get new-values :r1))
|
(get new-values :r1))
|
||||||
(identical? (get old-values :r2)
|
(identical? (get old-values :r2)
|
||||||
@@ -35,13 +44,64 @@
|
|||||||
(identical? (get old-values :r4)
|
(identical? (get old-values :r4)
|
||||||
(get new-values :r4)))))
|
(get new-values :r4)))))
|
||||||
|
|
||||||
|
(mf/defc numeric-input-wrapper*
|
||||||
|
{::mf/private true}
|
||||||
|
[{:keys [values name applied-tokens align on-detach radius] :rest props}]
|
||||||
|
(let [tokens (mf/use-ctx muc/active-tokens-by-type)
|
||||||
|
tokens (mf/with-memo [tokens name]
|
||||||
|
(delay
|
||||||
|
(-> (deref tokens)
|
||||||
|
(select-keys (get tk/tokens-by-input name))
|
||||||
|
(not-empty))))
|
||||||
|
on-detach-attr
|
||||||
|
(mf/use-fn
|
||||||
|
(mf/deps on-detach name)
|
||||||
|
#(on-detach % name))
|
||||||
|
|
||||||
|
r1-value (get applied-tokens :r1)
|
||||||
|
r2-value (get applied-tokens :r2)
|
||||||
|
r3-value (get applied-tokens :r3)
|
||||||
|
r4-value (get applied-tokens :r4)
|
||||||
|
all-equal? (= r1-value r2-value r3-value r4-value)
|
||||||
|
|
||||||
|
applied-token (if (= :all radius)
|
||||||
|
(if all-equal?
|
||||||
|
r1-value
|
||||||
|
:mixed)
|
||||||
|
:mixed)
|
||||||
|
|
||||||
|
|
||||||
|
props (mf/spread-props props
|
||||||
|
{:placeholder (if (or (= :multiple (:applied-tokens values))
|
||||||
|
(= :multiple (get values name)))
|
||||||
|
(tr "settings.multiple") "--")
|
||||||
|
:class (stl/css :numeric-input-measures)
|
||||||
|
:applied-token applied-token
|
||||||
|
:tokens (if (delay? tokens) @tokens tokens)
|
||||||
|
:align align
|
||||||
|
:on-detach on-detach-attr
|
||||||
|
:value (get values name)})]
|
||||||
|
[:> numeric-input* props]))
|
||||||
|
|
||||||
(mf/defc border-radius-menu*
|
(mf/defc border-radius-menu*
|
||||||
{::mf/wrap [#(mf/memo' % check-border-radius-menu-props)]}
|
{::mf/wrap [#(mf/memo' % check-border-radius-menu-props)]}
|
||||||
[{:keys [class ids values]}]
|
[{:keys [class ids values applied-tokens]}]
|
||||||
(let [all-equal? (all-equal? values)
|
(let [token-numeric-inputs
|
||||||
|
(features/use-feature "tokens/numeric-input")
|
||||||
|
|
||||||
|
all-equal? (all-equal? values)
|
||||||
radius-expanded* (mf/use-state false)
|
radius-expanded* (mf/use-state false)
|
||||||
radius-expanded (deref radius-expanded*)
|
radius-expanded (deref radius-expanded*)
|
||||||
|
|
||||||
|
;; DETACH
|
||||||
|
on-detach-token
|
||||||
|
(mf/use-fn
|
||||||
|
(mf/deps ids)
|
||||||
|
(fn [token attr]
|
||||||
|
(st/emit! (dwta/unapply-token {:token (first token)
|
||||||
|
:attributes #{attr}
|
||||||
|
:shape-ids ids}))))
|
||||||
|
|
||||||
change-radius
|
change-radius
|
||||||
(mf/use-fn
|
(mf/use-fn
|
||||||
(mf/deps ids)
|
(mf/deps ids)
|
||||||
@@ -94,23 +154,39 @@
|
|||||||
|
|
||||||
[:div {:class (dm/str class " " (stl/css :radius))}
|
[:div {:class (dm/str class " " (stl/css :radius))}
|
||||||
(if (not radius-expanded)
|
(if (not radius-expanded)
|
||||||
[:div {:class (stl/css :radius-1)
|
(if token-numeric-inputs
|
||||||
:title (tr "workspace.options.radius")}
|
[:div {:class (stl/css :radius-1)
|
||||||
[:> icon* {:icon-id i/corner-radius
|
:title (tr "workspace.options.radius")}
|
||||||
:size "s"
|
[:> numeric-input-wrapper*
|
||||||
:class (stl/css :icon)}]
|
{:on-change on-single-radius-change
|
||||||
[:> deprecated-input/numeric-input*
|
:on-detach on-detach-token
|
||||||
{:placeholder (cond
|
:icon i/corner-radius
|
||||||
(not all-equal?)
|
:min 0
|
||||||
"Mixed"
|
:name :border-radius
|
||||||
(= :multiple (:r1 values))
|
:nillable true
|
||||||
(tr "settings.multiple")
|
:property (tr "workspace.options.width")
|
||||||
:else
|
:applied-tokens applied-tokens
|
||||||
"--")
|
:radius :all
|
||||||
:min 0
|
:values (if all-equal? (:r1 values) nil)}]]
|
||||||
:nillable true
|
|
||||||
:on-change on-single-radius-change
|
[:div {:class (stl/css :radius-1)
|
||||||
:value (if all-equal? (:r1 values) nil)}]]
|
:title (tr "workspace.options.radius")}
|
||||||
|
[:> icon* {:icon-id i/corner-radius
|
||||||
|
:size "s"
|
||||||
|
:class (stl/css :icon)}]
|
||||||
|
|
||||||
|
[:* [:> deprecated-input/numeric-input*
|
||||||
|
{:placeholder (cond
|
||||||
|
(not all-equal?)
|
||||||
|
"Mixed"
|
||||||
|
(= :multiple (:r1 values))
|
||||||
|
(tr "settings.multiple")
|
||||||
|
:else
|
||||||
|
"--")
|
||||||
|
:min 0
|
||||||
|
:nillable true
|
||||||
|
:on-change on-single-radius-change
|
||||||
|
:value (if all-equal? (:r1 values) nil)}]]])
|
||||||
|
|
||||||
[:div {:class (stl/css :radius-4)}
|
[:div {:class (stl/css :radius-4)}
|
||||||
[:div {:class (stl/css :small-input)}
|
[:div {:class (stl/css :small-input)}
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
(nil? (get values name)))
|
(nil? (get values name)))
|
||||||
(tr "settings.multiple")
|
(tr "settings.multiple")
|
||||||
"--")
|
"--")
|
||||||
:class (stl/css :numeric-input-measures)
|
:class (stl/css :numeric-input-layout)
|
||||||
:applied-token (get applied-tokens name)
|
:applied-token (get applied-tokens name)
|
||||||
:tokens tokens
|
:tokens tokens
|
||||||
:align align
|
:align align
|
||||||
|
|||||||
@@ -433,6 +433,6 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.numeric-input-measures {
|
.numeric-input-layout {
|
||||||
--dropdown-width: var(--7-columns-dropdown-width);
|
--dropdown-width: var(--7-columns-dropdown-width);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
@use "refactor/common-refactor.scss" as deprecated;
|
@use "refactor/common-refactor.scss" as deprecated;
|
||||||
@use "../../../sidebar/common/sidebar.scss" as sidebar;
|
@use "../../../sidebar/common/sidebar.scss" as sidebar;
|
||||||
|
@use "ds/_utils.scss" as *;
|
||||||
|
|
||||||
.element-set {
|
.element-set {
|
||||||
display: grid;
|
display: grid;
|
||||||
@@ -188,7 +189,6 @@
|
|||||||
@extend .button-icon;
|
@extend .button-icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add a proper variable to this sizing
|
|
||||||
.numeric-input-measures {
|
.numeric-input-measures {
|
||||||
--dropdown-width: var(--7-columns-dropdown-width);
|
--dropdown-width: var(--7-columns-dropdown-width);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user