mirror of
https://github.com/penpot/penpot.git
synced 2025-07-23 10:37:12 +02:00
♻️ Move app.common.pages to app.common.files
This commit is contained in:
parent
8345548a7a
commit
52fbc678f3
139 changed files with 1459 additions and 1510 deletions
|
@ -8,8 +8,8 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[cuerdas.core :as str]))
|
||||
|
||||
|
@ -34,18 +34,18 @@
|
|||
[shape]
|
||||
(or
|
||||
;; path and path-like shapes
|
||||
(cph/path-shape? shape)
|
||||
(cph/bool-shape? shape)
|
||||
(cfh/path-shape? shape)
|
||||
(cfh/bool-shape? shape)
|
||||
|
||||
;; imported SVG images
|
||||
(cph/svg-raw-shape? shape)
|
||||
(cfh/svg-raw-shape? shape)
|
||||
(some? (:svg-attrs shape))
|
||||
|
||||
;; CSS masks are not enough we need to delegate to SVG
|
||||
(cph/mask-shape? shape)
|
||||
(cfh/mask-shape? shape)
|
||||
|
||||
;; Texts with shadows or strokes we render in SVG
|
||||
(and (cph/text-shape? shape)
|
||||
(and (cfh/text-shape? shape)
|
||||
(or (d/not-empty? (:shadow shape))
|
||||
(d/not-empty? (:strokes shape))))
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
["react-dom/server" :as rds]
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.config :as cfg]
|
||||
[app.main.ui.shapes.text.html-text :as text]
|
||||
|
@ -38,7 +38,7 @@
|
|||
svg-markup
|
||||
indent))
|
||||
|
||||
(cph/text-shape? shape)
|
||||
(cfh/text-shape? shape)
|
||||
(let [text-shape-html (rds/renderToStaticMarkup (mf/element text/text-shape #js {:shape shape :code? true}))]
|
||||
(dm/fmt "%<div class=\"%\">\n%\n%</div>"
|
||||
indent
|
||||
|
@ -47,7 +47,7 @@
|
|||
text-shape-html
|
||||
indent))
|
||||
|
||||
(cph/image-shape? shape)
|
||||
(cfh/image-shape? shape)
|
||||
(let [data (or (:metadata shape) (:fill-image shape))
|
||||
image-url (cfg/resolve-file-media data)]
|
||||
(dm/fmt "%<img src=\"%\" class=\"%\">\n%</img>"
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.shapes.bounds :as gsb]
|
||||
[app.common.geom.shapes.points :as gpo]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.text :as txt]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.main.ui.shapes.text.styles :as sts]
|
||||
|
@ -279,7 +279,7 @@ body {
|
|||
(when wrapper? (str/fmt ".%s-wrapper > * {\n%s\n}" selector wrapper-child-properties))
|
||||
(when svg? (str/fmt ".%s > svg {\n%s\n}" selector svg-child-props))
|
||||
(str/fmt ".%s {\n%s\n}" selector properties)
|
||||
(when (cph/text-shape? shape) (generate-text-css shape))]))))))
|
||||
(when (cfh/text-shape? shape) (generate-text-css shape))]))))))
|
||||
|
||||
(defn get-css-property
|
||||
([objects shape property]
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
[app.common.geom.shapes :as gsh]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.main.ui.formats :as fmt]
|
||||
[app.util.code-gen.common :as cgc]
|
||||
|
@ -31,10 +31,10 @@
|
|||
(cond
|
||||
(or (and (ctl/any-layout-immediate-child? objects shape)
|
||||
(not (ctl/layout-absolute? shape))
|
||||
(or (cph/group-like-shape? shape)
|
||||
(cph/frame-shape? shape)
|
||||
(or (cfh/group-like-shape? shape)
|
||||
(cfh/frame-shape? shape)
|
||||
(cgc/svg-markup? shape)))
|
||||
(cph/root-frame? shape))
|
||||
(cfh/root-frame? shape))
|
||||
:relative
|
||||
|
||||
(and (ctl/any-layout-immediate-child? objects shape)
|
||||
|
@ -47,7 +47,7 @@
|
|||
(defn get-shape-position
|
||||
[shape objects coord]
|
||||
|
||||
(when (and (not (cph/root-frame? shape))
|
||||
(when (and (not (cfh/root-frame? shape))
|
||||
(or (not (ctl/any-layout-immediate-child? objects shape))
|
||||
(ctl/layout-absolute? shape)))
|
||||
|
||||
|
@ -73,7 +73,7 @@
|
|||
|
||||
(defmethod get-value :flex
|
||||
[_ shape objects]
|
||||
(let [parent (cph/get-parent objects (:id shape))]
|
||||
(let [parent (cfh/get-parent objects (:id shape))]
|
||||
(when (and (ctl/flex-layout-immediate-child? objects shape)
|
||||
(or (and (contains? #{:row :row-reverse} (:layout-flex-dir parent))
|
||||
(= :fill (:layout-item-h-sizing shape)))
|
||||
|
@ -83,7 +83,7 @@
|
|||
|
||||
(defn get-shape-size
|
||||
[shape objects type]
|
||||
(let [parent (cph/get-parent objects (:id shape))
|
||||
(let [parent (cfh/get-parent objects (:id shape))
|
||||
sizing (if (= type :width)
|
||||
(:layout-item-h-sizing shape)
|
||||
(:layout-item-v-sizing shape))]
|
||||
|
@ -148,7 +148,7 @@
|
|||
(let [single-fill? (= (count fills) 1)
|
||||
ffill (first fills)
|
||||
gradient? (some? (:fill-color-gradient ffill))]
|
||||
(when (and (not (cgc/svg-markup? shape)) (not (cph/group-shape? shape)) single-fill? gradient?)
|
||||
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill? gradient?)
|
||||
(fill->color ffill))))
|
||||
|
||||
(defmethod get-value :background-color
|
||||
|
@ -156,12 +156,12 @@
|
|||
(let [single-fill? (= (count fills) 1)
|
||||
ffill (first fills)
|
||||
gradient? (some? (:fill-color-gradient ffill))]
|
||||
(when (and (not (cgc/svg-markup? shape)) (not (cph/group-shape? shape)) single-fill? (not gradient?))
|
||||
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill? (not gradient?))
|
||||
(fill->color ffill))))
|
||||
|
||||
(defmethod get-value :background-image
|
||||
[_ {:keys [fills] :as shape} _]
|
||||
(when (and (not (cgc/svg-markup? shape)) (not (cph/group-shape? shape)) (> (count fills) 1))
|
||||
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) (> (count fills) 1))
|
||||
(->> fills
|
||||
(map fill->color))))
|
||||
|
||||
|
@ -186,7 +186,7 @@
|
|||
(defmethod get-value :border-radius
|
||||
[_ {:keys [rx r1 r2 r3 r4] :as shape} _]
|
||||
(cond
|
||||
(cph/circle-shape? shape)
|
||||
(cfh/circle-shape? shape)
|
||||
"50%"
|
||||
|
||||
(some? rx)
|
||||
|
@ -219,7 +219,7 @@
|
|||
|
||||
(defmethod get-value :overflow
|
||||
[_ shape _]
|
||||
(when (and (cph/frame-shape? shape)
|
||||
(when (and (cfh/frame-shape? shape)
|
||||
(not (cgc/svg-markup? shape))
|
||||
(not (:show-content shape)))
|
||||
"hidden"))
|
||||
|
@ -363,7 +363,7 @@
|
|||
(defmethod get-value :z-index
|
||||
[_ {:keys [layout-item-z-index] :as shape} objects]
|
||||
(cond
|
||||
(cph/root-frame? shape)
|
||||
(cfh/root-frame? shape)
|
||||
0
|
||||
|
||||
(ctl/any-layout-immediate-child? objects shape)
|
||||
|
@ -381,7 +381,7 @@
|
|||
(and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-h shape)))
|
||||
(:layout-item-min-h shape)
|
||||
|
||||
(and (ctl/auto-height? shape) (cph/frame-shape? shape) (not (:show-content shape)))
|
||||
(and (ctl/auto-height? shape) (cfh/frame-shape? shape) (not (:show-content shape)))
|
||||
(-> shape :selrect :height)))
|
||||
|
||||
(defmethod get-value :max-width
|
||||
|
@ -396,7 +396,7 @@
|
|||
(and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-w shape)))
|
||||
(:layout-item-min-w shape)
|
||||
|
||||
(and (ctl/auto-width? shape) (cph/frame-shape? shape) (not (:show-content shape)))
|
||||
(and (ctl/auto-width? shape) (cfh/frame-shape? shape) (not (:show-content shape)))
|
||||
(-> shape :selrect :width)))
|
||||
|
||||
(defmethod get-value :align-self
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
https://en.wikipedia.org/wiki/Range_tree"
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.files.page-diff :as diff]
|
||||
[app.common.geom.grid :as gg]
|
||||
[app.common.geom.snap :as snap]
|
||||
[app.common.pages.diff :as diff]
|
||||
[app.common.pages.helpers :as cph]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
[app.common.types.shape.layout :as ctl]
|
||||
[app.common.uuid :as uuid]
|
||||
|
@ -87,7 +87,7 @@
|
|||
(cond-> page-data
|
||||
(and (not (ctl/any-layout-descent? objects frame))
|
||||
(not (:hidden frame))
|
||||
(not (cph/hidden-parent? objects frame-id)))
|
||||
(not (cfh/hidden-parent? objects frame-id)))
|
||||
|
||||
(-> ;; Update root frame information
|
||||
(assoc-in [uuid/zero :objects-data frame-id] frame-data)
|
||||
|
@ -115,7 +115,7 @@
|
|||
(cond-> page-data
|
||||
(and (not (ctl/any-layout-descent? objects shape))
|
||||
(not (:hidden shape))
|
||||
(not (cph/hidden-parent? objects (:id shape))))
|
||||
(not (cfh/hidden-parent? objects (:id shape))))
|
||||
(-> (assoc-in [frame-id :objects-data (:id shape)] shape-data)
|
||||
(update-in [frame-id :x] (make-insert-tree-data shape-data :x))
|
||||
(update-in [frame-id :y] (make-insert-tree-data shape-data :y))))))
|
||||
|
@ -135,7 +135,7 @@
|
|||
;; Guide inside frame, we add the information only on that frame
|
||||
(cond-> page-data
|
||||
(and (not (:hidden frame))
|
||||
(not (cph/hidden-parent? objects frame-id)))
|
||||
(not (cfh/hidden-parent? objects frame-id)))
|
||||
(-> (assoc-in [frame-id :objects-data (:id guide)] guide-data)
|
||||
(update-in [frame-id (:axis guide)] (make-insert-tree-data guide-data (:axis guide)))))
|
||||
|
||||
|
@ -214,7 +214,7 @@
|
|||
[snap-data {:keys [objects options] :as page}]
|
||||
(let [frames (ctst/get-frames objects)
|
||||
shapes (->> (vals (:objects page))
|
||||
(remove cph/frame-shape?))
|
||||
(remove cfh/frame-shape?))
|
||||
guides (vals (:guides options))
|
||||
|
||||
page-data
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue