0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-16 08:51:32 -05:00

💄 Minor cosmetic changes on shapes related namespaces.

This commit is contained in:
Andrey Antukh 2020-12-02 14:36:50 +01:00 committed by Hirunatan
parent 247273631c
commit 7b1f84f509
3 changed files with 43 additions and 45 deletions

View file

@ -9,25 +9,23 @@
(ns app.main.ui.shapes.shape
(: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.uuid :as uuid]
[app.main.ui.context :as muc]
[app.main.ui.shapes.filters :as filters]
[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/wrap-props false}
[props]
(let [shape (unchecked-get props "shape")
children (unchecked-get props "children")
(let [shape (obj/get props "shape")
children (obj/get props "children")
render-id (mf/use-memo #(str (uuid/next)))
filter-id (str "filter_" render-id)
group-props (-> props
(obj/clone)
group-props (-> (obj/clone props)
(obj/without ["shape" "children"])
(obj/set! "id" (str "shape-" (:id shape)))
(obj/set! "className" "shape")
@ -38,5 +36,4 @@
[:& filters/filters {:shape shape :filter-id filter-id}]
[:& grad/gradient {:shape shape :attr :fill-color-gradient}]
[:& grad/gradient {:shape shape :attr :stroke-color-gradient}]]
children]]))

View file

@ -111,7 +111,7 @@
(mf/fnc frame-container
{::mf/wrap-props false}
[props]
(let [shape (unchecked-get props "shape")
(let [shape (obj/get props "shape")
childs (mapv #(get objects %) (:shapes shape))
shape (geom/transform-shape shape)
props (obj/merge! #js {} props

View file

@ -8,31 +8,32 @@
;; Copyright (c) 2020 UXBOX Labs SL
(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
[rumext.alpha :as mf]
[okulary.core :as l]
[beicon.core :as rx]
[app.common.geom.shapes :as geom]
[app.main.refs :as refs]
[app.main.store :as st]
[app.main.streams :as ms]
[app.main.ui.hooks :as hooks]
[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.image :as image]
[app.main.store :as st]
[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.shapes.rect :as rect]
[app.main.ui.workspace.shapes.bounding-box :refer [bounding-box]]
[app.main.ui.workspace.shapes.common :as common]
[app.main.ui.workspace.shapes.frame :as frame]
[app.main.ui.workspace.shapes.group :as group]
[app.main.ui.workspace.shapes.path :as path]
[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 frame-wrapper)
@ -43,10 +44,10 @@
(defn- shape-wrapper-memo-equals?
[np op]
(let [n-shape (unchecked-get np "shape")
o-shape (unchecked-get op "shape")
n-frame (unchecked-get np "frame")
o-frame (unchecked-get op "frame")]
(let [n-shape (obj/get np "shape")
o-shape (obj/get op "shape")
n-frame (obj/get np "frame")
o-frame (obj/get op "frame")]
;; (prn "shape-wrapper-memo-equals?" (identical? n-frame o-frame))
(if (= (:type n-shape) :group)
false
@ -55,28 +56,28 @@
(defn make-is-moving-ref
[id]
(let [check-moving (fn [local]
(and (= :move (:transform local))
(contains? (:selected local) id)))]
(l/derived check-moving refs/workspace-local)))
(fn []
(let [check-moving (fn [local]
(and (= :move (:transform local))
(contains? (:selected local) id)))]
(l/derived check-moving refs/workspace-local))))
(mf/defc shape-wrapper
{::mf/wrap [#(mf/memo' % shape-wrapper-memo-equals?)]
::mf/wrap-props false}
[props]
(let [shape (unchecked-get props "shape")
frame (unchecked-get props "frame")
ghost? (unchecked-get props "ghost?")
shape (-> (geom/transform-shape shape)
(geom/translate-to-frame frame))
opts #js {:shape shape
:frame frame}
(let [shape (obj/get props "shape")
frame (obj/get props "frame")
ghost? (obj/get props "ghost?")
shape (-> (geom/transform-shape shape)
(geom/translate-to-frame frame))
opts #js {:shape shape
:frame frame}
alt? (hooks/use-rxsub ms/keyboard-alt)
alt? (hooks/use-rxsub ms/keyboard-alt)
moving-iref (mf/use-memo (mf/deps (:id shape))
#(make-is-moving-ref (:id shape)))
moving? (mf/deref moving-iref)]
moving-iref (mf/use-memo (mf/deps (:id shape)) (make-is-moving-ref (:id shape)))
moving? (mf/deref moving-iref)]
(when (and shape
(or ghost? (not moving?))