mirror of
https://github.com/penpot/penpot.git
synced 2025-03-13 00:01:51 -05:00
✨ Add shortcuts for dashboard viewer and path
This commit is contained in:
parent
8072caeff1
commit
771bb20976
8 changed files with 145 additions and 54 deletions
|
@ -790,3 +790,46 @@
|
|||
(watch [_ state _]
|
||||
(let [team-id (:current-team-id state)]
|
||||
(rx/of (rt/nav :dashboard-team-settings {:team-id team-id}))))))
|
||||
|
||||
(defn go-to-drafts
|
||||
[]
|
||||
(ptk/reify ::go-to-drafts
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [team-id (:current-team-id state)
|
||||
projects (:dashboard-projects state)
|
||||
default-project (d/seek :is-default (vals projects))]
|
||||
(when default-project
|
||||
(rx/of (rt/nav :dashboard-files {:team-id team-id
|
||||
:project-id (:id default-project)})))))))
|
||||
|
||||
(defn go-to-libs
|
||||
[]
|
||||
(ptk/reify ::go-to-libs
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [team-id (:current-team-id state)]
|
||||
(rx/of (rt/nav :dashboard-libraries {:team-id team-id}))))))
|
||||
|
||||
(defn create-element
|
||||
[]
|
||||
(ptk/reify ::create-element
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [team-id (:current-team-id state)
|
||||
route (:route state)
|
||||
pparams (:path-params route)
|
||||
in-project? (contains? pparams :project-id)
|
||||
name (if in-project?
|
||||
(name (gensym (str (tr "dashboard.new-file-prefix") " ")))
|
||||
(name (gensym (str (tr "dashboard.new-project-prefix") " "))))
|
||||
params (if in-project?
|
||||
{:project-id (:project-id pparams)
|
||||
:name name}
|
||||
{:name name
|
||||
:team-id team-id})
|
||||
action-name (if in-project? :create-file :create-project)
|
||||
action (if in-project? file-created project-created)]
|
||||
|
||||
(->> (rp/mutation! action-name params)
|
||||
(rx/map action))))))
|
33
frontend/src/app/main/data/dashboard/shortcuts.cljs
Normal file
33
frontend/src/app/main/data/dashboard/shortcuts.cljs
Normal file
|
@ -0,0 +1,33 @@
|
|||
;; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
;;
|
||||
;; Copyright (c) UXBOX Labs SL
|
||||
|
||||
(ns app.main.data.dashboard.shortcuts
|
||||
(:require
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.shortcuts :as ds]
|
||||
[app.main.store :as st]
|
||||
))
|
||||
|
||||
(def shortcuts
|
||||
{:go-to-search {:tooltip (ds/meta "F")
|
||||
:command (ds/c-mod "f")
|
||||
:fn (st/emitf (dd/go-to-search))}
|
||||
|
||||
:go-to-drafts {:tooltip "G D"
|
||||
:command "g d"
|
||||
:fn (st/emitf (dd/go-to-drafts))}
|
||||
|
||||
:go-to-libs {:tooltip "G L"
|
||||
:command "g l"
|
||||
:fn (st/emitf (dd/go-to-libs))}
|
||||
|
||||
:create-new-project {:tooltip "+"
|
||||
:command "+"
|
||||
:fn (st/emitf (dd/create-element))}})
|
||||
|
||||
(defn get-tooltip [shortcut]
|
||||
(assert (contains? shortcuts shortcut) (str shortcut))
|
||||
(get-in shortcuts [shortcut :tooltip]))
|
|
@ -544,18 +544,17 @@
|
|||
(rx/of (rt/nav rname pparams qparams))))))
|
||||
|
||||
(defn go-to-workspace
|
||||
[page-id]
|
||||
([] (go-to-workspace nil))
|
||||
([page-id]
|
||||
(ptk/reify ::go-to-workspace
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [project-id (get-in state [:viewer :project :id])
|
||||
file-id (get-in state [:viewer :file :id])
|
||||
pparams {:project-id project-id :file-id file-id}
|
||||
qparams {:page-id page-id}]
|
||||
qparams {:page-id (or page-id (:current-page-id state))}]
|
||||
(rx/of (rt/nav-new-window*
|
||||
{:rname :workspace
|
||||
:path-params pparams
|
||||
:query-params qparams
|
||||
:name (str "workspace-" file-id)}))))))
|
||||
|
||||
|
||||
:name (str "workspace-" file-id)})))))))
|
|
@ -49,7 +49,11 @@
|
|||
|
||||
:open-comments {:tooltip "G C"
|
||||
:command "g c"
|
||||
:fn #(st/emit! (dv/go-to-section :comments))}})
|
||||
:fn #(st/emit! (dv/go-to-section :comments))}
|
||||
|
||||
: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))
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
(ns app.main.data.workspace
|
||||
(:require
|
||||
[app.common.attrs :as attrs]
|
||||
[app.common.data :as d]
|
||||
[app.common.geom.align :as gal]
|
||||
[app.common.geom.matrix :as gmt]
|
||||
|
@ -1199,12 +1200,19 @@
|
|||
(rx/of (dch/update-shapes [id] assign-proportions))))))
|
||||
|
||||
(defn toggle-proportion-lock
|
||||
[]
|
||||
(ptk/reify ::toggle-propotion-lock
|
||||
[]
|
||||
(ptk/reify ::toggle-propotion-lock
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [selected (wsh/lookup-selected state)]
|
||||
(rx/of (dch/update-shapes selected #(update % :proportion-lock not)))))))
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (wsh/lookup-page-objects state page-id)
|
||||
selected (wsh/lookup-selected state)
|
||||
selected-obj (-> (map #(get objects %) selected))
|
||||
multi (attrs/get-attrs-multi selected-obj [:proportion-lock])
|
||||
multi? (= :multiple (:proportion-lock multi))]
|
||||
(if multi?
|
||||
(rx/of (dch/update-shapes selected #(assoc % :proportion-lock true)))
|
||||
(rx/of (dch/update-shapes selected #(update % :proportion-lock not))))))))
|
||||
|
||||
;; --- Update Shape Flags
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
[potok.core :as ptk]))
|
||||
|
||||
;; Change this to :info :debug or :trace to debug this module
|
||||
(log/set-level! :warn)
|
||||
(log/set-level! :debug)
|
||||
|
||||
(s/def ::coll-of-uuid
|
||||
(s/every ::us/uuid))
|
||||
|
|
|
@ -32,8 +32,8 @@
|
|||
(rx/empty))))))
|
||||
|
||||
(def shortcuts
|
||||
{:move-nodes {:tooltip "V"
|
||||
:command "v"
|
||||
{:move-nodes {:tooltip "M"
|
||||
:command "m"
|
||||
:fn #(st/emit! (drp/change-edit-mode :move))}
|
||||
|
||||
:draw-nodes {:tooltip "P"
|
||||
|
@ -60,12 +60,12 @@
|
|||
:command "k"
|
||||
:fn #(st/emit! (drp/separate-nodes))}
|
||||
|
||||
:make-corner {:tooltip "B"
|
||||
:command "b"
|
||||
:make-corner {:tooltip "X"
|
||||
:command "x"
|
||||
:fn #(st/emit! (drp/make-corner))}
|
||||
|
||||
:make-curve {:tooltip (ds/meta "B")
|
||||
:command (ds/c-mod "b")
|
||||
:make-curve {:tooltip "C"
|
||||
:command "c"
|
||||
:fn #(st/emit! (drp/make-curve))}
|
||||
|
||||
:snap-nodes {:tooltip (ds/meta "'")
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
(:require
|
||||
[app.common.spec :as us]
|
||||
[app.main.data.dashboard :as dd]
|
||||
[app.main.data.dashboard.shortcuts :as sc]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.context :as ctx]
|
||||
|
@ -20,6 +21,7 @@
|
|||
[app.main.ui.dashboard.search :refer [search-page]]
|
||||
[app.main.ui.dashboard.sidebar :refer [sidebar]]
|
||||
[app.main.ui.dashboard.team :refer [team-settings-page team-members-page]]
|
||||
[app.main.ui.hooks :as hooks]
|
||||
[rumext.alpha :as mf]))
|
||||
|
||||
(defn ^boolean uuid-str?
|
||||
|
@ -88,6 +90,8 @@
|
|||
projects (mf/deref refs/dashboard-projects)
|
||||
project (get projects project-id)]
|
||||
|
||||
(hooks/use-shortcuts ::viewer sc/shortcuts)
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps team-id)
|
||||
(fn []
|
||||
|
|
Loading…
Add table
Reference in a new issue