mirror of
https://github.com/penpot/penpot.git
synced 2025-12-12 06:24:17 +01:00
♻️ Replace offsetx and offsety names
This commit is contained in:
@@ -1575,10 +1575,10 @@ Will return a value that matches this schema:
|
|||||||
(if (map? shadow)
|
(if (map? shadow)
|
||||||
(let [legacy-shadow-type (get "type" shadow)]
|
(let [legacy-shadow-type (get "type" shadow)]
|
||||||
(-> shadow
|
(-> shadow
|
||||||
(set/rename-keys {"x" :offsetX
|
(set/rename-keys {"x" :offset-x
|
||||||
"offsetX" :offsetX
|
"offsetX" :offset-x
|
||||||
"y" :offsetY
|
"y" :offset-y
|
||||||
"offsetY" :offsetY
|
"offsetY" :offset-y
|
||||||
"blur" :blur
|
"blur" :blur
|
||||||
"spread" :spread
|
"spread" :spread
|
||||||
"color" :color
|
"color" :color
|
||||||
@@ -1589,7 +1589,7 @@ Will return a value that matches this schema:
|
|||||||
(= "false" %) false
|
(= "false" %) false
|
||||||
(= legacy-shadow-type "innerShadow") true
|
(= legacy-shadow-type "innerShadow") true
|
||||||
:else false))
|
:else false))
|
||||||
(select-keys [:offsetX :offsetY :blur :spread :color :inset])))
|
(select-keys [:offset-x :offset-y :blur :spread :color :inset])))
|
||||||
shadow))]
|
shadow))]
|
||||||
(cond
|
(cond
|
||||||
;; Reference value - keep as string
|
;; Reference value - keep as string
|
||||||
@@ -1860,8 +1860,8 @@ Will return a value that matches this schema:
|
|||||||
(mapv (fn [shadow]
|
(mapv (fn [shadow]
|
||||||
(if (map? shadow)
|
(if (map? shadow)
|
||||||
(-> shadow
|
(-> shadow
|
||||||
(set/rename-keys {:offsetX "offsetX"
|
(set/rename-keys {:offset-x "offsetX"
|
||||||
:offsetY "offsetY"
|
:offset-y "offsetY"
|
||||||
:blur "blur"
|
:blur "blur"
|
||||||
:spread "spread"
|
:spread "spread"
|
||||||
:color "color"
|
:color "color"
|
||||||
|
|||||||
@@ -1897,15 +1897,15 @@
|
|||||||
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-single")]
|
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-single")]
|
||||||
(t/is (some? token))
|
(t/is (some? token))
|
||||||
(t/is (= :shadow (:type 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)))))
|
(:value token)))))
|
||||||
|
|
||||||
(t/testing "multiple shadow token"
|
(t/testing "multiple shadow token"
|
||||||
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-multiple")]
|
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-multiple")]
|
||||||
(t/is (some? token))
|
(t/is (some? token))
|
||||||
(t/is (= :shadow (:type token)))
|
(t/is (= :shadow (:type token)))
|
||||||
(t/is (= [{:offsetX "0", :offsetY "2px", :blur "4px", :spread "0", :color "#000", :inset true}
|
(t/is (= [{:offset-x "0", :offset-y "2px", :blur "4px", :spread "0", :color "#000", :inset true}
|
||||||
{:offsetX "0", :offsetY "8px", :blur "16px", :spread "0", :color "#000", :inset true}]
|
{:offset-x "0", :offset-y "8px", :blur "16px", :spread "0", :color "#000", :inset true}]
|
||||||
(:value token)))))
|
(:value token)))))
|
||||||
|
|
||||||
(t/testing "shadow token with reference"
|
(t/testing "shadow token with reference"
|
||||||
@@ -1918,7 +1918,7 @@
|
|||||||
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-with-type")]
|
(let [token (ctob/get-token-by-name lib "shadow-test" "test.shadow-with-type")]
|
||||||
(t/is (some? token))
|
(t/is (some? token))
|
||||||
(t/is (= :shadow (:type 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)))))
|
(:value token)))))
|
||||||
|
|
||||||
(t/testing "shadow token with description"
|
(t/testing "shadow token with description"
|
||||||
@@ -1937,14 +1937,14 @@
|
|||||||
(ctob/make-token
|
(ctob/make-token
|
||||||
{:name "shadow.single"
|
{:name "shadow.single"
|
||||||
:type :shadow
|
: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"})
|
:description "A single shadow"})
|
||||||
"shadow.multiple"
|
"shadow.multiple"
|
||||||
(ctob/make-token
|
(ctob/make-token
|
||||||
{:name "shadow.multiple"
|
{:name "shadow.multiple"
|
||||||
:type :shadow
|
: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"}
|
||||||
{:offsetX "0" :offsetY "8px" :blur "16px" :spread "0" :color "#0000001A"}]})
|
{:offset-x "0" :offset-y "8px" :blur "16px" :spread "0" :color "#0000001A"}]})
|
||||||
"shadow.ref"
|
"shadow.ref"
|
||||||
(ctob/make-token
|
(ctob/make-token
|
||||||
{:name "shadow.ref"
|
{:name "shadow.ref"
|
||||||
@@ -1991,7 +1991,7 @@
|
|||||||
(ctob/make-token
|
(ctob/make-token
|
||||||
{:name "shadow.test"
|
{:name "shadow.test"
|
||||||
:type :shadow
|
: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"})
|
:description "Round trip test"})
|
||||||
"shadow.ref"
|
"shadow.ref"
|
||||||
(ctob/make-token
|
(ctob/make-token
|
||||||
|
|||||||
@@ -5947,8 +5947,8 @@
|
|||||||
"~:spread": "10",
|
"~:spread": "10",
|
||||||
"~:color": "rgb(160, 73, 73)",
|
"~:color": "rgb(160, 73, 73)",
|
||||||
"~:inset": true,
|
"~:inset": true,
|
||||||
"~:offsetX": "10",
|
"~:offset-x": "10",
|
||||||
"~:offsetY": "10"
|
"~:offset-y": "10"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"~:description": "",
|
"~:description": "",
|
||||||
|
|||||||
@@ -368,8 +368,8 @@
|
|||||||
(let [add-keyed-errors (fn [shadow-result k errors]
|
(let [add-keyed-errors (fn [shadow-result k errors]
|
||||||
(update shadow-result :errors concat
|
(update shadow-result :errors concat
|
||||||
(map #(assoc % :shadow-key k :shadow-index shadow-index) errors)))
|
(map #(assoc % :shadow-key k :shadow-index shadow-index) errors)))
|
||||||
parsers {:offsetX parse-sd-token-general-value
|
parsers {:offset-x parse-sd-token-general-value
|
||||||
:offsetY parse-sd-token-general-value
|
:offset-y parse-sd-token-general-value
|
||||||
:blur parse-sd-token-shadow-blur
|
:blur parse-sd-token-shadow-blur
|
||||||
:spread parse-sd-token-shadow-spread
|
:spread parse-sd-token-shadow-spread
|
||||||
:color parse-sd-token-color-value
|
:color parse-sd-token-color-value
|
||||||
|
|||||||
@@ -153,11 +153,11 @@
|
|||||||
(defn value->shadow
|
(defn value->shadow
|
||||||
"Transform a token shadow value into penpot shadow data structure"
|
"Transform a token shadow value into penpot shadow data structure"
|
||||||
[value]
|
[value]
|
||||||
(mapv (fn [{:keys [offsetX offsetY blur spread color inset]}]
|
(mapv (fn [{:keys [offset-x offset-y blur spread color inset]}]
|
||||||
{:id (random-uuid)
|
{:id (random-uuid)
|
||||||
:hidden false
|
:hidden false
|
||||||
:offset-x offsetX
|
:offset-x offset-x
|
||||||
:offset-y offsetY
|
:offset-y offset-y
|
||||||
:blur blur
|
:blur blur
|
||||||
:color (value->color color)
|
:color (value->color color)
|
||||||
:spread spread
|
:spread spread
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
:letter-spacing "Letter Spacing"
|
:letter-spacing "Letter Spacing"
|
||||||
:text-case "Text Case"
|
:text-case "Text Case"
|
||||||
:text-decoration "Text Decoration"
|
:text-decoration "Text Decoration"
|
||||||
:offsetX "X"
|
:offset-x "X"
|
||||||
:offsetY "Y"
|
:offset-y "Y"
|
||||||
:blur "Blur"
|
:blur "Blur"
|
||||||
:spread "Spread"
|
:spread "Spread"
|
||||||
:color "Color"
|
:color "Color"
|
||||||
|
|||||||
@@ -211,7 +211,7 @@
|
|||||||
|
|
||||||
(defn- check-empty-shadow-token [token]
|
(defn- check-empty-shadow-token [token]
|
||||||
(when (or (empty? (:value 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)))
|
(:value token)))
|
||||||
(wte/get-error-code :error.token/empty-input)))
|
(wte/get-error-code :error.token/empty-input)))
|
||||||
|
|
||||||
@@ -940,10 +940,10 @@
|
|||||||
|
|
||||||
(def ^:private shadow-inputs
|
(def ^:private shadow-inputs
|
||||||
#(d/ordered-map
|
#(d/ordered-map
|
||||||
:offsetX
|
:offset-x
|
||||||
{:label (tr "workspace.tokens.shadow-x")
|
{:label (tr "workspace.tokens.shadow-x")
|
||||||
:placeholder (tr "workspace.tokens.shadow-x")}
|
:placeholder (tr "workspace.tokens.shadow-x")}
|
||||||
:offsetY
|
:offset-y
|
||||||
{:label (tr "workspace.tokens.shadow-y")
|
{:label (tr "workspace.tokens.shadow-y")
|
||||||
:placeholder (tr "workspace.tokens.shadow-y")}
|
:placeholder (tr "workspace.tokens.shadow-y")}
|
||||||
:blur
|
:blur
|
||||||
|
|||||||
@@ -39,8 +39,8 @@
|
|||||||
[rumext.v2 :as mf]))
|
[rumext.v2 :as mf]))
|
||||||
|
|
||||||
(def ^:private default-token-shadow
|
(def ^:private default-token-shadow
|
||||||
{:offsetX "4"
|
{:offset-x "4"
|
||||||
:offsetY "4"
|
:offset-y "4"
|
||||||
:blur "4"
|
:blur "4"
|
||||||
:spread "0"})
|
:spread "0"})
|
||||||
|
|
||||||
@@ -59,10 +59,10 @@
|
|||||||
color-token (get-subtoken token index :color composite-type)
|
color-token (get-subtoken token index :color composite-type)
|
||||||
color-token (hooks/use-equal-memo color-token)
|
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-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)
|
offset-y-token (hooks/use-equal-memo offset-y-token)
|
||||||
|
|
||||||
blur-token (get-subtoken token index :blur composite-type)
|
blur-token (get-subtoken token index :blur composite-type)
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
{:aria-label (tr "workspace.tokens.shadow-x")
|
{:aria-label (tr "workspace.tokens.shadow-x")
|
||||||
:icon i/character-x
|
:icon i/character-x
|
||||||
:placeholder (tr "workspace.tokens.shadow-x")
|
:placeholder (tr "workspace.tokens.shadow-x")
|
||||||
:name :offsetX
|
:name :offset-x
|
||||||
:token offset-x-token
|
:token offset-x-token
|
||||||
:index index
|
:index index
|
||||||
:composite-type composite-type
|
:composite-type composite-type
|
||||||
@@ -121,7 +121,7 @@
|
|||||||
{:aria-label (tr "workspace.tokens.shadow-y")
|
{:aria-label (tr "workspace.tokens.shadow-y")
|
||||||
:icon i/character-y
|
:icon i/character-y
|
||||||
:placeholder (tr "workspace.tokens.shadow-y")
|
:placeholder (tr "workspace.tokens.shadow-y")
|
||||||
:name :offsetY
|
:name :offset-y
|
||||||
:token offset-y-token
|
:token offset-y-token
|
||||||
:index index
|
:index index
|
||||||
:composite-type composite-type
|
:composite-type composite-type
|
||||||
@@ -198,8 +198,8 @@
|
|||||||
[:shadow {:optinal true}
|
[:shadow {:optinal true}
|
||||||
[:vector
|
[:vector
|
||||||
[:map
|
[:map
|
||||||
[:offsetX {:optional true} [:maybe :string]]
|
[:offset-x {:optional true} [:maybe :string]]
|
||||||
[:offsetY {:optional true} [:maybe :string]]
|
[:offset-y {:optional true} [:maybe :string]]
|
||||||
[:blur {:optional true} [:maybe :string]]
|
[:blur {:optional true} [:maybe :string]]
|
||||||
[:spread {:optional true} [:maybe :string]]
|
[:spread {:optional true} [:maybe :string]]
|
||||||
[:color {:optional true} [:maybe :string]]
|
[:color {:optional true} [:maybe :string]]
|
||||||
@@ -231,9 +231,9 @@
|
|||||||
valid-composite-shadow?
|
valid-composite-shadow?
|
||||||
(and (seq shadows)
|
(and (seq shadows)
|
||||||
(every?
|
(every?
|
||||||
(fn [{:keys [offsetX offsetY blur spread color]}]
|
(fn [{:keys [offset-x offset-y blur spread color]}]
|
||||||
(and (not (str/blank? offsetX))
|
(and (not (str/blank? offset-x))
|
||||||
(not (str/blank? offsetY))
|
(not (str/blank? offset-y))
|
||||||
(not (str/blank? blur))
|
(not (str/blank? blur))
|
||||||
(not (str/blank? spread))
|
(not (str/blank? spread))
|
||||||
(not (str/blank? color))))
|
(not (str/blank? color))))
|
||||||
|
|||||||
@@ -151,8 +151,8 @@
|
|||||||
;; export interface Shadow {
|
;; export interface Shadow {
|
||||||
;; id?: string;
|
;; id?: string;
|
||||||
;; style?: 'drop-shadow' | 'inner-shadow';
|
;; style?: 'drop-shadow' | 'inner-shadow';
|
||||||
;; offsetX?: number;
|
;; offset-x?: number;
|
||||||
;; offsetY?: number;
|
;; offset-y?: number;
|
||||||
;; blur?: number;
|
;; blur?: number;
|
||||||
;; spread?: number;
|
;; spread?: number;
|
||||||
;; hidden?: boolean;
|
;; hidden?: boolean;
|
||||||
@@ -164,8 +164,8 @@
|
|||||||
(obj/without-empty
|
(obj/without-empty
|
||||||
#js {:id (-> id format-id)
|
#js {:id (-> id format-id)
|
||||||
:style (-> style format-key)
|
:style (-> style format-key)
|
||||||
:offsetX offset-x
|
:offset-x offset-x
|
||||||
:offsetY offset-y
|
:offset-y offset-y
|
||||||
:blur blur
|
:blur blur
|
||||||
:spread spread
|
:spread spread
|
||||||
:hidden hidden
|
:hidden hidden
|
||||||
|
|||||||
@@ -147,7 +147,7 @@
|
|||||||
;; export interface Shadow {
|
;; export interface Shadow {
|
||||||
;; id?: string;
|
;; id?: string;
|
||||||
;; style?: 'drop-shadow' | 'inner-shadow';
|
;; style?: 'drop-shadow' | 'inner-shadow';
|
||||||
;; offsetX?: number;
|
;; offset--y?: number;
|
||||||
;; offsetY?: number;
|
;; offsetY?: number;
|
||||||
;; blur?: number;
|
;; blur?: number;
|
||||||
;; spread?: number;
|
;; spread?: number;
|
||||||
@@ -160,8 +160,8 @@
|
|||||||
(d/without-nils
|
(d/without-nils
|
||||||
{:id (-> (obj/get shadow "id") parse-id)
|
{:id (-> (obj/get shadow "id") parse-id)
|
||||||
:style (-> (obj/get shadow "style") parse-keyword)
|
:style (-> (obj/get shadow "style") parse-keyword)
|
||||||
:offset-x (obj/get shadow "offsetX")
|
:offset-x (obj/get shadow "offset-x")
|
||||||
:offset-y (obj/get shadow "offsetY")
|
:offset-y (obj/get shadow "offset-y")
|
||||||
:blur (obj/get shadow "blur")
|
:blur (obj/get shadow "blur")
|
||||||
:spread (obj/get shadow "spread")
|
:spread (obj/get shadow "spread")
|
||||||
:hidden (obj/get shadow "hidden")
|
:hidden (obj/get shadow "hidden")
|
||||||
|
|||||||
@@ -474,8 +474,8 @@
|
|||||||
(t/async
|
(t/async
|
||||||
done
|
done
|
||||||
(let [shadow-token {:name "shadow.sm"
|
(let [shadow-token {:name "shadow.sm"
|
||||||
:value [{:offsetX 10
|
:value [{:offset-x 10
|
||||||
:offsetY 10
|
:offset-y 10
|
||||||
:blur 10
|
:blur 10
|
||||||
:spread 10
|
:spread 10
|
||||||
:color "rgba(0,0,0,0.5)"
|
:color "rgba(0,0,0,0.5)"
|
||||||
|
|||||||
Reference in New Issue
Block a user