mirror of
https://github.com/penpot/penpot.git
synced 2025-05-28 19:16:11 +02:00
36 lines
1.1 KiB
Clojure
36 lines
1.1 KiB
Clojure
;; 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.main.ui.shapes.rect
|
|
(:require
|
|
[app.common.geom.shapes :as gsh]
|
|
[app.main.ui.shapes.attrs :as attrs]
|
|
[app.main.ui.shapes.custom-stroke :refer [shape-custom-stroke]]
|
|
[app.main.ui.shapes.gradients :refer [gradient]]
|
|
[app.util.object :as obj]
|
|
[rumext.alpha :as mf]))
|
|
|
|
(mf/defc rect-shape
|
|
{::mf/wrap-props false}
|
|
[props]
|
|
(let [shape (unchecked-get props "shape")
|
|
{:keys [id x y width height]} shape
|
|
transform (gsh/transform-matrix shape)
|
|
|
|
props (-> (attrs/extract-style-attrs shape)
|
|
(obj/merge!
|
|
#js {:x x
|
|
:y y
|
|
:transform transform
|
|
:width width
|
|
:height height}))
|
|
|
|
path? (some? (.-d props))]
|
|
|
|
[:& shape-custom-stroke {:shape shape}
|
|
(if path?
|
|
[:> :path props]
|
|
[:> :rect props])]))
|