♻️ Rename specs -> types

NO FUNCTIONALITY IS CHANGED in this commit, only moving things around
This commit is contained in:
Andrés Moya 2022-06-09 12:00:32 +02:00 committed by Alejandro Alonso
parent 29220cd0d3
commit 6f94745aed
38 changed files with 348 additions and 352 deletions

View file

@ -7,7 +7,6 @@
[app.common.logging :as l] [app.common.logging :as l]
[app.common.pages :as cp] [app.common.pages :as cp]
[app.common.pages.migrations :as pmg] [app.common.pages.migrations :as pmg]
[app.common.spec.file :as spec.file]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cfg] [app.config :as cfg]
[app.db :as db] [app.db :as db]

View file

@ -11,9 +11,9 @@
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.pages.changes :as ch] [app.common.pages.changes :as ch]
[app.common.pages.changes-spec :as pcs]
[app.common.pages.init :as init] [app.common.pages.init :as init]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.change :as spec.change]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[cuerdas.core :as str])) [cuerdas.core :as str]))
@ -44,9 +44,9 @@
:frame-id (:current-frame-id file)))] :frame-id (:current-frame-id file)))]
(when fail-on-spec? (when fail-on-spec?
(us/verify ::spec.change/change change)) (us/verify ::pcs/change change))
(let [valid? (us/valid? ::spec.change/change change)] (let [valid? (us/valid? ::pcs/change change)]
#?(:cljs #?(:cljs
(when-not valid? (.warn js/console "Invalid shape" (clj->js change)))) (when-not valid? (.warn js/console "Invalid shape" (clj->js change))))

View file

@ -16,8 +16,8 @@
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.pages.init :as init] [app.common.pages.init :as init]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.change :as spec.change] [app.common.pages.changes-spec :as pcs]
[app.common.spec.shape :as spec.shape])) [app.common.types.shape :as cts]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Specific helpers ;; Specific helpers
@ -49,7 +49,7 @@
;; When verify? false we spec the schema validation. Currently used to make just ;; When verify? false we spec the schema validation. Currently used to make just
;; 1 validation even if the changes are applied twice ;; 1 validation even if the changes are applied twice
(when verify? (when verify?
(us/assert ::spec.change/changes items)) (us/assert ::pcs/changes items))
(let [result (reduce #(or (process-change %1 %2) %1) data items)] (let [result (reduce #(or (process-change %1 %2) %1) data items)]
;; Validate result shapes (only on the backend) ;; Validate result shapes (only on the backend)
@ -59,7 +59,7 @@
(doseq [[id shape] (:objects page)] (doseq [[id shape] (:objects page)]
(when-not (= shape (get-in data [:pages-index page-id :objects id])) (when-not (= shape (get-in data [:pages-index page-id :objects id]))
;; If object has change verify is correct ;; If object has change verify is correct
(us/verify ::spec.shape/shape shape)))))) (us/verify ::cts/shape shape))))))
result))) result)))

View file

@ -4,14 +4,14 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.change (ns app.common.pages.changes-spec
(:require (:require
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.color :as color] [app.common.types.color :as ctc]
[app.common.spec.file :as file] [app.common.types.file :as ctf]
[app.common.spec.page :as page] [app.common.types.page :as ctp]
[app.common.spec.shape :as shape] [app.common.types.shape :as cts]
[app.common.spec.typography :as typg] [app.common.types.typography :as ctt]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
(s/def ::index integer?) (s/def ::index integer?)
@ -52,7 +52,7 @@
(s/keys :req-un [:internal.changes.set-option/option (s/keys :req-un [:internal.changes.set-option/option
:internal.changes.set-option/value])) :internal.changes.set-option/value]))
(s/def :internal.changes.add-obj/obj ::shape/shape) (s/def :internal.changes.add-obj/obj ::cts/shape)
(defn- valid-container-id-frame? (defn- valid-container-id-frame?
[o] [o]
@ -89,18 +89,18 @@
valid-container-id?)) valid-container-id?))
(defmethod change-spec :reg-objects [_] (defmethod change-spec :reg-objects [_]
(s/and (s/keys :req-un [::shape/shapes] (s/and (s/keys :req-un [::cts/shapes]
:opt-un [::page-id ::component-id]) :opt-un [::page-id ::component-id])
valid-container-id?)) valid-container-id?))
(defmethod change-spec :mov-objects [_] (defmethod change-spec :mov-objects [_]
(s/and (s/keys :req-un [::parent-id ::shape/shapes] (s/and (s/keys :req-un [::parent-id ::cts/shapes]
:opt-un [::page-id ::component-id ::index]) :opt-un [::page-id ::component-id ::index])
valid-container-id?)) valid-container-id?))
(defmethod change-spec :add-page [_] (defmethod change-spec :add-page [_]
(s/or :empty (s/keys :req-un [::id ::name]) (s/or :empty (s/keys :req-un [::id ::name])
:complete (s/keys :req-un [::page/page]))) :complete (s/keys :req-un [::ctp/page])))
(defmethod change-spec :mod-page [_] (defmethod change-spec :mod-page [_]
(s/keys :req-un [::id ::name])) (s/keys :req-un [::id ::name]))
@ -112,21 +112,21 @@
(s/keys :req-un [::id ::index])) (s/keys :req-un [::id ::index]))
(defmethod change-spec :add-color [_] (defmethod change-spec :add-color [_]
(s/keys :req-un [::color/color])) (s/keys :req-un [::ctc/color]))
(defmethod change-spec :mod-color [_] (defmethod change-spec :mod-color [_]
(s/keys :req-un [::color/color])) (s/keys :req-un [::ctc/color]))
(defmethod change-spec :del-color [_] (defmethod change-spec :del-color [_]
(s/keys :req-un [::id])) (s/keys :req-un [::id]))
(s/def :internal.changes.add-recent-color/color ::color/recent-color) (s/def :internal.changes.add-recent-color/color ::ctc/recent-color)
(defmethod change-spec :add-recent-color [_] (defmethod change-spec :add-recent-color [_]
(s/keys :req-un [:internal.changes.add-recent-color/color])) (s/keys :req-un [:internal.changes.add-recent-color/color]))
(s/def :internal.changes.add-media/object ::file/media-object) (s/def :internal.changes.add-media/object ::ctf/media-object)
(defmethod change-spec :add-media [_] (defmethod change-spec :add-media [_]
(s/keys :req-un [:internal.changes.add-media/object])) (s/keys :req-un [:internal.changes.add-media/object]))
@ -149,7 +149,7 @@
(s/keys :req-un [::id])) (s/keys :req-un [::id]))
(s/def :internal.changes.add-component/shapes (s/def :internal.changes.add-component/shapes
(s/coll-of ::shape/shape)) (s/coll-of ::cts/shape))
(defmethod change-spec :add-component [_] (defmethod change-spec :add-component [_]
(s/keys :req-un [::id ::name :internal.changes.add-component/shapes] (s/keys :req-un [::id ::name :internal.changes.add-component/shapes]
@ -163,13 +163,13 @@
(s/keys :req-un [::id])) (s/keys :req-un [::id]))
(defmethod change-spec :add-typography [_] (defmethod change-spec :add-typography [_]
(s/keys :req-un [::typg/typography])) (s/keys :req-un [::ctt/typography]))
(defmethod change-spec :mod-typography [_] (defmethod change-spec :mod-typography [_]
(s/keys :req-un [::typg/typography])) (s/keys :req-un [::ctt/typography]))
(defmethod change-spec :del-typography [_] (defmethod change-spec :del-typography [_]
(s/keys :req-un [::typg/id])) (s/keys :req-un [::ctt/id]))
(s/def ::change (s/multi-spec change-spec :type)) (s/def ::change (s/multi-spec change-spec :type))
(s/def ::changes (s/coll-of ::change)) (s/def ::changes (s/coll-of ::change))

View file

@ -11,7 +11,7 @@
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.math :as mth] [app.common.math :as mth]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.page :as spec.page] [app.common.types.page :as ctp]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[cuerdas.core :as str])) [cuerdas.core :as str]))
@ -64,7 +64,7 @@
(defn get-shape (defn get-shape
[container shape-id] [container shape-id]
(us/assert ::spec.page/container container) (us/assert ::ctp/container container)
(us/assert ::us/uuid shape-id) (us/assert ::us/uuid shape-id)
(-> container (-> container
(get :objects) (get :objects)

View file

@ -15,7 +15,7 @@
[app.common.geom.shapes.path :as gsp] [app.common.geom.shapes.path :as gsp]
[app.common.path.bool :as pb] [app.common.path.bool :as pb]
[app.common.path.commands :as pc] [app.common.path.commands :as pc]
[app.common.spec.radius :as ctr])) [app.common.types.shape.radius :as ctsr]))
(def ^:const bezier-circle-c 0.551915024494) (def ^:const bezier-circle-c 0.551915024494)
@ -152,7 +152,7 @@
(defn rect->path (defn rect->path
"Creates a bezier curve that approximates a rounded corner rectangle" "Creates a bezier curve that approximates a rounded corner rectangle"
[{:keys [x y width height] :as shape}] [{:keys [x y width height] :as shape}]
(case (ctr/radius-mode shape) (case (ctsr/radius-mode shape)
:radius-1 :radius-1
(let [radius (gso/shape-corners-1 shape)] (let [radius (gso/shape-corners-1 shape)]
(draw-rounded-rect-path x y width height radius)) (draw-rounded-rect-path x y width height radius))

View file

@ -4,7 +4,7 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.color (ns app.common.types.color
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.spec :as us] [app.common.spec :as us]

View file

@ -4,12 +4,11 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.file (ns app.common.types.file
(:require (:require
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.color :as color] [app.common.types.color :as ctc]
[app.common.spec.page :as page] [app.common.types.page :as ctp]
[app.common.spec.typography]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
(s/def :internal.media-object/name string?) (s/def :internal.media-object/name string?)
@ -31,13 +30,13 @@
:opt-un [:internal.media-object/path])) :opt-un [:internal.media-object/path]))
(s/def ::colors (s/def ::colors
(s/map-of uuid? ::color/color)) (s/map-of uuid? ::ctc/color))
(s/def ::recent-colors (s/def ::recent-colors
(s/coll-of ::color/recent-color :kind vector?)) (s/coll-of ::ctc/recent-color :kind vector?))
(s/def ::typographies (s/def ::typographies
(s/map-of uuid? :app.common.spec.typography/typography)) (s/map-of uuid? :ctst/typography))
(s/def ::pages (s/def ::pages
(s/coll-of uuid? :kind vector?)) (s/coll-of uuid? :kind vector?))
@ -46,10 +45,10 @@
(s/map-of uuid? ::media-object)) (s/map-of uuid? ::media-object))
(s/def ::pages-index (s/def ::pages-index
(s/map-of uuid? ::page/page)) (s/map-of uuid? ::ctp/page))
(s/def ::components (s/def ::components
(s/map-of uuid? ::page/container)) (s/map-of uuid? ::ctp/container))
(s/def ::data (s/def ::data
(s/keys :req-un [::pages-index (s/keys :req-un [::pages-index

View file

@ -4,11 +4,11 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.page (ns app.common.types.page
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.shape :as shape] [app.common.types.shape :as cts]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
;; --- Grid options ;; --- Grid options
@ -90,7 +90,7 @@
(s/def ::id uuid?) (s/def ::id uuid?)
(s/def ::name string?) (s/def ::name string?)
(s/def ::objects (s/map-of uuid? ::shape/shape)) (s/def ::objects (s/map-of uuid? ::cts/shape))
(s/def ::page (s/def ::page
(s/keys :req-un [::id ::name ::objects ::options])) (s/keys :req-un [::id ::name ::objects ::options]))

View file

@ -4,17 +4,17 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.shape (ns app.common.types.shape
(:require (:require
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.blur :as blur] [app.common.types.color :as ctc]
[app.common.spec.color :as color] [app.common.types.shape.blur :as ctsb]
[app.common.spec.export :as export] [app.common.types.shape.export :as ctse]
[app.common.spec.interactions :as cti] [app.common.types.shape.interactions :as ctsi]
[app.common.spec.radius :as radius] [app.common.types.shape.radius :as ctsr]
[app.common.spec.shadow :as shadow] [app.common.types.shape.shadow :as ctss]
[clojure.set :as set] [clojure.set :as set]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
@ -47,7 +47,7 @@
(s/def ::fill-color string?) (s/def ::fill-color string?)
(s/def ::fill-opacity ::us/safe-number) (s/def ::fill-opacity ::us/safe-number)
(s/def ::fill-color-gradient (s/nilable ::color/gradient)) (s/def ::fill-color-gradient (s/nilable ::ctc/gradient))
(s/def ::fill-color-ref-file (s/nilable uuid?)) (s/def ::fill-color-ref-file (s/nilable uuid?))
(s/def ::fill-color-ref-id (s/nilable uuid?)) (s/def ::fill-color-ref-id (s/nilable uuid?))
@ -69,7 +69,7 @@
(s/def ::proportion ::us/safe-number) (s/def ::proportion ::us/safe-number)
(s/def ::proportion-lock boolean?) (s/def ::proportion-lock boolean?)
(s/def ::stroke-color string?) (s/def ::stroke-color string?)
(s/def ::stroke-color-gradient (s/nilable ::color/gradient)) (s/def ::stroke-color-gradient (s/nilable ::ctc/gradient))
(s/def ::stroke-color-ref-file (s/nilable uuid?)) (s/def ::stroke-color-ref-file (s/nilable uuid?))
(s/def ::stroke-color-ref-id (s/nilable uuid?)) (s/def ::stroke-color-ref-id (s/nilable uuid?))
(s/def ::stroke-opacity ::us/safe-number) (s/def ::stroke-opacity ::us/safe-number)
@ -102,7 +102,7 @@
(s/keys :req-un [::x ::y ::x1 ::y1 ::x2 ::y2 ::width ::height])) (s/keys :req-un [::x ::y ::x1 ::y1 ::x2 ::y2 ::width ::height]))
(s/def ::exports (s/def ::exports
(s/coll-of ::export/export :kind vector?)) (s/coll-of ::ctse/export :kind vector?))
(s/def ::points (s/def ::points
(s/every ::gpt/point :kind vector?)) (s/every ::gpt/point :kind vector?))
@ -187,12 +187,12 @@
::constraints-h ::constraints-h
::constraints-v ::constraints-v
::fixed-scroll ::fixed-scroll
::radius/rx ::ctsr/rx
::radius/ry ::ctsr/ry
::radius/r1 ::ctsr/r1
::radius/r2 ::ctsr/r2
::radius/r3 ::ctsr/r3
::radius/r4 ::ctsr/r4
::x ::x
::y ::y
::exports ::exports
@ -213,9 +213,9 @@
::width ::width
::height ::height
::masked-group? ::masked-group?
::cti/interactions ::ctsi/interactions
::shadow/shadow ::ctss/shadow
::blur/blur ::ctsb/blur
::opacity ::opacity
::blend-mode])) ::blend-mode]))

View file

@ -4,7 +4,7 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.blur (ns app.common.types.shape.blur
(:require (:require
[app.common.spec :as us] [app.common.spec :as us]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))

View file

@ -4,12 +4,11 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.export (ns app.common.types.shape.export
(:require (:require
[app.common.spec :as us] [app.common.spec :as us]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
(s/def ::suffix string?) (s/def ::suffix string?)
(s/def ::scale ::us/safe-number) (s/def ::scale ::us/safe-number)
(s/def ::type keyword?) (s/def ::type keyword?)
@ -19,4 +18,3 @@
::suffix ::suffix
::scale])) ::scale]))

View file

@ -4,7 +4,7 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.interactions (ns app.common.types.shape.interactions
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]

View file

@ -4,7 +4,7 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.radius (ns app.common.types.shape.radius
(:require (:require
[app.common.pages.common :refer [editable-attrs]] [app.common.pages.common :refer [editable-attrs]]
[app.common.spec :as us] [app.common.spec :as us]

View file

@ -4,10 +4,10 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.shadow (ns app.common.types.shape.shadow
(:require (:require
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.color :as color] [app.common.types.color :as ctc]
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))
@ -24,7 +24,7 @@
(s/def ::color string?) (s/def ::color string?)
(s/def ::opacity ::us/safe-number) (s/def ::opacity ::us/safe-number)
(s/def ::gradient (s/nilable ::color/gradient)) (s/def ::gradient (s/nilable ::ctc/gradient))
(s/def ::file-id (s/nilable uuid?)) (s/def ::file-id (s/nilable uuid?))
(s/def ::ref-id (s/nilable uuid?)) (s/def ::ref-id (s/nilable uuid?))

View file

@ -4,7 +4,7 @@
;; ;;
;; Copyright (c) UXBOX Labs SL ;; Copyright (c) UXBOX Labs SL
(ns app.common.spec.typography (ns app.common.types.typography
(:require (:require
[clojure.spec.alpha :as s])) [clojure.spec.alpha :as s]))

View file

@ -10,62 +10,62 @@
[clojure.pprint :refer [pprint]] [clojure.pprint :refer [pprint]]
[app.common.exceptions :as ex] [app.common.exceptions :as ex]
[app.common.pages.init :as cpi] [app.common.pages.init :as cpi]
[app.common.spec.interactions :as csi] [app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.common.geom.point :as gpt])) [app.common.geom.point :as gpt]))
(t/deftest set-event-type (t/deftest set-event-type
(let [interaction csi/default-interaction (let [interaction ctsi/default-interaction
shape (cpi/make-minimal-shape :rect) shape (cpi/make-minimal-shape :rect)
frame (cpi/make-minimal-shape :frame)] frame (cpi/make-minimal-shape :frame)]
(t/testing "Set event type unchanged" (t/testing "Set event type unchanged"
(let [new-interaction (let [new-interaction
(csi/set-event-type interaction :click shape)] (ctsi/set-event-type interaction :click shape)]
(t/is (= :click (:event-type new-interaction))))) (t/is (= :click (:event-type new-interaction)))))
(t/testing "Set event type changed" (t/testing "Set event type changed"
(let [new-interaction (let [new-interaction
(csi/set-event-type interaction :mouse-press shape)] (ctsi/set-event-type interaction :mouse-press shape)]
(t/is (= :mouse-press (:event-type new-interaction))))) (t/is (= :mouse-press (:event-type new-interaction)))))
(t/testing "Set after delay on non-frame" (t/testing "Set after delay on non-frame"
(let [result (ex/try (let [result (ex/try
(csi/set-event-type interaction :after-delay shape))] (ctsi/set-event-type interaction :after-delay shape))]
(t/is (ex/exception? result)))) (t/is (ex/exception? result))))
(t/testing "Set after delay on frame" (t/testing "Set after delay on frame"
(let [new-interaction (let [new-interaction
(csi/set-event-type interaction :after-delay frame)] (ctsi/set-event-type interaction :after-delay frame)]
(t/is (= :after-delay (:event-type new-interaction))) (t/is (= :after-delay (:event-type new-interaction)))
(t/is (= 600 (:delay new-interaction))))) (t/is (= 600 (:delay new-interaction)))))
(t/testing "Set after delay with previous data" (t/testing "Set after delay with previous data"
(let [interaction (assoc interaction :delay 300) (let [interaction (assoc interaction :delay 300)
new-interaction new-interaction
(csi/set-event-type interaction :after-delay frame)] (ctsi/set-event-type interaction :after-delay frame)]
(t/is (= :after-delay (:event-type new-interaction))) (t/is (= :after-delay (:event-type new-interaction)))
(t/is (= 300 (:delay new-interaction))))))) (t/is (= 300 (:delay new-interaction)))))))
(t/deftest set-action-type (t/deftest set-action-type
(let [interaction csi/default-interaction] (let [interaction ctsi/default-interaction]
(t/testing "Set action type unchanged" (t/testing "Set action type unchanged"
(let [new-interaction (let [new-interaction
(csi/set-action-type interaction :navigate)] (ctsi/set-action-type interaction :navigate)]
(t/is (= :navigate (:action-type new-interaction))))) (t/is (= :navigate (:action-type new-interaction)))))
(t/testing "Set action type changed" (t/testing "Set action type changed"
(let [new-interaction (let [new-interaction
(csi/set-action-type interaction :prev-screen)] (ctsi/set-action-type interaction :prev-screen)]
(t/is (= :prev-screen (:action-type new-interaction))))) (t/is (= :prev-screen (:action-type new-interaction)))))
(t/testing "Set action type navigate" (t/testing "Set action type navigate"
(let [interaction {:event-type :click (let [interaction {:event-type :click
:action-type :prev-screen} :action-type :prev-screen}
new-interaction new-interaction
(csi/set-action-type interaction :navigate)] (ctsi/set-action-type interaction :navigate)]
(t/is (= :navigate (:action-type new-interaction))) (t/is (= :navigate (:action-type new-interaction)))
(t/is (nil? (:destination new-interaction))) (t/is (nil? (:destination new-interaction)))
(t/is (= false (:preserve-scroll new-interaction))))) (t/is (= false (:preserve-scroll new-interaction)))))
@ -77,14 +77,14 @@
:destination destination :destination destination
:preserve-scroll true} :preserve-scroll true}
new-interaction new-interaction
(csi/set-action-type interaction :navigate)] (ctsi/set-action-type interaction :navigate)]
(t/is (= :navigate (:action-type new-interaction))) (t/is (= :navigate (:action-type new-interaction)))
(t/is (= destination (:destination new-interaction))) (t/is (= destination (:destination new-interaction)))
(t/is (= true (:preserve-scroll new-interaction))))) (t/is (= true (:preserve-scroll new-interaction)))))
(t/testing "Set action type open-overlay" (t/testing "Set action type open-overlay"
(let [new-interaction (let [new-interaction
(csi/set-action-type interaction :open-overlay)] (ctsi/set-action-type interaction :open-overlay)]
(t/is (= :open-overlay (:action-type new-interaction))) (t/is (= :open-overlay (:action-type new-interaction)))
(t/is (= :center (:overlay-pos-type new-interaction))) (t/is (= :center (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 0 0) (:overlay-position new-interaction))))) (t/is (= (gpt/point 0 0) (:overlay-position new-interaction)))))
@ -93,14 +93,14 @@
(let [interaction (assoc interaction :overlay-pos-type :top-left (let [interaction (assoc interaction :overlay-pos-type :top-left
:overlay-position (gpt/point 100 200)) :overlay-position (gpt/point 100 200))
new-interaction new-interaction
(csi/set-action-type interaction :open-overlay)] (ctsi/set-action-type interaction :open-overlay)]
(t/is (= :open-overlay (:action-type new-interaction))) (t/is (= :open-overlay (:action-type new-interaction)))
(t/is (= :top-left (:overlay-pos-type new-interaction))) (t/is (= :top-left (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 100 200) (:overlay-position new-interaction))))) (t/is (= (gpt/point 100 200) (:overlay-position new-interaction)))))
(t/testing "Set action type toggle-overlay" (t/testing "Set action type toggle-overlay"
(let [new-interaction (let [new-interaction
(csi/set-action-type interaction :toggle-overlay)] (ctsi/set-action-type interaction :toggle-overlay)]
(t/is (= :toggle-overlay (:action-type new-interaction))) (t/is (= :toggle-overlay (:action-type new-interaction)))
(t/is (= :center (:overlay-pos-type new-interaction))) (t/is (= :center (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 0 0) (:overlay-position new-interaction))))) (t/is (= (gpt/point 0 0) (:overlay-position new-interaction)))))
@ -109,14 +109,14 @@
(let [interaction (assoc interaction :overlay-pos-type :top-left (let [interaction (assoc interaction :overlay-pos-type :top-left
:overlay-position (gpt/point 100 200)) :overlay-position (gpt/point 100 200))
new-interaction new-interaction
(csi/set-action-type interaction :toggle-overlay)] (ctsi/set-action-type interaction :toggle-overlay)]
(t/is (= :toggle-overlay (:action-type new-interaction))) (t/is (= :toggle-overlay (:action-type new-interaction)))
(t/is (= :top-left (:overlay-pos-type new-interaction))) (t/is (= :top-left (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 100 200) (:overlay-position new-interaction))))) (t/is (= (gpt/point 100 200) (:overlay-position new-interaction)))))
(t/testing "Set action type close-overlay" (t/testing "Set action type close-overlay"
(let [new-interaction (let [new-interaction
(csi/set-action-type interaction :close-overlay)] (ctsi/set-action-type interaction :close-overlay)]
(t/is (= :close-overlay (:action-type new-interaction))) (t/is (= :close-overlay (:action-type new-interaction)))
(t/is (nil? (:destination new-interaction))))) (t/is (nil? (:destination new-interaction)))))
@ -124,89 +124,89 @@
(let [destination (uuid/next) (let [destination (uuid/next)
interaction (assoc interaction :destination destination) interaction (assoc interaction :destination destination)
new-interaction new-interaction
(csi/set-action-type interaction :close-overlay)] (ctsi/set-action-type interaction :close-overlay)]
(t/is (= :close-overlay (:action-type new-interaction))) (t/is (= :close-overlay (:action-type new-interaction)))
(t/is (= destination (:destination new-interaction))))) (t/is (= destination (:destination new-interaction)))))
(t/testing "Set action type prev-screen" (t/testing "Set action type prev-screen"
(let [new-interaction (let [new-interaction
(csi/set-action-type interaction :prev-screen)] (ctsi/set-action-type interaction :prev-screen)]
(t/is (= :prev-screen (:action-type new-interaction))))) (t/is (= :prev-screen (:action-type new-interaction)))))
(t/testing "Set action type open-url" (t/testing "Set action type open-url"
(let [new-interaction (let [new-interaction
(csi/set-action-type interaction :open-url)] (ctsi/set-action-type interaction :open-url)]
(t/is (= :open-url (:action-type new-interaction))) (t/is (= :open-url (:action-type new-interaction)))
(t/is (= "" (:url new-interaction))))) (t/is (= "" (:url new-interaction)))))
(t/testing "Set action type open-url with previous data" (t/testing "Set action type open-url with previous data"
(let [interaction (assoc interaction :url "https://example.com") (let [interaction (assoc interaction :url "https://example.com")
new-interaction new-interaction
(csi/set-action-type interaction :open-url)] (ctsi/set-action-type interaction :open-url)]
(t/is (= :open-url (:action-type new-interaction))) (t/is (= :open-url (:action-type new-interaction)))
(t/is (= "https://example.com" (:url new-interaction))))))) (t/is (= "https://example.com" (:url new-interaction)))))))
(t/deftest option-delay (t/deftest option-delay
(let [frame (cpi/make-minimal-shape :frame) (let [frame (cpi/make-minimal-shape :frame)
i1 csi/default-interaction i1 ctsi/default-interaction
i2 (csi/set-event-type i1 :after-delay frame)] i2 (ctsi/set-event-type i1 :after-delay frame)]
(t/testing "Has delay" (t/testing "Has delay"
(t/is (not (csi/has-delay i1))) (t/is (not (ctsi/has-delay i1)))
(t/is (csi/has-delay i2))) (t/is (ctsi/has-delay i2)))
(t/testing "Set delay" (t/testing "Set delay"
(let [new-interaction (csi/set-delay i2 1000)] (let [new-interaction (ctsi/set-delay i2 1000)]
(t/is (= 1000 (:delay new-interaction))))))) (t/is (= 1000 (:delay new-interaction)))))))
(t/deftest option-destination (t/deftest option-destination
(let [destination (uuid/next) (let [destination (uuid/next)
i1 csi/default-interaction i1 ctsi/default-interaction
i2 (csi/set-action-type i1 :prev-screen) i2 (ctsi/set-action-type i1 :prev-screen)
i3 (csi/set-action-type i1 :open-overlay)] i3 (ctsi/set-action-type i1 :open-overlay)]
(t/testing "Has destination" (t/testing "Has destination"
(t/is (csi/has-destination i1)) (t/is (ctsi/has-destination i1))
(t/is (not (csi/has-destination i2)))) (t/is (not (ctsi/has-destination i2))))
(t/testing "Set destination" (t/testing "Set destination"
(let [new-interaction (csi/set-destination i1 destination)] (let [new-interaction (ctsi/set-destination i1 destination)]
(t/is (= destination (:destination new-interaction))) (t/is (= destination (:destination new-interaction)))
(t/is (nil? (:overlay-pos-type new-interaction))) (t/is (nil? (:overlay-pos-type new-interaction)))
(t/is (nil? (:overlay-position new-interaction))))) (t/is (nil? (:overlay-position new-interaction)))))
(t/testing "Set destination of overlay" (t/testing "Set destination of overlay"
(let [new-interaction (csi/set-destination i3 destination)] (let [new-interaction (ctsi/set-destination i3 destination)]
(t/is (= destination (:destination new-interaction))) (t/is (= destination (:destination new-interaction)))
(t/is (= :center (:overlay-pos-type new-interaction))) (t/is (= :center (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 0 0) (:overlay-position new-interaction))))))) (t/is (= (gpt/point 0 0) (:overlay-position new-interaction)))))))
(t/deftest option-preserve-scroll (t/deftest option-preserve-scroll
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-action-type i1 :prev-screen)] i2 (ctsi/set-action-type i1 :prev-screen)]
(t/testing "Has preserve-scroll" (t/testing "Has preserve-scroll"
(t/is (csi/has-preserve-scroll i1)) (t/is (ctsi/has-preserve-scroll i1))
(t/is (not (csi/has-preserve-scroll i2)))) (t/is (not (ctsi/has-preserve-scroll i2))))
(t/testing "Set preserve-scroll" (t/testing "Set preserve-scroll"
(let [new-interaction (csi/set-preserve-scroll i1 true)] (let [new-interaction (ctsi/set-preserve-scroll i1 true)]
(t/is (= true (:preserve-scroll new-interaction))))))) (t/is (= true (:preserve-scroll new-interaction)))))))
(t/deftest option-url (t/deftest option-url
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-action-type i1 :open-url)] i2 (ctsi/set-action-type i1 :open-url)]
(t/testing "Has url" (t/testing "Has url"
(t/is (not (csi/has-url i1))) (t/is (not (ctsi/has-url i1)))
(t/is (csi/has-url i2))) (t/is (ctsi/has-url i2)))
(t/testing "Set url" (t/testing "Set url"
(let [new-interaction (csi/set-url i2 "https://example.com")] (let [new-interaction (ctsi/set-url i2 "https://example.com")]
(t/is (= "https://example.com" (:url new-interaction))))))) (t/is (= "https://example.com" (:url new-interaction)))))))
@ -220,35 +220,35 @@
objects {(:id base-frame) base-frame objects {(:id base-frame) base-frame
(:id overlay-frame) overlay-frame} (:id overlay-frame) overlay-frame}
i1 csi/default-interaction i1 ctsi/default-interaction
i2 (csi/set-action-type i1 :open-overlay) i2 (ctsi/set-action-type i1 :open-overlay)
i3 (-> i1 i3 (-> i1
(csi/set-action-type :open-overlay) (ctsi/set-action-type :open-overlay)
(csi/set-destination (:id overlay-frame)))] (ctsi/set-destination (:id overlay-frame)))]
(t/testing "Has overlay options" (t/testing "Has overlay options"
(t/is (not (csi/has-overlay-opts i1))) (t/is (not (ctsi/has-overlay-opts i1)))
(t/is (csi/has-overlay-opts i2))) (t/is (ctsi/has-overlay-opts i2)))
(t/testing "Set overlay-pos-type without destination" (t/testing "Set overlay-pos-type without destination"
(let [new-interaction (csi/set-overlay-pos-type i2 :top-right base-frame objects)] (let [new-interaction (ctsi/set-overlay-pos-type i2 :top-right base-frame objects)]
(t/is (= :top-right (:overlay-pos-type new-interaction))) (t/is (= :top-right (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 0 0) (:overlay-position new-interaction))))) (t/is (= (gpt/point 0 0) (:overlay-position new-interaction)))))
(t/testing "Set overlay-pos-type with destination and auto" (t/testing "Set overlay-pos-type with destination and auto"
(let [new-interaction (csi/set-overlay-pos-type i3 :bottom-right base-frame objects)] (let [new-interaction (ctsi/set-overlay-pos-type i3 :bottom-right base-frame objects)]
(t/is (= :bottom-right (:overlay-pos-type new-interaction))) (t/is (= :bottom-right (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 0 0) (:overlay-position new-interaction))))) (t/is (= (gpt/point 0 0) (:overlay-position new-interaction)))))
(t/testing "Set overlay-pos-type with destination and manual" (t/testing "Set overlay-pos-type with destination and manual"
(let [new-interaction (csi/set-overlay-pos-type i3 :manual base-frame objects)] (let [new-interaction (ctsi/set-overlay-pos-type i3 :manual base-frame objects)]
(t/is (= :manual (:overlay-pos-type new-interaction))) (t/is (= :manual (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 35 40) (:overlay-position new-interaction))))) (t/is (= (gpt/point 35 40) (:overlay-position new-interaction)))))
(t/testing "Toggle overlay-pos-type" (t/testing "Toggle overlay-pos-type"
(let [new-interaction (csi/toggle-overlay-pos-type i3 :center base-frame objects) (let [new-interaction (ctsi/toggle-overlay-pos-type i3 :center base-frame objects)
new-interaction-2 (csi/toggle-overlay-pos-type new-interaction :center base-frame objects) new-interaction-2 (ctsi/toggle-overlay-pos-type new-interaction :center base-frame objects)
new-interaction-3 (csi/toggle-overlay-pos-type new-interaction-2 :top-right base-frame objects)] new-interaction-3 (ctsi/toggle-overlay-pos-type new-interaction-2 :top-right base-frame objects)]
(t/is (= :manual (:overlay-pos-type new-interaction))) (t/is (= :manual (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 35 40) (:overlay-position new-interaction))) (t/is (= (gpt/point 35 40) (:overlay-position new-interaction)))
(t/is (= :center (:overlay-pos-type new-interaction-2))) (t/is (= :center (:overlay-pos-type new-interaction-2)))
@ -257,73 +257,73 @@
(t/is (= (gpt/point 0 0) (:overlay-position new-interaction-3))))) (t/is (= (gpt/point 0 0) (:overlay-position new-interaction-3)))))
(t/testing "Set overlay-position" (t/testing "Set overlay-position"
(let [new-interaction (csi/set-overlay-position i3 (gpt/point 50 60))] (let [new-interaction (ctsi/set-overlay-position i3 (gpt/point 50 60))]
(t/is (= :manual (:overlay-pos-type new-interaction))) (t/is (= :manual (:overlay-pos-type new-interaction)))
(t/is (= (gpt/point 50 60) (:overlay-position new-interaction))))) (t/is (= (gpt/point 50 60) (:overlay-position new-interaction)))))
(t/testing "Set close-click-outside" (t/testing "Set close-click-outside"
(let [new-interaction (csi/set-close-click-outside i3 true)] (let [new-interaction (ctsi/set-close-click-outside i3 true)]
(t/is (not (:close-click-outside i3))) (t/is (not (:close-click-outside i3)))
(t/is (:close-click-outside new-interaction)))) (t/is (:close-click-outside new-interaction))))
(t/testing "Set background-overlay" (t/testing "Set background-overlay"
(let [new-interaction (csi/set-background-overlay i3 true)] (let [new-interaction (ctsi/set-background-overlay i3 true)]
(t/is (not (:background-overlay i3))) (t/is (not (:background-overlay i3)))
(t/is (:background-overlay new-interaction)))))) (t/is (:background-overlay new-interaction))))))
(t/deftest animation-checks (t/deftest animation-checks
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-action-type i1 :open-overlay) i2 (ctsi/set-action-type i1 :open-overlay)
i3 (csi/set-action-type i1 :toggle-overlay) i3 (ctsi/set-action-type i1 :toggle-overlay)
i4 (csi/set-action-type i1 :close-overlay) i4 (ctsi/set-action-type i1 :close-overlay)
i5 (csi/set-action-type i1 :prev-screen) i5 (ctsi/set-action-type i1 :prev-screen)
i6 (csi/set-action-type i1 :open-url)] i6 (ctsi/set-action-type i1 :open-url)]
(t/testing "Has animation?" (t/testing "Has animation?"
(t/is (csi/has-animation? i1)) (t/is (ctsi/has-animation? i1))
(t/is (csi/has-animation? i2)) (t/is (ctsi/has-animation? i2))
(t/is (csi/has-animation? i3)) (t/is (ctsi/has-animation? i3))
(t/is (csi/has-animation? i4)) (t/is (ctsi/has-animation? i4))
(t/is (not (csi/has-animation? i5))) (t/is (not (ctsi/has-animation? i5)))
(t/is (not (csi/has-animation? i6)))) (t/is (not (ctsi/has-animation? i6))))
(t/testing "Valid push?" (t/testing "Valid push?"
(t/is (csi/allow-push? (:action-type i1))) (t/is (ctsi/allow-push? (:action-type i1)))
(t/is (not (csi/allow-push? (:action-type i2)))) (t/is (not (ctsi/allow-push? (:action-type i2))))
(t/is (not (csi/allow-push? (:action-type i3)))) (t/is (not (ctsi/allow-push? (:action-type i3))))
(t/is (not (csi/allow-push? (:action-type i4)))) (t/is (not (ctsi/allow-push? (:action-type i4))))
(t/is (not (csi/allow-push? (:action-type i5)))) (t/is (not (ctsi/allow-push? (:action-type i5))))
(t/is (not (csi/allow-push? (:action-type i6))))))) (t/is (not (ctsi/allow-push? (:action-type i6)))))))
(t/deftest set-animation-type (t/deftest set-animation-type
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-animation-type i1 :dissolve)] i2 (ctsi/set-animation-type i1 :dissolve)]
(t/testing "Set animation type nil" (t/testing "Set animation type nil"
(let [new-interaction (let [new-interaction
(csi/set-animation-type i1 nil)] (ctsi/set-animation-type i1 nil)]
(t/is (nil? (-> new-interaction :animation :animation-type))))) (t/is (nil? (-> new-interaction :animation :animation-type)))))
(t/testing "Set animation type unchanged" (t/testing "Set animation type unchanged"
(let [new-interaction (let [new-interaction
(csi/set-animation-type i2 :dissolve)] (ctsi/set-animation-type i2 :dissolve)]
(t/is (= :dissolve (-> new-interaction :animation :animation-type))))) (t/is (= :dissolve (-> new-interaction :animation :animation-type)))))
(t/testing "Set animation type changed" (t/testing "Set animation type changed"
(let [new-interaction (let [new-interaction
(csi/set-animation-type i2 :slide)] (ctsi/set-animation-type i2 :slide)]
(t/is (= :slide (-> new-interaction :animation :animation-type))))) (t/is (= :slide (-> new-interaction :animation :animation-type)))))
(t/testing "Set animation type reset" (t/testing "Set animation type reset"
(let [new-interaction (let [new-interaction
(csi/set-animation-type i2 nil)] (ctsi/set-animation-type i2 nil)]
(t/is (nil? (-> new-interaction :animation))))) (t/is (nil? (-> new-interaction :animation)))))
(t/testing "Set animation type dissolve" (t/testing "Set animation type dissolve"
(let [new-interaction (let [new-interaction
(csi/set-animation-type i1 :dissolve)] (ctsi/set-animation-type i1 :dissolve)]
(t/is (= :dissolve (-> new-interaction :animation :animation-type))) (t/is (= :dissolve (-> new-interaction :animation :animation-type)))
(t/is (= 300 (-> new-interaction :animation :duration))) (t/is (= 300 (-> new-interaction :animation :duration)))
(t/is (= :linear (-> new-interaction :animation :easing))))) (t/is (= :linear (-> new-interaction :animation :easing)))))
@ -336,14 +336,14 @@
:direction :left :direction :left
:offset-effect true}) :offset-effect true})
new-interaction new-interaction
(csi/set-animation-type interaction :dissolve)] (ctsi/set-animation-type interaction :dissolve)]
(t/is (= :dissolve (-> new-interaction :animation :animation-type))) (t/is (= :dissolve (-> new-interaction :animation :animation-type)))
(t/is (= 1000 (-> new-interaction :animation :duration))) (t/is (= 1000 (-> new-interaction :animation :duration)))
(t/is (= :ease-out (-> new-interaction :animation :easing))))) (t/is (= :ease-out (-> new-interaction :animation :easing)))))
(t/testing "Set animation type slide" (t/testing "Set animation type slide"
(let [new-interaction (let [new-interaction
(csi/set-animation-type i1 :slide)] (ctsi/set-animation-type i1 :slide)]
(t/is (= :slide (-> new-interaction :animation :animation-type))) (t/is (= :slide (-> new-interaction :animation :animation-type)))
(t/is (= 300 (-> new-interaction :animation :duration))) (t/is (= 300 (-> new-interaction :animation :duration)))
(t/is (= :linear (-> new-interaction :animation :easing))) (t/is (= :linear (-> new-interaction :animation :easing)))
@ -359,7 +359,7 @@
:direction :left :direction :left
:offset-effect true}) :offset-effect true})
new-interaction new-interaction
(csi/set-animation-type interaction :slide)] (ctsi/set-animation-type interaction :slide)]
(t/is (= :slide (-> new-interaction :animation :animation-type))) (t/is (= :slide (-> new-interaction :animation :animation-type)))
(t/is (= 1000 (-> new-interaction :animation :duration))) (t/is (= 1000 (-> new-interaction :animation :duration)))
(t/is (= :ease-out (-> new-interaction :animation :easing))) (t/is (= :ease-out (-> new-interaction :animation :easing)))
@ -369,7 +369,7 @@
(t/testing "Set animation type push" (t/testing "Set animation type push"
(let [new-interaction (let [new-interaction
(csi/set-animation-type i1 :push)] (ctsi/set-animation-type i1 :push)]
(t/is (= :push (-> new-interaction :animation :animation-type))) (t/is (= :push (-> new-interaction :animation :animation-type)))
(t/is (= 300 (-> new-interaction :animation :duration))) (t/is (= 300 (-> new-interaction :animation :duration)))
(t/is (= :linear (-> new-interaction :animation :easing))) (t/is (= :linear (-> new-interaction :animation :easing)))
@ -383,7 +383,7 @@
:direction :left :direction :left
:offset-effect true}) :offset-effect true})
new-interaction new-interaction
(csi/set-animation-type interaction :push)] (ctsi/set-animation-type interaction :push)]
(t/is (= :push (-> new-interaction :animation :animation-type))) (t/is (= :push (-> new-interaction :animation :animation-type)))
(t/is (= 1000 (-> new-interaction :animation :duration))) (t/is (= 1000 (-> new-interaction :animation :duration)))
(t/is (= :ease-out (-> new-interaction :animation :easing))) (t/is (= :ease-out (-> new-interaction :animation :easing)))
@ -391,9 +391,9 @@
(t/deftest allowed-animation (t/deftest allowed-animation
(let [i1 (csi/set-action-type csi/default-interaction :open-overlay) (let [i1 (ctsi/set-action-type ctsi/default-interaction :open-overlay)
i2 (csi/set-action-type csi/default-interaction :close-overlay) i2 (ctsi/set-action-type ctsi/default-interaction :close-overlay)
i3 (csi/set-action-type csi/default-interaction :toggle-overlay)] i3 (ctsi/set-action-type ctsi/default-interaction :toggle-overlay)]
(t/testing "Cannot use animation push for an overlay action" (t/testing "Cannot use animation push for an overlay action"
(let [bad-interaction-1 (assoc i1 :animation {:animation-type :push (let [bad-interaction-1 (assoc i1 :animation {:animation-type :push
@ -408,72 +408,72 @@
:duration 1000 :duration 1000
:easing :ease-out :easing :ease-out
:direction :left})] :direction :left})]
(t/is (not (csi/allowed-animation? (:action-type bad-interaction-1) (t/is (not (ctsi/allowed-animation? (:action-type bad-interaction-1)
(-> bad-interaction-1 :animation :animation-type)))) (-> bad-interaction-1 :animation :animation-type))))
(t/is (not (csi/allowed-animation? (:action-type bad-interaction-2) (t/is (not (ctsi/allowed-animation? (:action-type bad-interaction-2)
(-> bad-interaction-1 :animation :animation-type)))) (-> bad-interaction-1 :animation :animation-type))))
(t/is (not (csi/allowed-animation? (:action-type bad-interaction-3) (t/is (not (ctsi/allowed-animation? (:action-type bad-interaction-3)
(-> bad-interaction-1 :animation :animation-type)))))) (-> bad-interaction-1 :animation :animation-type))))))
(t/testing "Remove animation if moving to an forbidden state" (t/testing "Remove animation if moving to an forbidden state"
(let [interaction (csi/set-animation-type csi/default-interaction :push) (let [interaction (ctsi/set-animation-type ctsi/default-interaction :push)
new-interaction (csi/set-action-type interaction :open-overlay)] new-interaction (ctsi/set-action-type interaction :open-overlay)]
(t/is (nil? (:animation new-interaction))))))) (t/is (nil? (:animation new-interaction)))))))
(t/deftest option-duration (t/deftest option-duration
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-animation-type csi/default-interaction :dissolve)] i2 (ctsi/set-animation-type ctsi/default-interaction :dissolve)]
(t/testing "Has duration?" (t/testing "Has duration?"
(t/is (not (csi/has-duration? i1))) (t/is (not (ctsi/has-duration? i1)))
(t/is (csi/has-duration? i2))) (t/is (ctsi/has-duration? i2)))
(t/testing "Set duration" (t/testing "Set duration"
(let [new-interaction (csi/set-duration i2 1000)] (let [new-interaction (ctsi/set-duration i2 1000)]
(t/is (= 1000 (-> new-interaction :animation :duration))))))) (t/is (= 1000 (-> new-interaction :animation :duration)))))))
(t/deftest option-easing (t/deftest option-easing
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-animation-type csi/default-interaction :dissolve)] i2 (ctsi/set-animation-type ctsi/default-interaction :dissolve)]
(t/testing "Has easing?" (t/testing "Has easing?"
(t/is (not (csi/has-easing? i1))) (t/is (not (ctsi/has-easing? i1)))
(t/is (csi/has-easing? i2))) (t/is (ctsi/has-easing? i2)))
(t/testing "Set easing" (t/testing "Set easing"
(let [new-interaction (csi/set-easing i2 :ease-in)] (let [new-interaction (ctsi/set-easing i2 :ease-in)]
(t/is (= :ease-in (-> new-interaction :animation :easing))))))) (t/is (= :ease-in (-> new-interaction :animation :easing)))))))
(t/deftest option-way (t/deftest option-way
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-animation-type csi/default-interaction :slide) i2 (ctsi/set-animation-type ctsi/default-interaction :slide)
i3 (csi/set-action-type i2 :open-overlay)] i3 (ctsi/set-action-type i2 :open-overlay)]
(t/testing "Has way?" (t/testing "Has way?"
(t/is (not (csi/has-way? i1))) (t/is (not (ctsi/has-way? i1)))
(t/is (csi/has-way? i2)) (t/is (ctsi/has-way? i2))
(t/is (not (csi/has-way? i3))) (t/is (not (ctsi/has-way? i3)))
(t/is (some? (-> i3 :animation :way)))) ; <- it exists but is ignored (t/is (some? (-> i3 :animation :way)))) ; <- it exists but is ignored
(t/testing "Set way" (t/testing "Set way"
(let [new-interaction (csi/set-way i2 :out)] (let [new-interaction (ctsi/set-way i2 :out)]
(t/is (= :out (-> new-interaction :animation :way))))))) (t/is (= :out (-> new-interaction :animation :way)))))))
(t/deftest option-direction (t/deftest option-direction
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-animation-type csi/default-interaction :push) i2 (ctsi/set-animation-type ctsi/default-interaction :push)
i3 (csi/set-animation-type csi/default-interaction :dissolve)] i3 (ctsi/set-animation-type ctsi/default-interaction :dissolve)]
(t/testing "Has direction?" (t/testing "Has direction?"
(t/is (not (csi/has-direction? i1))) (t/is (not (ctsi/has-direction? i1)))
(t/is (csi/has-direction? i2))) (t/is (ctsi/has-direction? i2)))
(t/testing "Set direction" (t/testing "Set direction"
(let [new-interaction (csi/set-direction i2 :left)] (let [new-interaction (ctsi/set-direction i2 :left)]
(t/is (= :left (-> new-interaction :animation :direction))))) (t/is (= :left (-> new-interaction :animation :direction)))))
(t/testing "Invert direction" (t/testing "Invert direction"
@ -483,12 +483,12 @@
a-up (assoc a-right :direction :up) a-up (assoc a-right :direction :up)
a-down (assoc a-right :direction :down) a-down (assoc a-right :direction :down)
a-nil' (csi/invert-direction nil) a-nil' (ctsi/invert-direction nil)
a-none' (csi/invert-direction a-none) a-none' (ctsi/invert-direction a-none)
a-right' (csi/invert-direction a-right) a-right' (ctsi/invert-direction a-right)
a-left' (csi/invert-direction a-left) a-left' (ctsi/invert-direction a-left)
a-up' (csi/invert-direction a-up) a-up' (ctsi/invert-direction a-up)
a-down' (csi/invert-direction a-down)] a-down' (ctsi/invert-direction a-down)]
(t/is (nil? a-nil')) (t/is (nil? a-nil'))
(t/is (nil? (:direction a-none'))) (t/is (nil? (:direction a-none')))
@ -499,44 +499,44 @@
(t/deftest option-offset-effect (t/deftest option-offset-effect
(let [i1 csi/default-interaction (let [i1 ctsi/default-interaction
i2 (csi/set-animation-type csi/default-interaction :slide) i2 (ctsi/set-animation-type ctsi/default-interaction :slide)
i3 (csi/set-action-type i2 :open-overlay)] i3 (ctsi/set-action-type i2 :open-overlay)]
(t/testing "Has offset-effect" (t/testing "Has offset-effect"
(t/is (not (csi/has-offset-effect? i1))) (t/is (not (ctsi/has-offset-effect? i1)))
(t/is (csi/has-offset-effect? i2)) (t/is (ctsi/has-offset-effect? i2))
(t/is (not (csi/has-offset-effect? i3))) (t/is (not (ctsi/has-offset-effect? i3)))
(t/is (some? (-> i3 :animation :offset-effect)))) ; <- it exists but is ignored (t/is (some? (-> i3 :animation :offset-effect)))) ; <- it exists but is ignored
(t/testing "Set offset-effect" (t/testing "Set offset-effect"
(let [new-interaction (csi/set-offset-effect i2 true)] (let [new-interaction (ctsi/set-offset-effect i2 true)]
(t/is (= true (-> new-interaction :animation :offset-effect))))))) (t/is (= true (-> new-interaction :animation :offset-effect)))))))
(t/deftest modify-interactions (t/deftest modify-interactions
(let [i1 (csi/set-action-type csi/default-interaction :open-overlay) (let [i1 (ctsi/set-action-type ctsi/default-interaction :open-overlay)
i2 (csi/set-action-type csi/default-interaction :close-overlay) i2 (ctsi/set-action-type ctsi/default-interaction :close-overlay)
i3 (csi/set-action-type csi/default-interaction :prev-screen) i3 (ctsi/set-action-type ctsi/default-interaction :prev-screen)
interactions [i1 i2]] interactions [i1 i2]]
(t/testing "Add interaction to nil" (t/testing "Add interaction to nil"
(let [new-interactions (csi/add-interaction nil i3)] (let [new-interactions (ctsi/add-interaction nil i3)]
(t/is (= (count new-interactions) 1)) (t/is (= (count new-interactions) 1))
(t/is (= (:action-type (last new-interactions)) :prev-screen)))) (t/is (= (:action-type (last new-interactions)) :prev-screen))))
(t/testing "Add interaction to normal" (t/testing "Add interaction to normal"
(let [new-interactions (csi/add-interaction interactions i3)] (let [new-interactions (ctsi/add-interaction interactions i3)]
(t/is (= (count new-interactions) 3)) (t/is (= (count new-interactions) 3))
(t/is (= (:action-type (last new-interactions)) :prev-screen)))) (t/is (= (:action-type (last new-interactions)) :prev-screen))))
(t/testing "Remove interaction" (t/testing "Remove interaction"
(let [new-interactions (csi/remove-interaction interactions 0)] (let [new-interactions (ctsi/remove-interaction interactions 0)]
(t/is (= (count new-interactions) 1)) (t/is (= (count new-interactions) 1))
(t/is (= (:action-type (last new-interactions)) :close-overlay)))) (t/is (= (:action-type (last new-interactions)) :close-overlay))))
(t/testing "Update interaction" (t/testing "Update interaction"
(let [new-interactions (csi/update-interaction interactions 1 #(csi/set-action-type % :open-url))] (let [new-interactions (ctsi/update-interaction interactions 1 #(ctsi/set-action-type % :open-url))]
(t/is (= (count new-interactions) 2)) (t/is (= (count new-interactions) 2))
(t/is (= (:action-type (last new-interactions)) :open-url)))))) (t/is (= (:action-type (last new-interactions)) :open-url))))))
@ -556,16 +556,16 @@
ids-map {(:id frame1) (:id frame4) ids-map {(:id frame1) (:id frame4)
(:id frame2) (:id frame5)} (:id frame2) (:id frame5)}
i1 (csi/set-destination csi/default-interaction (:id frame1)) i1 (ctsi/set-destination ctsi/default-interaction (:id frame1))
i2 (csi/set-destination csi/default-interaction (:id frame2)) i2 (ctsi/set-destination ctsi/default-interaction (:id frame2))
i3 (csi/set-destination csi/default-interaction (:id frame3)) i3 (ctsi/set-destination ctsi/default-interaction (:id frame3))
i4 (csi/set-destination csi/default-interaction nil) i4 (ctsi/set-destination ctsi/default-interaction nil)
i5 (csi/set-destination csi/default-interaction (:id frame6)) i5 (ctsi/set-destination ctsi/default-interaction (:id frame6))
interactions [i1 i2 i3 i4 i5]] interactions [i1 i2 i3 i4 i5]]
(t/testing "Remap interactions" (t/testing "Remap interactions"
(let [new-interactions (csi/remap-interactions interactions ids-map objects)] (let [new-interactions (ctsi/remap-interactions interactions ids-map objects)]
(t/is (= (count new-interactions) 4)) (t/is (= (count new-interactions) 4))
(t/is (= (:id frame4) (:destination (get new-interactions 0)))) (t/is (= (:id frame4) (:destination (get new-interactions 0))))
(t/is (= (:id frame5) (:destination (get new-interactions 1)))) (t/is (= (:id frame5) (:destination (get new-interactions 1))))

View file

@ -10,7 +10,7 @@
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.interactions :as cti] [app.common.types.shape.interactions :as ctsi]
[app.main.data.comments :as dcm] [app.main.data.comments :as dcm]
[app.main.data.fonts :as df] [app.main.data.fonts :as df]
[app.main.repo :as rp] [app.main.repo :as rp]
@ -389,7 +389,7 @@
([frame-id animation] ([frame-id animation]
(us/verify ::us/uuid frame-id) (us/verify ::us/uuid frame-id)
(us/verify (s/nilable ::cti/animation) animation) (us/verify (s/nilable ::ctsi/animation) animation)
(ptk/reify ::go-to-frame (ptk/reify ::go-to-frame
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
@ -480,7 +480,7 @@
(us/verify ::gpt/point position) (us/verify ::gpt/point position)
(us/verify (s/nilable ::us/boolean) close-click-outside) (us/verify (s/nilable ::us/boolean) close-click-outside)
(us/verify (s/nilable ::us/boolean) background-overlay) (us/verify (s/nilable ::us/boolean) background-overlay)
(us/verify (s/nilable ::cti/animation) animation) (us/verify (s/nilable ::ctsi/animation) animation)
(ptk/reify ::open-overlay (ptk/reify ::open-overlay
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
@ -505,7 +505,7 @@
(us/verify ::gpt/point position) (us/verify ::gpt/point position)
(us/verify (s/nilable ::us/boolean) close-click-outside) (us/verify (s/nilable ::us/boolean) close-click-outside)
(us/verify (s/nilable ::us/boolean) background-overlay) (us/verify (s/nilable ::us/boolean) background-overlay)
(us/verify (s/nilable ::cti/animation) animation) (us/verify (s/nilable ::ctsi/animation) animation)
(ptk/reify ::toggle-overlay (ptk/reify ::toggle-overlay
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]
@ -524,13 +524,13 @@
animation) animation)
(do-close-overlay state (do-close-overlay state
(:id frame) (:id frame)
(cti/invert-direction animation))))))) (ctsi/invert-direction animation)))))))
(defn close-overlay (defn close-overlay
([frame-id] (close-overlay frame-id nil)) ([frame-id] (close-overlay frame-id nil))
([frame-id animation] ([frame-id animation]
(us/verify ::us/uuid frame-id) (us/verify ::us/uuid frame-id)
(us/verify (s/nilable ::cti/animation) animation) (us/verify (s/nilable ::ctsi/animation) animation)
(ptk/reify ::close-overlay (ptk/reify ::close-overlay
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]

View file

@ -18,9 +18,9 @@
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.shape :as spec.shape]
[app.common.text :as txt] [app.common.text :as txt]
[app.common.transit :as t] [app.common.transit :as t]
[app.common.types.shape :as cts]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cfg] [app.config :as cfg]
[app.main.data.events :as ev] [app.main.data.events :as ev]
@ -62,7 +62,7 @@
[cuerdas.core :as str] [cuerdas.core :as str]
[potok.core :as ptk])) [potok.core :as ptk]))
(s/def ::shape-attrs ::spec.shape/shape-attrs) (s/def ::shape-attrs ::cts/shape-attrs)
(s/def ::set-of-string (s/def ::set-of-string
(s/every string? :kind set?)) (s/every string? :kind set?))

View file

@ -10,9 +10,9 @@
[app.common.logging :as log] [app.common.logging :as log]
[app.common.pages :as cp] [app.common.pages :as cp]
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.changes-spec :as pcs]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.change :as spec.change]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
[app.main.data.workspace.undo :as dwu] [app.main.data.workspace.undo :as dwu]
@ -159,8 +159,8 @@
[:workspace-data] [:workspace-data]
[:workspace-libraries file-id :data])] [:workspace-libraries file-id :data])]
(try (try
(us/assert ::spec.change/changes redo-changes) (us/assert ::pcs/changes redo-changes)
(us/assert ::spec.change/changes undo-changes) (us/assert ::pcs/changes undo-changes)
(update-in state path (fn [file] (update-in state path (fn [file]
(-> file (-> file

View file

@ -13,9 +13,9 @@
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.interactions :as csi] [app.common.types.page :as ctp]
[app.common.spec.page :as csp] [app.common.types.shape :as cts]
[app.common.spec.shape :as spec.shape] [app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
@ -29,7 +29,7 @@
;; Change this to :info :debug or :trace to debug this module ;; Change this to :info :debug or :trace to debug this module
(log/set-level! :warn) (log/set-level! :warn)
(s/def ::shape-attrs ::spec.shape/shape-attrs) (s/def ::shape-attrs ::cts/shape-attrs)
(s/def ::set-of-string (s/every string? :kind set?)) (s/def ::set-of-string (s/every string? :kind set?))
(s/def ::ordered-set-of-uuid (s/every uuid? :kind d/ordered-set?)) (s/def ::ordered-set-of-uuid (s/every uuid? :kind d/ordered-set?))
@ -382,7 +382,7 @@
;; If any of the deleted shapes is the destination of ;; If any of the deleted shapes is the destination of
;; some interaction, this must be deleted, too. ;; some interaction, this must be deleted, too.
(let [interactions (:interactions shape)] (let [interactions (:interactions shape)]
(some #(and (csi/has-destination %) (some #(and (ctsi/has-destination %)
(contains? ids (:destination %))) (contains? ids (:destination %)))
interactions))) interactions)))
(vals objects)) (vals objects))
@ -451,13 +451,13 @@
(update shape :interactions (update shape :interactions
(fn [interactions] (fn [interactions]
(when interactions (when interactions
(d/removev #(and (csi/has-destination %) (d/removev #(and (ctsi/has-destination %)
(contains? ids (:destination %))) (contains? ids (:destination %)))
interactions)))))) interactions))))))
(cond-> (cond->
(seq starting-flows) (seq starting-flows)
(pcb/update-page-option :flows (fn [flows] (pcb/update-page-option :flows (fn [flows]
(reduce #(csp/remove-flow %1 (:id %2)) (reduce #(ctp/remove-flow %1 (:id %2))
flows flows
starting-flows)))))] starting-flows)))))]

View file

@ -10,7 +10,7 @@
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.page :as csp] [app.common.types.page :as ctp]
[app.main.data.workspace.changes :as dwc] [app.main.data.workspace.changes :as dwc]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
[beicon.core :as rx] [beicon.core :as rx]
@ -24,7 +24,7 @@
(merge guide)))) (merge guide))))
(defn update-guides [guide] (defn update-guides [guide]
(us/verify ::csp/guide guide) (us/verify ::ctp/guide guide)
(ptk/reify ::update-guides (ptk/reify ::update-guides
ptk/WatchEvent ptk/WatchEvent
(watch [it state _] (watch [it state _]
@ -36,7 +36,7 @@
(rx/of (dwc/commit-changes changes)))))) (rx/of (dwc/commit-changes changes))))))
(defn remove-guide [guide] (defn remove-guide [guide]
(us/verify ::csp/guide guide) (us/verify ::ctp/guide guide)
(ptk/reify ::remove-guide (ptk/reify ::remove-guide
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]

View file

@ -11,8 +11,8 @@
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.interactions :as csi] [app.common.types.page :as ctp]
[app.common.spec.page :as csp] [app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
[app.main.data.workspace.common :as dwc] [app.main.data.workspace.common :as dwc]
@ -41,7 +41,7 @@
(rx/of (dch/commit-changes (rx/of (dch/commit-changes
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/update-page-option :flows csp/add-flow new-flow)))))))) (pcb/update-page-option :flows ctp/add-flow new-flow))))))))
(defn add-flow-selected-frame (defn add-flow-selected-frame
[] []
@ -61,7 +61,7 @@
(rx/of (dch/commit-changes (rx/of (dch/commit-changes
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/update-page-option :flows csp/remove-flow flow-id)))))))) (pcb/update-page-option :flows ctp/remove-flow flow-id))))))))
(defn rename-flow (defn rename-flow
[flow-id name] [flow-id name]
@ -74,8 +74,8 @@
(rx/of (dch/commit-changes (rx/of (dch/commit-changes
(-> (pcb/empty-changes it) (-> (pcb/empty-changes it)
(pcb/with-page page) (pcb/with-page page)
(pcb/update-page-option :flows csp/update-flow flow-id (pcb/update-page-option :flows ctp/update-flow flow-id
#(csp/rename-flow % name))))))))) #(ctp/rename-flow % name)))))))))
(defn start-rename-flow (defn start-rename-flow
[id] [id]
@ -99,8 +99,8 @@
in the page" in the page"
[objects frame-id] [objects frame-id]
(let [children (cph/get-children-with-self objects frame-id)] (let [children (cph/get-children-with-self objects frame-id)]
(or (some csi/flow-origin? (map :interactions children)) (or (some ctsi/flow-origin? (map :interactions children))
(some #(csi/flow-to? % frame-id) (map :interactions (vals objects)))))) (some #(ctsi/flow-to? % frame-id) (map :interactions (vals objects))))))
(defn add-new-interaction (defn add-new-interaction
([shape] (add-new-interaction shape nil)) ([shape] (add-new-interaction shape nil))
@ -116,15 +116,15 @@
page-id page-id
:options :options
:flows] []) :flows] [])
flow (csp/get-frame-flow flows (:id frame))] flow (ctp/get-frame-flow flows (:id frame))]
(rx/concat (rx/concat
(rx/of (dch/update-shapes [(:id shape)] (rx/of (dch/update-shapes [(:id shape)]
(fn [shape] (fn [shape]
(let [new-interaction (csi/set-destination (let [new-interaction (ctsi/set-destination
csi/default-interaction ctsi/default-interaction
destination)] destination)]
(update shape :interactions (update shape :interactions
csi/add-interaction new-interaction))))) ctsi/add-interaction new-interaction)))))
(when (and (not (connected-frame? objects (:id frame))) (when (and (not (connected-frame? objects (:id frame)))
(nil? flow)) (nil? flow))
(rx/of (add-flow (:id frame)))))))))) (rx/of (add-flow (:id frame))))))))))
@ -137,7 +137,7 @@
(rx/of (dch/update-shapes [(:id shape)] (rx/of (dch/update-shapes [(:id shape)]
(fn [shape] (fn [shape]
(update shape :interactions (update shape :interactions
csi/remove-interaction index))))))) ctsi/remove-interaction index)))))))
(defn update-interaction (defn update-interaction
[shape index update-fn] [shape index update-fn]
@ -147,7 +147,7 @@
(rx/of (dch/update-shapes [(:id shape)] (rx/of (dch/update-shapes [(:id shape)]
(fn [shape] (fn [shape]
(update shape :interactions (update shape :interactions
csi/update-interaction index update-fn))))))) ctsi/update-interaction index update-fn)))))))
(declare move-edit-interaction) (declare move-edit-interaction)
(declare finish-edit-interaction) (declare finish-edit-interaction)
@ -219,11 +219,11 @@
change-interaction change-interaction
(fn [interaction] (fn [interaction]
(cond-> interaction (cond-> interaction
(not (csi/has-destination interaction)) (not (ctsi/has-destination interaction))
(csi/set-action-type :navigate) (ctsi/set-action-type :navigate)
:always :always
(csi/set-destination (:id target-frame))))] (ctsi/set-destination (:id target-frame))))]
(cond (cond
(or (nil? shape) (or (nil? shape)
@ -322,7 +322,7 @@
new-interactions new-interactions
(update interactions index (update interactions index
#(csi/set-overlay-position % overlay-pos))] #(ctsi/set-overlay-position % overlay-pos))]
(rx/of (dch/update-shapes [(:id shape)] #(merge % {:interactions new-interactions}))))))) (rx/of (dch/update-shapes [(:id shape)] #(merge % {:interactions new-interactions})))))))

View file

@ -11,12 +11,12 @@
[app.common.logging :as log] [app.common.logging :as log]
[app.common.pages :as cp] [app.common.pages :as cp]
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.changes-spec :as pcs]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.change :as spec.change] [app.common.types.color :as ctc]
[app.common.spec.color :as spec.color] [app.common.types.file :as ctf]
[app.common.spec.file :as spec.file] [app.common.types.typography :as ctt]
[app.common.spec.typography :as spec.typography]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
[app.main.data.events :as ev] [app.main.data.events :as ev]
@ -98,7 +98,7 @@
color (-> color color (-> color
(assoc :id id) (assoc :id id)
(assoc :name (default-color-name color)))] (assoc :name (default-color-name color)))]
(us/assert ::spec.color/color color) (us/assert ::ctc/color color)
(ptk/reify ::add-color (ptk/reify ::add-color
IDeref IDeref
(-deref [_] color) (-deref [_] color)
@ -112,7 +112,7 @@
(defn add-recent-color (defn add-recent-color
[color] [color]
(us/assert ::spec.color/recent-color color) (us/assert ::ctc/recent-color color)
(ptk/reify ::add-recent-color (ptk/reify ::add-recent-color
ptk/WatchEvent ptk/WatchEvent
(watch [it _ _] (watch [it _ _]
@ -141,7 +141,7 @@
(defn update-color (defn update-color
[color file-id] [color file-id]
(us/assert ::spec.color/color color) (us/assert ::ctc/color color)
(us/assert ::us/uuid file-id) (us/assert ::us/uuid file-id)
(ptk/reify ::update-color (ptk/reify ::update-color
ptk/WatchEvent ptk/WatchEvent
@ -175,7 +175,7 @@
(defn add-media (defn add-media
[media] [media]
(us/assert ::spec.file/media-object media) (us/assert ::ctf/media-object media)
(ptk/reify ::add-media (ptk/reify ::add-media
ptk/WatchEvent ptk/WatchEvent
(watch [it _ _] (watch [it _ _]
@ -217,7 +217,7 @@
([typography] (add-typography typography true)) ([typography] (add-typography typography true))
([typography edit?] ([typography edit?]
(let [typography (update typography :id #(or % (uuid/next)))] (let [typography (update typography :id #(or % (uuid/next)))]
(us/assert ::spec.typography/typography typography) (us/assert ::ctt/typography typography)
(ptk/reify ::add-typography (ptk/reify ::add-typography
IDeref IDeref
(-deref [_] typography) (-deref [_] typography)
@ -244,7 +244,7 @@
(defn update-typography (defn update-typography
[typography file-id] [typography file-id]
(us/assert ::spec.typography/typography typography) (us/assert ::ctt/typography typography)
(us/assert ::us/uuid file-id) (us/assert ::us/uuid file-id)
(ptk/reify ::update-typography (ptk/reify ::update-typography
ptk/WatchEvent ptk/WatchEvent
@ -462,7 +462,7 @@
(defn ext-library-changed (defn ext-library-changed
[file-id modified-at revn changes] [file-id modified-at revn changes]
(us/assert ::us/uuid file-id) (us/assert ::us/uuid file-id)
(us/assert ::spec.change/changes changes) (us/assert ::pcs/changes changes)
(ptk/reify ::ext-library-changed (ptk/reify ::ext-library-changed
ptk/UpdateEvent ptk/UpdateEvent
(update [_ state] (update [_ state]

View file

@ -14,8 +14,8 @@
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.color :as color]
[app.common.text :as txt] [app.common.text :as txt]
[app.common.types.color :as ctc]
[app.main.data.workspace.common :as dwc] [app.main.data.workspace.common :as dwc]
[app.main.data.workspace.groups :as dwg] [app.main.data.workspace.groups :as dwg]
[app.main.data.workspace.state-helpers :as wsh] [app.main.data.workspace.state-helpers :as wsh]
@ -299,7 +299,7 @@
(defmethod uses-assets? :colors (defmethod uses-assets? :colors
[_ shape library-id _] [_ shape library-id _]
(color/uses-library-colors? shape library-id)) (ctc/uses-library-colors? shape library-id))
(defmethod uses-assets? :typographies (defmethod uses-assets? :typographies
[_ shape library-id _] [_ shape library-id _]
@ -331,7 +331,7 @@
(let [library-colors (get-assets library-id :colors state)] (let [library-colors (get-assets library-id :colors state)]
(pcb/update-shapes changes (pcb/update-shapes changes
[(:id shape)] [(:id shape)]
#(color/sync-shape-colors % library-id library-colors)))) #(ctc/sync-shape-colors % library-id library-colors))))
(defmethod generate-sync-shape :typographies (defmethod generate-sync-shape :typographies
[_ changes library-id state container shape] [_ changes library-id state container shape]

View file

@ -7,8 +7,8 @@
(ns app.main.data.workspace.notifications (ns app.main.data.workspace.notifications
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.pages.changes-spec :as pcs]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.change :as spec.change]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.websocket :as dws] [app.main.data.websocket :as dws]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
@ -184,7 +184,7 @@
(s/def ::file-id uuid?) (s/def ::file-id uuid?)
(s/def ::session-id uuid?) (s/def ::session-id uuid?)
(s/def ::revn integer?) (s/def ::revn integer?)
(s/def ::changes ::spec.change/changes) (s/def ::changes ::pcs/changes)
(s/def ::file-change-event (s/def ::file-change-event
(s/keys :req-un [::type ::profile-id ::file-id ::session-id ::revn ::changes])) (s/keys :req-un [::type ::profile-id ::file-id ::session-id ::revn ::changes]))

View file

@ -9,9 +9,9 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.logging :as log] [app.common.logging :as log]
[app.common.pages :as cp] [app.common.pages :as cp]
[app.common.pages.changes-spec :as pcs]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.change :as spec.change] [app.common.types.file :as ctf]
[app.common.spec.file :as spec.file]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.config :as cf] [app.config :as cf]
[app.main.data.dashboard :as dd] [app.main.data.dashboard :as dd]
@ -199,7 +199,7 @@
:updated-at (dt/now))))))) :updated-at (dt/now)))))))
(s/def ::shapes-changes-persisted (s/def ::shapes-changes-persisted
(s/keys :req-un [::revn ::spec.change/changes])) (s/keys :req-un [::revn ::pcs/changes]))
(defn shapes-persisted-event? [event] (defn shapes-persisted-event? [event]
(= (ptk/type event) ::changes-persisted)) (= (ptk/type event) ::changes-persisted))
@ -237,7 +237,7 @@
(s/def ::version ::us/integer) (s/def ::version ::us/integer)
(s/def ::revn ::us/integer) (s/def ::revn ::us/integer)
(s/def ::ordering ::us/integer) (s/def ::ordering ::us/integer)
(s/def ::data ::spec.file/data) (s/def ::data ::ctf/data)
(s/def ::file ::dd/file) (s/def ::file ::dd/file)
(s/def ::project ::dd/project) (s/def ::project ::dd/project)

View file

@ -14,8 +14,8 @@
[app.common.pages.changes-builder :as pcb] [app.common.pages.changes-builder :as pcb]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.interactions :as cti] [app.common.types.page :as ctp]
[app.common.spec.page :as ctp] [app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.modal :as md] [app.main.data.modal :as md]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
@ -326,7 +326,7 @@
:shapes []) :shapes [])
(dissoc :use-for-thumbnail?) (dissoc :use-for-thumbnail?)
(gsh/move delta) (gsh/move delta)
(d/update-when :interactions #(cti/remap-interactions % ids-map objects))) (d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))
changes (-> (pcb/add-object changes new-frame) changes (-> (pcb/add-object changes new-frame)
(pcb/amend-last-change #(assoc % :old-id (:id obj)))) (pcb/amend-last-change #(assoc % :old-id (:id obj))))
@ -361,7 +361,7 @@
:frame-id frame-id) :frame-id frame-id)
(dissoc :shapes) (dissoc :shapes)
(gsh/move delta) (gsh/move delta)
(d/update-when :interactions #(cti/remap-interactions % ids-map objects))) (d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))
changes (-> (pcb/add-object changes new-obj {:ignore-touched true}) changes (-> (pcb/add-object changes new-obj {:ignore-touched true})
(pcb/amend-last-change #(assoc % :old-id (:id obj))))] (pcb/amend-last-change #(assoc % :old-id (:id obj))))]

View file

@ -6,8 +6,8 @@
(ns app.main.data.workspace.undo (ns app.main.data.workspace.undo
(:require (:require
[app.common.pages.changes-spec :as pcs]
[app.common.spec :as us] [app.common.spec :as us]
[app.common.spec.change :as spec.change]
[cljs.spec.alpha :as s] [cljs.spec.alpha :as s]
[potok.core :as ptk])) [potok.core :as ptk]))
@ -15,8 +15,8 @@
;; Undo / Redo ;; Undo / Redo
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(s/def ::undo-changes ::spec.change/changes) (s/def ::undo-changes ::pcs/changes)
(s/def ::redo-changes ::spec.change/changes) (s/def ::redo-changes ::pcs/changes)
(s/def ::undo-entry (s/def ::undo-entry
(s/keys :req-un [::undo-changes ::redo-changes])) (s/keys :req-un [::undo-changes ::redo-changes]))

View file

@ -10,8 +10,8 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.spec.radius :as ctr] [app.common.types.shape :refer [stroke-caps-line stroke-caps-marker]]
[app.common.spec.shape :refer [stroke-caps-line stroke-caps-marker]] [app.common.types.shape.radius :as ctsr]
[app.main.ui.context :as muc] [app.main.ui.context :as muc]
[app.util.object :as obj] [app.util.object :as obj]
[app.util.svg :as usvg] [app.util.svg :as usvg]
@ -31,7 +31,7 @@
(defn add-border-radius [attrs {:keys [x y width height] :as shape}] (defn add-border-radius [attrs {:keys [x y width height] :as shape}]
(case (ctr/radius-mode shape) (case (ctsr/radius-mode shape)
:radius-1 :radius-1
(let [radius (gsh/shape-corners-1 shape)] (let [radius (gsh/shape-corners-1 shape)]
(obj/merge! attrs #js {:rx radius :ry radius})) (obj/merge! attrs #js {:rx radius :ry radius}))

View file

@ -6,7 +6,7 @@
(ns app.main.ui.viewer.handoff.attributes.layout (ns app.main.ui.viewer.handoff.attributes.layout
(:require (:require
[app.common.spec.radius :as ctr] [app.common.types.shape.radius :as ctsr]
[app.main.ui.components.copy-button :refer [copy-button]] [app.main.ui.components.copy-button :refer [copy-button]]
[app.main.ui.formats :as fmt] [app.main.ui.formats :as fmt]
[app.util.code-gen :as cg] [app.util.code-gen :as cg]
@ -59,13 +59,13 @@
[:div.attributes-value (fmt/format-pixels y)] [:div.attributes-value (fmt/format-pixels y)]
[:& copy-button {:data (copy-data selrect :y)}]]) [:& copy-button {:data (copy-data selrect :y)}]])
(when (ctr/radius-1? shape) (when (ctsr/radius-1? shape)
[:div.attributes-unit-row [:div.attributes-unit-row
[:div.attributes-label (tr "handoff.attributes.layout.radius")] [:div.attributes-label (tr "handoff.attributes.layout.radius")]
[:div.attributes-value (fmt/format-pixels (:rx shape 0))] [:div.attributes-value (fmt/format-pixels (:rx shape 0))]
[:& copy-button {:data (copy-data shape :rx)}]]) [:& copy-button {:data (copy-data shape :rx)}]])
(when (ctr/radius-4? shape) (when (ctsr/radius-4? shape)
[:div.attributes-unit-row [:div.attributes-unit-row
[:div.attributes-label (tr "handoff.attributes.layout.radius")] [:div.attributes-label (tr "handoff.attributes.layout.radius")]
[:div.attributes-value [:div.attributes-value

View file

@ -11,7 +11,7 @@
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec.page :as csp] [app.common.types.page :as ctp]
[app.main.data.comments :as dcm] [app.main.data.comments :as dcm]
[app.main.data.viewer :as dv] [app.main.data.viewer :as dv]
[app.main.refs :as refs] [app.main.refs :as refs]
@ -108,7 +108,7 @@
frames (:frames page) frames (:frames page)
frame (get frames index) frame (get frames index)
current-flow (mf/use-state current-flow (mf/use-state
(csp/get-frame-flow flows (:id frame))) (ctp/get-frame-flow flows (:id frame)))
show-dropdown? (mf/use-state false) show-dropdown? (mf/use-state false)
toggle-dropdown (mf/use-fn #(swap! show-dropdown? not)) toggle-dropdown (mf/use-fn #(swap! show-dropdown? not))

View file

@ -10,7 +10,7 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec.interactions :as cti] [app.common.types.shape.interactions :as ctsi]
[app.main.data.viewer :as dv] [app.main.data.viewer :as dv]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
@ -56,7 +56,7 @@
background-overlay (:background-overlay interaction) background-overlay (:background-overlay interaction)
dest-frame (get objects dest-frame-id) dest-frame (get objects dest-frame-id)
position (cti/calc-overlay-position interaction position (ctsi/calc-overlay-position interaction
base-frame base-frame
dest-frame dest-frame
frame-offset)] frame-offset)]
@ -123,7 +123,7 @@
background-overlay (:background-overlay interaction) background-overlay (:background-overlay interaction)
dest-frame (get objects dest-frame-id) dest-frame (get objects dest-frame-id)
position (cti/calc-overlay-position interaction position (ctsi/calc-overlay-position interaction
base-frame base-frame
dest-frame dest-frame
frame-offset)] frame-offset)]
@ -235,7 +235,7 @@
(if-not svg-element? (if-not svg-element?
[:> shape-container {:shape shape [:> shape-container {:shape shape
:cursor (when (cti/actionable? interactions) "pointer") :cursor (when (ctsi/actionable? interactions) "pointer")
:on-mouse-down #(on-mouse-down % shape base-frame frame-offset objects) :on-mouse-down #(on-mouse-down % shape base-frame frame-offset objects)
:on-mouse-up #(on-mouse-up % shape base-frame frame-offset objects) :on-mouse-up #(on-mouse-up % shape base-frame frame-offset objects)
:on-mouse-enter #(on-mouse-enter % shape base-frame frame-offset objects) :on-mouse-enter #(on-mouse-enter % shape base-frame frame-offset objects)

View file

@ -9,7 +9,7 @@
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec.page :as csp] [app.common.types.page :as ctp]
[app.main.data.events :as ev] [app.main.data.events :as ev]
[app.main.data.modal :as modal] [app.main.data.modal :as modal]
[app.main.data.workspace :as dw] [app.main.data.workspace :as dw]
@ -329,7 +329,7 @@
is-frame? (and single? has-frame?)] is-frame? (and single? has-frame?)]
(when (and prototype? is-frame?) (when (and prototype? is-frame?)
(let [flow (csp/get-frame-flow flows (-> shapes first :id))] (let [flow (ctp/get-frame-flow flows (-> shapes first :id))]
(if (some? flow) (if (some? flow)
[:& menu-entry {:title (tr "workspace.shape.menu.delete-flow-start") [:& menu-entry {:title (tr "workspace.shape.menu.delete-flow-start")
:on-click (do-remove-flow flow)}] :on-click (do-remove-flow flow)}]

View file

@ -9,8 +9,8 @@
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec.interactions :as csi] [app.common.types.page :as ctp]
[app.common.spec.page :as csp] [app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.main.data.workspace :as dw] [app.main.data.workspace :as dw]
[app.main.data.workspace.interactions :as dwi] [app.main.data.workspace.interactions :as dwi]
@ -80,7 +80,7 @@
{:dissolve (tr "workspace.options.interaction-animation-dissolve") {:dissolve (tr "workspace.options.interaction-animation-dissolve")
:slide (tr "workspace.options.interaction-animation-slide")} :slide (tr "workspace.options.interaction-animation-slide")}
(csi/allow-push? (:action-type interaction)) (ctsi/allow-push? (:action-type interaction))
(assoc :push (tr "workspace.options.interaction-animation-push")))) (assoc :push (tr "workspace.options.interaction-animation-push"))))
(defn- easing-names (defn- easing-names
@ -166,7 +166,7 @@
(mf/defc shape-flows (mf/defc shape-flows
[{:keys [flows shape]}] [{:keys [flows shape]}]
(when (= (:type shape) :frame) (when (= (:type shape) :frame)
(let [flow (csp/get-frame-flow flows (:id shape))] (let [flow (ctp/get-frame-flow flows (:id shape))]
[:div.element-set.interactions-options [:div.element-set.interactions-options
[:div.element-set-title [:div.element-set-title
[:span (tr "workspace.options.flows.flow-start")]] [:span (tr "workspace.options.flows.flow-start")]]
@ -202,27 +202,27 @@
change-event-type change-event-type
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value d/read-string)] (let [value (-> event dom/get-target dom/get-value d/read-string)]
(update-interaction index #(csi/set-event-type % value shape)))) (update-interaction index #(ctsi/set-event-type % value shape))))
change-action-type change-action-type
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value d/read-string)] (let [value (-> event dom/get-target dom/get-value d/read-string)]
(update-interaction index #(csi/set-action-type % value)))) (update-interaction index #(ctsi/set-action-type % value))))
change-delay change-delay
(fn [value] (fn [value]
(update-interaction index #(csi/set-delay % value))) (update-interaction index #(ctsi/set-delay % value)))
change-destination change-destination
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value) (let [value (-> event dom/get-target dom/get-value)
value (when (not= value "") (uuid/uuid value))] value (when (not= value "") (uuid/uuid value))]
(update-interaction index #(csi/set-destination % value)))) (update-interaction index #(ctsi/set-destination % value))))
change-preserve-scroll change-preserve-scroll
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/checked?)] (let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(csi/set-preserve-scroll % value)))) (update-interaction index #(ctsi/set-preserve-scroll % value))))
change-url change-url
(fn [event] (fn [event]
@ -238,55 +238,55 @@
(if (dom/valid? target) (if (dom/valid? target)
(do (do
(dom/remove-class! target "error") (dom/remove-class! target "error")
(update-interaction index #(csi/set-url % value))) (update-interaction index #(ctsi/set-url % value)))
(dom/add-class! target "error")))) (dom/add-class! target "error"))))
change-overlay-pos-type change-overlay-pos-type
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value d/read-string)] (let [value (-> event dom/get-target dom/get-value d/read-string)]
(update-interaction index #(csi/set-overlay-pos-type % value shape objects)))) (update-interaction index #(ctsi/set-overlay-pos-type % value shape objects))))
toggle-overlay-pos-type toggle-overlay-pos-type
(fn [pos-type] (fn [pos-type]
(update-interaction index #(csi/toggle-overlay-pos-type % pos-type shape objects))) (update-interaction index #(ctsi/toggle-overlay-pos-type % pos-type shape objects)))
change-close-click-outside change-close-click-outside
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/checked?)] (let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(csi/set-close-click-outside % value)))) (update-interaction index #(ctsi/set-close-click-outside % value))))
change-background-overlay change-background-overlay
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/checked?)] (let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(csi/set-background-overlay % value)))) (update-interaction index #(ctsi/set-background-overlay % value))))
change-animation-type change-animation-type
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value d/read-string)] (let [value (-> event dom/get-target dom/get-value d/read-string)]
(update-interaction index #(csi/set-animation-type % value)))) (update-interaction index #(ctsi/set-animation-type % value))))
change-duration change-duration
(fn [value] (fn [value]
(update-interaction index #(csi/set-duration % value))) (update-interaction index #(ctsi/set-duration % value)))
change-easing change-easing
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value d/read-string)] (let [value (-> event dom/get-target dom/get-value d/read-string)]
(update-interaction index #(csi/set-easing % value)))) (update-interaction index #(ctsi/set-easing % value))))
change-way change-way
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value d/read-string)] (let [value (-> event dom/get-target dom/get-value d/read-string)]
(update-interaction index #(csi/set-way % value)))) (update-interaction index #(ctsi/set-way % value))))
change-direction change-direction
(fn [value] (fn [value]
(update-interaction index #(csi/set-direction % value))) (update-interaction index #(ctsi/set-direction % value)))
change-offset-effect change-offset-effect
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/checked?)] (let [value (-> event dom/get-target dom/checked?)]
(update-interaction index #(csi/set-offset-effect % value)))) (update-interaction index #(ctsi/set-offset-effect % value))))
] ]
[:* [:*
@ -318,7 +318,7 @@
:value (dm/str value)} name]))]] :value (dm/str value)} name]))]]
; Delay ; Delay
(when (csi/has-delay interaction) (when (ctsi/has-delay interaction)
[:div.interactions-element [:div.interactions-element
[:span.element-set-subtitle.wide (tr "workspace.options.interaction-delay")] [:span.element-set-subtitle.wide (tr "workspace.options.interaction-delay")]
[:div.input-element {:title (tr "workspace.options.interaction-ms")} [:div.input-element {:title (tr "workspace.options.interaction-ms")}
@ -340,7 +340,7 @@
:value (str value)} name])]] :value (str value)} name])]]
; Destination ; Destination
(when (csi/has-destination interaction) (when (ctsi/has-destination interaction)
[:div.interactions-element [:div.interactions-element
[:span.element-set-subtitle.wide (tr "workspace.options.interaction-destination")] [:span.element-set-subtitle.wide (tr "workspace.options.interaction-destination")]
[:select.input-select [:select.input-select
@ -356,7 +356,7 @@
:value (str (:id frame))} (:name frame)]))]]) :value (str (:id frame))} (:name frame)]))]])
; Preserve scroll ; Preserve scroll
(when (csi/has-preserve-scroll interaction) (when (ctsi/has-preserve-scroll interaction)
[:div.interactions-element [:div.interactions-element
[:div.input-checkbox [:div.input-checkbox
[:input {:type "checkbox" [:input {:type "checkbox"
@ -367,7 +367,7 @@
(tr "workspace.options.interaction-preserve-scroll")]]]) (tr "workspace.options.interaction-preserve-scroll")]]])
; URL ; URL
(when (csi/has-url interaction) (when (ctsi/has-url interaction)
[:div.interactions-element [:div.interactions-element
[:span.element-set-subtitle.wide (tr "workspace.options.interaction-url")] [:span.element-set-subtitle.wide (tr "workspace.options.interaction-url")]
[:input.input-text {:type "url" [:input.input-text {:type "url"
@ -375,7 +375,7 @@
:default-value (str (:url interaction)) :default-value (str (:url interaction))
:on-blur change-url}]]) :on-blur change-url}]])
(when (csi/has-overlay-opts interaction) (when (ctsi/has-overlay-opts interaction)
[:* [:*
; Overlay position (select) ; Overlay position (select)
[:div.interactions-element [:div.interactions-element
@ -437,7 +437,7 @@
[:label {:for (str "background-" index)} [:label {:for (str "background-" index)}
(tr "workspace.options.interaction-background")]]]]) (tr "workspace.options.interaction-background")]]]])
(when (csi/has-animation? interaction) (when (ctsi/has-animation? interaction)
[:* [:*
; Animation select ; Animation select
[:div.interactions-element.separator [:div.interactions-element.separator
@ -450,7 +450,7 @@
[:option {:value (str value)} name])]] [:option {:value (str value)} name])]]
; Direction ; Direction
(when (csi/has-way? interaction) (when (ctsi/has-way? interaction)
[:div.interactions-element.interactions-way-buttons [:div.interactions-element.interactions-way-buttons
[:div.input-radio [:div.input-radio
[:input {:type "radio" [:input {:type "radio"
@ -470,7 +470,7 @@
[:label {:for "way-out"} (tr "workspace.options.interaction-out")]]]) [:label {:for "way-out"} (tr "workspace.options.interaction-out")]]])
; Direction ; Direction
(when (csi/has-direction? interaction) (when (ctsi/has-direction? interaction)
[:div.interactions-element.interactions-direction-buttons [:div.interactions-element.interactions-direction-buttons
[:div.element-set-actions-button [:div.element-set-actions-button
{:class (dom/classnames :active (= direction :right)) {:class (dom/classnames :active (= direction :right))
@ -490,7 +490,7 @@
i/animate-up]]) i/animate-up]])
; Duration ; Duration
(when (csi/has-duration? interaction) (when (ctsi/has-duration? interaction)
[:div.interactions-element [:div.interactions-element
[:span.element-set-subtitle.wide (tr "workspace.options.interaction-duration")] [:span.element-set-subtitle.wide (tr "workspace.options.interaction-duration")]
[:div.input-element {:title (tr "workspace.options.interaction-ms")} [:div.input-element {:title (tr "workspace.options.interaction-ms")}
@ -502,7 +502,7 @@
[:span.after (tr "workspace.options.interaction-ms")]]]) [:span.after (tr "workspace.options.interaction-ms")]]])
; Easing ; Easing
(when (csi/has-easing? interaction) (when (ctsi/has-easing? interaction)
[:div.interactions-element [:div.interactions-element
[:span.element-set-subtitle.wide (tr "workspace.options.interaction-easing")] [:span.element-set-subtitle.wide (tr "workspace.options.interaction-easing")]
[:select.input-select [:select.input-select
@ -519,7 +519,7 @@
:ease-in-out i/easing-ease-in-out)]]) :ease-in-out i/easing-ease-in-out)]])
; Offset effect ; Offset effect
(when (csi/has-offset-effect? interaction) (when (ctsi/has-offset-effect? interaction)
[:div.interactions-element [:div.interactions-element
[:div.input-checkbox [:div.input-checkbox
[:input {:type "checkbox" [:input {:type "checkbox"

View file

@ -8,7 +8,7 @@
(:require (:require
[app.common.data :as d] [app.common.data :as d]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.spec.radius :as ctr] [app.common.types.shape.radius :as ctsr]
[app.main.constants :refer [size-presets]] [app.main.constants :refer [size-presets]]
[app.main.data.workspace :as udw] [app.main.data.workspace :as udw]
[app.main.data.workspace.changes :as dch] [app.main.data.workspace.changes :as dch]
@ -99,8 +99,8 @@
show-presets-dropdown? (mf/use-state false) show-presets-dropdown? (mf/use-state false)
radius-mode (ctr/radius-mode values) radius-mode (ctsr/radius-mode values)
all-equal? (ctr/all-equal? values) all-equal? (ctsr/all-equal? values)
radius-multi? (mf/use-state nil) radius-multi? (mf/use-state nil)
radius-input-ref (mf/use-ref nil) radius-input-ref (mf/use-ref nil)
@ -154,7 +154,7 @@
(fn [update-fn] (fn [update-fn]
(dch/update-shapes ids-with-children (dch/update-shapes ids-with-children
(fn [shape] (fn [shape]
(if (ctr/has-radius? shape) (if (ctsr/has-radius? shape)
(update-fn shape) (update-fn shape)
shape))))) shape)))))
@ -163,21 +163,21 @@
(mf/deps ids) (mf/deps ids)
(fn [_value] (fn [_value]
(if all-equal? (if all-equal?
(st/emit! (change-radius ctr/switch-to-radius-1)) (st/emit! (change-radius ctsr/switch-to-radius-1))
(reset! radius-multi? true)))) (reset! radius-multi? true))))
on-switch-to-radius-4 on-switch-to-radius-4
(mf/use-callback (mf/use-callback
(mf/deps ids) (mf/deps ids)
(fn [_value] (fn [_value]
(st/emit! (change-radius ctr/switch-to-radius-4)) (st/emit! (change-radius ctsr/switch-to-radius-4))
(reset! radius-multi? false))) (reset! radius-multi? false)))
on-radius-1-change on-radius-1-change
(mf/use-callback (mf/use-callback
(mf/deps ids) (mf/deps ids)
(fn [value] (fn [value]
(st/emit! (change-radius #(ctr/set-radius-1 % value))))) (st/emit! (change-radius #(ctsr/set-radius-1 % value)))))
on-radius-multi-change on-radius-multi-change
(mf/use-callback (mf/use-callback
@ -185,15 +185,15 @@
(fn [event] (fn [event]
(let [value (-> event dom/get-target dom/get-value d/parse-integer)] (let [value (-> event dom/get-target dom/get-value d/parse-integer)]
(when (some? value) (when (some? value)
(st/emit! (change-radius ctr/switch-to-radius-1) (st/emit! (change-radius ctsr/switch-to-radius-1)
(change-radius #(ctr/set-radius-1 % value))) (change-radius #(ctsr/set-radius-1 % value)))
(reset! radius-multi? false))))) (reset! radius-multi? false)))))
on-radius-4-change on-radius-4-change
(mf/use-callback (mf/use-callback
(mf/deps ids) (mf/deps ids)
(fn [value attr] (fn [value attr]
(st/emit! (change-radius #(ctr/set-radius-4 % attr value))))) (st/emit! (change-radius #(ctsr/set-radius-4 % attr value)))))
on-width-change #(on-size-change % :width) on-width-change #(on-size-change % :width)
on-height-change #(on-size-change % :height) on-height-change #(on-size-change % :height)

View file

@ -11,7 +11,7 @@
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.geom.shapes :as gsh] [app.common.geom.shapes :as gsh]
[app.common.pages.helpers :as cph] [app.common.pages.helpers :as cph]
[app.common.spec.interactions :as cti] [app.common.types.shape.interactions :as ctsi]
[app.main.data.workspace :as dw] [app.main.data.workspace :as dw]
[app.main.refs :as refs] [app.main.refs :as refs]
[app.main.store :as st] [app.main.store :as st]
@ -275,7 +275,7 @@
[:g.non-selected [:g.non-selected
(for [shape active-shapes] (for [shape active-shapes]
(for [[index interaction] (d/enumerate (:interactions shape))] (for [[index interaction] (d/enumerate (:interactions shape))]
(let [dest-shape (when (cti/destination? interaction) (let [dest-shape (when (ctsi/destination? interaction)
(get objects (:destination interaction))) (get objects (:destination interaction)))
selected? (contains? selected (:id shape)) selected? (contains? selected (:id shape))
level (calc-level index (:interactions shape))] level (calc-level index (:interactions shape))]
@ -304,7 +304,7 @@
(if (seq (:interactions shape)) (if (seq (:interactions shape))
(for [[index interaction] (d/enumerate (:interactions shape))] (for [[index interaction] (d/enumerate (:interactions shape))]
(when-not (= index editing-interaction-index) (when-not (= index editing-interaction-index)
(let [dest-shape (when (cti/destination? interaction) (let [dest-shape (when (ctsi/destination? interaction)
(get objects (:destination interaction))) (get objects (:destination interaction)))
level (calc-level index (:interactions shape))] level (calc-level index (:interactions shape))]
[:g {:key (dm/str "interaction-path-" (:id shape) "-" index)} [:g {:key (dm/str "interaction-path-" (:id shape) "-" index)}

View file

@ -10,7 +10,7 @@
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.common.spec.interactions :as cti] [app.common.types.shape.interactions :as ctsi]
[app.common.uuid :as uuid] [app.common.uuid :as uuid]
[app.util.color :as uc] [app.util.color :as uc]
[app.util.json :as json] [app.util.json :as json]
@ -939,17 +939,17 @@
(let [interaction {:event-type (get-meta node :event-type keyword) (let [interaction {:event-type (get-meta node :event-type keyword)
:action-type (get-meta node :action-type keyword)}] :action-type (get-meta node :action-type keyword)}]
(cond-> interaction (cond-> interaction
(cti/has-delay interaction) (ctsi/has-delay interaction)
(assoc :delay (get-meta node :delay d/parse-double)) (assoc :delay (get-meta node :delay d/parse-double))
(cti/has-destination interaction) (ctsi/has-destination interaction)
(assoc :destination (get-meta node :destination uuid/uuid) (assoc :destination (get-meta node :destination uuid/uuid)
:preserve-scroll (get-meta node :preserve-scroll str->bool)) :preserve-scroll (get-meta node :preserve-scroll str->bool))
(cti/has-url interaction) (ctsi/has-url interaction)
(assoc :url (get-meta node :url str)) (assoc :url (get-meta node :url str))
(cti/has-overlay-opts interaction) (ctsi/has-overlay-opts interaction)
(assoc :overlay-pos-type (get-meta node :overlay-pos-type keyword) (assoc :overlay-pos-type (get-meta node :overlay-pos-type keyword)
:overlay-position (gpt/point :overlay-position (gpt/point
(get-meta node :overlay-position-x d/parse-double) (get-meta node :overlay-position-x d/parse-double)