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

Move viewer app shapes from canvas to dedicated namespace.

This commit is contained in:
Andrey Antukh 2016-07-10 12:42:49 +03:00
parent f1955c2a7c
commit b154bb8ff4
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
2 changed files with 48 additions and 23 deletions

View file

@ -14,12 +14,7 @@
[uxbox.main.state :as st]
[uxbox.main.ui.shapes :as uus]
[uxbox.main.ui.icons :as i]
[uxbox.main.ui.shapes.rect :refer (rect-shape)]
[uxbox.main.ui.shapes.icon :refer (icon-shape)]
[uxbox.main.ui.shapes.text :refer (text-shape)]
[uxbox.main.ui.shapes.group :refer (group-shape)]
[uxbox.main.ui.shapes.line :refer (line-shape)]
[uxbox.main.ui.shapes.circle :refer (circle-shape)]))
[uxbox.view.ui.viewer.shapes :as shapes]))
;; --- Refs
@ -57,22 +52,6 @@
[:svg.page-layout {:width width :height height}
(background)
(for [id (reverse (:shapes page))]
(-> (shape id)
(-> (shapes/shape id)
(rum/with-key (str id))))]]))
;; --- Shapes
(mx/defc shape-component
[{:keys [type] :as shape}]
(case type
:group (group-shape shape shape-component)
:text (text-shape shape)
:line (line-shape shape)
:icon (icon-shape shape)
:rect (rect-shape shape)
:circle (circle-shape shape)))
(mx/defc shape
[sid]
(let [item (get-in @st/state [:shapes-by-id sid])]
(shape-component item)))

View file

@ -0,0 +1,46 @@
;; 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.view.ui.viewer.shapes
(:require [sablono.core :refer-macros [html]]
[lentes.core :as l]
[rum.core :as rum]
[uxbox.util.mixins :as mx :include-macros true]
[uxbox.util.data :refer (parse-int)]
[uxbox.main.state :as st]
[uxbox.main.ui.shapes :as uus]
[uxbox.main.ui.icons :as i]
[uxbox.main.ui.shapes.rect :refer (rect-shape)]
[uxbox.main.ui.shapes.icon :refer (icon-shape)]
[uxbox.main.ui.shapes.text :refer (text-shape)]
[uxbox.main.ui.shapes.group :refer (group-shape)]
[uxbox.main.ui.shapes.line :refer (line-shape)]
[uxbox.main.ui.shapes.circle :refer (circle-shape)]))
;; --- Interactions Wrapper
(mx/defc interactions-wrapper
[shape factory]
(let [interactions (:interactions shape)]
[:g (factory shape)]))
;; --- Shapes
(mx/defc shape*
[{:keys [type] :as shape}]
(case type
:group (group-shape shape #(interactions-wrapper % shape*))
:text (text-shape shape)
:line (line-shape shape)
:icon (icon-shape shape)
:rect (rect-shape shape)
:circle (circle-shape shape)))
(mx/defc shape
[sid]
(let [item (get-in @st/state [:shapes-by-id sid])]
(interactions-wrapper item shape*)))