mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 07:01:38 +02:00
✨ Adapt zoom widget to new state layout.
This commit is contained in:
parent
1e57de2d6e
commit
904664319a
2 changed files with 28 additions and 36 deletions
|
@ -527,38 +527,29 @@
|
||||||
|
|
||||||
;; --- Zoom Management
|
;; --- Zoom Management
|
||||||
|
|
||||||
(defrecord IncreaseZoom []
|
(def increase-zoom
|
||||||
ptk/UpdateEvent
|
(ptk/reify ::increase-zoom
|
||||||
(update [_ state]
|
ptk/UpdateEvent
|
||||||
(let [increase #(nth c/zoom-levels
|
(update [_ state]
|
||||||
(+ (index-of c/zoom-levels %) 1)
|
(let [increase #(nth c/zoom-levels
|
||||||
(last c/zoom-levels))]
|
(+ (index-of c/zoom-levels %) 1)
|
||||||
(update-in state [:workspace :zoom] (fnil increase 1)))))
|
(last c/zoom-levels))]
|
||||||
|
(update-in state [:workspace-local :zoom] (fnil increase 1))))))
|
||||||
|
|
||||||
(defn increase-zoom
|
(def decrease-zoom
|
||||||
[]
|
(ptk/reify ::decrease-zoom
|
||||||
(IncreaseZoom.))
|
ptk/UpdateEvent
|
||||||
|
(update [_ state]
|
||||||
|
(let [decrease #(nth c/zoom-levels
|
||||||
|
(- (index-of c/zoom-levels %) 1)
|
||||||
|
(first c/zoom-levels))]
|
||||||
|
(update-in state [:workspace-local :zoom] (fnil decrease 1))))))
|
||||||
|
|
||||||
(defrecord DecreaseZoom []
|
(def reset-zoom
|
||||||
ptk/UpdateEvent
|
(ptk/reify ::reset-zoom
|
||||||
(update [_ state]
|
ptk/UpdateEvent
|
||||||
(let [decrease #(nth c/zoom-levels
|
(update [_ state]
|
||||||
(- (index-of c/zoom-levels %) 1)
|
(assoc-in state [:workspace-local :zoom] 1))))
|
||||||
(first c/zoom-levels))]
|
|
||||||
(update-in state [:workspace :zoom] (fnil decrease 1)))))
|
|
||||||
|
|
||||||
(defn decrease-zoom
|
|
||||||
[]
|
|
||||||
(DecreaseZoom.))
|
|
||||||
|
|
||||||
(defrecord ResetZoom []
|
|
||||||
ptk/UpdateEvent
|
|
||||||
(update [_ state]
|
|
||||||
(assoc-in state [:workspace :zoom] 1)))
|
|
||||||
|
|
||||||
(defn reset-zoom
|
|
||||||
[]
|
|
||||||
(ResetZoom.))
|
|
||||||
|
|
||||||
;; --- Grid Alignment
|
;; --- Grid Alignment
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,11 @@
|
||||||
;; --- Zoom Widget
|
;; --- Zoom Widget
|
||||||
|
|
||||||
(mf/defc zoom-widget
|
(mf/defc zoom-widget
|
||||||
|
{:wrap [mf/wrap-memo]}
|
||||||
[props]
|
[props]
|
||||||
(let [zoom (mf/deref refs/selected-zoom)
|
(let [zoom (mf/deref refs/selected-zoom)
|
||||||
increase #(st/emit! (dw/increase-zoom))
|
increase #(st/emit! dw/increase-zoom)
|
||||||
decrease #(st/emit! (dw/decrease-zoom))]
|
decrease #(st/emit! dw/decrease-zoom)]
|
||||||
[:ul.options-view
|
[:ul.options-view
|
||||||
[:li.zoom-input
|
[:li.zoom-input
|
||||||
[:span.add-zoom {:on-click decrease} "-"]
|
[:span.add-zoom {:on-click decrease} "-"]
|
||||||
|
@ -180,10 +181,10 @@
|
||||||
;; i/alignment]]
|
;; i/alignment]]
|
||||||
;; [:& user]
|
;; [:& user]
|
||||||
[:div.secondary-options
|
[:div.secondary-options
|
||||||
[:& zoom-widget]
|
[:& zoom-widget]
|
||||||
[:a.tooltip.tooltip-bottom.view-mode
|
[:a.tooltip.tooltip-bottom.view-mode
|
||||||
{:alt (tr "workspace.header.view-mode")
|
{:alt (tr "workspace.header.view-mode")
|
||||||
;; :on-click #(st/emit! (dw/->OpenView (:id page)))
|
;; :on-click #(st/emit! (dw/->OpenView (:id page)))
|
||||||
}
|
}
|
||||||
i/play]]
|
i/play]]
|
||||||
]))
|
]))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue