mirror of
https://github.com/penpot/penpot.git
synced 2025-02-08 16:18:11 -05: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
|
||||
|
||||
(defrecord IncreaseZoom []
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [increase #(nth c/zoom-levels
|
||||
(+ (index-of c/zoom-levels %) 1)
|
||||
(last c/zoom-levels))]
|
||||
(update-in state [:workspace :zoom] (fnil increase 1)))))
|
||||
(def increase-zoom
|
||||
(ptk/reify ::increase-zoom
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [increase #(nth c/zoom-levels
|
||||
(+ (index-of c/zoom-levels %) 1)
|
||||
(last c/zoom-levels))]
|
||||
(update-in state [:workspace-local :zoom] (fnil increase 1))))))
|
||||
|
||||
(defn increase-zoom
|
||||
[]
|
||||
(IncreaseZoom.))
|
||||
(def decrease-zoom
|
||||
(ptk/reify ::decrease-zoom
|
||||
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 []
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(let [decrease #(nth c/zoom-levels
|
||||
(- (index-of c/zoom-levels %) 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.))
|
||||
(def reset-zoom
|
||||
(ptk/reify ::reset-zoom
|
||||
ptk/UpdateEvent
|
||||
(update [_ state]
|
||||
(assoc-in state [:workspace-local :zoom] 1))))
|
||||
|
||||
;; --- Grid Alignment
|
||||
|
||||
|
|
|
@ -26,10 +26,11 @@
|
|||
;; --- Zoom Widget
|
||||
|
||||
(mf/defc zoom-widget
|
||||
{:wrap [mf/wrap-memo]}
|
||||
[props]
|
||||
(let [zoom (mf/deref refs/selected-zoom)
|
||||
increase #(st/emit! (dw/increase-zoom))
|
||||
decrease #(st/emit! (dw/decrease-zoom))]
|
||||
increase #(st/emit! dw/increase-zoom)
|
||||
decrease #(st/emit! dw/decrease-zoom)]
|
||||
[:ul.options-view
|
||||
[:li.zoom-input
|
||||
[:span.add-zoom {:on-click decrease} "-"]
|
||||
|
@ -180,10 +181,10 @@
|
|||
;; i/alignment]]
|
||||
;; [:& user]
|
||||
[:div.secondary-options
|
||||
[:& zoom-widget]
|
||||
[:a.tooltip.tooltip-bottom.view-mode
|
||||
[:& zoom-widget]
|
||||
[:a.tooltip.tooltip-bottom.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]]
|
||||
]))
|
||||
|
|
Loading…
Add table
Reference in a new issue