Don't render shape if it is nil.

This commit is contained in:
Andrey Antukh 2017-01-30 19:49:35 +01:00
parent 49b783273e
commit 12b9868f45
No known key found for this signature in database
GPG key ID: 4DFEBCB8316A8B95
2 changed files with 11 additions and 11 deletions

View file

@ -7,13 +7,13 @@
(ns uxbox.main.exports (ns uxbox.main.exports
"The main logic for SVG export functionality." "The main logic for SVG export functionality."
(:require [uxbox.main.store :as st] (:require [uxbox.main.store :as st]
[uxbox.main.ui.shapes.rect :refer (rect-shape)] [uxbox.main.ui.shapes.rect :refer [rect-shape]]
[uxbox.main.ui.shapes.icon :refer (icon-shape)] [uxbox.main.ui.shapes.icon :refer [icon-shape]]
[uxbox.main.ui.shapes.text :refer (text-shape)] [uxbox.main.ui.shapes.text :refer [text-shape]]
[uxbox.main.ui.shapes.group :refer (group-shape)] [uxbox.main.ui.shapes.group :refer [group-shape]]
[uxbox.main.ui.shapes.path :refer (path-shape)] [uxbox.main.ui.shapes.path :refer [path-shape]]
[uxbox.main.ui.shapes.circle :refer (circle-shape)] [uxbox.main.ui.shapes.circle :refer [circle-shape]]
[uxbox.main.ui.shapes.image :refer (image-shape)] [uxbox.main.ui.shapes.image :refer [image-shape]]
[uxbox.util.mixins :as mx :include-macros true])) [uxbox.util.mixins :as mx :include-macros true]))
(def ^:dynamic *state* st/state) (def ^:dynamic *state* st/state)
@ -43,8 +43,8 @@
(image-shape (assoc shape :image image))))) (image-shape (assoc shape :image image)))))
(mx/defc shape-component (mx/defc shape-component
[sid] [id]
(when-let [shape (get-in @*state* [:shapes sid])] (when-let [shape (get-in @*state* [:shapes id])]
(shape-wrapper shape))) (shape-wrapper shape)))
(mx/defc page-svg (mx/defc page-svg
@ -64,6 +64,6 @@
(defn render-page (defn render-page
[id] [id]
(let [page (get-in @st/state [:pages id])] (let [page (get-in @*state* [:pages id])]
(when (:shapes page) (when (:shapes page)
(mx/render-static-html (page-svg page))))) (mx/render-static-html (page-svg page)))))

View file

@ -42,7 +42,7 @@
(mx/defc component-container (mx/defc component-container
{:mixins [mx/reactive mx/static]} {:mixins [mx/reactive mx/static]}
[id] [id]
(let [shape (mx/react (focus-shape id))] (when-let [shape (mx/react (focus-shape id))]
(when-not (:hidden shape) (when-not (:hidden shape)
(render-component shape)))) (render-component shape))))