mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
Add resize handlers to element options.
This commit is contained in:
parent
da5d9c2422
commit
ca2c76325d
1 changed files with 53 additions and 34 deletions
|
@ -1,11 +1,15 @@
|
|||
(ns uxbox.ui.workspace.options
|
||||
(:require [sablono.core :as html :refer-macros [html]]
|
||||
[rum.core :as rum]
|
||||
[uxbox.rstore :as rs]
|
||||
[uxbox.shapes :as shapes]
|
||||
[uxbox.data.workspace :as dw]
|
||||
[uxbox.ui.icons :as i]
|
||||
[uxbox.ui.util :as util]
|
||||
[uxbox.ui.mixins :as mx]
|
||||
[uxbox.ui.workspace.base :as wb]))
|
||||
[uxbox.ui.dom :as dom]
|
||||
[uxbox.ui.workspace.base :as wb]
|
||||
[uxbox.util.data :refer (parse-int)]))
|
||||
|
||||
(def +menus-map+
|
||||
{:builtin/icon [:menu/measures :menu/fill]
|
||||
|
@ -70,6 +74,19 @@
|
|||
|
||||
(defmethod -render-menu :menu/measures
|
||||
[menu own shape]
|
||||
(letfn [(on-width-change [event]
|
||||
(let [value (dom/event->value event)
|
||||
value (parse-int value 0)
|
||||
sid (:id shape)]
|
||||
(-> (dw/update-shape-size sid {:width value})
|
||||
(rs/emit!))))
|
||||
(on-height-change [event]
|
||||
(let [value (dom/event->value event)
|
||||
value (parse-int value 0)
|
||||
sid (:id shape)]
|
||||
(println value)
|
||||
(-> (dw/update-shape-size sid {:height value})
|
||||
(rs/emit!))))]
|
||||
(html
|
||||
[:div.element-set {:key (str (:id menu))}
|
||||
[:div.element-set-title (:name menu)]
|
||||
|
@ -80,14 +97,16 @@
|
|||
[:input#width.input-text
|
||||
{:placeholder "Width"
|
||||
:type "number"
|
||||
:min "0"
|
||||
:value (:width shape)
|
||||
:on-change (constantly nil)}]
|
||||
:on-change on-width-change}]
|
||||
[:div.lock-size i/lock]
|
||||
[:input#width.input-text
|
||||
{:placeholder "Height"
|
||||
:type "number"
|
||||
:min "0"
|
||||
:value (:height shape)
|
||||
:on-change (constantly nil)}]]
|
||||
:on-change on-height-change}]]
|
||||
|
||||
[:span "Position"]
|
||||
[:div.row-flex
|
||||
|
@ -104,7 +123,7 @@
|
|||
|
||||
[:span "Rotation"]
|
||||
[:div.row-flex
|
||||
[:input.slidebar {:type "range"}]]]]))
|
||||
[:input.slidebar {:type "range"}]]]])))
|
||||
|
||||
(defn element-opts-render
|
||||
[own shape]
|
||||
|
|
Loading…
Reference in a new issue