diff --git a/frontend/src/app/main/data/style_dictionary.cljs b/frontend/src/app/main/data/style_dictionary.cljs index fbb53d8719..0d9e465592 100644 --- a/frontend/src/app/main/data/style_dictionary.cljs +++ b/frontend/src/app/main/data/style_dictionary.cljs @@ -133,7 +133,6 @@ :else {:errors [(wte/error-with-value :error.style-dictionary/invalid-token-value value)]}))) - (defn- parse-sd-token-stroke-width-value "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`. @@ -158,6 +157,15 @@ :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 "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`." @@ -253,6 +261,7 @@ :opacity (parse-sd-token-opacity-value value has-references?) :stroke-width (parse-sd-token-stroke-width-value value has-references?) :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) :font-weight (parse-sd-token-font-weight-value value) :number (parse-sd-token-number-value value) diff --git a/frontend/src/app/main/data/workspace/tokens/errors.cljs b/frontend/src/app/main/data/workspace/tokens/errors.cljs index ec8ad988b1..75e1649911 100644 --- a/frontend/src/app/main/data/workspace/tokens/errors.cljs +++ b/frontend/src/app/main/data/workspace/tokens/errors.cljs @@ -64,6 +64,10 @@ {:error/code :error.style-dictionary/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/code :error.style-dictionary/invalid-token-value-opacity :error/fn #(str/join "\n" [(str (tr "workspace.tokens.invalid-value" %) ".") (tr "workspace.tokens.opacity-range")])} diff --git a/frontend/translations/en.po b/frontend/translations/en.po index f19b050864..bddb09c091 100644 --- a/frontend/translations/en.po +++ b/frontend/translations/en.po @@ -7626,6 +7626,10 @@ msgstr "Right click to see options" msgid "workspace.tokens.value-with-units" 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 msgid "workspace.tokens.warning-name-change" msgstr "Renaming this token will break any reference to its old name."