Add shortcuts to viewer btns

This commit is contained in:
eva 2021-12-20 09:26:24 +01:00 committed by Alonso Torres
parent 771bb20976
commit f3548aff8c
8 changed files with 60 additions and 53 deletions

View file

@ -549,12 +549,14 @@
(ptk/reify ::go-to-workspace
ptk/WatchEvent
(watch [_ state _]
(let [project-id (get-in state [:viewer :project :id])
(let [route (:route state)
project-id (get-in state [:viewer :project :id])
file-id (get-in state [:viewer :file :id])
saved-page-id (get-in route [:query-params :page-id])
pparams {:project-id project-id :file-id file-id}
qparams {:page-id (or page-id (:current-page-id state))}]
qparams {:page-id (or page-id saved-page-id)}]
(rx/of (rt/nav-new-window*
{:rname :workspace
:path-params pparams
:query-params qparams
:name (str "workspace-" file-id)})))))))
:name (str "workspace-" file-id)})))))))

View file

@ -11,49 +11,53 @@
[app.main.store :as st]))
(def shortcuts
{:increase-zoom {:tooltip "+"
:command "+"
:fn (st/emitf dv/increase-zoom)}
{:increase-zoom {:tooltip "+"
:command "+"
:fn (st/emitf dv/increase-zoom)}
:decrease-zoom {:tooltip "-"
:command "-"
:fn (st/emitf dv/decrease-zoom)}
:decrease-zoom {:tooltip "-"
:command "-"
:fn (st/emitf dv/decrease-zoom)}
:select-all {:tooltip (ds/meta "A")
:command (ds/c-mod "a")
:fn (st/emitf (dv/select-all))}
:select-all {:tooltip (ds/meta "A")
:command (ds/c-mod "a")
:fn (st/emitf (dv/select-all))}
:zoom-50 {:tooltip (ds/shift "0")
:command "shift+0"
:fn (st/emitf dv/zoom-to-50)}
:zoom-50 {:tooltip (ds/shift "0")
:command "shift+0"
:fn (st/emitf dv/zoom-to-50)}
:reset-zoom {:tooltip (ds/shift "1")
:command "shift+1"
:fn (st/emitf dv/reset-zoom)}
:reset-zoom {:tooltip (ds/shift "1")
:command "shift+1"
:fn (st/emitf dv/reset-zoom)}
:zoom-200 {:tooltip (ds/shift "2")
:command "shift+2"
:fn (st/emitf dv/zoom-to-200)}
:zoom-200 {:tooltip (ds/shift "2")
:command "shift+2"
:fn (st/emitf dv/zoom-to-200)}
:next-frame {:tooltip ds/left-arrow
:command "left"
:fn (st/emitf dv/select-prev-frame)}
:next-frame {:tooltip ds/left-arrow
:command "left"
:fn (st/emitf dv/select-prev-frame)}
:prev-frame {:tooltip ds/right-arrow
:command "right"
:fn (st/emitf dv/select-next-frame)}
:prev-frame {:tooltip ds/right-arrow
:command "right"
:fn (st/emitf dv/select-next-frame)}
:open-handoff {:tooltip "G H"
:command "g h"
:fn #(st/emit! (dv/go-to-section :handoff))}
:open-handoff {:tooltip "G H"
:command "g h"
:fn #(st/emit! (dv/go-to-section :handoff))}
:open-comments {:tooltip "G C"
:command "g c"
:fn #(st/emit! (dv/go-to-section :comments))}
:open-comments {:tooltip "G C"
:command "g c"
:fn #(st/emit! (dv/go-to-section :comments))}
:open-workspace {:tooltip "G W"
:command "g w"
:fn #(st/emit! (dv/go-to-workspace))}})
:open-interactions {:tooltip "G V"
:command "g v"
:fn #(st/emit! (dv/go-to-section :interactions))}
:open-workspace {:tooltip "G W"
:command "g w"
:fn #(st/emit! (dv/go-to-workspace))}})
(defn get-tooltip [shortcut]
(assert (contains? shortcuts shortcut) (str shortcut))

View file

@ -8,6 +8,7 @@
(:require
[app.main.data.modal :as modal]
[app.main.data.viewer :as dv]
[app.main.data.viewer.shortcuts :as sc]
[app.main.store :as st]
[app.main.ui.components.dropdown :refer [dropdown]]
[app.main.ui.components.fullscreen :as fs]
@ -151,14 +152,14 @@
[:button.mode-zone-button.tooltip.tooltip-bottom
{:on-click #(navigate :interactions)
:class (dom/classnames :active (= section :interactions))
:alt (tr "viewer.header.interactions-section")}
:alt (tr "viewer.header.interactions-section" (sc/get-tooltip :open-interactions))}
i/play]
(when (:can-edit permissions)
[:button.mode-zone-button.tooltip.tooltip-bottom
{:on-click #(navigate :comments)
:class (dom/classnames :active (= section :comments))
:alt (tr "viewer.header.comments-section")}
:alt (tr "viewer.header.comments-section" (sc/get-tooltip :open-comments))}
i/chat])
(when (or (= (:type permissions) :membership)
@ -167,7 +168,7 @@
[:button.mode-zone-button.tooltip.tooltip-bottom
{:on-click #(navigate :handoff)
:class (dom/classnames :active (= section :handoff))
:alt (tr "viewer.header.handsoff-section")}
:alt (tr "viewer.header.handsoff-section" (sc/get-tooltip :open-handoff))}
i/code])]
[:& header-options {:section section