mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 21:09:00 -05:00
Cosmetic refactor on sidebar options ns.
This commit is contained in:
parent
a11b618d24
commit
95a72a3057
1 changed files with 50 additions and 62 deletions
|
@ -6,8 +6,7 @@
|
||||||
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
;; Copyright (c) 2015-2016 Juan de la Cruz <delacruzgarciajuan@gmail.com>
|
||||||
|
|
||||||
(ns uxbox.main.ui.workspace.sidebar.options
|
(ns uxbox.main.ui.workspace.sidebar.options
|
||||||
(:require [sablono.core :as html :refer-macros [html]]
|
(:require
|
||||||
[rum.core :as rum]
|
|
||||||
[lentes.core :as l]
|
[lentes.core :as l]
|
||||||
[uxbox.util.i18n :refer (tr)]
|
[uxbox.util.i18n :refer (tr)]
|
||||||
[uxbox.util.router :as r]
|
[uxbox.util.router :as r]
|
||||||
|
@ -83,12 +82,12 @@
|
||||||
|
|
||||||
;; --- Options
|
;; --- Options
|
||||||
|
|
||||||
(defn- options-render
|
(mx/defcs options
|
||||||
|
{:mixins [mx/static (mx/local)]}
|
||||||
[own shape]
|
[own shape]
|
||||||
(let [local (:rum/local own)
|
(let [local (:rum/local own)
|
||||||
menus (get +menus-map+ (:type shape))
|
menus (get +menus-map+ (:type shape))
|
||||||
active-menu (:menu @local (first menus))]
|
active-menu (:menu @local (first menus))]
|
||||||
(html
|
|
||||||
[:div
|
[:div
|
||||||
[:ul.element-icons
|
[:ul.element-icons
|
||||||
(for [menu-id (get +menus-map+ (:type shape))
|
(for [menu-id (get +menus-map+ (:type shape))
|
||||||
|
@ -99,13 +98,7 @@
|
||||||
:class (when selected? "selected")}
|
:class (when selected? "selected")}
|
||||||
(:icon menu)])]
|
(:icon menu)])]
|
||||||
(when-let [menu (get +menus-by-id+ active-menu)]
|
(when-let [menu (get +menus-by-id+ active-menu)]
|
||||||
((:comp menu) menu shape))])))
|
((:comp menu) menu shape))]))
|
||||||
|
|
||||||
(def ^:private options
|
|
||||||
(mx/component
|
|
||||||
{:render options-render
|
|
||||||
:name "options"
|
|
||||||
:mixins [mx/static (mx/local)]}))
|
|
||||||
|
|
||||||
(def selected-shape-ref
|
(def selected-shape-ref
|
||||||
(letfn [(getter [state]
|
(letfn [(getter [state]
|
||||||
|
@ -115,11 +108,11 @@
|
||||||
(-> (l/lens getter)
|
(-> (l/lens getter)
|
||||||
(l/derive st/state))))
|
(l/derive st/state))))
|
||||||
|
|
||||||
(defn options-toolbox-render
|
(mx/defc options-toolbox
|
||||||
[own]
|
{:mixins [mx/static mx/reactive]}
|
||||||
|
[]
|
||||||
(let [shape (mx/react selected-shape-ref)
|
(let [shape (mx/react selected-shape-ref)
|
||||||
close #(rs/emit! (udw/toggle-flag :element-options))]
|
close #(rs/emit! (udw/toggle-flag :element-options))]
|
||||||
(html
|
|
||||||
[:div.elementa-options.tool-window
|
[:div.elementa-options.tool-window
|
||||||
[:div.tool-window-bar
|
[:div.tool-window-bar
|
||||||
[:div.tool-window-icon i/options]
|
[:div.tool-window-icon i/options]
|
||||||
|
@ -128,10 +121,5 @@
|
||||||
[:div.tool-window-content
|
[:div.tool-window-content
|
||||||
[:div.element-options
|
[:div.element-options
|
||||||
(if shape
|
(if shape
|
||||||
(options shape))]]])))
|
(options shape))]]]))
|
||||||
|
|
||||||
(def options-toolbox
|
|
||||||
(mx/component
|
|
||||||
{:render options-toolbox-render
|
|
||||||
:name "options-toolbox"
|
|
||||||
:mixins [mx/static mx/reactive (mx/local)]}))
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue