File tree 5 files changed +28
-23
lines changed
5 files changed +28
-23
lines changed Original file line number Diff line number Diff line change 1
1
(ns components.shortcuts-scenes
2
2
(:require
3
3
[portfolio.reagent-18 :refer-macros [defscene ]]
4
+ [re-frame.core :as rf]
5
+ [re-pressed.core :as rp]
6
+ [renderer.history.events :as-alias history.e]
4
7
[renderer.ui :as ui]
5
8
[renderer.utils.keyboard :as keyb]))
6
9
10
+ (rf/dispatch [::rp/set-keydown-rules keyb/keydown-rules])
11
+
7
12
(defscene single-shortcut
8
13
:title " Single shortcut"
9
- [:div.toolbar.bg-primary.h-10.p-2
10
- [ui/shortcuts [[{:keyCode (keyb/key-codes " P" )
11
- :ctrlKey true
12
- :shiftKey true }]]]])
14
+ [:div.toolbar.bg-primary.h-10.p-2.gap-2
15
+ " Undo"
16
+ [ui/shortcuts [::history.e/undo ]]])
13
17
14
18
(defscene multiple-shortcuts
15
19
:title " Multiple shortcuts"
16
- [:div.toolbar.bg-primary.h-10.p-2
17
- [ui/shortcuts [[{:keyCode (keyb/key-codes " P" )
18
- :ctrlKey true
19
- :shiftKey true }]
20
- [{:keyCode (keyb/key-codes " ONE" )
21
- :altKey true }]]]])
20
+ [:div.toolbar.bg-primary.h-10.p-2.gap-2
21
+ " Redo"
22
+ [ui/shortcuts [::history.e/redo ]]])
22
23
23
24
(defscene no-shortcuts
24
25
:title " No shortcuts"
25
- [:div.toolbar.bg-primary.h-10.p-2
26
- [ui/shortcuts []]])
26
+ [:div.toolbar.bg-primary.h-10.p-2.gap-2
27
+ " Event with no shortcuts"
28
+ [ui/shortcuts [:event-id-with-no-shortcut ]]])
Original file line number Diff line number Diff line change 204
204
[ui/icon " file" ]
205
205
[:button.button-link.text-lg
206
206
{:on-click #(rf/dispatch [::document.e/new ])} " New" ]
207
- [ui/shortcuts @( rf/subscribe [::app.s/event-shortcuts [ :: document.e/new ]]) ]
207
+ [ui/shortcuts [::document.e/new ]]
208
208
209
209
[:span " or" ]
210
210
240
240
[:button.button-link.text-lg
241
241
{:on-click #(rf/dispatch [::document.e/open nil ])}
242
242
" Open" ]
243
- [ui/shortcuts @( rf/subscribe [::app.s/event-shortcuts [ :: document.e/open nil ]]) ]]
243
+ [ui/shortcuts [::document.e/open nil ]]]
244
244
245
245
(when (seq recent-documents)
246
246
[:<> [:h2.mb-3.mt-8.text-2xl " Recent" ]
262
262
[:button.button-link.text-lg
263
263
{:on-click #(rf/dispatch [::dialog.e/cmdk ])}
264
264
" Command panel" ]
265
- [ui/shortcuts @( rf/subscribe [::app.s/event-shortcuts [ :: dialog.e/cmdk ]]) ]]]
265
+ [ui/shortcuts [::dialog.e/cmdk ]]]]
266
266
[:div.flex.items-center.gap-2
267
267
[ui/icon " earth" ]
268
268
[:button.button-link.text-lg
Original file line number Diff line number Diff line change 69
69
(when icon [ui/icon icon])]
70
70
label
71
71
[:div.right-slot
72
- [ui/shortcuts @( rf/subscribe [ ::app.s/event-shortcuts action]) ]]]))
72
+ [ui/shortcuts action]]]))
73
73
74
74
(defn cmdk-group-inner
75
75
[items label]
Original file line number Diff line number Diff line change 561
561
[ui/icon " checkmark" ]]
562
562
label
563
563
[:div.right-slot
564
- [ui/shortcuts @( rf/subscribe [ ::app.s/event-shortcuts action]) ]]])
564
+ [ui/shortcuts action]]])
565
565
566
566
(defmethod menu-item :sub-menu
567
567
[{:keys [label items disabled]}]
603
603
:disabled disabled}
604
604
label
605
605
[:div.right-slot
606
- [ui/shortcuts @( rf/subscribe [ ::app.s/event-shortcuts action]) ]]])
606
+ [ui/shortcuts action]]])
607
607
608
608
(defn root-menu
609
609
[]
Original file line number Diff line number Diff line change 19
19
[" tailwind-merge" :refer [twMerge]]
20
20
[re-frame.core :as rf]
21
21
[reagent.core :as ra]
22
+ [renderer.app.subs :as-alias app.s]
22
23
[renderer.utils.keyboard :as keyb]))
23
24
24
25
(defn merge-with-class
74
75
(into [:span ])))
75
76
76
77
(defn shortcuts
77
- [v]
78
- (when (seq v)
79
- (->> (map format-shortcut v)
80
- (interpose [:span ])
81
- (into [:span.inline-flex.text-muted {:class " gap-1.5" }]))))
78
+ [event]
79
+ (let [event-shortcuts @(rf/subscribe [::app.s/event-shortcuts event])]
80
+ (when (seq event-shortcuts)
81
+ (->> event-shortcuts
82
+ (map format-shortcut)
83
+ (interpose [:span ])
84
+ (into [:span.inline-flex.text-muted {:class " gap-1.5" }])))))
82
85
83
86
(defn radio-icon-button
84
87
[icon-name active props]
You can’t perform that action at this time.
0 commit comments