mirror of
https://github.com/penpot/penpot.git
synced 2025-05-02 09:25:53 +02:00
🐛 Make shape interaction properly decode on binfile import
This commit is contained in:
parent
e69c0c3e27
commit
cc7f0b145c
2 changed files with 44 additions and 27 deletions
|
@ -392,17 +392,20 @@
|
||||||
|
|
||||||
(defn- parse-uuid
|
(defn- parse-uuid
|
||||||
[s]
|
[s]
|
||||||
(if (str/empty? s)
|
(if (uuid? s)
|
||||||
nil
|
s
|
||||||
(try
|
(if (str/empty? s)
|
||||||
(uuid/parse s)
|
nil
|
||||||
(catch #?(:clj Exception :cljs :default) _cause
|
(try
|
||||||
s))))
|
(uuid/parse s)
|
||||||
|
(catch #?(:clj Exception :cljs :default) _cause
|
||||||
|
s)))))
|
||||||
|
|
||||||
(defn- encode-uuid
|
(defn- encode-uuid
|
||||||
[v]
|
[v]
|
||||||
(when (uuid? v)
|
(if (uuid? v)
|
||||||
(str v)))
|
(str v)
|
||||||
|
v))
|
||||||
|
|
||||||
(register!
|
(register!
|
||||||
{:type ::uuid
|
{:type ::uuid
|
||||||
|
|
|
@ -109,13 +109,27 @@
|
||||||
(def check-animation!
|
(def check-animation!
|
||||||
(sm/check-fn schema:animation))
|
(sm/check-fn schema:animation))
|
||||||
|
|
||||||
|
(def schema:interaction-attrs
|
||||||
|
[:map {:title "InteractionAttrs"}
|
||||||
|
[:action-type {:optional true} [::sm/one-of action-types]]
|
||||||
|
[:event-type {:optional true} [::sm/one-of event-types]]
|
||||||
|
[:destination {:optional true} [:maybe ::sm/uuid]]
|
||||||
|
[:preserve-scroll {:optional true} :boolean]
|
||||||
|
[:animation {:optional true} schema:animation]
|
||||||
|
[:overlay-position {:optional true} ::gpt/point]
|
||||||
|
[:overlay-pos-type {:optional true} [::sm/one-of overlay-positioning-types]]
|
||||||
|
[:close-click-outside {:optional true} :boolean]
|
||||||
|
[:background-overlay {:optional true} :boolean]
|
||||||
|
[:position-relative-to {:optional true} [:maybe ::sm/uuid]]
|
||||||
|
[:url {:optional true} :string]])
|
||||||
|
|
||||||
(def schema:navigate-interaction
|
(def schema:navigate-interaction
|
||||||
[:map
|
[:map
|
||||||
[:action-type [:= :navigate]]
|
[:action-type [:= :navigate]]
|
||||||
[:event-type [::sm/one-of event-types]]
|
[:event-type [::sm/one-of event-types]]
|
||||||
[:destination {:optional true} [:maybe ::sm/uuid]]
|
[:destination {:optional true} [:maybe ::sm/uuid]]
|
||||||
[:preserve-scroll {:optional true} :boolean]
|
[:preserve-scroll {:optional true} :boolean]
|
||||||
[:animation {:optional true} ::animation]])
|
[:animation {:optional true} schema:animation]])
|
||||||
|
|
||||||
(def schema:open-overlay-interaction
|
(def schema:open-overlay-interaction
|
||||||
[:map
|
[:map
|
||||||
|
@ -126,7 +140,7 @@
|
||||||
[:destination {:optional true} [:maybe ::sm/uuid]]
|
[:destination {:optional true} [:maybe ::sm/uuid]]
|
||||||
[:close-click-outside {:optional true} :boolean]
|
[:close-click-outside {:optional true} :boolean]
|
||||||
[:background-overlay {:optional true} :boolean]
|
[:background-overlay {:optional true} :boolean]
|
||||||
[:animation {:optional true} ::animation]
|
[:animation {:optional true} schema:animation]
|
||||||
[:position-relative-to {:optional true} [:maybe ::sm/uuid]]])
|
[:position-relative-to {:optional true} [:maybe ::sm/uuid]]])
|
||||||
|
|
||||||
(def schema:toggle-overlay-interaction
|
(def schema:toggle-overlay-interaction
|
||||||
|
@ -138,7 +152,7 @@
|
||||||
[:destination {:optional true} [:maybe ::sm/uuid]]
|
[:destination {:optional true} [:maybe ::sm/uuid]]
|
||||||
[:close-click-outside {:optional true} :boolean]
|
[:close-click-outside {:optional true} :boolean]
|
||||||
[:background-overlay {:optional true} :boolean]
|
[:background-overlay {:optional true} :boolean]
|
||||||
[:animation {:optional true} ::animation]
|
[:animation {:optional true} schema:animation]
|
||||||
[:position-relative-to {:optional true} [:maybe ::sm/uuid]]])
|
[:position-relative-to {:optional true} [:maybe ::sm/uuid]]])
|
||||||
|
|
||||||
(def schema:close-overlay-interaction
|
(def schema:close-overlay-interaction
|
||||||
|
@ -146,7 +160,7 @@
|
||||||
[:action-type [:= :close-overlay]]
|
[:action-type [:= :close-overlay]]
|
||||||
[:event-type [::sm/one-of event-types]]
|
[:event-type [::sm/one-of event-types]]
|
||||||
[:destination {:optional true} [:maybe ::sm/uuid]]
|
[:destination {:optional true} [:maybe ::sm/uuid]]
|
||||||
[:animation {:optional true} ::animation]
|
[:animation {:optional true} schema:animation]
|
||||||
[:position-relative-to {:optional true} [:maybe ::sm/uuid]]])
|
[:position-relative-to {:optional true} [:maybe ::sm/uuid]]])
|
||||||
|
|
||||||
(def schema:prev-scren-interaction
|
(def schema:prev-scren-interaction
|
||||||
|
@ -161,21 +175,21 @@
|
||||||
[:url :string]])
|
[:url :string]])
|
||||||
|
|
||||||
(def schema:interaction
|
(def schema:interaction
|
||||||
[:multi {:dispatch :action-type
|
[:and {:title "Interaction"
|
||||||
:title "Interaction"
|
:gen/gen (sg/one-of (sg/generator schema:navigate-interaction)
|
||||||
:gen/gen (sg/one-of (sg/generator schema:navigate-interaction)
|
(sg/generator schema:open-overlay-interaction)
|
||||||
(sg/generator schema:open-overlay-interaction)
|
(sg/generator schema:close-overlay-interaction)
|
||||||
(sg/generator schema:close-overlay-interaction)
|
(sg/generator schema:toggle-overlay-interaction)
|
||||||
(sg/generator schema:toggle-overlay-interaction)
|
(sg/generator schema:prev-scren-interaction)
|
||||||
(sg/generator schema:prev-scren-interaction)
|
(sg/generator schema:open-url-interaction))}
|
||||||
(sg/generator schema:open-url-interaction))
|
schema:interaction-attrs
|
||||||
:decode/json #(update % :action-type keyword)}
|
[:multi {:dispatch :action-type}
|
||||||
[:navigate schema:navigate-interaction]
|
[:navigate schema:navigate-interaction]
|
||||||
[:open-overlay schema:open-overlay-interaction]
|
[:open-overlay schema:open-overlay-interaction]
|
||||||
[:toggle-overlay schema:toggle-overlay-interaction]
|
[:toggle-overlay schema:toggle-overlay-interaction]
|
||||||
[:close-overlay schema:close-overlay-interaction]
|
[:close-overlay schema:close-overlay-interaction]
|
||||||
[:prev-screen schema:prev-scren-interaction]
|
[:prev-screen schema:prev-scren-interaction]
|
||||||
[:open-url schema:open-url-interaction]])
|
[:open-url schema:open-url-interaction]]])
|
||||||
|
|
||||||
(sm/register! ::interaction schema:interaction)
|
(sm/register! ::interaction schema:interaction)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue