♻️ Remove unneeded fn parameters

This commit is contained in:
Xavier Julian 2025-09-16 12:16:40 +02:00 committed by Xaviju
parent 7bacd8fbca
commit 2bf7a9dd5f
3 changed files with 165 additions and 167 deletions

View File

@ -13,7 +13,7 @@
[app.main.ui.components.title-bar :refer [inspect-title-bar*]] [app.main.ui.components.title-bar :refer [inspect-title-bar*]]
[app.main.ui.inspect.attributes.common :refer [color-row]] [app.main.ui.inspect.attributes.common :refer [color-row]]
[app.util.code-gen.style-css :as css] [app.util.code-gen.style-css :as css]
[app.util.code-gen.style-css-formats :refer [format-color->css]] [app.util.code-gen.style-css-formats :refer [format-color-value]]
[app.util.i18n :refer [tr]] [app.util.i18n :refer [tr]]
[rumext.v2 :as mf])) [rumext.v2 :as mf]))
@ -26,7 +26,7 @@
(defn- copy-color-data (defn- copy-color-data
"Converts a fill object to CSS color string in the specified format." "Converts a fill object to CSS color string in the specified format."
[color format] [color format]
(format-color->css color {:format format})) (format-color-value color {:format format}))
(mf/defc shadow-block [{:keys [shadow]}] (mf/defc shadow-block [{:keys [shadow]}]
(let [color-format (mf/use-state :hex) (let [color-format (mf/use-state :hex)

View File

@ -53,7 +53,7 @@
:grid-template-rows :tracks :grid-template-rows :tracks
:grid-template-columns :tracks}) :grid-template-columns :tracks})
(defn format-color->css (defn format-color-value
"Format a color value to a CSS compatible string based on the given format." "Format a color value to a CSS compatible string based on the given format."
[value options] [value options]
(let [format (get options :format :hex)] (let [format (get options :format :hex)]
@ -77,19 +77,19 @@
(defn format-shadow->css (defn format-shadow->css
[{:keys [style offset-x offset-y blur spread color]} options] [{:keys [style offset-x offset-y blur spread color]} options]
(let [css-color (format-color->css color options)] (let [css-color (format-color-value color options)]
(dm/str (dm/str
(if (= style :inner-shadow) "inset " "") (if (= style :inner-shadow) "inset " "")
(str/fmt "%spx %spx %spx %spx %s" offset-x offset-y blur spread css-color)))) (str/fmt "%spx %spx %spx %spx %s" offset-x offset-y blur spread css-color))))
(defn- format-position (defn- format-position
[_ value _options] [value]
(cond (cond
(number? value) (fmt/format-pixels value) (number? value) (fmt/format-pixels value)
:else value)) :else value))
(defn- format-size (defn- format-size
[_ value _options] [value]
(cond (cond
(= value :fill) "100%" (= value :fill) "100%"
(= value :auto) "auto" (= value :auto) "auto"
@ -97,33 +97,33 @@
:else value)) :else value))
(defn- format-color (defn- format-color
[_ value options] [value options]
(let [format (get options :format :hex)] (let [format (get options :format :hex)]
(format-color->css value (assoc options :format format)))) (format-color-value value (assoc options :format format))))
(defn- format-color-array (defn- format-color-array
[_ value options] [value options]
(->> value (->> value
(map #(format-color->css % options)) (map #(format-color-value % options))
(str/join ", "))) (str/join ", ")))
(defn- format-border (defn- format-border
[_ {:keys [color style width]} options] [{:keys [color style width]} options]
(dm/fmt "% % %" (dm/fmt "% % %"
(fmt/format-pixels width) (fmt/format-pixels width)
(d/name style) (d/name style)
(format-color->css color options))) (format-color-value color options)))
(defn- format-border-style (defn- format-border-style
[_ value _options] [value]
(d/name (:style value))) (d/name (:style value)))
(defn- format-border-width (defn- format-border-width
[_ value _options] [value]
(fmt/format-pixels (:width value))) (fmt/format-pixels (:width value)))
(defn- format-size-array (defn- format-size-array
[_ value _options] [value]
(cond (cond
(and (coll? value) (d/not-empty? value)) (and (coll? value) (d/not-empty? value))
(->> value (->> value
@ -134,7 +134,7 @@
value)) value))
(defn format-string-or-size-array (defn format-string-or-size-array
[_ value _] [value]
(cond (cond
(string? value) (string? value)
value value
@ -148,11 +148,11 @@
value)) value))
(defn- format-keyword (defn- format-keyword
[_ value _options] [value]
(d/name value)) (d/name value))
(defn- format-tracks (defn- format-tracks
[_ value _options] [value]
(->> value (->> value
(map (fn [{:keys [type value]}] (map (fn [{:keys [type value]}]
(case type (case type
@ -163,37 +163,37 @@
(str/join " "))) (str/join " ")))
(defn- format-shadow (defn- format-shadow
[_ value options] [value options]
(->> value (->> value
(map #(format-shadow->css % options)) (map #(format-shadow->css % options))
(str/join ", "))) (str/join ", ")))
(defn- format-blur (defn- format-blur
[_ value _options] [value]
(dm/fmt "blur(%)" (fmt/format-pixels value))) (dm/fmt "blur(%)" (fmt/format-pixels value)))
(defn- format-matrix (defn- format-matrix
[_ value _options] [value]
(fmt/format-matrix value)) (fmt/format-matrix value))
(defn format-value (defn format-value
"Get the appropriate value formatter function for a given CSS property." "Get the appropriate value formatter function for a given CSS property."
[property value options] [property value options]
(let [property (css-formatters property)] (let [property (get css-formatters property)]
(case property (case property
:position (format-position property value options) :position (format-position value)
:size (format-size property value options) :size (format-size value)
:color (format-color property value options) :color (format-color value options)
:color-array (format-color-array property value options) :color-array (format-color-array value options)
:border (format-border property value options) :border (format-border value options)
:border-style (format-border-style property value options) :border-style (format-border-style value)
:border-width (format-border-width property value options) :border-width (format-border-width value)
:size-array (format-size-array property value options) :size-array (format-size-array value)
:string-or-size-array (format-string-or-size-array property value options) :string-or-size-array (format-string-or-size-array value)
:keyword (format-keyword property value options) :keyword (format-keyword value)
:tracks (format-tracks property value options) :tracks (format-tracks value)
:shadow (format-shadow property value options) :shadow (format-shadow value options)
:blur (format-blur property value options) :blur (format-blur value)
:matrix (format-matrix property value options) :matrix (format-matrix value)
(if (keyword? value) (d/name value) value)))) (if (keyword? value) (d/name value) value))))

View File

@ -72,26 +72,6 @@
(some? (get shape type)) (some? (get shape type))
(get shape type)))) (get shape type))))
(defn- get-position
[_ shape objects _]
(cond
(or (and (ctl/any-layout-immediate-child? objects shape)
(not (ctl/position-absolute? shape))
(or (cfh/group-like-shape? shape)
(cfh/frame-shape? shape)
(cgc/svg-markup? shape)))
(cfh/root-frame? shape))
:relative
(and (ctl/any-layout-immediate-child? objects shape)
(not (ctl/position-absolute? shape)))
nil
:else
:absolute))
(defn get-stroke-data (defn get-stroke-data
[stroke] [stroke]
(let [width (:stroke-width stroke) (let [width (:stroke-width stroke)
@ -126,16 +106,34 @@
;; SHAPE VALUES ;; SHAPE VALUES
(defn- get-position
[shape objects]
(cond
(or (and (ctl/any-layout-immediate-child? objects shape)
(not (ctl/position-absolute? shape))
(or (cfh/group-like-shape? shape)
(cfh/frame-shape? shape)
(cgc/svg-markup? shape)))
(cfh/root-frame? shape))
:relative
(and (ctl/any-layout-immediate-child? objects shape)
(not (ctl/position-absolute? shape)))
nil
:else
:absolute))
(defn- get-left-position (defn- get-left-position
[_ shape objects _] [shape objects]
(get-shape-position shape objects :x)) (get-shape-position shape objects :x))
(defn- get-top-position (defn- get-top-position
[_ shape objects _] [shape objects]
(get-shape-position shape objects :y)) (get-shape-position shape objects :y))
(defn- get-flex (defn- get-flex
[_ shape objects _] [shape objects]
(let [parent (cfh/get-parent objects (:id shape))] (let [parent (cfh/get-parent objects (:id shape))]
(when (and (ctl/flex-layout-immediate-child? objects shape) (when (and (ctl/flex-layout-immediate-child? objects shape)
(or (and (contains? #{:row :row-reverse} (:layout-flex-dir parent)) (or (and (contains? #{:row :row-reverse} (:layout-flex-dir parent))
@ -145,7 +143,7 @@
1))) 1)))
(defn- get-width (defn- get-width
[_ shape objects options] [shape objects options]
(let [root? (contains? (:root-shapes options) (:id shape))] (let [root? (contains? (:root-shapes options) (:id shape))]
(if (and root? (ctl/any-layout? shape)) (if (and root? (ctl/any-layout? shape))
:fill :fill
@ -154,7 +152,7 @@
(get-shape-size shape objects :width))))) (get-shape-size shape objects :width)))))
(defn- get-height (defn- get-height
[_ shape objects options] [shape objects options]
(let [root? (contains? (:root-shapes options) (:id shape))] (let [root? (contains? (:root-shapes options) (:id shape))]
(when-not (and root? (ctl/any-layout? shape)) (when-not (and root? (ctl/any-layout? shape))
;; Don't set fixed height for auto-height text shapes ;; Don't set fixed height for auto-height text shapes
@ -162,13 +160,13 @@
(get-shape-size shape objects :height))))) (get-shape-size shape objects :height)))))
(defn- get-flex-grow (defn- get-flex-grow
[_ shape _ options] [shape options]
(let [root? (contains? (:root-shapes options) (:id shape))] (let [root? (contains? (:root-shapes options) (:id shape))]
(when (and root? (ctl/any-layout? shape)) (when (and root? (ctl/any-layout? shape))
1))) 1)))
(defn- get-transform (defn- get-transform
[_ shape objects _] [shape objects]
(if (cgc/svg-markup? shape) (if (cgc/svg-markup? shape)
(let [parent (get objects (:parent-id shape)) (let [parent (get objects (:parent-id shape))
transform transform
@ -193,18 +191,18 @@
transform-str)))) transform-str))))
(defn- get-background (defn- get-background
[_ {:keys [fills] :as shape} _ _] [{:keys [fills] :as shape}]
(let [single-fill? (= (count fills) 1)] (let [single-fill? (= (count fills) 1)]
(when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill?) (when (and (not (cgc/svg-markup? shape)) (not (cfh/group-shape? shape)) single-fill?)
(fill->color (first fills))))) (fill->color (first fills)))))
(defn- get-border (defn- get-border
[_ shape _ _] [shape]
(when-not (cgc/svg-markup? shape) (when-not (cgc/svg-markup? shape)
(get-stroke-data (first (:strokes shape))))) (get-stroke-data (first (:strokes shape)))))
(defn- get-border-radius (defn- get-border-radius
[_ {:keys [rx r1 r2 r3 r4] :as shape} _ _] [{:keys [rx r1 r2 r3 r4] :as shape}]
(cond (cond
(cfh/circle-shape? shape) (cfh/circle-shape? shape)
"50%" "50%"
@ -216,106 +214,106 @@
[r1 r2 r3 r4])) [r1 r2 r3 r4]))
(defn- get-border-start-start-radius (defn- get-border-start-start-radius
[_ {:keys [_ r1 _ _ _] :as shape} _ _] [{:keys [_ r1 _ _ _] :as shape}]
(when (and r1 (not= r1 0)) (when (and r1 (not= r1 0))
[r1])) [r1]))
(defn- get-border-start-end-radius (defn- get-border-start-end-radius
[_ {:keys [_ _ r2 _ _] :as shape} _ _] [{:keys [_ _ r2 _ _] :as shape}]
(when (and r2 (not= r2 0)) (when (and r2 (not= r2 0))
[r2])) [r2]))
(defn- get-border-end-start-radius (defn- get-border-end-start-radius
[_ {:keys [_ _ _ r3 _] :as shape} _ _] [{:keys [_ _ _ r3 _] :as shape}]
(when (and r3 (not= r3 0)) (when (and r3 (not= r3 0))
[r3])) [r3]))
(defn- get-border-end-end-radius (defn- get-border-end-end-radius
[_ {:keys [_ _ _ _ r4] :as shape} _ _] [{:keys [_ _ _ _ r4] :as shape}]
(when (and r4 (not= r4 0)) (when (and r4 (not= r4 0))
[r4])) [r4]))
(defn- get-border-style (defn- get-border-style
[_ stroke _ _] [stroke]
(when-not (cgc/svg-markup? stroke) (when-not (cgc/svg-markup? stroke)
(get-stroke-data stroke))) (get-stroke-data stroke)))
(defn- get-border-width (defn- get-border-width
[_ stroke _ _] [stroke]
(when-not (cgc/svg-markup? stroke) (when-not (cgc/svg-markup? stroke)
(get-stroke-data stroke))) (get-stroke-data stroke)))
(defn- get-box-shadow (defn- get-box-shadow
[_ shape _ _] [shape]
(when-not (cgc/svg-markup? shape) (when-not (cgc/svg-markup? shape)
(:shadow shape))) (:shadow shape)))
(defn- get-filter (defn- get-filter
[_ shape _ _] [shape]
(when-not (cgc/svg-markup? shape) (when-not (cgc/svg-markup? shape)
(get-in shape [:blur :value]))) (get-in shape [:blur :value])))
(defn- get-display (defn- get-display
[_ shape _ _] [shape]
(cond (cond
(:hidden shape) "none" (:hidden shape) "none"
(ctl/flex-layout? shape) "flex" (ctl/flex-layout? shape) "flex"
(ctl/grid-layout? shape) "grid")) (ctl/grid-layout? shape) "grid"))
(defn- get-opacity (defn- get-opacity
[_ shape _ _] [shape]
(when (< (:opacity shape) 1) (when (< (:opacity shape) 1)
(:opacity shape))) (:opacity shape)))
(defn- get-overflow (defn- get-overflow
[_ shape _ _] [shape]
(when (and (cfh/frame-shape? shape) (when (and (cfh/frame-shape? shape)
(not (cgc/svg-markup? shape)) (not (cgc/svg-markup? shape))
(not (:show-content shape))) (not (:show-content shape)))
"hidden")) "hidden"))
(defn- get-flex-direction (defn- get-flex-direction
[_ shape _ _] [shape]
(:layout-flex-dir shape)) (:layout-flex-dir shape))
(defn- get-align-items (defn- get-align-items
[_ shape _ _] [shape]
(:layout-align-items shape)) (:layout-align-items shape))
(defn- get-align-content (defn- get-align-content
[_ shape _ _] [shape]
(:layout-align-content shape)) (:layout-align-content shape))
(defn- get-justify-items (defn- get-justify-items
[_ shape _ _] [shape]
(:layout-justify-items shape)) (:layout-justify-items shape))
(defn- get-justify-content (defn- get-justify-content
[_ shape _ _] [shape]
(:layout-justify-content shape)) (:layout-justify-content shape))
(defn- get-flex-wrap (defn- get-flex-wrap
[_ shape _ _] [shape]
(:layout-wrap-type shape)) (:layout-wrap-type shape))
(defn- get-gap (defn- get-gap
[_ shape _ _] [shape]
(let [[g1 g2] (ctl/gaps shape)] (let [[g1 g2] (ctl/gaps shape)]
(when (and (= g1 g2) (or (not= g1 0) (not= g2 0))) (when (and (= g1 g2) (or (not= g1 0) (not= g2 0)))
[g1]))) [g1])))
(defn- get-row-gap (defn- get-row-gap
[_ shape _ _] [shape]
(let [[g1 g2] (ctl/gaps shape)] (let [[g1 g2] (ctl/gaps shape)]
(when (and (not= g1 g2) (not= g1 0)) [g1]))) (when (and (not= g1 g2) (not= g1 0)) [g1])))
(defn- get-column-gap (defn- get-column-gap
[_ shape _ _] [shape]
(let [[g1 g2] (ctl/gaps shape)] (let [[g1 g2] (ctl/gaps shape)]
(when (and (not= g1 g2) (not= g2 0)) [g2]))) (when (and (not= g1 g2) (not= g2 0)) [g2])))
(defn- get-padding (defn- get-padding
[_ {:keys [layout-padding]} _ _] [{:keys [layout-padding]}]
(when (some? layout-padding) (when (some? layout-padding)
(let [default-padding {:p1 0 :p2 0 :p3 0 :p4 0} (let [default-padding {:p1 0 :p2 0 :p3 0 :p4 0}
{:keys [p1 p2 p3 p4]} (merge default-padding layout-padding)] {:keys [p1 p2 p3 p4]} (merge default-padding layout-padding)]
@ -323,35 +321,35 @@
[p1 p2 p3 p4])))) [p1 p2 p3 p4]))))
(defn- get-padding-block-start (defn- get-padding-block-start
[_ {:keys [layout-padding]} _ _] [{:keys [layout-padding]}]
(when (and (:p1 layout-padding) (not= (:p1 layout-padding) 0)) (when (and (:p1 layout-padding) (not= (:p1 layout-padding) 0))
[(:p1 layout-padding)])) [(:p1 layout-padding)]))
(defn- get-padding-inline-end (defn- get-padding-inline-end
[_ {:keys [layout-padding]} _ _] [{:keys [layout-padding]}]
(when (and (:p2 layout-padding) (not= (:p2 layout-padding) 0)) (when (and (:p2 layout-padding) (not= (:p2 layout-padding) 0))
[(:p2 layout-padding)])) [(:p2 layout-padding)]))
(defn- get-padding-block-end (defn- get-padding-block-end
[_ {:keys [layout-padding]} _ _] [{:keys [layout-padding]}]
(when (and (:p3 layout-padding) (not= (:p3 layout-padding) 0)) (when (and (:p3 layout-padding) (not= (:p3 layout-padding) 0))
[(:p3 layout-padding)])) [(:p3 layout-padding)]))
(defn- get-padding-inline-start (defn- get-padding-inline-start
[_ {:keys [layout-padding]} _ _] [{:keys [layout-padding]}]
(when (and (:p4 layout-padding) (not= (:p4 layout-padding) 0)) (when (and (:p4 layout-padding) (not= (:p4 layout-padding) 0))
[(:p4 layout-padding)])) [(:p4 layout-padding)]))
(defn- get-grid-template-rows (defn- get-grid-template-rows
[_ shape _ _] [shape]
(:layout-grid-rows shape)) (:layout-grid-rows shape))
(defn- get-grid-template-columns (defn- get-grid-template-columns
[_ shape _ _] [shape]
(:layout-grid-columns shape)) (:layout-grid-columns shape))
(defn- get-grid-template-areas (defn- get-grid-template-areas
[_ shape _ _] [shape]
(when (and (ctl/grid-layout? shape) (when (and (ctl/grid-layout? shape)
(some area-cell? (vals (:layout-grid-cells shape)))) (some area-cell? (vals (:layout-grid-cells shape))))
(let [result (let [result
@ -370,15 +368,15 @@
result))) result)))
(defn- get-grid-column (defn- get-grid-column
[_ shape objects _] [shape objects]
(get-grid-coord shape objects :column :column-span)) (get-grid-coord shape objects :column :column-span))
(defn- get-grid-row (defn- get-grid-row
[_ shape objects _] [shape objects]
(get-grid-coord shape objects :row :row-span)) (get-grid-coord shape objects :row :row-span))
(defn- get-grid-area (defn- get-grid-area
[_ shape objects _] [shape objects]
(when (and (ctl/grid-layout-immediate-child? objects shape) (when (and (ctl/grid-layout-immediate-child? objects shape)
(not (ctl/position-absolute? shape))) (not (ctl/position-absolute? shape)))
(let [parent (get objects (:parent-id shape)) (let [parent (get objects (:parent-id shape))
@ -387,7 +385,7 @@
(str/replace (:area-name cell) " " "-"))))) (str/replace (:area-name cell) " " "-")))))
(defn- get-flex-shrink (defn- get-flex-shrink
[_ shape objects _] [shape objects]
(when (and (ctl/flex-layout-immediate-child? objects shape) (when (and (ctl/flex-layout-immediate-child? objects shape)
(not (and (contains? #{:row :reverse-row} (:layout-flex-dir shape)) (not (and (contains? #{:row :reverse-row} (:layout-flex-dir shape))
@ -403,7 +401,7 @@
0)) 0))
(defn- get-margin (defn- get-margin
[_ {:keys [layout-item-margin] :as shape} objects _] [{:keys [layout-item-margin] :as shape} objects]
(when (ctl/any-layout-immediate-child? objects shape) (when (ctl/any-layout-immediate-child? objects shape)
(let [default-margin {:m1 0 :m2 0 :m3 0 :m4 0} (let [default-margin {:m1 0 :m2 0 :m3 0 :m4 0}
@ -412,28 +410,28 @@
[m1 m2 m3 m4])))) [m1 m2 m3 m4]))))
(defn- get-margin-block-start (defn- get-margin-block-start
[_ {:keys [layout-item-margin] :as shape} objects _] [{:keys [layout-item-margin] :as shape} objects]
(when (and (ctl/any-layout-immediate-child? objects shape) (:m1 layout-item-margin) (not= (:m1 layout-item-margin) 0)) (when (and (ctl/any-layout-immediate-child? objects shape) (:m1 layout-item-margin) (not= (:m1 layout-item-margin) 0))
[(:m1 layout-item-margin)])) [(:m1 layout-item-margin)]))
(defn- get-margin-inline-end (defn- get-margin-inline-end
[_ {:keys [layout-item-margin] :as shape} objects _] [{:keys [layout-item-margin] :as shape} objects]
(when (and (ctl/any-layout-immediate-child? objects shape) (:m2 layout-item-margin) (not= (:m2 layout-item-margin) 0)) (when (and (ctl/any-layout-immediate-child? objects shape) (:m2 layout-item-margin) (not= (:m2 layout-item-margin) 0))
[(:m2 layout-item-margin)])) [(:m2 layout-item-margin)]))
(defn- get-margin-block-end (defn- get-margin-block-end
[_ {:keys [layout-item-margin] :as shape} objects _] [{:keys [layout-item-margin] :as shape} objects]
(when (and (ctl/any-layout-immediate-child? objects shape) (:m3 layout-item-margin) (not= (:m3 layout-item-margin) 0)) (when (and (ctl/any-layout-immediate-child? objects shape) (:m3 layout-item-margin) (not= (:m3 layout-item-margin) 0))
[(:m3 layout-item-margin)])) [(:m3 layout-item-margin)]))
(defn- get-margin-inline-start (defn- get-margin-inline-start
[_ {:keys [layout-item-margin] :as shape} objects _] [{:keys [layout-item-margin] :as shape} objects]
(when (and (ctl/any-layout-immediate-child? objects shape) (:m4 layout-item-margin) (not= (:m4 layout-item-margin) 0)) (when (and (ctl/any-layout-immediate-child? objects shape) (:m4 layout-item-margin) (not= (:m4 layout-item-margin) 0))
[(:m4 layout-item-margin)])) [(:m4 layout-item-margin)]))
(defn- get-z-index (defn- get-z-index
[_ {:keys [layout-item-z-index] :as shape} objects _] [{:keys [layout-item-z-index] :as shape} objects]
(cond (cond
(cfh/root-frame? shape) (cfh/root-frame? shape)
0 0
@ -442,14 +440,14 @@
layout-item-z-index)) layout-item-z-index))
(defn- get-max-height (defn- get-max-height
[_ shape objects _] [shape objects]
(prn "max-height" shape) (prn "max-height" shape)
(cond (cond
(ctl/any-layout-immediate-child? objects shape) (ctl/any-layout-immediate-child? objects shape)
(:layout-item-max-h shape))) (:layout-item-max-h shape)))
(defn- get-min-height (defn- get-min-height
[_ shape objects _] [shape objects]
(cond (cond
(and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-h shape))) (and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-h shape)))
(:layout-item-min-h shape) (:layout-item-min-h shape)
@ -457,13 +455,13 @@
(-> shape :selrect :height))) (-> shape :selrect :height)))
(defn- get-max-width (defn- get-max-width
[_ shape objects _] [shape objects]
(cond (cond
(ctl/any-layout-immediate-child? objects shape) (ctl/any-layout-immediate-child? objects shape)
(:layout-item-max-w shape))) (:layout-item-max-w shape)))
(defn- get-min-width (defn- get-min-width
[_ shape objects _] [shape objects]
(cond (cond
(and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-w shape))) (and (ctl/any-layout-immediate-child? objects shape) (some? (:layout-item-min-w shape)))
(:layout-item-min-w shape) (:layout-item-min-w shape)
@ -472,7 +470,7 @@
(-> shape :selrect :width))) (-> shape :selrect :width)))
(defn- get-align-self (defn- get-align-self
[_ shape objects _] [shape objects]
(cond (cond
(ctl/flex-layout-immediate-child? objects shape) (ctl/flex-layout-immediate-child? objects shape)
(:layout-item-align-self shape) (:layout-item-align-self shape)
@ -484,7 +482,7 @@
(when (not= align-self :auto) align-self)))) (when (not= align-self :auto) align-self))))
(defn- get-justify-self (defn- get-justify-self
[_ shape objects _] [shape objects]
(cond (cond
(ctl/grid-layout-immediate-child? objects shape) (ctl/grid-layout-immediate-child? objects shape)
(let [parent (get objects (:parent-id shape)) (let [parent (get objects (:parent-id shape))
@ -493,7 +491,7 @@
(when (not= justify-self :auto) justify-self)))) (when (not= justify-self :auto) justify-self))))
(defn- get-grid-auto-flow (defn- get-grid-auto-flow
[_ shape _ _] [shape]
(when (and (ctl/grid-layout? shape) (= (:layout-grid-dir shape) :column)) (when (and (ctl/grid-layout? shape) (= (:layout-grid-dir shape) :column))
"column")) "column"))
@ -502,78 +500,78 @@
[property shape objects options] [property shape objects options]
(case property (case property
;; Positioning ;; Positioning
:position (get-position property shape objects options) :position (get-position shape objects)
:left (get-left-position property shape objects options) :left (get-left-position shape objects)
:top (get-top-position property shape objects options) :top (get-top-position shape objects)
:z-index (get-z-index property shape objects options) :z-index (get-z-index shape objects)
:transform (get-transform property shape objects options) :transform (get-transform shape objects)
;; Size ;; Size
:width (get-width property shape objects options) :width (get-width shape objects options)
:height (get-height property shape objects options) :height (get-height shape objects options)
(:max-width :max-inline-size) (get-max-width property shape objects options) (:max-width :max-inline-size) (get-max-width shape objects)
(:min-width :min-inline-size) (get-min-width property shape objects options) (:min-width :min-inline-size) (get-min-width shape objects)
(:max-height :max-block-size) (get-max-height property shape objects options) (:max-height :max-block-size) (get-max-height shape objects)
(:min-height :min-block-size) (get-min-height property shape objects options) (:min-height :min-block-size) (get-min-height shape objects)
;; Spacing ;; Spacing
:margin (get-margin property shape objects options) :margin (get-margin shape objects)
:margin-block-start (get-margin-block-start property shape objects options) :margin-block-start (get-margin-block-start shape objects)
:margin-inline-end (get-margin-inline-end property shape objects options) :margin-inline-end (get-margin-inline-end shape objects)
:margin-block-end (get-margin-block-end property shape objects options) :margin-block-end (get-margin-block-end shape objects)
:margin-inline-start (get-margin-inline-start property shape objects options) :margin-inline-start (get-margin-inline-start shape objects)
:padding (get-padding property shape objects options) :padding (get-padding shape)
:padding-block-start (get-padding-block-start property shape objects options) :padding-block-start (get-padding-block-start shape)
:padding-inline-end (get-padding-inline-end property shape objects options) :padding-inline-end (get-padding-inline-end shape)
:padding-block-end (get-padding-block-end property shape objects options) :padding-block-end (get-padding-block-end shape)
:padding-inline-start (get-padding-inline-start property shape objects options) :padding-inline-start (get-padding-inline-start shape)
;; Border & Background ;; Border & Background
:border (get-border property shape objects options) :border (get-border shape)
:border-style (get-border-style property shape objects options) :border-style (get-border-style shape)
:border-width (get-border-width property shape objects options) :border-width (get-border-width shape)
:border-radius (get-border-radius property shape objects options) :border-radius (get-border-radius shape)
:border-start-start-radius (get-border-start-start-radius property shape objects options) :border-start-start-radius (get-border-start-start-radius shape)
:border-start-end-radius (get-border-start-end-radius property shape objects options) :border-start-end-radius (get-border-start-end-radius shape)
:border-end-start-radius (get-border-end-start-radius property shape objects options) :border-end-start-radius (get-border-end-start-radius shape)
:border-end-end-radius (get-border-end-end-radius property shape objects options) :border-end-end-radius (get-border-end-end-radius shape)
:background (get-background property shape objects options) :background (get-background shape)
;; Visual Effects ;; Visual Effects
:opacity (get-opacity property shape objects options) :opacity (get-opacity shape)
:box-shadow (get-box-shadow property shape objects options) :box-shadow (get-box-shadow shape)
:filter (get-filter property shape objects options) :filter (get-filter shape)
:overflow (get-overflow property shape objects options) :overflow (get-overflow shape)
;; Display ;; Display
:display (get-display property shape objects options) :display (get-display shape)
;; Flexbox ;; Flexbox
:flex (get-flex property shape objects options) :flex (get-flex shape objects)
:flex-grow (get-flex-grow property shape objects options) :flex-grow (get-flex-grow shape options)
:flex-shrink (get-flex-shrink property shape objects options) :flex-shrink (get-flex-shrink shape objects)
:flex-direction (get-flex-direction property shape objects options) :flex-direction (get-flex-direction shape)
:flex-wrap (get-flex-wrap property shape objects options) :flex-wrap (get-flex-wrap shape)
:align-items (get-align-items property shape objects options) :align-items (get-align-items shape)
:align-content (get-align-content property shape objects options) :align-content (get-align-content shape)
:align-self (get-align-self property shape objects options) :align-self (get-align-self shape objects)
:justify-content (get-justify-content property shape objects options) :justify-content (get-justify-content shape)
:justify-items (get-justify-items property shape objects options) :justify-items (get-justify-items shape)
:justify-self (get-justify-self property shape objects options) :justify-self (get-justify-self shape objects)
;; Grid ;; Grid
:grid-template-rows (get-grid-template-rows property shape objects options) :grid-template-rows (get-grid-template-rows shape)
:grid-template-columns (get-grid-template-columns property shape objects options) :grid-template-columns (get-grid-template-columns shape)
:grid-template-areas (get-grid-template-areas property shape objects options) :grid-template-areas (get-grid-template-areas shape)
:grid-column (get-grid-column property shape objects options) :grid-column (get-grid-column shape objects)
:grid-row (get-grid-row property shape objects options) :grid-row (get-grid-row shape objects)
:grid-area (get-grid-area property shape objects options) :grid-area (get-grid-area shape objects)
:grid-auto-flow (get-grid-auto-flow property shape objects options) :grid-auto-flow (get-grid-auto-flow shape)
;; Spacing (Flex/Grid) ;; Spacing (Flex/Grid)
:gap (get-gap property shape objects options) :gap (get-gap shape)
:row-gap (get-row-gap property shape objects options) :row-gap (get-row-gap shape)
:column-gap (get-column-gap property shape objects options) :column-gap (get-column-gap shape)
;; Default ;; Default
(get shape property))) (get shape property)))