mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
Add more stuff related to viewer app rendering.
This commit is contained in:
parent
10ccdf32fa
commit
f20ce6f057
3 changed files with 83 additions and 33 deletions
|
@ -215,4 +215,8 @@
|
||||||
background-color: $secondary-ui-bg;
|
background-color: $secondary-ui-bg;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,16 +9,70 @@
|
||||||
(:require [sablono.core :refer-macros [html]]
|
(:require [sablono.core :refer-macros [html]]
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util.mixins :as mx]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.main.ui.icons :as i]))
|
[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)]))
|
||||||
|
|
||||||
(defn canvas-render
|
;; --- Refs
|
||||||
[own]
|
|
||||||
(html
|
|
||||||
[:div.view-canvas "VIEW CONTENT"]))
|
|
||||||
|
|
||||||
(def canvas
|
(defn- resolve-selected-page
|
||||||
(mx/component
|
[state]
|
||||||
{:render canvas-render
|
(let [index (get-in state [:route :params :id])
|
||||||
:name "canvas"
|
index (parse-int index 0)]
|
||||||
:mixins [mx/static]}))
|
(get-in state [:pages index])))
|
||||||
|
|
||||||
|
(def page-ref
|
||||||
|
(-> (l/lens resolve-selected-page)
|
||||||
|
(l/derive st/state)))
|
||||||
|
|
||||||
|
;; --- Background (Component)
|
||||||
|
|
||||||
|
(mx/defc background
|
||||||
|
[]
|
||||||
|
[:rect
|
||||||
|
{:x 0 :y 0
|
||||||
|
:width "100%"
|
||||||
|
:height "100%"
|
||||||
|
:fill "white"}])
|
||||||
|
|
||||||
|
;; --- Canvas (Component)
|
||||||
|
|
||||||
|
(declare shape)
|
||||||
|
|
||||||
|
(mx/defc canvas
|
||||||
|
{:mixins [mx/static mx/reactive]}
|
||||||
|
[]
|
||||||
|
(let [page (rum/react page-ref)
|
||||||
|
width (:width page)
|
||||||
|
height (:height page)]
|
||||||
|
[:div.view-canvas
|
||||||
|
[:svg.page-layout {:width width :height height}
|
||||||
|
(background)
|
||||||
|
(for [id (reverse (:shapes page))]
|
||||||
|
(-> (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)))
|
||||||
|
|
|
@ -10,14 +10,13 @@
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[rum.core :as rum]
|
[rum.core :as rum]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.mixins :as mx]
|
[uxbox.util.mixins :as mx :include-macros true]
|
||||||
[uxbox.util.data :refer (parse-int)]
|
[uxbox.util.data :refer (parse-int)]
|
||||||
[uxbox.util.rstore :as rs]
|
[uxbox.util.rstore :as rs]
|
||||||
[uxbox.main.state :as st]
|
[uxbox.main.state :as st]
|
||||||
[uxbox.main.ui.icons :as i]
|
[uxbox.main.ui.icons :as i]
|
||||||
[uxbox.view.data.viewer :as dv]))
|
[uxbox.view.data.viewer :as dv]))
|
||||||
|
|
||||||
|
|
||||||
;; --- Refs
|
;; --- Refs
|
||||||
|
|
||||||
(def pages-ref
|
(def pages-ref
|
||||||
|
@ -35,28 +34,21 @@
|
||||||
|
|
||||||
;; --- Component
|
;; --- Component
|
||||||
|
|
||||||
(defn- sitemap-render
|
(mx/defc sitemap
|
||||||
[own]
|
{:mixins [mx/static mx/reactive]}
|
||||||
|
[]
|
||||||
(let [project-name (mx/react project-name-ref)
|
(let [project-name (mx/react project-name-ref)
|
||||||
pages (mx/react pages-ref)
|
pages (mx/react pages-ref)
|
||||||
selected (mx/react selected-ref)
|
selected (mx/react selected-ref)
|
||||||
on-click #(rs/emit! (dv/select-page %))]
|
on-click #(rs/emit! (dv/select-page %))]
|
||||||
(html
|
[:div.view-sitemap
|
||||||
[:div.view-sitemap
|
[:span.sitemap-title project-name]
|
||||||
[:span.sitemap-title project-name]
|
[:ul.sitemap-list
|
||||||
[:ul.sitemap-list
|
(for [[i page] (map-indexed vector pages)
|
||||||
(for [[i page] (map-indexed vector pages)
|
:let [selected? (= i selected)]]
|
||||||
:let [selected? (= i selected)]]
|
[:li {:class (when selected? "selected")
|
||||||
[:li {:class (when selected? "selected")
|
:on-click (partial on-click i)
|
||||||
:on-click (partial on-click i)
|
:key (str i)}
|
||||||
:key (str i)}
|
[:div.page-icon i/page]
|
||||||
[:div.page-icon i/page]
|
[:span (:name page)]])]]))
|
||||||
[:span (:name page)]])]])))
|
|
||||||
|
|
||||||
(def sitemap
|
|
||||||
(mx/component
|
|
||||||
{:render sitemap-render
|
|
||||||
:name "sitemap"
|
|
||||||
:mixins [mx/static mx/reactive]}))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue