mirror of
https://github.com/penpot/penpot.git
synced 2026-08-01 10:56:20 +00:00
🐛 Don't allow letter-spacing value with % (#7100)
This commit is contained in:
parent
36bafc0d40
commit
ccd6ae5ade
@ -133,7 +133,6 @@
|
|||||||
|
|
||||||
:else {:errors [(wte/error-with-value :error.style-dictionary/invalid-token-value value)]})))
|
:else {:errors [(wte/error-with-value :error.style-dictionary/invalid-token-value value)]})))
|
||||||
|
|
||||||
|
|
||||||
(defn- parse-sd-token-stroke-width-value
|
(defn- parse-sd-token-stroke-width-value
|
||||||
"Parses `value` of a dimensions `sd-token` into a map like `{:value 1 :unit \"px\"}`.
|
"Parses `value` of a dimensions `sd-token` into a map like `{:value 1 :unit \"px\"}`.
|
||||||
If the `value` is not parseable and/or has missing references returns a map with `:errors`.
|
If the `value` is not parseable and/or has missing references returns a map with `:errors`.
|
||||||
@ -158,6 +157,15 @@
|
|||||||
|
|
||||||
:else {:errors [(wte/error-with-value :error.style-dictionary/invalid-token-value value)]})))
|
:else {:errors [(wte/error-with-value :error.style-dictionary/invalid-token-value value)]})))
|
||||||
|
|
||||||
|
(defn- parse-sd-token-letter-spacing-value
|
||||||
|
"Parses `value` of a text-case `sd-token` into a map like `{:value \"1\"}`.
|
||||||
|
If the `value` is not parseable and/or has missing references returns a map with `:errors`."
|
||||||
|
[value]
|
||||||
|
(let [parsed-value (parse-sd-token-general-value value)]
|
||||||
|
(if (= (:unit parsed-value) "%")
|
||||||
|
{:errors [(wte/error-with-value :error.style-dictionary/value-with-percent value)]}
|
||||||
|
parsed-value)))
|
||||||
|
|
||||||
(defn- parse-sd-token-text-case-value
|
(defn- parse-sd-token-text-case-value
|
||||||
"Parses `value` of a text-case `sd-token` into a map like `{:value \"uppercase\"}`.
|
"Parses `value` of a text-case `sd-token` into a map like `{:value \"uppercase\"}`.
|
||||||
If the `value` is not parseable and/or has missing references returns a map with `:errors`."
|
If the `value` is not parseable and/or has missing references returns a map with `:errors`."
|
||||||
@ -253,6 +261,7 @@
|
|||||||
:opacity (parse-sd-token-opacity-value value has-references?)
|
:opacity (parse-sd-token-opacity-value value has-references?)
|
||||||
:stroke-width (parse-sd-token-stroke-width-value value has-references?)
|
:stroke-width (parse-sd-token-stroke-width-value value has-references?)
|
||||||
:text-case (parse-sd-token-text-case-value value)
|
:text-case (parse-sd-token-text-case-value value)
|
||||||
|
:letter-spacing (parse-sd-token-letter-spacing-value value)
|
||||||
:text-decoration (parse-sd-token-text-decoration-value value)
|
:text-decoration (parse-sd-token-text-decoration-value value)
|
||||||
:font-weight (parse-sd-token-font-weight-value value)
|
:font-weight (parse-sd-token-font-weight-value value)
|
||||||
:number (parse-sd-token-number-value value)
|
:number (parse-sd-token-number-value value)
|
||||||
|
|||||||
@ -64,6 +64,10 @@
|
|||||||
{:error/code :error.style-dictionary/value-with-units
|
{:error/code :error.style-dictionary/value-with-units
|
||||||
:error/fn #(str (tr "workspace.tokens.value-with-units"))}
|
:error/fn #(str (tr "workspace.tokens.value-with-units"))}
|
||||||
|
|
||||||
|
:error.style-dictionary/value-with-percent
|
||||||
|
{:error/code :error.style-dictionary/value-with-percent
|
||||||
|
:error/fn #(str (tr "workspace.tokens.value-with-percent"))}
|
||||||
|
|
||||||
:error.style-dictionary/invalid-token-value-opacity
|
:error.style-dictionary/invalid-token-value-opacity
|
||||||
{:error/code :error.style-dictionary/invalid-token-value-opacity
|
{:error/code :error.style-dictionary/invalid-token-value-opacity
|
||||||
:error/fn #(str/join "\n" [(str (tr "workspace.tokens.invalid-value" %) ".") (tr "workspace.tokens.opacity-range")])}
|
:error/fn #(str/join "\n" [(str (tr "workspace.tokens.invalid-value" %) ".") (tr "workspace.tokens.opacity-range")])}
|
||||||
|
|||||||
@ -7626,6 +7626,10 @@ msgstr "Right click to see options"
|
|||||||
msgid "workspace.tokens.value-with-units"
|
msgid "workspace.tokens.value-with-units"
|
||||||
msgstr "Invalid value: Units are not allowed."
|
msgstr "Invalid value: Units are not allowed."
|
||||||
|
|
||||||
|
#: src/app/main/data/workspace/tokens/errors.cljs:61
|
||||||
|
msgid "workspace.tokens.value-with-percent"
|
||||||
|
msgstr "Invalid value: % is not allowed."
|
||||||
|
|
||||||
#: src/app/main/ui/workspace/tokens/form.cljs:555
|
#: src/app/main/ui/workspace/tokens/form.cljs:555
|
||||||
msgid "workspace.tokens.warning-name-change"
|
msgid "workspace.tokens.warning-name-change"
|
||||||
msgstr "Renaming this token will break any reference to its old name."
|
msgstr "Renaming this token will break any reference to its old name."
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user