0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-11 23:31:21 -05:00

🐛 Fix type inconsistency on gradient type

Normalize to keyword and add migration for ensure that
all shapes uses the correct type
This commit is contained in:
Andrey Antukh 2024-01-09 18:48:09 +01:00
parent 8919a7067e
commit 04f3d99def
4 changed files with 35 additions and 3 deletions

View file

@ -6,4 +6,4 @@
(ns app.common.files.defaults)
(def version 37)
(def version 38)

View file

@ -671,3 +671,31 @@
(defmethod migrate 37
[data]
(d/without-nils data))
(defmethod migrate 38
[data]
(letfn [(fix-gradient [{:keys [type] :as gradient}]
(if (string? type)
(assoc gradient :type (keyword type))
gradient))
(update-fill [fill]
(d/update-when fill :fill-color-gradient fix-gradient))
(update-object [object]
(d/update-when object :fills #(mapv update-fill %)))
(update-shape [shape]
(let [shape (update-object shape)]
(if (cfh/text-shape? shape)
(-> shape
(update :content (partial txt/transform-nodes identity update-fill))
(d/update-when :position-data #(mapv update-object %)))
shape)))
(update-container [container]
(update container :objects update-vals update-shape))]
(-> data
(update :pages-index update-vals update-container)
(update :components update-vals update-container))))

View file

@ -56,7 +56,7 @@
(sm/define! ::gradient
[:map {:title "Gradient"}
[:type [::sm/one-of #{:linear :radial "linear" "radial"}]]
[:type [::sm/one-of #{:linear :radial}]]
[:start-x ::sm/safe-number]
[:start-y ::sm/safe-number]
[:end-x ::sm/safe-number]

View file

@ -375,8 +375,8 @@
{:frame-id uuid/zero
:fills [{:fill-color clr/white
:fill-opacity 1}]
:name "Board"
:strokes []
:name "Board"
:shapes []
:hide-fill-on-export false})
@ -390,11 +390,15 @@
(def ^:private minimal-group-attrs
{:type :group
:name "Group"
:fills []
:strokes []
:shapes []})
(def ^:private minimal-bool-attrs
{:type :bool
:name "Bool"
:fills []
:strokes []
:shapes []})
(def ^:private minimal-text-attrs