mirror of
https://github.com/penpot/penpot.git
synced 2025-06-04 06:31:37 +02:00
💄 Minor cosmetic changes on shapes related namespaces.
This commit is contained in:
parent
247273631c
commit
7b1f84f509
3 changed files with 43 additions and 45 deletions
|
@ -9,25 +9,23 @@
|
||||||
|
|
||||||
(ns app.main.ui.shapes.shape
|
(ns app.main.ui.shapes.shape
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
|
||||||
[cuerdas.core :as str]
|
|
||||||
[app.util.object :as obj]
|
|
||||||
[app.common.uuid :as uuid]
|
|
||||||
[app.common.geom.shapes :as geom]
|
[app.common.geom.shapes :as geom]
|
||||||
|
[app.common.uuid :as uuid]
|
||||||
|
[app.main.ui.context :as muc]
|
||||||
[app.main.ui.shapes.filters :as filters]
|
[app.main.ui.shapes.filters :as filters]
|
||||||
[app.main.ui.shapes.gradients :as grad]
|
[app.main.ui.shapes.gradients :as grad]
|
||||||
[app.main.ui.context :as muc]))
|
[app.util.object :as obj]
|
||||||
|
[cuerdas.core :as str]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(mf/defc shape-container
|
(mf/defc shape-container
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
|
(let [shape (obj/get props "shape")
|
||||||
(let [shape (unchecked-get props "shape")
|
children (obj/get props "children")
|
||||||
children (unchecked-get props "children")
|
|
||||||
render-id (mf/use-memo #(str (uuid/next)))
|
render-id (mf/use-memo #(str (uuid/next)))
|
||||||
filter-id (str "filter_" render-id)
|
filter-id (str "filter_" render-id)
|
||||||
group-props (-> props
|
group-props (-> (obj/clone props)
|
||||||
(obj/clone)
|
|
||||||
(obj/without ["shape" "children"])
|
(obj/without ["shape" "children"])
|
||||||
(obj/set! "id" (str "shape-" (:id shape)))
|
(obj/set! "id" (str "shape-" (:id shape)))
|
||||||
(obj/set! "className" "shape")
|
(obj/set! "className" "shape")
|
||||||
|
@ -38,5 +36,4 @@
|
||||||
[:& filters/filters {:shape shape :filter-id filter-id}]
|
[:& filters/filters {:shape shape :filter-id filter-id}]
|
||||||
[:& grad/gradient {:shape shape :attr :fill-color-gradient}]
|
[:& grad/gradient {:shape shape :attr :fill-color-gradient}]
|
||||||
[:& grad/gradient {:shape shape :attr :stroke-color-gradient}]]
|
[:& grad/gradient {:shape shape :attr :stroke-color-gradient}]]
|
||||||
|
|
||||||
children]]))
|
children]]))
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
(mf/fnc frame-container
|
(mf/fnc frame-container
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (obj/get props "shape")
|
||||||
childs (mapv #(get objects %) (:shapes shape))
|
childs (mapv #(get objects %) (:shapes shape))
|
||||||
shape (geom/transform-shape shape)
|
shape (geom/transform-shape shape)
|
||||||
props (obj/merge! #js {} props
|
props (obj/merge! #js {} props
|
||||||
|
|
|
@ -8,31 +8,32 @@
|
||||||
;; Copyright (c) 2020 UXBOX Labs SL
|
;; Copyright (c) 2020 UXBOX Labs SL
|
||||||
|
|
||||||
(ns app.main.ui.workspace.shapes
|
(ns app.main.ui.workspace.shapes
|
||||||
"A workspace specific shapes wrappers."
|
"A workspace specific shapes wrappers.
|
||||||
|
|
||||||
|
Shapes that has some peculiarities are defined in its own
|
||||||
|
namespace under app.ui.workspace.shapes.* prefix, all the
|
||||||
|
others are defined using a generic wrapper implemented in
|
||||||
|
common."
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]
|
[app.common.geom.shapes :as geom]
|
||||||
[okulary.core :as l]
|
[app.main.refs :as refs]
|
||||||
[beicon.core :as rx]
|
[app.main.store :as st]
|
||||||
[app.main.streams :as ms]
|
[app.main.streams :as ms]
|
||||||
[app.main.ui.hooks :as hooks]
|
|
||||||
[app.main.ui.cursors :as cur]
|
[app.main.ui.cursors :as cur]
|
||||||
[app.main.ui.shapes.rect :as rect]
|
[app.main.ui.hooks :as hooks]
|
||||||
[app.main.ui.shapes.circle :as circle]
|
[app.main.ui.shapes.circle :as circle]
|
||||||
[app.main.ui.shapes.image :as image]
|
[app.main.ui.shapes.image :as image]
|
||||||
[app.main.store :as st]
|
[app.main.ui.shapes.rect :as rect]
|
||||||
[app.main.refs :as refs]
|
|
||||||
|
|
||||||
;; Shapes that has some peculiarities are defined in its own
|
|
||||||
;; namespace under app.ui.workspace.shapes.* prefix, all the
|
|
||||||
;; others are defined using a generic wrapper implemented in
|
|
||||||
;; common.
|
|
||||||
[app.main.ui.workspace.shapes.bounding-box :refer [bounding-box]]
|
[app.main.ui.workspace.shapes.bounding-box :refer [bounding-box]]
|
||||||
[app.main.ui.workspace.shapes.common :as common]
|
[app.main.ui.workspace.shapes.common :as common]
|
||||||
[app.main.ui.workspace.shapes.frame :as frame]
|
[app.main.ui.workspace.shapes.frame :as frame]
|
||||||
[app.main.ui.workspace.shapes.group :as group]
|
[app.main.ui.workspace.shapes.group :as group]
|
||||||
[app.main.ui.workspace.shapes.path :as path]
|
[app.main.ui.workspace.shapes.path :as path]
|
||||||
[app.main.ui.workspace.shapes.text :as text]
|
[app.main.ui.workspace.shapes.text :as text]
|
||||||
[app.common.geom.shapes :as geom]))
|
[app.util.object :as obj]
|
||||||
|
[beicon.core :as rx]
|
||||||
|
[okulary.core :as l]
|
||||||
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(declare group-wrapper)
|
(declare group-wrapper)
|
||||||
(declare frame-wrapper)
|
(declare frame-wrapper)
|
||||||
|
@ -43,10 +44,10 @@
|
||||||
|
|
||||||
(defn- shape-wrapper-memo-equals?
|
(defn- shape-wrapper-memo-equals?
|
||||||
[np op]
|
[np op]
|
||||||
(let [n-shape (unchecked-get np "shape")
|
(let [n-shape (obj/get np "shape")
|
||||||
o-shape (unchecked-get op "shape")
|
o-shape (obj/get op "shape")
|
||||||
n-frame (unchecked-get np "frame")
|
n-frame (obj/get np "frame")
|
||||||
o-frame (unchecked-get op "frame")]
|
o-frame (obj/get op "frame")]
|
||||||
;; (prn "shape-wrapper-memo-equals?" (identical? n-frame o-frame))
|
;; (prn "shape-wrapper-memo-equals?" (identical? n-frame o-frame))
|
||||||
(if (= (:type n-shape) :group)
|
(if (= (:type n-shape) :group)
|
||||||
false
|
false
|
||||||
|
@ -55,18 +56,19 @@
|
||||||
|
|
||||||
(defn make-is-moving-ref
|
(defn make-is-moving-ref
|
||||||
[id]
|
[id]
|
||||||
|
(fn []
|
||||||
(let [check-moving (fn [local]
|
(let [check-moving (fn [local]
|
||||||
(and (= :move (:transform local))
|
(and (= :move (:transform local))
|
||||||
(contains? (:selected local) id)))]
|
(contains? (:selected local) id)))]
|
||||||
(l/derived check-moving refs/workspace-local)))
|
(l/derived check-moving refs/workspace-local))))
|
||||||
|
|
||||||
(mf/defc shape-wrapper
|
(mf/defc shape-wrapper
|
||||||
{::mf/wrap [#(mf/memo' % shape-wrapper-memo-equals?)]
|
{::mf/wrap [#(mf/memo' % shape-wrapper-memo-equals?)]
|
||||||
::mf/wrap-props false}
|
::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (obj/get props "shape")
|
||||||
frame (unchecked-get props "frame")
|
frame (obj/get props "frame")
|
||||||
ghost? (unchecked-get props "ghost?")
|
ghost? (obj/get props "ghost?")
|
||||||
shape (-> (geom/transform-shape shape)
|
shape (-> (geom/transform-shape shape)
|
||||||
(geom/translate-to-frame frame))
|
(geom/translate-to-frame frame))
|
||||||
opts #js {:shape shape
|
opts #js {:shape shape
|
||||||
|
@ -74,8 +76,7 @@
|
||||||
|
|
||||||
alt? (hooks/use-rxsub ms/keyboard-alt)
|
alt? (hooks/use-rxsub ms/keyboard-alt)
|
||||||
|
|
||||||
moving-iref (mf/use-memo (mf/deps (:id shape))
|
moving-iref (mf/use-memo (mf/deps (:id shape)) (make-is-moving-ref (:id shape)))
|
||||||
#(make-is-moving-ref (:id shape)))
|
|
||||||
moving? (mf/deref moving-iref)]
|
moving? (mf/deref moving-iref)]
|
||||||
|
|
||||||
(when (and shape
|
(when (and shape
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue