mirror of
https://github.com/penpot/penpot.git
synced 2025-07-26 05:47:24 +02:00
Move all files under frontend directory.
This commit is contained in:
parent
92b45b2d05
commit
e21798f1ed
603 changed files with 10 additions and 31 deletions
78
frontend/src/uxbox/main/ui/shapes/group.cljs
Normal file
78
frontend/src/uxbox/main/ui/shapes/group.cljs
Normal file
|
@ -0,0 +1,78 @@
|
|||
;; 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) 2016 Andrey Antukh <niwi@niwi.nz>
|
||||
|
||||
(ns uxbox.main.ui.shapes.group
|
||||
(:require [lentes.core :as l]
|
||||
[uxbox.main.state :as st]
|
||||
[uxbox.util.mixins :as mx :include-macros true]
|
||||
[uxbox.main.ui.shapes.common :as common]
|
||||
[uxbox.main.ui.shapes.attrs :as attrs]
|
||||
[uxbox.main.ui.shapes.icon :as icon]
|
||||
[uxbox.main.ui.shapes.rect :as rect]
|
||||
[uxbox.main.ui.shapes.circle :as circle]
|
||||
[uxbox.main.ui.shapes.text :as text]
|
||||
[uxbox.main.ui.shapes.path :as path]
|
||||
[uxbox.main.ui.shapes.image :as image]
|
||||
[uxbox.main.geom :as geom]))
|
||||
|
||||
;; --- Helpers
|
||||
|
||||
(declare group-component)
|
||||
|
||||
(defn- focus-shape
|
||||
[id]
|
||||
(-> (l/in [:shapes id])
|
||||
(l/derive st/state)))
|
||||
|
||||
(defn render-component
|
||||
[shape]
|
||||
(case (:type shape)
|
||||
:group (group-component shape)
|
||||
:text (text/text-component shape)
|
||||
:icon (icon/icon-component shape)
|
||||
:rect (rect/rect-component shape)
|
||||
:path (path/path-component shape)
|
||||
:image (image/image-component shape)
|
||||
:circle (circle/circle-component shape)))
|
||||
|
||||
(mx/defc component-container
|
||||
{:mixins [mx/reactive mx/static]}
|
||||
[id]
|
||||
(let [shape (mx/react (focus-shape id))]
|
||||
(when-not (:hidden shape)
|
||||
(render-component shape))))
|
||||
|
||||
;; --- Group Component
|
||||
|
||||
(declare group-shape)
|
||||
|
||||
(mx/defc group-component
|
||||
{:mixins [mx/static mx/reactive]}
|
||||
[{:keys [id x y width height group] :as shape}]
|
||||
(let [selected (mx/react common/selected-ref)
|
||||
selected? (contains? selected id)
|
||||
on-mouse-down #(common/on-mouse-down % shape selected)]
|
||||
[:g.shape.group-shape
|
||||
{:class (when selected? "selected")
|
||||
:on-mouse-down on-mouse-down}
|
||||
(group-shape shape component-container)]))
|
||||
|
||||
;; --- Group Shape
|
||||
|
||||
(mx/defc group-shape
|
||||
{:mixins [mx/static mx/reactive]}
|
||||
[{:keys [items id dx dy rotation] :as shape} factory]
|
||||
(let [key (str "shape-" id)
|
||||
rfm (geom/transformation-matrix shape)
|
||||
attrs (merge {:id key :key key :transform (str rfm)}
|
||||
(attrs/extract-style-attrs shape)
|
||||
(attrs/make-debug-attrs shape))]
|
||||
[:g attrs
|
||||
(for [item (reverse items)
|
||||
:let [key (str item)]]
|
||||
(-> (factory item)
|
||||
(mx/with-key key)))]))
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue