From 7e70f0ce30ca19576105ca705f5f7cce94614367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Fri, 14 Oct 2022 17:15:20 +0200 Subject: [PATCH 1/3] :recycle: Move internal.xxx namespaces to separated files --- common/src/app/common/types/file.cljc | 20 ++--- .../app/common/types/file/media_object.cljc | 21 +++++ common/src/app/common/types/page.cljc | 77 ++----------------- common/src/app/common/types/page/flow.cljc | 24 ++++++ common/src/app/common/types/page/grid.cljc | 44 +++++++++++ common/src/app/common/types/page/guide.cljc | 27 +++++++ common/src/app/common/types/shape.cljc | 76 ++---------------- common/src/app/common/types/shape/path.cljc | 20 +++++ common/src/app/common/types/shape/text.cljc | 72 +++++++++++++++++ 9 files changed, 226 insertions(+), 155 deletions(-) create mode 100644 common/src/app/common/types/file/media_object.cljc create mode 100644 common/src/app/common/types/page/flow.cljc create mode 100644 common/src/app/common/types/page/grid.cljc create mode 100644 common/src/app/common/types/page/guide.cljc create mode 100644 common/src/app/common/types/shape/path.cljc create mode 100644 common/src/app/common/types/shape/text.cljc diff --git a/common/src/app/common/types/file.cljc b/common/src/app/common/types/file.cljc index 74f11a20b..ed02a19a3 100644 --- a/common/src/app/common/types/file.cljc +++ b/common/src/app/common/types/file.cljc @@ -11,12 +11,12 @@ [app.common.geom.shapes :as gsh] [app.common.pages.common :refer [file-version]] [app.common.pages.helpers :as cph] - [app.common.spec :as us] [app.common.types.color :as ctc] [app.common.types.colors-list :as ctcl] [app.common.types.component :as ctk] [app.common.types.components-list :as ctkl] [app.common.types.container :as ctn] + [app.common.types.file.media-object :as ctfm] [app.common.types.page :as ctp] [app.common.types.pages-list :as ctpl] [app.common.types.shape-tree :as ctst] @@ -28,23 +28,13 @@ ;; Specs -(s/def :internal.media-object/name string?) -(s/def :internal.media-object/width ::us/safe-integer) -(s/def :internal.media-object/height ::us/safe-integer) -(s/def :internal.media-object/mtype string?) - -;; NOTE: This is marked as nilable for backward compatibility, but -;; right now is just exists or not exists. We can thin in a gradual -;; migration and then mark it as not nilable. -(s/def :internal.media-object/path (s/nilable string?)) - (s/def ::media-object (s/keys :req-un [::id ::name - :internal.media-object/width - :internal.media-object/height - :internal.media-object/mtype] - :opt-un [:internal.media-object/path])) + ::ctfm/width + ::ctfm/height + ::ctfm/mtype] + :opt-un [::ctfm/path])) (s/def ::colors (s/map-of uuid? ::ctc/color)) diff --git a/common/src/app/common/types/file/media_object.cljc b/common/src/app/common/types/file/media_object.cljc new file mode 100644 index 000000000..8b3f6eec2 --- /dev/null +++ b/common/src/app/common/types/file/media_object.cljc @@ -0,0 +1,21 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + +(ns app.common.types.file.media-object + (:require + [app.common.spec :as us] + [clojure.spec.alpha :as s])) + +(s/def ::name string?) +(s/def ::width ::us/safe-integer) +(s/def ::height ::us/safe-integer) +(s/def ::mtype string?) + +;; NOTE: This is marked as nilable for backward compatibility, but +;; right now is just exists or not exists. We can thin in a gradual +;; migration and then mark it as not nilable. +(s/def ::path (s/nilable string?)) + diff --git a/common/src/app/common/types/page.cljc b/common/src/app/common/types/page.cljc index 2aee3761a..975915ced 100644 --- a/common/src/app/common/types/page.cljc +++ b/common/src/app/common/types/page.cljc @@ -7,85 +7,24 @@ (ns app.common.types.page (:require [app.common.data :as d] - [app.common.spec :as us] + [app.common.types.page.flow :as ctpf] + [app.common.types.page.grid :as ctpg] + [app.common.types.page.guide :as ctpu] [app.common.types.shape :as cts] [app.common.uuid :as uuid] [clojure.spec.alpha :as s])) -;; --- Grid options - -(s/def :internal.grid.color/color string?) -(s/def :internal.grid.color/opacity ::us/safe-number) - -(s/def :internal.grid/size (s/nilable ::us/safe-integer)) -(s/def :internal.grid/item-length (s/nilable ::us/safe-number)) - -(s/def :internal.grid/color (s/keys :req-un [:internal.grid.color/color - :internal.grid.color/opacity])) -(s/def :internal.grid/type #{:stretch :left :center :right}) -(s/def :internal.grid/gutter (s/nilable ::us/safe-integer)) -(s/def :internal.grid/margin (s/nilable ::us/safe-integer)) - -(s/def :internal.grid/square - (s/keys :req-un [:internal.grid/size - :internal.grid/color])) - -(s/def :internal.grid/column - (s/keys :req-un [:internal.grid/color] - :opt-un [:internal.grid/size - :internal.grid/type - :internal.grid/item-length - :internal.grid/margin - :internal.grid/gutter])) - -(s/def :internal.grid/row :internal.grid/column) - -(s/def ::saved-grids - (s/keys :opt-un [:internal.grid/square - :internal.grid/row - :internal.grid/column])) - -;; --- Background options +;; --- Background color (s/def ::background string?) -;; --- Flow options - -(s/def :internal.flow/id uuid?) -(s/def :internal.flow/name string?) -(s/def :internal.flow/starting-frame uuid?) - -(s/def ::flow - (s/keys :req-un [:internal.flow/id - :internal.flow/name - :internal.flow/starting-frame])) - -(s/def ::flows - (s/coll-of ::flow :kind vector?)) - -;; --- Guides - -(s/def :internal.guides/id uuid?) -(s/def :internal.guides/axis #{:x :y}) -(s/def :internal.guides/position ::us/safe-number) -(s/def :internal.guides/frame-id (s/nilable uuid?)) - -(s/def ::guide - (s/keys :req-un [:internal.guides/id - :internal.guides/axis - :internal.guides/position] - :opt-un [:internal.guides/frame-id])) - -(s/def ::guides - (s/map-of uuid? ::guide)) - -;; --- Page Options +;; --- Page options (s/def ::options (s/keys :opt-un [::background - ::saved-grids - ::flows - ::guides])) + ::ctpg/saved-grids + ::ctpf/flows + ::ctpu/guides])) ;; --- Page diff --git a/common/src/app/common/types/page/flow.cljc b/common/src/app/common/types/page/flow.cljc new file mode 100644 index 000000000..20aea3019 --- /dev/null +++ b/common/src/app/common/types/page/flow.cljc @@ -0,0 +1,24 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + +(ns app.common.types.page.flow + (:require + [clojure.spec.alpha :as s])) + +;; --- Interaction Flows + +(s/def ::id uuid?) +(s/def ::name string?) +(s/def ::starting-frame uuid?) + +(s/def ::flow + (s/keys :req-un [::id + ::name + ::starting-frame])) + +(s/def ::flows + (s/coll-of ::flow :kind vector?)) + diff --git a/common/src/app/common/types/page/grid.cljc b/common/src/app/common/types/page/grid.cljc new file mode 100644 index 000000000..b5d609d66 --- /dev/null +++ b/common/src/app/common/types/page/grid.cljc @@ -0,0 +1,44 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + +(ns app.common.types.page.grid + (:require + [app.common.spec :as us] + [clojure.spec.alpha :as s])) + +;; --- Board grids + +(s/def :grid/color string?) +(s/def :grid/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 ::type #{:stretch :left :center :right}) +(s/def ::gutter (s/nilable ::us/safe-integer)) +(s/def ::margin (s/nilable ::us/safe-integer)) + +(s/def ::square + (s/keys :req-un [::size + ::color])) + +(s/def ::column + (s/keys :req-un [::color] + :opt-un [::size + ::type + ::item-length + ::margin + ::gutter])) + +(s/def ::row ::column) + +(s/def ::saved-grids + (s/keys :opt-un [::square + ::row + ::column])) + diff --git a/common/src/app/common/types/page/guide.cljc b/common/src/app/common/types/page/guide.cljc new file mode 100644 index 000000000..cfff18c31 --- /dev/null +++ b/common/src/app/common/types/page/guide.cljc @@ -0,0 +1,27 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + +(ns app.common.types.page.guide + (:require + [app.common.spec :as us] + [clojure.spec.alpha :as s])) + +;; --- Page guides + +(s/def ::id uuid?) +(s/def ::axis #{:x :y}) +(s/def ::position ::us/safe-number) +(s/def ::frame-id (s/nilable uuid?)) + +(s/def ::guide + (s/keys :req-un [::id + ::axis + ::position] + :opt-un [::frame-id])) + +(s/def ::guides + (s/map-of uuid? ::guide)) + diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index 249c589ce..21b488e4a 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -19,8 +19,10 @@ [app.common.types.shape.export :as ctse] [app.common.types.shape.interactions :as ctsi] [app.common.types.shape.layout :as ctsl] + [app.common.types.shape.path :as ctsp] [app.common.types.shape.radius :as ctsr] [app.common.types.shape.shadow :as ctss] + [app.common.types.shape.text :as ctsx] [app.common.uuid :as uuid] [clojure.set :as set] [clojure.spec.alpha :as s])) @@ -229,74 +231,6 @@ ::opacity ::blend-mode]))) -(s/def :internal.shape.text/type #{"root" "paragraph-set" "paragraph"}) -(s/def :internal.shape.text/children - (s/coll-of :internal.shape.text/content - :kind vector? - :min-count 1)) - -(s/def :internal.shape.text/text string?) -(s/def :internal.shape.text/key string?) - -(s/def :internal.shape.text/content - (s/nilable - (s/or :text-container - (s/keys :req-un [:internal.shape.text/type] - :opt-un [:internal.shape.text/key - :internal.shape.text/children]) - :text-content - (s/keys :req-un [:internal.shape.text/text])))) - -(s/def :internal.shape.text/position-data - (s/coll-of :internal.shape.text/position-data-element - :kind vector? - :min-count 1)) - -(s/def :internal.shape.text/position-data-element - (s/keys :req-un [:internal.shape.text.position-data/x - :internal.shape.text.position-data/y - :internal.shape.text.position-data/width - :internal.shape.text.position-data/height] - :opt-un [:internal.shape.text.position-data/fill-color - :internal.shape.text.position-data/fill-opacity - :internal.shape.text.position-data/font-family - :internal.shape.text.position-data/font-size - :internal.shape.text.position-data/font-style - :internal.shape.text.position-data/font-weight - :internal.shape.text.position-data/rtl - :internal.shape.text.position-data/text - :internal.shape.text.position-data/text-decoration - :internal.shape.text.position-data/text-transform])) - -(s/def :internal.shape.text.position-data/x ::us/safe-number) -(s/def :internal.shape.text.position-data/y ::us/safe-number) -(s/def :internal.shape.text.position-data/width ::us/safe-number) -(s/def :internal.shape.text.position-data/height ::us/safe-number) - -(s/def :internal.shape.text.position-data/fill-color ::fill-color) -(s/def :internal.shape.text.position-data/fill-opacity ::fill-opacity) -(s/def :internal.shape.text.position-data/fill-color-gradient ::fill-color-gradient) - -(s/def :internal.shape.text.position-data/font-family string?) -(s/def :internal.shape.text.position-data/font-size string?) -(s/def :internal.shape.text.position-data/font-style string?) -(s/def :internal.shape.text.position-data/font-weight string?) -(s/def :internal.shape.text.position-data/rtl boolean?) -(s/def :internal.shape.text.position-data/text string?) -(s/def :internal.shape.text.position-data/text-decoration string?) -(s/def :internal.shape.text.position-data/text-transform string?) - -(s/def :internal.shape.path/command keyword?) -(s/def :internal.shape.path/params - (s/nilable (s/map-of keyword? any?))) - -(s/def :internal.shape.path/command-item - (s/keys :req-un [:internal.shape.path/command] - :opt-un [:internal.shape.path/params])) - -(s/def :internal.shape.path/content - (s/coll-of :internal.shape.path/command-item :kind vector?)) - (defmulti shape-spec :type) (defmethod shape-spec :default [_] @@ -304,12 +238,12 @@ (defmethod shape-spec :text [_] (s/and ::shape-attrs - (s/keys :opt-un [:internal.shape.text/content - :internal.shape.text/position-data]))) + (s/keys :opt-un [::ctsx/content + ::ctsx/position-data]))) (defmethod shape-spec :path [_] (s/and ::shape-attrs - (s/keys :opt-un [:internal.shape.path/content]))) + (s/keys :opt-un [::ctsp/content]))) (defmethod shape-spec :frame [_] (s/and ::shape-attrs diff --git a/common/src/app/common/types/shape/path.cljc b/common/src/app/common/types/shape/path.cljc new file mode 100644 index 000000000..85adef0ae --- /dev/null +++ b/common/src/app/common/types/shape/path.cljc @@ -0,0 +1,20 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + +(ns app.common.types.shape.path + (:require + [clojure.spec.alpha :as s])) + +(s/def ::command keyword?) +(s/def ::params (s/nilable (s/map-of keyword? any?))) + +(s/def ::command-item + (s/keys :req-un [::command] + :opt-un [::params])) + +(s/def ::content + (s/coll-of ::command-item :kind vector?)) + diff --git a/common/src/app/common/types/shape/text.cljc b/common/src/app/common/types/shape/text.cljc new file mode 100644 index 000000000..d67e1a86d --- /dev/null +++ b/common/src/app/common/types/shape/text.cljc @@ -0,0 +1,72 @@ +;; This Source Code Form is subject to the terms of the Mozilla Public +;; License, v. 2.0. If a copy of the MPL was not distributed with this +;; file, You can obtain one at http://mozilla.org/MPL/2.0/. +;; +;; Copyright (c) UXBOX Labs SL + +(ns app.common.types.shape.text + (:require + [app.common.spec :as us] + [app.common.types.color :as ctc] + [clojure.spec.alpha :as s])) + +(s/def ::type #{"root" "paragraph-set" "paragraph"}) +(s/def ::text string?) +(s/def ::key string?) +(s/def ::fill-color string?) +(s/def ::fill-opacity ::us/safe-number) +(s/def ::fill-color-gradient (s/nilable ::ctc/gradient)) + +(s/def ::content + (s/nilable + (s/or :text-container + (s/keys :req-un [::type] + :opt-un [::key + ::children]) + :text-content + (s/keys :req-un [::text])))) + +(s/def ::children + (s/coll-of ::content + :kind vector? + :min-count 1)) + +(s/def ::position-data + (s/coll-of ::position-data-element + :kind vector? + :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/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/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?) + From 04f8bbb1f2068fb6a1c1022fc3be118788c1557d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Mon, 17 Oct 2022 16:32:00 +0200 Subject: [PATCH 2/3] :books: Fix copyright --- common/src/app/common/types/file/media_object.cljc | 2 +- common/src/app/common/types/page/flow.cljc | 2 +- common/src/app/common/types/page/grid.cljc | 2 +- common/src/app/common/types/page/guide.cljc | 2 +- common/src/app/common/types/shape/blur.cljc | 2 +- common/src/app/common/types/shape/export.cljc | 2 +- common/src/app/common/types/shape/interactions.cljc | 2 +- common/src/app/common/types/shape/layout.cljc | 2 +- common/src/app/common/types/shape/path.cljc | 2 +- common/src/app/common/types/shape/radius.cljc | 2 +- common/src/app/common/types/shape/shadow.cljc | 2 +- common/src/app/common/types/shape/text.cljc | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/common/src/app/common/types/file/media_object.cljc b/common/src/app/common/types/file/media_object.cljc index 8b3f6eec2..615a4e944 100644 --- a/common/src/app/common/types/file/media_object.cljc +++ b/common/src/app/common/types/file/media_object.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.file.media-object (:require diff --git a/common/src/app/common/types/page/flow.cljc b/common/src/app/common/types/page/flow.cljc index 20aea3019..62f2b1504 100644 --- a/common/src/app/common/types/page/flow.cljc +++ b/common/src/app/common/types/page/flow.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.page.flow (:require diff --git a/common/src/app/common/types/page/grid.cljc b/common/src/app/common/types/page/grid.cljc index b5d609d66..fae6e7de1 100644 --- a/common/src/app/common/types/page/grid.cljc +++ b/common/src/app/common/types/page/grid.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.page.grid (:require diff --git a/common/src/app/common/types/page/guide.cljc b/common/src/app/common/types/page/guide.cljc index cfff18c31..d7a5eca81 100644 --- a/common/src/app/common/types/page/guide.cljc +++ b/common/src/app/common/types/page/guide.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.page.guide (:require diff --git a/common/src/app/common/types/shape/blur.cljc b/common/src/app/common/types/shape/blur.cljc index 03257d8f9..f10a93503 100644 --- a/common/src/app/common/types/shape/blur.cljc +++ b/common/src/app/common/types/shape/blur.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.blur (:require diff --git a/common/src/app/common/types/shape/export.cljc b/common/src/app/common/types/shape/export.cljc index 057d575e0..e63430b28 100644 --- a/common/src/app/common/types/shape/export.cljc +++ b/common/src/app/common/types/shape/export.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.export (:require diff --git a/common/src/app/common/types/shape/interactions.cljc b/common/src/app/common/types/shape/interactions.cljc index db55d26db..103c32a83 100644 --- a/common/src/app/common/types/shape/interactions.cljc +++ b/common/src/app/common/types/shape/interactions.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.interactions (:require diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index 4e7e7059b..81ed9f108 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.layout (:require diff --git a/common/src/app/common/types/shape/path.cljc b/common/src/app/common/types/shape/path.cljc index 85adef0ae..ef0163711 100644 --- a/common/src/app/common/types/shape/path.cljc +++ b/common/src/app/common/types/shape/path.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.path (:require diff --git a/common/src/app/common/types/shape/radius.cljc b/common/src/app/common/types/shape/radius.cljc index a93a8a927..94651847f 100644 --- a/common/src/app/common/types/shape/radius.cljc +++ b/common/src/app/common/types/shape/radius.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.radius (:require diff --git a/common/src/app/common/types/shape/shadow.cljc b/common/src/app/common/types/shape/shadow.cljc index e2e92e586..6e0085939 100644 --- a/common/src/app/common/types/shape/shadow.cljc +++ b/common/src/app/common/types/shape/shadow.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.shadow (:require diff --git a/common/src/app/common/types/shape/text.cljc b/common/src/app/common/types/shape/text.cljc index d67e1a86d..bdb6768e5 100644 --- a/common/src/app/common/types/shape/text.cljc +++ b/common/src/app/common/types/shape/text.cljc @@ -2,7 +2,7 @@ ;; License, v. 2.0. If a copy of the MPL was not distributed with this ;; file, You can obtain one at http://mozilla.org/MPL/2.0/. ;; -;; Copyright (c) UXBOX Labs SL +;; Copyright (c) KALEIDOS INC (ns app.common.types.shape.text (:require 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 3/3] :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 f8e1be45d..4a6c69efa 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 06c5c497b..9ce0da1c6 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 ed02a19a3..1ff989e50 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 615a4e944..c5174c505 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 fae6e7de1..ea2640be1 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 6e0085939..839152d0f 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 bdb6768e5..2d3ed4368 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?)