mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -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>
|
||||
|
||||
(ns uxbox.main.ui.workspace.sidebar.options
|
||||
(:require [sablono.core :as html :refer-macros [html]]
|
||||
[rum.core :as rum]
|
||||
(:require
|
||||
[lentes.core :as l]
|
||||
[uxbox.util.i18n :refer (tr)]
|
||||
[uxbox.util.router :as r]
|
||||
|
@ -83,12 +82,12 @@
|
|||
|
||||
;; --- Options
|
||||
|
||||
(defn- options-render
|
||||
(mx/defcs options
|
||||
{:mixins [mx/static (mx/local)]}
|
||||
[own shape]
|
||||
(let [local (:rum/local own)
|
||||
menus (get +menus-map+ (:type shape))
|
||||
active-menu (:menu @local (first menus))]
|
||||
(html
|
||||
[:div
|
||||
[:ul.element-icons
|
||||
(for [menu-id (get +menus-map+ (:type shape))
|
||||
|
@ -99,13 +98,7 @@
|
|||
:class (when selected? "selected")}
|
||||
(:icon menu)])]
|
||||
(when-let [menu (get +menus-by-id+ active-menu)]
|
||||
((:comp menu) menu shape))])))
|
||||
|
||||
(def ^:private options
|
||||
(mx/component
|
||||
{:render options-render
|
||||
:name "options"
|
||||
:mixins [mx/static (mx/local)]}))
|
||||
((:comp menu) menu shape))]))
|
||||
|
||||
(def selected-shape-ref
|
||||
(letfn [(getter [state]
|
||||
|
@ -115,11 +108,11 @@
|
|||
(-> (l/lens getter)
|
||||
(l/derive st/state))))
|
||||
|
||||
(defn options-toolbox-render
|
||||
[own]
|
||||
(mx/defc options-toolbox
|
||||
{:mixins [mx/static mx/reactive]}
|
||||
[]
|
||||
(let [shape (mx/react selected-shape-ref)
|
||||
close #(rs/emit! (udw/toggle-flag :element-options))]
|
||||
(html
|
||||
[:div.elementa-options.tool-window
|
||||
[:div.tool-window-bar
|
||||
[:div.tool-window-icon i/options]
|
||||
|
@ -128,10 +121,5 @@
|
|||
[:div.tool-window-content
|
||||
[:div.element-options
|
||||
(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