0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 23:49:45 -05:00

Move selrect and selection components under own namespace.

This commit is contained in:
Andrey Antukh 2016-01-26 22:27:05 +02:00
parent 6aef94418b
commit 77ec0e86d2
3 changed files with 42 additions and 34 deletions

View file

@ -16,7 +16,8 @@
[uxbox.ui.mixins :as mx]
[uxbox.ui.dom :as dom]
[uxbox.ui.workspace.base :as wb]
[uxbox.ui.workspace.selrect :refer (mouse-selrect shapes-selrect)]
[uxbox.ui.workspace.canvas.selection :refer (shapes-selection)]
[uxbox.ui.workspace.canvas.selrect :refer (selrect)]
[uxbox.ui.workspace.grid :refer (grid)]
[uxbox.ui.workspace.options :refer (element-opts)])
(:import goog.events.EventType))
@ -158,12 +159,12 @@
(background)
(grid 1)
[:svg.page-layout {}
(shapes-selrect shapes-selected)
(shapes-selection shapes-selected)
[:g.main {}
(for [item (sequence xf (:shapes page))]
(-> (shape item workspace-selected)
(rum/with-key (str (:id item)))))
(mouse-selrect)]]])))
(selrect)]]])))
(def canvas
(mx/component

View file

@ -1,5 +1,4 @@
(ns uxbox.ui.workspace.selrect
"Components for indicate the user selection and selected shapes group."
(ns uxbox.ui.workspace.canvas.selection
(:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum]
[beicon.core :as rx]
@ -11,31 +10,6 @@
[uxbox.ui.mixins :as mx]
[uxbox.ui.dom :as dom]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Mouse Selection Rect
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn mouse-selrect-render
[own]
(when-let [data (rum/react wb/selrect-pos)]
(let [{:keys [x y width height]} (wb/selrect->rect data)]
(html
[:rect.selection-rect
{:x x
:y y
:width width
:height height}]))))
(def ^:static mouse-selrect
(mx/component
{:render mouse-selrect-render
:name "mouse-selrect"
:mixins [mx/static rum/reactive]}))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Shapes Selection Rect
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(def ^:private selection-circle-style
{:fillOpacity "0.5"
:strokeWidth "1px"
@ -46,7 +20,7 @@
:fill "#333"
:stroke "#333"})
(defn shapes-selrect-render
(defn shapes-selection-render
[own shapes]
(when (seq shapes)
(let [{:keys [width height x y]} (sh/outer-rect shapes)]
@ -64,8 +38,8 @@
[:circle.bottom-right (merge default-selection-props
{:cx (+ x width) :cy (+ y height)})]]))))
(def ^:static shapes-selrect
(def ^:static shapes-selection
(mx/component
{:render shapes-selrect-render
:name "shapes-selrect"
{:render shapes-selection-render
:name "shapes-selection"
:mixins [mx/static]}))

View file

@ -0,0 +1,33 @@
(ns uxbox.ui.workspace.canvas.selrect
"Components for indicate the user selection and selected shapes group."
(:require [sablono.core :as html :refer-macros [html]]
[rum.core :as rum]
[beicon.core :as rx]
[cats.labs.lens :as l]
[uxbox.rstore :as rs]
[uxbox.state :as st]
[uxbox.shapes :as sh]
[uxbox.ui.workspace.base :as wb]
[uxbox.ui.mixins :as mx]
[uxbox.ui.dom :as dom]))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Component
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn selrect-render
[own]
(when-let [data (rum/react wb/selrect-pos)]
(let [{:keys [x y width height]} (wb/selrect->rect data)]
(html
[:rect.selection-rect
{:x x
:y y
:width width
:height height}]))))
(def ^:static selrect
(mx/component
{:render selrect-render
:name "selrect"
:mixins [mx/static rum/reactive]}))