From 8463d501cdc170cb27f8390ad418666c5781c61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Mon, 17 Oct 2022 17:06:07 +0200 Subject: [PATCH] :recycle: Remove some undeclared namespaces --- common/src/app/common/pages/changes_spec.cljc | 4 +- common/src/app/common/types/color.cljc | 94 +++++++++---------- common/src/app/common/types/file.cljc | 10 +- .../app/common/types/file/media_object.cljc | 9 ++ common/src/app/common/types/page/grid.cljc | 10 +- common/src/app/common/types/shape/shadow.cljc | 17 ++-- common/src/app/common/types/shape/text.cljc | 59 ++++++------ 7 files changed, 103 insertions(+), 100 deletions(-) diff --git a/common/src/app/common/pages/changes_spec.cljc b/common/src/app/common/pages/changes_spec.cljc index f8e1be45d1..4a6c69efa5 100644 --- a/common/src/app/common/pages/changes_spec.cljc +++ b/common/src/app/common/pages/changes_spec.cljc @@ -8,7 +8,7 @@ (:require [app.common.spec :as us] [app.common.types.color :as ctc] - [app.common.types.file :as ctf] + [app.common.types.file.media-object :as ctfm] [app.common.types.page :as ctp] [app.common.types.shape :as cts] [app.common.types.typography :as ctt] @@ -126,7 +126,7 @@ (s/keys :req-un [:internal.changes.add-recent-color/color])) -(s/def :internal.changes.add-media/object ::ctf/media-object) +(s/def :internal.changes.add-media/object ::ctfm/media-object) (defmethod change-spec :add-media [_] (s/keys :req-un [:internal.changes.add-media/object])) diff --git a/common/src/app/common/types/color.cljc b/common/src/app/common/types/color.cljc index 06c5c497ba..9ce0da1c6c 100644 --- a/common/src/app/common/types/color.cljc +++ b/common/src/app/common/types/color.cljc @@ -9,77 +9,77 @@ [app.common.data :as d] [app.common.spec :as us] [app.common.text :as txt] + [app.common.types.color.generic :as-alias color-generic] + [app.common.types.color.gradient :as-alias color-gradient] + [app.common.types.color.gradient.stop :as-alias color-gradient-stop] [clojure.spec.alpha :as s])) -;; TODO: waiting clojure 1.11 to rename this all :internal.stuff to a -;; more consistent name. - ;; TODO: maybe define ::color-hex-string with proper hex color spec? ;; --- GRADIENTS (s/def ::id uuid?) -(s/def :internal.gradient.stop/color string?) -(s/def :internal.gradient.stop/opacity ::us/safe-number) -(s/def :internal.gradient.stop/offset ::us/safe-number) +(s/def ::color-gradient/type #{:linear :radial}) +(s/def ::color-gradient/start-x ::us/safe-number) +(s/def ::color-gradient/start-y ::us/safe-number) +(s/def ::color-gradient/end-x ::us/safe-number) +(s/def ::color-gradient/end-y ::us/safe-number) +(s/def ::color-gradient/width ::us/safe-number) -(s/def :internal.gradient/type #{:linear :radial}) -(s/def :internal.gradient/start-x ::us/safe-number) -(s/def :internal.gradient/start-y ::us/safe-number) -(s/def :internal.gradient/end-x ::us/safe-number) -(s/def :internal.gradient/end-y ::us/safe-number) -(s/def :internal.gradient/width ::us/safe-number) +(s/def ::color-gradient-stop/color string?) +(s/def ::color-gradient-stop/opacity ::us/safe-number) +(s/def ::color-gradient-stop/offset ::us/safe-number) -(s/def :internal.gradient/stop - (s/keys :req-un [:internal.gradient.stop/color - :internal.gradient.stop/opacity - :internal.gradient.stop/offset])) +(s/def ::color-gradient/stop + (s/keys :req-un [::color-gradient-stop/color + ::color-gradient-stop/opacity + ::color-gradient-stop/offset])) -(s/def :internal.gradient/stops - (s/coll-of :internal.gradient/stop :kind vector?)) +(s/def ::color-gradient/stops + (s/coll-of ::color-gradient/stop :kind vector?)) (s/def ::gradient - (s/keys :req-un [:internal.gradient/type - :internal.gradient/start-x - :internal.gradient/start-y - :internal.gradient/end-x - :internal.gradient/end-y - :internal.gradient/width - :internal.gradient/stops])) + (s/keys :req-un [::color-gradient/type + ::color-gradient/start-x + ::color-gradient/start-y + ::color-gradient/end-x + ::color-gradient/end-y + ::color-gradient/width + ::color-gradient/stops])) ;; --- COLORS -(s/def :internal.color/name string?) -(s/def :internal.color/path (s/nilable string?)) -(s/def :internal.color/value (s/nilable string?)) -(s/def :internal.color/color (s/nilable string?)) -(s/def :internal.color/opacity (s/nilable ::us/safe-number)) -(s/def :internal.color/gradient (s/nilable ::gradient)) -(s/def :internal.color/ref-id uuid?) -(s/def :internal.color/ref-file uuid?) +(s/def ::color-generic/name string?) +(s/def ::color-generic/path (s/nilable string?)) +(s/def ::color-generic/value (s/nilable string?)) +(s/def ::color-generic/color (s/nilable string?)) +(s/def ::color-generic/opacity (s/nilable ::us/safe-number)) +(s/def ::color-generic/gradient (s/nilable ::gradient)) +(s/def ::color-generic/ref-id uuid?) +(s/def ::color-generic/ref-file uuid?) (s/def ::shape-color (s/keys :req-un [:us/color - :internal.color/opacity] - :opt-un [:internal.color/gradient - :internal.color/ref-id - :internal.color/ref-file])) + ::color-generic/opacity] + :opt-un [::color-generic/gradient + ::color-generic/ref-id + ::color-generic/ref-file])) (s/def ::color (s/keys :opt-un [::id - :internal.color/name - :internal.color/path - :internal.color/value - :internal.color/color - :internal.color/opacity - :internal.color/gradient])) + ::color-generic/name + ::color-generic/path + ::color-generic/value + ::color-generic/color + ::color-generic/opacity + ::color-generic/gradient])) (s/def ::recent-color - (s/keys :opt-un [:internal.color/value - :internal.color/color - :internal.color/opacity - :internal.color/gradient])) + (s/keys :opt-un [::color-generic/value + ::color-generic/color + ::color-generic/opacity + ::color-generic/gradient])) ;; --- Helpers for color in different parts of a shape diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index ed02a19a3f..1ff989e503 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -28,14 +28,6 @@ ;; Specs -(s/def ::media-object - (s/keys :req-un [::id - ::name - ::ctfm/width - ::ctfm/height - ::ctfm/mtype] - :opt-un [::ctfm/path])) - (s/def ::colors (s/map-of uuid? ::ctc/color)) @@ -49,7 +41,7 @@ (s/coll-of uuid? :kind vector?)) (s/def ::media - (s/map-of uuid? ::media-object)) + (s/map-of uuid? ::ctfm/media-object)) (s/def ::pages-index (s/map-of uuid? ::ctp/page)) diff --git a/common/src/app/common/types/file/media_object.cljc b/common/src/app/common/types/file/media_object.cljc index 615a4e9448..c5174c5051 100644 --- a/common/src/app/common/types/file/media_object.cljc +++ b/common/src/app/common/types/file/media_object.cljc @@ -9,6 +9,7 @@ [app.common.spec :as us] [clojure.spec.alpha :as s])) +(s/def ::id uuid?) (s/def ::name string?) (s/def ::width ::us/safe-integer) (s/def ::height ::us/safe-integer) @@ -19,3 +20,11 @@ ;; migration and then mark it as not nilable. (s/def ::path (s/nilable string?)) +(s/def ::media-object + (s/keys :req-un [::id + ::name + ::width + ::height + ::mtype] + :opt-un [::path])) + diff --git a/common/src/app/common/types/page/grid.cljc b/common/src/app/common/types/page/grid.cljc index fae6e7de14..ea2640be1f 100644 --- a/common/src/app/common/types/page/grid.cljc +++ b/common/src/app/common/types/page/grid.cljc @@ -7,18 +7,20 @@ (ns app.common.types.page.grid (:require [app.common.spec :as us] + [app.common.types.page.grid.color :as-alias grid-color] [clojure.spec.alpha :as s])) ;; --- Board grids -(s/def :grid/color string?) -(s/def :grid/opacity ::us/safe-number) + +(s/def ::grid-color/color string?) +(s/def ::grid-color/opacity ::us/safe-number) (s/def ::size (s/nilable ::us/safe-integer)) (s/def ::item-length (s/nilable ::us/safe-number)) -(s/def ::color (s/keys :req-un [:grid/color - :grid/opacity])) +(s/def ::color (s/keys :req-un [::grid-color/color + ::grid-color/opacity])) (s/def ::type #{:stretch :left :center :right}) (s/def ::gutter (s/nilable ::us/safe-integer)) (s/def ::margin (s/nilable ::us/safe-integer)) diff --git a/common/src/app/common/types/shape/shadow.cljc b/common/src/app/common/types/shape/shadow.cljc index 6e00859390..839152d0f5 100644 --- a/common/src/app/common/types/shape/shadow.cljc +++ b/common/src/app/common/types/shape/shadow.cljc @@ -21,7 +21,6 @@ (s/def ::spread ::us/safe-number) (s/def ::hidden boolean?) - (s/def ::color string?) (s/def ::opacity ::us/safe-number) (s/def ::gradient (s/nilable ::ctc/gradient)) @@ -36,14 +35,14 @@ ::id])) (s/def ::shadow-props - (s/keys :req-un [:internal.shadow/id - :internal.shadow/style - :shadow/color - :internal.shadow/offset-x - :internal.shadow/offset-y - :internal.shadow/blur - :internal.shadow/spread - :internal.shadow/hidden])) + (s/keys :req-un [::id + ::style + ::color + ::offset-x + ::offset-y + ::blur + ::spread + ::hidden])) (s/def ::shadow (s/coll-of ::shadow-props :kind vector?)) diff --git a/common/src/app/common/types/shape/text.cljc b/common/src/app/common/types/shape/text.cljc index bdb6768e55..2d3ed43686 100644 --- a/common/src/app/common/types/shape/text.cljc +++ b/common/src/app/common/types/shape/text.cljc @@ -8,6 +8,7 @@ (:require [app.common.spec :as us] [app.common.types.color :as ctc] + [app.common.types.shape.text.position-data :as-alias position-data] [clojure.spec.alpha :as s])) (s/def ::type #{"root" "paragraph-set" "paragraph"}) @@ -37,36 +38,36 @@ :min-count 1)) (s/def ::position-data-element - (s/keys :req-un [:position-data/x - :position-data/y - :position-data/width - :position-data/height] - :opt-un [:position-data/fill-color - :position-data/fill-opacity - :position-data/font-family - :position-data/font-size - :position-data/font-style - :position-data/font-weight - :position-data/rtl - :position-data/text - :position-data/text-decoration - :position-data/text-transform])) + (s/keys :req-un [::position-data/x + ::position-data/y + ::position-data/width + ::position-data/height] + :opt-un [::position-data/fill-color + ::position-data/fill-opacity + ::position-data/font-family + ::position-data/font-size + ::position-data/font-style + ::position-data/font-weight + ::position-data/rtl + ::position-data/text + ::position-data/text-decoration + ::position-data/text-transform])) -(s/def :position-data/x ::us/safe-number) -(s/def :position-data/y ::us/safe-number) -(s/def :position-data/width ::us/safe-number) -(s/def :position-data/height ::us/safe-number) +(s/def ::position-data/x ::us/safe-number) +(s/def ::position-data/y ::us/safe-number) +(s/def ::position-data/width ::us/safe-number) +(s/def ::position-data/height ::us/safe-number) -(s/def :position-data/fill-color ::fill-color) -(s/def :position-data/fill-opacity ::fill-opacity) -(s/def :position-data/fill-color-gradient ::fill-color-gradient) +(s/def ::position-data/fill-color ::fill-color) +(s/def ::position-data/fill-opacity ::fill-opacity) +(s/def ::position-data/fill-color-gradient ::fill-color-gradient) -(s/def :position-data/font-family string?) -(s/def :position-data/font-size string?) -(s/def :position-data/font-style string?) -(s/def :position-data/font-weight string?) -(s/def :position-data/rtl boolean?) -(s/def :position-data/text string?) -(s/def :position-data/text-decoration string?) -(s/def :position-data/text-transform string?) +(s/def ::position-data/font-family string?) +(s/def ::position-data/font-size string?) +(s/def ::position-data/font-style string?) +(s/def ::position-data/font-weight string?) +(s/def ::position-data/rtl boolean?) +(s/def ::position-data/text string?) +(s/def ::position-data/text-decoration string?) +(s/def ::position-data/text-transform string?)