mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 16:21:57 -05:00
♻️ Move internal.xxx namespaces to separated files
This commit is contained in:
parent
0618aa32a0
commit
7e70f0ce30
9 changed files with 226 additions and 155 deletions
|
@ -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))
|
||||
|
|
21
common/src/app/common/types/file/media_object.cljc
Normal file
21
common/src/app/common/types/file/media_object.cljc
Normal file
|
@ -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?))
|
||||
|
|
@ -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
|
||||
|
||||
|
|
24
common/src/app/common/types/page/flow.cljc
Normal file
24
common/src/app/common/types/page/flow.cljc
Normal file
|
@ -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?))
|
||||
|
44
common/src/app/common/types/page/grid.cljc
Normal file
44
common/src/app/common/types/page/grid.cljc
Normal file
|
@ -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]))
|
||||
|
27
common/src/app/common/types/page/guide.cljc
Normal file
27
common/src/app/common/types/page/guide.cljc
Normal file
|
@ -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))
|
||||
|
|
@ -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
|
||||
|
|
20
common/src/app/common/types/shape/path.cljc
Normal file
20
common/src/app/common/types/shape/path.cljc
Normal file
|
@ -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?))
|
||||
|
72
common/src/app/common/types/shape/text.cljc
Normal file
72
common/src/app/common/types/shape/text.cljc
Normal file
|
@ -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?)
|
||||
|
Loading…
Add table
Reference in a new issue