0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 00:40:30 -05:00

Add menu option for guides

This commit is contained in:
alonso.torres 2022-01-21 14:04:20 +01:00
parent f303d7b33e
commit f0fd1bb40c
2 changed files with 17 additions and 7 deletions

View file

@ -58,6 +58,10 @@
:command (ds/c-mod "shift+'") :command (ds/c-mod "shift+'")
:fn #(st/emit! (dw/toggle-layout-flags :snap-grid))} :fn #(st/emit! (dw/toggle-layout-flags :snap-grid))}
:toggle-snap-guide {:tooltip (ds/meta-shift "G")
:command (ds/c-mod "shift+G")
:fn #(st/emit! (dw/toggle-layout-flags :snap-guides))}
:toggle-alignment {:tooltip (ds/meta "\\") :toggle-alignment {:tooltip (ds/meta "\\")
:command (ds/c-mod "\\") :command (ds/c-mod "\\")
:fn #(st/emit! (dw/toggle-layout-flags :dynamic-alignment))} :fn #(st/emit! (dw/toggle-layout-flags :dynamic-alignment))}

View file

@ -194,7 +194,13 @@
(fn [_error] (fn [_error]
(st/emit! (dm/error (tr "errors.unexpected-error")))) (st/emit! (dm/error (tr "errors.unexpected-error"))))
(st/emitf dm/hide))))))) (st/emitf dm/hide)))))))
on-item-click (fn [item] (fn [event] (do (dom/stop-propagation event) (reset! show-sub-menu? item))))]
on-item-click
(mf/use-callback
(fn [item]
(fn [event]
(dom/stop-propagation event)
(reset! show-sub-menu? item))))]
(mf/use-effect (mf/use-effect
(mf/deps @editing?) (mf/deps @editing?)
@ -314,12 +320,12 @@
[:& dropdown {:show (= @show-sub-menu? :preferences) [:& dropdown {:show (= @show-sub-menu? :preferences)
:on-close #(reset! show-sub-menu? false)} :on-close #(reset! show-sub-menu? false)}
[:ul.sub-menu.preferences [:ul.sub-menu.preferences
#_[:li {:on-click #()} [:li {:on-click #(st/emit! (dw/toggle-layout-flags :snap-guides))}
[:span [:span
(if (contains? layout :snap-guide) (if (contains? layout :snap-guides)
(tr "workspace.header.menu.disable-snap-guides") (tr "workspace.header.menu.disable-snap-guides")
(tr "workspace.header.menu.enable-snap-guides"))] (tr "workspace.header.menu.enable-snap-guides"))]
[:span.shortcut (sc/get-tooltip :toggle-snap-grid)]] [:span.shortcut (sc/get-tooltip :toggle-snap-guide)]]
[:li {:on-click #(st/emit! (dw/toggle-layout-flags :snap-grid))} [:li {:on-click #(st/emit! (dw/toggle-layout-flags :snap-grid))}
[:span [:span