♻️ Replace offsetx and offsety names

This commit is contained in:
Eva Marco
2025-12-02 17:47:35 +01:00
parent 81c6cb52ca
commit bdcbde37c3
11 changed files with 47 additions and 47 deletions

View File

@@ -1575,10 +1575,10 @@ Will return a value that matches this schema:
(if (map? shadow)
(let [legacy-shadow-type (get "type" shadow)]
(-> shadow
(set/rename-keys {"x" :offsetX
"offsetX" :offsetX
"y" :offsetY
"offsetY" :offsetY
(set/rename-keys {"x" :offset-x
"offsetX" :offset-x
"y" :offset-y
"offsetY" :offset-y
"blur" :blur
"spread" :spread
"color" :color
@@ -1589,7 +1589,7 @@ Will return a value that matches this schema:
(= "false" %) false
(= legacy-shadow-type "innerShadow") true
:else false))
(select-keys [:offsetX :offsetY :blur :spread :color :inset])))
(select-keys [:offset-x :offset-y :blur :spread :color :inset])))
shadow))]
(cond
;; Reference value - keep as string
@@ -1860,8 +1860,8 @@ Will return a value that matches this schema:
(mapv (fn [shadow]
(if (map? shadow)
(-> shadow
(set/rename-keys {:offsetX "offsetX"
:offsetY "offsetY"
(set/rename-keys {:offset-x "offsetX"
:offset-y "offsetY"
:blur "blur"
:spread "spread"
:color "color"

View File

@@ -1897,15 +1897,15 @@
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-single")]
(t/is (some? token))
(t/is (= :shadow (:type token)))
(t/is (= [{:offsetX "0", :offsetY "2px", :blur "4px", :spread "0", :color "#000", :inset false}]
(t/is (= [{:offset-x "0", :offset-y "2px", :blur "4px", :spread "0", :color "#000", :inset false}]
(:value token)))))
(t/testing "multiple shadow token"
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-multiple")]
(t/is (some? token))
(t/is (= :shadow (:type token)))
(t/is (= [{:offsetX "0", :offsetY "2px", :blur "4px", :spread "0", :color "#000", :inset true}
{:offsetX "0", :offsetY "8px", :blur "16px", :spread "0", :color "#000", :inset true}]
(t/is (= [{:offset-x "0", :offset-y "2px", :blur "4px", :spread "0", :color "#000", :inset true}
{:offset-x "0", :offset-y "8px", :blur "16px", :spread "0", :color "#000", :inset true}]
(:value token)))))
(t/testing "shadow token with reference"
@@ -1918,7 +1918,7 @@
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-with-type")]
(t/is (some? token))
(t/is (= :shadow (:type token)))
(t/is (= [{:offsetX "0", :offsetY "4px", :blur "8px", :spread "0", :color "rgba(0,0,0,0.2)", :inset false}]
(t/is (= [{:offset-x "0", :offset-y "4px", :blur "8px", :spread "0", :color "rgba(0,0,0,0.2)", :inset false}]
(:value token)))))
(t/testing "shadow token with description"
@@ -1937,14 +1937,14 @@
(ctob/make-token
{:name "shadow.single"
:type :shadow
:value [{:offsetX "0" :offsetY "2px" :blur "4px" :spread "0" :color "#0000001A"}]
:value [{:offset-x "0" :offset-y "2px" :blur "4px" :spread "0" :color "#0000001A"}]
:description "A single shadow"})
"shadow.multiple"
(ctob/make-token
{:name "shadow.multiple"
:type :shadow
:value [{:offsetX "0" :offsetY "2px" :blur "4px" :spread "0" :color "#0000001A"}
{:offsetX "0" :offsetY "8px" :blur "16px" :spread "0" :color "#0000001A"}]})
:value [{:offset-x "0" :offset-y "2px" :blur "4px" :spread "0" :color "#0000001A"}
{:offset-x "0" :offset-y "8px" :blur "16px" :spread "0" :color "#0000001A"}]})
"shadow.ref"
(ctob/make-token
{:name "shadow.ref"
@@ -1991,7 +1991,7 @@
(ctob/make-token
{:name "shadow.test"
:type :shadow
:value [{:offsetX "1" :offsetY "1" :blur "1" :spread "1" :color "red" :inset true}]
:value [{:offset-x "1" :offset-y "1" :blur "1" :spread "1" :color "red" :inset true}]
:description "Round trip test"})
"shadow.ref"
(ctob/make-token

View File

@@ -5947,8 +5947,8 @@
"~:spread": "10",
"~:color": "rgb(160, 73, 73)",
"~:inset": true,
"~:offsetX": "10",
"~:offsetY": "10"
"~:offset-x": "10",
"~:offset-y": "10"
}
],
"~:description": "",

View File

@@ -368,8 +368,8 @@
(let [add-keyed-errors (fn [shadow-result k errors]
(update shadow-result :errors concat
(map #(assoc % :shadow-key k :shadow-index shadow-index) errors)))
parsers {:offsetX parse-sd-token-general-value
:offsetY parse-sd-token-general-value
parsers {:offset-x parse-sd-token-general-value
:offset-y parse-sd-token-general-value
:blur parse-sd-token-shadow-blur
:spread parse-sd-token-shadow-spread
:color parse-sd-token-color-value

View File

@@ -153,11 +153,11 @@
(defn value->shadow
"Transform a token shadow value into penpot shadow data structure"
[value]
(mapv (fn [{:keys [offsetX offsetY blur spread color inset]}]
(mapv (fn [{:keys [offset-x offset-y blur spread color inset]}]
{:id (random-uuid)
:hidden false
:offset-x offsetX
:offset-y offsetY
:offset-x offset-x
:offset-y offset-y
:blur blur
:color (value->color color)
:spread spread

View File

@@ -16,8 +16,8 @@
:letter-spacing "Letter Spacing"
:text-case "Text Case"
:text-decoration "Text Decoration"
:offsetX "X"
:offsetY "Y"
:offset-x "X"
:offset-y "Y"
:blur "Blur"
:spread "Spread"
:color "Color"

View File

@@ -211,7 +211,7 @@
(defn- check-empty-shadow-token [token]
(when (or (empty? (:value token))
(some (fn [shadow] (not-every? #(contains? shadow %) [:offsetX :offsetY :blur :spread :color]))
(some (fn [shadow] (not-every? #(contains? shadow %) [:offset-x :offset-y :blur :spread :color]))
(:value token)))
(wte/get-error-code :error.token/empty-input)))
@@ -940,10 +940,10 @@
(def ^:private shadow-inputs
#(d/ordered-map
:offsetX
:offset-x
{:label (tr "workspace.tokens.shadow-x")
:placeholder (tr "workspace.tokens.shadow-x")}
:offsetY
:offset-y
{:label (tr "workspace.tokens.shadow-y")
:placeholder (tr "workspace.tokens.shadow-y")}
:blur

View File

@@ -39,8 +39,8 @@
[rumext.v2 :as mf]))
(def ^:private default-token-shadow
{:offsetX "4"
:offsetY "4"
{:offset-x "4"
:offset-y "4"
:blur "4"
:spread "0"})
@@ -59,10 +59,10 @@
color-token (get-subtoken token index :color composite-type)
color-token (hooks/use-equal-memo color-token)
offset-x-token (get-subtoken token index :offsetX composite-type)
offset-x-token (get-subtoken token index :offset-x composite-type)
offset-x-token (hooks/use-equal-memo offset-x-token)
offset-y-token (get-subtoken token index :offsetY composite-type)
offset-y-token (get-subtoken token index :offset-y composite-type)
offset-y-token (hooks/use-equal-memo offset-y-token)
blur-token (get-subtoken token index :blur composite-type)
@@ -110,7 +110,7 @@
{:aria-label (tr "workspace.tokens.shadow-x")
:icon i/character-x
:placeholder (tr "workspace.tokens.shadow-x")
:name :offsetX
:name :offset-x
:token offset-x-token
:index index
:composite-type composite-type
@@ -121,7 +121,7 @@
{:aria-label (tr "workspace.tokens.shadow-y")
:icon i/character-y
:placeholder (tr "workspace.tokens.shadow-y")
:name :offsetY
:name :offset-y
:token offset-y-token
:index index
:composite-type composite-type
@@ -198,8 +198,8 @@
[:shadow {:optinal true}
[:vector
[:map
[:offsetX {:optional true} [:maybe :string]]
[:offsetY {:optional true} [:maybe :string]]
[:offset-x {:optional true} [:maybe :string]]
[:offset-y {:optional true} [:maybe :string]]
[:blur {:optional true} [:maybe :string]]
[:spread {:optional true} [:maybe :string]]
[:color {:optional true} [:maybe :string]]
@@ -231,9 +231,9 @@
valid-composite-shadow?
(and (seq shadows)
(every?
(fn [{:keys [offsetX offsetY blur spread color]}]
(and (not (str/blank? offsetX))
(not (str/blank? offsetY))
(fn [{:keys [offset-x offset-y blur spread color]}]
(and (not (str/blank? offset-x))
(not (str/blank? offset-y))
(not (str/blank? blur))
(not (str/blank? spread))
(not (str/blank? color))))

View File

@@ -151,8 +151,8 @@
;; export interface Shadow {
;; id?: string;
;; style?: 'drop-shadow' | 'inner-shadow';
;; offsetX?: number;
;; offsetY?: number;
;; offset-x?: number;
;; offset-y?: number;
;; blur?: number;
;; spread?: number;
;; hidden?: boolean;
@@ -164,8 +164,8 @@
(obj/without-empty
#js {:id (-> id format-id)
:style (-> style format-key)
:offsetX offset-x
:offsetY offset-y
:offset-x offset-x
:offset-y offset-y
:blur blur
:spread spread
:hidden hidden

View File

@@ -147,7 +147,7 @@
;; export interface Shadow {
;; id?: string;
;; style?: 'drop-shadow' | 'inner-shadow';
;; offsetX?: number;
;; offset--y?: number;
;; offsetY?: number;
;; blur?: number;
;; spread?: number;
@@ -160,8 +160,8 @@
(d/without-nils
{:id (-> (obj/get shadow "id") parse-id)
:style (-> (obj/get shadow "style") parse-keyword)
:offset-x (obj/get shadow "offsetX")
:offset-y (obj/get shadow "offsetY")
:offset-x (obj/get shadow "offset-x")
:offset-y (obj/get shadow "offset-y")
:blur (obj/get shadow "blur")
:spread (obj/get shadow "spread")
:hidden (obj/get shadow "hidden")

View File

@@ -474,8 +474,8 @@
(t/async
done
(let [shadow-token {:name "shadow.sm"
:value [{:offsetX 10
:offsetY 10
:value [{:offset-x 10
:offset-y 10
:blur 10
:spread 10
:color "rgba(0,0,0,0.5)"