File tree Expand file tree Collapse file tree 2 files changed +31
-15
lines changed Expand file tree Collapse file tree 2 files changed +31
-15
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
- import { useAsyncCallback , useOnline } from 'actionsack'
2
+ import { useAsyncCallback , useOnline , useKeyboardListener } from 'actionsack'
3
3
4
4
import Button from './Button'
5
5
import Toolbar from './Toolbar'
@@ -51,6 +51,29 @@ function DuplicateButton(props) {
51
51
)
52
52
}
53
53
54
+ function SaveButton ( { loading, onClick } ) {
55
+ useKeyboardListener ( '⌥-s' , e => {
56
+ e . preventDefault ( )
57
+ onClick ( )
58
+ } )
59
+
60
+ return (
61
+ < Button
62
+ border
63
+ large
64
+ center
65
+ color = { COLORS . GREEN }
66
+ onClick = { onClick }
67
+ data-cy = "save-button"
68
+ style = { { minWidth : 84 , borderBottomRightRadius : 0 , borderTopRightRadius : 0 } }
69
+ title = "Save"
70
+ disabled = { loading }
71
+ >
72
+ { loading ? 'Saving…' : 'Save' }
73
+ </ Button >
74
+ )
75
+ }
76
+
54
77
function SnippetToolbar ( {
55
78
toggleVisibility,
56
79
isVisible,
@@ -108,21 +131,8 @@ function SnippetToolbar({
108
131
} }
109
132
>
110
133
< div className = "flex" >
134
+ < SaveButton loading = { loading } onClick = { saveSnippet } />
111
135
< Button
112
- border
113
- large
114
- center
115
- color = { COLORS . GREEN }
116
- onClick = { saveSnippet }
117
- data-cy = "save-button"
118
- style = { { minWidth : 84 , borderBottomRightRadius : 0 , borderTopRightRadius : 0 } }
119
- title = "Save"
120
- disabled = { loading }
121
- >
122
- { loading ? 'Saving…' : 'Save' }
123
- </ Button >
124
- < Button
125
- id = "save-menu"
126
136
title = "Save menu dropdown"
127
137
border
128
138
large
Original file line number Diff line number Diff line change @@ -144,6 +144,12 @@ export default function About() {
144
144
< kbd > ⇧ ⌘ S</ kbd >
145
145
</ td >
146
146
</ tr >
147
+ < tr >
148
+ < td > Save snippet</ td >
149
+ < td >
150
+ < kbd > ⌥ S</ kbd >
151
+ </ td >
152
+ </ tr >
147
153
< tr >
148
154
< td > Copy image to clipboard</ td >
149
155
< td >
You can’t perform that action at this time.
0 commit comments