mirror of
https://github.com/penpot/penpot.git
synced 2025-07-25 17:57:12 +02:00
🐛 Add migration for fix invalid shadows
This commit is contained in:
parent
17a208d67b
commit
8d0afd8c96
7 changed files with 86 additions and 30 deletions
|
@ -123,7 +123,6 @@
|
||||||
FileTime
|
FileTime
|
||||||
(inst-ms* [v] (.toMillis ^FileTime v)))
|
(inst-ms* [v] (.toMillis ^FileTime v)))
|
||||||
|
|
||||||
|
|
||||||
(defmethod print-method Duration
|
(defmethod print-method Duration
|
||||||
[mv ^java.io.Writer writer]
|
[mv ^java.io.Writer writer]
|
||||||
(.write writer (str "#app/duration \"" (str/lower (subs (str mv) 2)) "\"")))
|
(.write writer (str "#app/duration \"" (str/lower (subs (str mv) 2)) "\"")))
|
||||||
|
|
|
@ -6,4 +6,4 @@
|
||||||
|
|
||||||
(ns app.common.files.defaults)
|
(ns app.common.files.defaults)
|
||||||
|
|
||||||
(def version 43)
|
(def version 44)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
[app.common.svg :as csvg]
|
[app.common.svg :as csvg]
|
||||||
[app.common.text :as txt]
|
[app.common.text :as txt]
|
||||||
[app.common.types.shape :as cts]
|
[app.common.types.shape :as cts]
|
||||||
|
[app.common.types.shape.shadow :as ctss]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[cuerdas.core :as str]))
|
[cuerdas.core :as str]))
|
||||||
|
|
||||||
|
@ -803,3 +804,28 @@
|
||||||
(-> data
|
(-> data
|
||||||
(update :pages-index update-vals update-container)
|
(update :pages-index update-vals update-container)
|
||||||
(update :components update-vals update-container))))
|
(update :components update-vals update-container))))
|
||||||
|
|
||||||
|
(def ^:private valid-shadow?
|
||||||
|
(sm/lazy-validator ::ctss/shadow))
|
||||||
|
|
||||||
|
(defmethod migrate 44
|
||||||
|
[data]
|
||||||
|
(letfn [(fix-shadow [shadow]
|
||||||
|
(if (string? (:color shadow))
|
||||||
|
(let [color {:color (:color shadow)
|
||||||
|
:opacity 1}]
|
||||||
|
(assoc shadow :color color))
|
||||||
|
shadow))
|
||||||
|
|
||||||
|
(update-object [object]
|
||||||
|
(d/update-when object :shadow
|
||||||
|
#(into []
|
||||||
|
(comp (map fix-shadow)
|
||||||
|
(filter valid-shadow?))
|
||||||
|
%)))
|
||||||
|
|
||||||
|
(update-container [container]
|
||||||
|
(d/update-when container :objects update-vals update-object))]
|
||||||
|
(-> data
|
||||||
|
(update :pages-index update-vals update-container)
|
||||||
|
(update :components update-vals update-container))))
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
[app.common.schema.generators :as sg]
|
[app.common.schema.generators :as sg]
|
||||||
[app.common.schema.openapi :as-alias oapi]
|
[app.common.schema.openapi :as-alias oapi]
|
||||||
[app.common.schema.registry :as sr]
|
[app.common.schema.registry :as sr]
|
||||||
|
[app.common.time :as tm]
|
||||||
[app.common.uri :as u]
|
[app.common.uri :as u]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[clojure.core :as c]
|
[clojure.core :as c]
|
||||||
|
@ -625,7 +626,8 @@
|
||||||
{:title "inst"
|
{:title "inst"
|
||||||
:description "Satisfies Inst protocol"
|
:description "Satisfies Inst protocol"
|
||||||
:error/message "expected to be number in safe range"
|
:error/message "expected to be number in safe range"
|
||||||
:gen/gen (sg/small-int)
|
:gen/gen (->> (sg/small-int)
|
||||||
|
(sg/fmap (fn [v] (tm/instant v))))
|
||||||
::oapi/type "number"
|
::oapi/type "number"
|
||||||
::oapi/format "int64"}})
|
::oapi/format "int64"}})
|
||||||
|
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
;;
|
;;
|
||||||
;; Copyright (c) KALEIDOS INC
|
;; Copyright (c) KALEIDOS INC
|
||||||
|
|
||||||
;; Here we put the time functions that are common between frontend and backend.
|
|
||||||
;; In the future we may create an unified API for both.
|
|
||||||
|
|
||||||
(ns app.common.time
|
(ns app.common.time
|
||||||
|
"A new cross-platform date and time API. It should be prefered over
|
||||||
|
a platform specific implementation found on `app.util.time`."
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(:require
|
(:require
|
||||||
["luxon" :as lxn])
|
["luxon" :as lxn])
|
||||||
:clj
|
:clj
|
||||||
(:import
|
(:import
|
||||||
java.time.Instant)))
|
java.time.Instant
|
||||||
|
java.time.Duration)))
|
||||||
|
|
||||||
#?(:cljs
|
#?(:cljs
|
||||||
(def DateTime lxn/DateTime))
|
(def DateTime lxn/DateTime))
|
||||||
|
@ -25,3 +25,38 @@
|
||||||
[]
|
[]
|
||||||
#?(:clj (Instant/now)
|
#?(:clj (Instant/now)
|
||||||
:cljs (.local ^js DateTime)))
|
:cljs (.local ^js DateTime)))
|
||||||
|
|
||||||
|
(defn instant
|
||||||
|
[s]
|
||||||
|
#?(:clj (Instant/ofEpochMilli s)
|
||||||
|
:cljs (.fromMillis ^js DateTime s #js {:zone "local" :setZone false})))
|
||||||
|
|
||||||
|
#?(:cljs
|
||||||
|
(extend-protocol IComparable
|
||||||
|
DateTime
|
||||||
|
(-compare [it other]
|
||||||
|
(if ^boolean (.equals it other)
|
||||||
|
0
|
||||||
|
(if (< (inst-ms it) (inst-ms other)) -1 1)))
|
||||||
|
|
||||||
|
Duration
|
||||||
|
(-compare [it other]
|
||||||
|
(if ^boolean (.equals it other)
|
||||||
|
0
|
||||||
|
(if (< (inst-ms it) (inst-ms other)) -1 1)))))
|
||||||
|
|
||||||
|
#?(:cljs
|
||||||
|
(extend-protocol cljs.core/Inst
|
||||||
|
DateTime
|
||||||
|
(inst-ms* [inst] (.toMillis ^js inst))
|
||||||
|
|
||||||
|
Duration
|
||||||
|
(inst-ms* [inst] (.toMillis ^js inst)))
|
||||||
|
|
||||||
|
:clj
|
||||||
|
(extend-protocol clojure.core/Inst
|
||||||
|
Duration
|
||||||
|
(inst-ms* [v] (.toMillis ^Duration v))
|
||||||
|
|
||||||
|
Instant
|
||||||
|
(inst-ms* [v] (.toEpochMilli ^Instant v))))
|
||||||
|
|
|
@ -70,18 +70,20 @@
|
||||||
[:offset ::sm/safe-number]]]]])
|
[:offset ::sm/safe-number]]]]])
|
||||||
|
|
||||||
(sm/define! ::color
|
(sm/define! ::color
|
||||||
[:map {:title "Color"}
|
[:and
|
||||||
[:id {:optional true} ::sm/uuid]
|
[:map {:title "Color"}
|
||||||
[:name {:optional true} :string]
|
[:id {:optional true} ::sm/uuid]
|
||||||
[:path {:optional true} [:maybe :string]]
|
[:name {:optional true} :string]
|
||||||
[:value {:optional true} [:maybe :string]]
|
[:path {:optional true} [:maybe :string]]
|
||||||
[:color {:optional true} [:maybe ::rgb-color]]
|
[:value {:optional true} [:maybe :string]]
|
||||||
[:opacity {:optional true} [:maybe ::sm/safe-number]]
|
[:color {:optional true} [:maybe ::rgb-color]]
|
||||||
[:modified-at {:optional true} ::sm/inst]
|
[:opacity {:optional true} [:maybe ::sm/safe-number]]
|
||||||
[:ref-id {:optional true} ::sm/uuid]
|
[:modified-at {:optional true} ::sm/inst]
|
||||||
[:ref-file {:optional true} ::sm/uuid]
|
[:ref-id {:optional true} ::sm/uuid]
|
||||||
[:gradient {:optional true} [:maybe ::gradient]]
|
[:ref-file {:optional true} ::sm/uuid]
|
||||||
[:image {:optional true} [:maybe ::image-color]]])
|
[:gradient {:optional true} [:maybe ::gradient]]
|
||||||
|
[:image {:optional true} [:maybe ::image-color]]]
|
||||||
|
[::sm/contains-any {:strict true} [:color :gradient :image]]])
|
||||||
|
|
||||||
(sm/define! ::recent-color
|
(sm/define! ::recent-color
|
||||||
[:and
|
[:and
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
(ns app.common.types.shape.shadow
|
(ns app.common.types.shape.shadow
|
||||||
(:require
|
(:require
|
||||||
[app.common.schema :as sm]
|
[app.common.schema :as sm]
|
||||||
[app.common.types.color :as ctc]
|
[app.common.types.color :as ctc]))
|
||||||
[app.common.types.shape.shadow.color :as-alias shadow-color]))
|
|
||||||
|
|
||||||
(def styles #{:drop-shadow :inner-shadow})
|
(def styles #{:drop-shadow :inner-shadow})
|
||||||
|
|
||||||
|
@ -21,11 +20,4 @@
|
||||||
[:blur ::sm/safe-number]
|
[:blur ::sm/safe-number]
|
||||||
[:spread ::sm/safe-number]
|
[:spread ::sm/safe-number]
|
||||||
[:hidden :boolean]
|
[:hidden :boolean]
|
||||||
;;FIXME: reuse color?
|
[:color ::ctc/color]])
|
||||||
[:color
|
|
||||||
[:map
|
|
||||||
[:color {:optional true} :string]
|
|
||||||
[:opacity {:optional true} ::sm/safe-number]
|
|
||||||
[:gradient {:optional true} [:maybe ::ctc/gradient]]
|
|
||||||
[:file-id {:optional true} [:maybe ::sm/uuid]]
|
|
||||||
[:id {:optional true} [:maybe ::sm/uuid]]]]])
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue