@atlaskit/editor-toolbar 0.0.0 → 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/examples/toolbar/examples/ExampleManuallyComposedToolbar.tsx +319 -166
- package/package.json +6 -5
- package/src/ui/ToolbarButton.tsx +23 -6
- package/src/ui/ToolbarDropdownItem.tsx +17 -7
- package/src/ui/ToolbarDropdownMenu.tsx +3 -0
- package/src/ui/ToolbarTooltip.tsx +16 -0
- package/src/ui/icons/AIChatIcon.tsx +1 -1
- package/tsconfig.app.json +3 -0
- package/tsconfig.dev.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
1
|
# @atlaskit/editor-toolbar
|
|
2
|
+
|
|
3
|
+
## 0.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#187668](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187668)
|
|
8
|
+
[`83251dd8644c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/83251dd8644c4) -
|
|
9
|
+
[ux] [ED-28537] add support for tooltips, disabled states and hover states for new toolbar package
|
|
10
|
+
- Updated dependencies
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { Box } from '@atlaskit/primitives/compiled';
|
|
4
|
+
import Toggle from '@atlaskit/toggle';
|
|
4
5
|
import { token } from '@atlaskit/tokens';
|
|
5
6
|
|
|
6
7
|
import { ColorIndicatorWrapper } from '../../../src/ui/ColorIndicatorWrapper';
|
|
@@ -35,6 +36,7 @@ import { ToolbarDropdownItem } from '../../../src/ui/ToolbarDropdownItem';
|
|
|
35
36
|
import { ToolbarDropdownMenu } from '../../../src/ui/ToolbarDropdownMenu';
|
|
36
37
|
import { ToolbarKeyboardShortcutHint } from '../../../src/ui/ToolbarKeyboardShortcutHint';
|
|
37
38
|
import { ToolbarSection } from '../../../src/ui/ToolbarSection';
|
|
39
|
+
import { ToolbarTooltip } from '../../../src/ui/ToolbarTooltip';
|
|
38
40
|
|
|
39
41
|
import { useExampleToolbarState } from './useExampleToolbarState';
|
|
40
42
|
|
|
@@ -52,23 +54,92 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
52
54
|
lastAction,
|
|
53
55
|
} = useExampleToolbarState();
|
|
54
56
|
|
|
57
|
+
const [isRovoDisabled, setIsRovoDisabled] = useState(false);
|
|
58
|
+
const toggleRovoButton = () => {
|
|
59
|
+
setIsRovoDisabled(!isRovoDisabled);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const [isAdjustLengthDisabled, setIsAdjustLengthDisabled] = useState(false);
|
|
63
|
+
const toggleAdjustLengthButton = () => {
|
|
64
|
+
setIsAdjustLengthDisabled(!isAdjustLengthDisabled);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const [isTextStylesDisabled, setIsTextStylesDisabled] = useState(false);
|
|
68
|
+
const toggleTextStylesButton = () => {
|
|
69
|
+
setIsTextStylesDisabled(!isTextStylesDisabled);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const [isImproveWritingDisabled, setIsImproveWritingDisabled] = useState(false);
|
|
73
|
+
const toggleImproveWritingButton = () => {
|
|
74
|
+
setIsImproveWritingDisabled(!isImproveWritingDisabled);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const [isBoldDisabled, setIsBoldDisabled] = useState(false);
|
|
78
|
+
const toggleBoldStyle = () => {
|
|
79
|
+
setIsBoldDisabled(!isBoldDisabled);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const [isItalicDisabled, setIsItalicDisabled] = useState(false);
|
|
83
|
+
const toggleItalicStyle = () => {
|
|
84
|
+
setIsItalicDisabled(!isItalicDisabled);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const [isTextColorDisabled, setIsTextColorDisabled] = useState(false);
|
|
88
|
+
const toggleTextColorButton = () => {
|
|
89
|
+
setIsTextColorDisabled(!isTextColorDisabled);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const [isBulletedListDisabled, setIsBulletedListDisabled] = useState(false);
|
|
93
|
+
const toggleBulletedListButton = () => {
|
|
94
|
+
setIsBulletedListDisabled(!isBulletedListDisabled);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const [isNumberedListDisabled, setIsNumberedListDisabled] = useState(false);
|
|
98
|
+
const toggleNumberedListButton = () => {
|
|
99
|
+
setIsNumberedListDisabled(!isNumberedListDisabled);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const [isLinkDisabled, setIsLinkDisabled] = useState(false);
|
|
103
|
+
const toggleLinkButton = () => {
|
|
104
|
+
setIsLinkDisabled(!isLinkDisabled);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const [isCommentDisabled, setIsCommentDisabled] = useState(false);
|
|
108
|
+
const toggleCommentButton = () => {
|
|
109
|
+
setIsCommentDisabled(!isCommentDisabled);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const [isCreateJiraWorkItemDisabled, setIsCreateJiraWorkItemDisabled] = useState(false);
|
|
113
|
+
const toggleCreateJiraWorkItemButton = () => {
|
|
114
|
+
setIsCreateJiraWorkItemDisabled(!isCreateJiraWorkItemDisabled);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const [isAppsAndExtensionsDisabled, setIsAppsAndExtensionsDisabled] = useState(false);
|
|
118
|
+
const toggleAppsAndExtensionsButton = () => {
|
|
119
|
+
setIsAppsAndExtensionsDisabled(!isAppsAndExtensionsDisabled);
|
|
120
|
+
}
|
|
121
|
+
|
|
55
122
|
return (
|
|
56
123
|
<>
|
|
57
124
|
<Toolbar label="Editor Toolbar">
|
|
58
125
|
<ToolbarSection>
|
|
59
126
|
<ToolbarButtonGroup>
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
127
|
+
<ToolbarTooltip content="Ask Rovo">
|
|
128
|
+
<ToolbarButton
|
|
129
|
+
icon={AIChatIcon}
|
|
130
|
+
label="Ask Rovo"
|
|
131
|
+
onClick={onClick('Ask Rovo')}
|
|
132
|
+
groupLocation="start"
|
|
133
|
+
isDisabled={isRovoDisabled}
|
|
134
|
+
>
|
|
135
|
+
Ask Rovo
|
|
136
|
+
</ToolbarButton>
|
|
137
|
+
</ToolbarTooltip>
|
|
68
138
|
<ToolbarDropdownMenu icon={MoreItemsIcon} label="More formatting" groupLocation="end">
|
|
69
139
|
<ToolbarDropdownItem
|
|
70
140
|
elemBefore={<AIAdjustLengthIcon label="Adjust length" />}
|
|
71
141
|
onClick={onClick('Adjust length')}
|
|
142
|
+
isDisabled={isAdjustLengthDisabled}
|
|
72
143
|
>
|
|
73
144
|
Adjust length
|
|
74
145
|
</ToolbarDropdownItem>
|
|
@@ -76,13 +147,16 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
76
147
|
</ToolbarButtonGroup>
|
|
77
148
|
|
|
78
149
|
<ToolbarButtonGroup>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
150
|
+
<ToolbarTooltip content="Improve writing">
|
|
151
|
+
<ToolbarButton
|
|
152
|
+
icon={AICommandIcon}
|
|
153
|
+
label="Improve writing"
|
|
154
|
+
onClick={onClick('Improve writing')}
|
|
155
|
+
isDisabled={isImproveWritingDisabled}
|
|
156
|
+
>
|
|
157
|
+
Improve writing
|
|
158
|
+
</ToolbarButton>
|
|
159
|
+
</ToolbarTooltip>
|
|
86
160
|
</ToolbarButtonGroup>
|
|
87
161
|
</ToolbarSection>
|
|
88
162
|
|
|
@@ -90,114 +164,121 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
90
164
|
|
|
91
165
|
<ToolbarSection>
|
|
92
166
|
<ToolbarButtonGroup>
|
|
93
|
-
<
|
|
94
|
-
|
|
95
|
-
{
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
elemBefore={<TextIcon label="Normal text" />}
|
|
111
|
-
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥0" />}
|
|
112
|
-
onClick={onClick('Normal text', onSetTextStyle('normal'))}
|
|
113
|
-
isSelected={textStyle === 'normal'}
|
|
114
|
-
textStyle="normal"
|
|
167
|
+
<ToolbarTooltip content="Text styles">
|
|
168
|
+
<ToolbarDropdownMenu
|
|
169
|
+
icon={
|
|
170
|
+
{
|
|
171
|
+
none: TextIcon,
|
|
172
|
+
normal: TextIcon,
|
|
173
|
+
heading1: HeadingOneIcon,
|
|
174
|
+
heading2: HeadingTwoIcon,
|
|
175
|
+
heading3: HeadingThreeIcon,
|
|
176
|
+
heading4: HeadingFourIcon,
|
|
177
|
+
heading5: HeadingFiveIcon,
|
|
178
|
+
heading6: HeadingSixIcon,
|
|
179
|
+
quote: QuoteIcon,
|
|
180
|
+
}[textStyle]
|
|
181
|
+
}
|
|
182
|
+
label="Text styles"
|
|
183
|
+
isDisabled={isTextStylesDisabled}
|
|
115
184
|
>
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
185
|
+
<ToolbarDropdownItem
|
|
186
|
+
elemBefore={<TextIcon label="Normal text" />}
|
|
187
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥0" />}
|
|
188
|
+
onClick={onClick('Normal text', onSetTextStyle('normal'))}
|
|
189
|
+
isSelected={textStyle === 'normal'}
|
|
190
|
+
textStyle="normal"
|
|
191
|
+
>
|
|
192
|
+
Normal text
|
|
193
|
+
</ToolbarDropdownItem>
|
|
194
|
+
<ToolbarDropdownItem
|
|
195
|
+
elemBefore={<HeadingOneIcon label="Heading One" />}
|
|
196
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥1" />}
|
|
197
|
+
onClick={onClick('Heading one', onSetTextStyle('heading1'))}
|
|
198
|
+
isSelected={textStyle === 'heading1'}
|
|
199
|
+
textStyle="heading1"
|
|
200
|
+
>
|
|
201
|
+
Heading 1
|
|
202
|
+
</ToolbarDropdownItem>
|
|
203
|
+
<ToolbarDropdownItem
|
|
204
|
+
elemBefore={<HeadingTwoIcon label="Heading Two" />}
|
|
205
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥2" />}
|
|
206
|
+
onClick={onClick('Heading two', onSetTextStyle('heading2'))}
|
|
207
|
+
isSelected={textStyle === 'heading2'}
|
|
208
|
+
textStyle="heading2"
|
|
209
|
+
>
|
|
210
|
+
Heading 2
|
|
211
|
+
</ToolbarDropdownItem>
|
|
212
|
+
<ToolbarDropdownItem
|
|
213
|
+
elemBefore={<HeadingThreeIcon label="Heading Three" />}
|
|
214
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥3" />}
|
|
215
|
+
onClick={onClick('Heading three', onSetTextStyle('heading3'))}
|
|
216
|
+
isSelected={textStyle === 'heading3'}
|
|
217
|
+
textStyle="heading3"
|
|
218
|
+
>
|
|
219
|
+
Heading 3
|
|
220
|
+
</ToolbarDropdownItem>
|
|
221
|
+
<ToolbarDropdownItem
|
|
222
|
+
elemBefore={<HeadingFourIcon label="Heading Four" />}
|
|
223
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥4" />}
|
|
224
|
+
onClick={onClick('Heading four', onSetTextStyle('heading4'))}
|
|
225
|
+
isSelected={textStyle === 'heading4'}
|
|
226
|
+
textStyle="heading4"
|
|
227
|
+
>
|
|
228
|
+
Heading 4
|
|
229
|
+
</ToolbarDropdownItem>
|
|
230
|
+
<ToolbarDropdownItem
|
|
231
|
+
elemBefore={<HeadingFiveIcon label="Heading Five" />}
|
|
232
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥5" />}
|
|
233
|
+
onClick={onClick('Heading five', onSetTextStyle('heading5'))}
|
|
234
|
+
isSelected={textStyle === 'heading5'}
|
|
235
|
+
textStyle="heading5"
|
|
236
|
+
>
|
|
237
|
+
Heading 5
|
|
238
|
+
</ToolbarDropdownItem>
|
|
239
|
+
<ToolbarDropdownItem
|
|
240
|
+
elemBefore={<HeadingSixIcon label="Heading Six" />}
|
|
241
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥6" />}
|
|
242
|
+
onClick={onClick('Heading six', onSetTextStyle('heading6'))}
|
|
243
|
+
isSelected={textStyle === 'heading6'}
|
|
244
|
+
textStyle="heading6"
|
|
245
|
+
>
|
|
246
|
+
Heading 6
|
|
247
|
+
</ToolbarDropdownItem>
|
|
248
|
+
<ToolbarDropdownItem
|
|
249
|
+
elemBefore={<QuoteIcon label="Quote" />}
|
|
250
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥9" />}
|
|
251
|
+
onClick={onClick('Quote', onSetTextStyle('quote'))}
|
|
252
|
+
isSelected={textStyle === 'quote'}
|
|
253
|
+
textStyle="normal"
|
|
254
|
+
>
|
|
255
|
+
Quote
|
|
256
|
+
</ToolbarDropdownItem>
|
|
257
|
+
</ToolbarDropdownMenu>
|
|
258
|
+
</ToolbarTooltip>
|
|
182
259
|
</ToolbarButtonGroup>
|
|
183
260
|
|
|
184
261
|
<ToolbarButtonGroup>
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
262
|
+
<ToolbarTooltip content={formatting.italic && !formatting.bold ? 'Italic' : 'Bold'}>
|
|
263
|
+
<ToolbarButton
|
|
264
|
+
icon={formatting.italic && !formatting.bold ? ItalicIcon : BoldIcon}
|
|
265
|
+
label={formatting.italic && !formatting.bold ? 'Italic' : 'Bold'}
|
|
266
|
+
onClick={onClick(
|
|
267
|
+
formatting.italic && !formatting.bold ? 'Italic' : 'Bold',
|
|
268
|
+
onToggleFormatting(formatting.italic && !formatting.bold ? 'italic' : 'bold'),
|
|
269
|
+
)}
|
|
270
|
+
groupLocation="start"
|
|
271
|
+
isSelected={formatting.bold || formatting.italic}
|
|
272
|
+
isDisabled={formatting.italic ? isItalicDisabled : isBoldDisabled}
|
|
273
|
+
/>
|
|
274
|
+
</ToolbarTooltip>
|
|
195
275
|
<ToolbarDropdownMenu icon={MoreItemsIcon} label="More formatting" groupLocation="end">
|
|
196
276
|
<ToolbarDropdownItem
|
|
197
277
|
elemBefore={<BoldIcon label="Bold" />}
|
|
198
278
|
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘B" />}
|
|
199
279
|
onClick={onClick('Bold', onToggleFormatting('bold'))}
|
|
200
280
|
isSelected={formatting.bold}
|
|
281
|
+
isDisabled={isBoldDisabled}
|
|
201
282
|
>
|
|
202
283
|
Bold
|
|
203
284
|
</ToolbarDropdownItem>
|
|
@@ -206,6 +287,7 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
206
287
|
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘I" />}
|
|
207
288
|
onClick={onClick('Italic', onToggleFormatting('italic'))}
|
|
208
289
|
isSelected={formatting.italic}
|
|
290
|
+
isDisabled={isItalicDisabled}
|
|
209
291
|
>
|
|
210
292
|
Italic
|
|
211
293
|
</ToolbarDropdownItem>
|
|
@@ -213,41 +295,47 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
213
295
|
</ToolbarButtonGroup>
|
|
214
296
|
|
|
215
297
|
<ToolbarButtonGroup>
|
|
216
|
-
<
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
<
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
elemBefore={<TextIcon label="Text color" />}
|
|
233
|
-
onClick={onClick('Text color')}
|
|
298
|
+
<ToolbarTooltip content="Text color">
|
|
299
|
+
<ToolbarDropdownMenu
|
|
300
|
+
icon={({ label, color, shouldRecommendSmallIcon, size, spacing, testId }) => (
|
|
301
|
+
<ColorIndicatorWrapper color={token('color.border.accent.blue')}>
|
|
302
|
+
<TextColorIcon
|
|
303
|
+
label={label}
|
|
304
|
+
color={color}
|
|
305
|
+
shouldRecommendSmallIcon={shouldRecommendSmallIcon}
|
|
306
|
+
size={size}
|
|
307
|
+
spacing={spacing}
|
|
308
|
+
testId={testId}
|
|
309
|
+
/>
|
|
310
|
+
</ColorIndicatorWrapper>
|
|
311
|
+
)}
|
|
312
|
+
label="Text color"
|
|
313
|
+
isDisabled={isTextColorDisabled}
|
|
234
314
|
>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
315
|
+
<ToolbarDropdownItem
|
|
316
|
+
elemBefore={<TextIcon label="Text color" />}
|
|
317
|
+
onClick={onClick('Text color')}
|
|
318
|
+
>
|
|
319
|
+
Text color
|
|
320
|
+
</ToolbarDropdownItem>
|
|
321
|
+
</ToolbarDropdownMenu>
|
|
322
|
+
</ToolbarTooltip>
|
|
238
323
|
</ToolbarButtonGroup>
|
|
239
324
|
|
|
240
325
|
<ToolbarButtonGroup>
|
|
241
|
-
<
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
326
|
+
<ToolbarTooltip content={listOrAlignment === 'numbered' ? 'Numbered list' : 'Bulleted list'}>
|
|
327
|
+
<ToolbarButton
|
|
328
|
+
icon={listOrAlignment === 'numbered' ? ListNumberedIcon : ListBulletedIcon}
|
|
329
|
+
label={listOrAlignment === 'numbered' ? 'Numbered list' : 'Bulleted list'}
|
|
330
|
+
onClick={onClick(
|
|
331
|
+
listOrAlignment === 'numbered' ? 'Numbered list' : 'Bulleted list',
|
|
332
|
+
onToggleListOrAlignment(listOrAlignment === 'numbered' ? 'numbered' : 'bulleted'),
|
|
333
|
+
)}
|
|
334
|
+
groupLocation="start"
|
|
335
|
+
isSelected={listOrAlignment !== 'none'}
|
|
336
|
+
isDisabled={listOrAlignment === 'numbered' ? isNumberedListDisabled : isBulletedListDisabled}
|
|
337
|
+
/>
|
|
338
|
+
</ToolbarTooltip>
|
|
251
339
|
<ToolbarDropdownMenu
|
|
252
340
|
icon={MoreItemsIcon}
|
|
253
341
|
label="Lists, indentation and alignment"
|
|
@@ -258,6 +346,7 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
258
346
|
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⇧8" />}
|
|
259
347
|
onClick={onClick('Bulleted list', onToggleListOrAlignment('bulleted'))}
|
|
260
348
|
isSelected={listOrAlignment === 'bulleted'}
|
|
349
|
+
isDisabled={isBulletedListDisabled}
|
|
261
350
|
>
|
|
262
351
|
Bulleted list
|
|
263
352
|
</ToolbarDropdownItem>
|
|
@@ -266,6 +355,7 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
266
355
|
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⇧7" />}
|
|
267
356
|
onClick={onClick('Numbered list', onToggleListOrAlignment('numbered'))}
|
|
268
357
|
isSelected={listOrAlignment === 'numbered'}
|
|
358
|
+
isDisabled={isNumberedListDisabled}
|
|
269
359
|
>
|
|
270
360
|
Numbered list
|
|
271
361
|
</ToolbarDropdownItem>
|
|
@@ -277,7 +367,9 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
277
367
|
|
|
278
368
|
<ToolbarSection>
|
|
279
369
|
<ToolbarButtonGroup>
|
|
280
|
-
<
|
|
370
|
+
<ToolbarTooltip content="Link">
|
|
371
|
+
<ToolbarButton icon={LinkIcon} label="Link" onClick={onClick('Link')} isDisabled={isLinkDisabled} />
|
|
372
|
+
</ToolbarTooltip>
|
|
281
373
|
</ToolbarButtonGroup>
|
|
282
374
|
</ToolbarSection>
|
|
283
375
|
|
|
@@ -285,7 +377,9 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
285
377
|
|
|
286
378
|
<ToolbarSection>
|
|
287
379
|
<ToolbarButtonGroup>
|
|
288
|
-
<
|
|
380
|
+
<ToolbarTooltip content="Comment">
|
|
381
|
+
<ToolbarButton icon={CommentIcon} label="Comment" onClick={onClick('Comment')} isDisabled={isCommentDisabled} />
|
|
382
|
+
</ToolbarTooltip>
|
|
289
383
|
</ToolbarButtonGroup>
|
|
290
384
|
</ToolbarSection>
|
|
291
385
|
|
|
@@ -293,14 +387,17 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
293
387
|
|
|
294
388
|
<ToolbarSection>
|
|
295
389
|
<ToolbarButtonGroup>
|
|
296
|
-
<
|
|
297
|
-
<
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
390
|
+
<ToolbarTooltip content="Apps and extensions">
|
|
391
|
+
<ToolbarDropdownMenu icon={AppsIcon} label="Apps and extensions" isDisabled={isAppsAndExtensionsDisabled}>
|
|
392
|
+
<ToolbarDropdownItem
|
|
393
|
+
elemBefore={<AddIcon label="Create Jira work item" />}
|
|
394
|
+
onClick={onClick('Create Jira work item')}
|
|
395
|
+
isDisabled={isCreateJiraWorkItemDisabled}
|
|
396
|
+
>
|
|
397
|
+
Create Jira work item
|
|
398
|
+
</ToolbarDropdownItem>
|
|
399
|
+
</ToolbarDropdownMenu>
|
|
400
|
+
</ToolbarTooltip>
|
|
304
401
|
</ToolbarButtonGroup>
|
|
305
402
|
</ToolbarSection>
|
|
306
403
|
|
|
@@ -308,14 +405,16 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
308
405
|
|
|
309
406
|
<ToolbarSection>
|
|
310
407
|
<ToolbarButtonGroup>
|
|
311
|
-
<
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
408
|
+
<ToolbarTooltip content={pinning === 'pinned' ? 'Unpin the toolbar' : 'Pin the toolbar at the top'}>
|
|
409
|
+
<ToolbarButton
|
|
410
|
+
icon={pinning === 'pinned' ? PinnedIcon : PinIcon}
|
|
411
|
+
label={pinning === 'pinned' ? 'Unpin toolbar' : 'Pin toolbar'}
|
|
412
|
+
onClick={onClick(
|
|
413
|
+
pinning === 'pinned' ? 'Unpin toolbar' : 'Pin toolbar',
|
|
414
|
+
onTogglePinning,
|
|
415
|
+
)}
|
|
416
|
+
/>
|
|
417
|
+
</ToolbarTooltip>
|
|
319
418
|
</ToolbarButtonGroup>
|
|
320
419
|
</ToolbarSection>
|
|
321
420
|
</Toolbar>
|
|
@@ -324,13 +423,67 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
324
423
|
Last action: ${lastAction || 'None'}
|
|
325
424
|
Text style: ${textStyle}
|
|
326
425
|
Formatting: ${Object.entries(formatting)
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
426
|
+
.filter(([, value]) => value)
|
|
427
|
+
.map(([key]) => key)
|
|
428
|
+
.join(', ')}
|
|
330
429
|
List/Align: ${listOrAlignment}
|
|
331
430
|
Pinning: ${pinning}
|
|
332
431
|
`}
|
|
333
432
|
</Box>
|
|
433
|
+
<Box>
|
|
434
|
+
<div>
|
|
435
|
+
Disable Rovo Button
|
|
436
|
+
<Toggle onChange={toggleRovoButton} />
|
|
437
|
+
</div>
|
|
438
|
+
<div>
|
|
439
|
+
Disable Adjust Length Button
|
|
440
|
+
<Toggle onChange={toggleAdjustLengthButton} />
|
|
441
|
+
</div>
|
|
442
|
+
<div>
|
|
443
|
+
Disable Improve Writing Button
|
|
444
|
+
<Toggle onChange={toggleImproveWritingButton} />
|
|
445
|
+
</div>
|
|
446
|
+
<div>
|
|
447
|
+
Disable Text Styles
|
|
448
|
+
<Toggle onChange={toggleTextStylesButton} />
|
|
449
|
+
</div>
|
|
450
|
+
<div>
|
|
451
|
+
Disable Bold Formatting
|
|
452
|
+
<Toggle onChange={toggleBoldStyle} />
|
|
453
|
+
</div>
|
|
454
|
+
<div>
|
|
455
|
+
Disable Italic Formatting
|
|
456
|
+
<Toggle onChange={toggleItalicStyle} />
|
|
457
|
+
</div>
|
|
458
|
+
<div>
|
|
459
|
+
Disable Text Color
|
|
460
|
+
<Toggle onChange={toggleTextColorButton} />
|
|
461
|
+
</div>
|
|
462
|
+
<div>
|
|
463
|
+
Disable Bulleted List
|
|
464
|
+
<Toggle onChange={toggleBulletedListButton} />
|
|
465
|
+
</div>
|
|
466
|
+
<div>
|
|
467
|
+
Disable Numbered List
|
|
468
|
+
<Toggle onChange={toggleNumberedListButton} />
|
|
469
|
+
</div>
|
|
470
|
+
<div>
|
|
471
|
+
Disable Link
|
|
472
|
+
<Toggle onChange={toggleLinkButton} />
|
|
473
|
+
</div>
|
|
474
|
+
<div>
|
|
475
|
+
Disable Comment
|
|
476
|
+
<Toggle onChange={toggleCommentButton} />
|
|
477
|
+
</div>
|
|
478
|
+
<div>
|
|
479
|
+
Disable Apps and Extensions
|
|
480
|
+
<Toggle onChange={toggleAppsAndExtensionsButton} />
|
|
481
|
+
</div>
|
|
482
|
+
<div>
|
|
483
|
+
Disable Create Jira Work Item
|
|
484
|
+
<Toggle onChange={toggleCreateJiraWorkItemButton} />
|
|
485
|
+
</div>
|
|
486
|
+
</Box>
|
|
334
487
|
</>
|
|
335
488
|
);
|
|
336
489
|
};
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"registry": "https://registry.npmjs.org/"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.0.
|
|
6
|
+
"version": "0.0.1",
|
|
7
7
|
"description": "Common UI for Toolbars across the platform",
|
|
8
8
|
"atlassian": {
|
|
9
9
|
"team": "Editor"
|
|
@@ -26,13 +26,14 @@
|
|
|
26
26
|
"@atlaskit/badge": "^18.1.0",
|
|
27
27
|
"@atlaskit/button": "^23.2.0",
|
|
28
28
|
"@atlaskit/css": "^0.12.0",
|
|
29
|
-
"@atlaskit/dropdown-menu": "^16.
|
|
30
|
-
"@atlaskit/icon": "^27.
|
|
31
|
-
"@atlaskit/icon-lab": "^5.
|
|
29
|
+
"@atlaskit/dropdown-menu": "^16.2.0",
|
|
30
|
+
"@atlaskit/icon": "^27.5.0",
|
|
31
|
+
"@atlaskit/icon-lab": "^5.2.0",
|
|
32
32
|
"@atlaskit/logo": "^19.5.0",
|
|
33
33
|
"@atlaskit/popup": "^4.3.0",
|
|
34
34
|
"@atlaskit/primitives": "^14.10.0",
|
|
35
|
-
"@atlaskit/tokens": "^5.
|
|
35
|
+
"@atlaskit/tokens": "^5.6.0",
|
|
36
|
+
"@atlaskit/tooltip": "^20.3.0",
|
|
36
37
|
"@babel/runtime": "^7.0.0",
|
|
37
38
|
"@compiled/react": "^0.18.3"
|
|
38
39
|
},
|
package/src/ui/ToolbarButton.tsx
CHANGED
|
@@ -7,6 +7,12 @@ import { token } from '@atlaskit/tokens';
|
|
|
7
7
|
|
|
8
8
|
import { type IconComponent, type ToolbarButtonGroupLocation } from '../types';
|
|
9
9
|
|
|
10
|
+
const ICON_COLOR = {
|
|
11
|
+
default: token('color.icon.subtle'),
|
|
12
|
+
disabled: token('color.icon.disabled'),
|
|
13
|
+
selected: token('color.icon.selected'),
|
|
14
|
+
};
|
|
15
|
+
|
|
10
16
|
const styles = cssMap({
|
|
11
17
|
button: {
|
|
12
18
|
display: 'flex',
|
|
@@ -21,22 +27,29 @@ const styles = cssMap({
|
|
|
21
27
|
fontWeight: token('font.weight.medium'),
|
|
22
28
|
paddingLeft: token('space.100'),
|
|
23
29
|
paddingRight: token('space.100'),
|
|
24
|
-
|
|
30
|
+
'&:focus-visible': {
|
|
31
|
+
outlineOffset: '0',
|
|
32
|
+
zIndex: 1,
|
|
33
|
+
position: 'relative',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
enabled: {
|
|
25
37
|
'&:hover': {
|
|
26
38
|
backgroundColor: token('color.background.neutral.subtle.hovered'),
|
|
27
39
|
},
|
|
28
|
-
|
|
29
40
|
'&:active': {
|
|
30
41
|
backgroundColor: token('color.background.neutral.subtle.pressed'),
|
|
31
42
|
},
|
|
32
43
|
},
|
|
44
|
+
disabled: {
|
|
45
|
+
color: token('color.text.disabled'),
|
|
46
|
+
cursor: 'not-allowed',
|
|
47
|
+
},
|
|
33
48
|
selected: {
|
|
34
49
|
backgroundColor: token('color.background.selected'),
|
|
35
|
-
|
|
36
50
|
'&:hover': {
|
|
37
51
|
backgroundColor: token('color.background.selected.hovered'),
|
|
38
52
|
},
|
|
39
|
-
|
|
40
53
|
'&:active': {
|
|
41
54
|
backgroundColor: token('color.background.selected.pressed'),
|
|
42
55
|
},
|
|
@@ -75,6 +88,7 @@ type ToolbarButtonProps = Partial<TriggerProps> & {
|
|
|
75
88
|
label: string;
|
|
76
89
|
icon: IconComponent;
|
|
77
90
|
groupLocation?: ToolbarButtonGroupLocation;
|
|
91
|
+
isDisabled?: boolean;
|
|
78
92
|
};
|
|
79
93
|
|
|
80
94
|
export const ToolbarButton = forwardRef(
|
|
@@ -93,15 +107,17 @@ export const ToolbarButton = forwardRef(
|
|
|
93
107
|
onFocus,
|
|
94
108
|
testId,
|
|
95
109
|
groupLocation,
|
|
110
|
+
isDisabled,
|
|
96
111
|
}: ToolbarButtonProps,
|
|
97
112
|
ref: Ref<HTMLButtonElement>,
|
|
98
113
|
) => {
|
|
114
|
+
const iconColor = isDisabled ? ICON_COLOR.disabled : isSelected ? ICON_COLOR.selected : ICON_COLOR.default;
|
|
99
115
|
return (
|
|
100
116
|
<Pressable
|
|
101
117
|
ref={ref}
|
|
102
118
|
xcss={cx(
|
|
103
119
|
styles.button,
|
|
104
|
-
isSelected
|
|
120
|
+
isDisabled ? styles.disabled : isSelected ? styles.selected : styles.enabled,
|
|
105
121
|
groupLocation === 'start' && styles.groupStart,
|
|
106
122
|
groupLocation === 'middle' && styles.groupMiddle,
|
|
107
123
|
groupLocation === 'end' && styles.groupEnd,
|
|
@@ -114,11 +130,12 @@ export const ToolbarButton = forwardRef(
|
|
|
114
130
|
onBlur={onBlur}
|
|
115
131
|
onFocus={onFocus}
|
|
116
132
|
testId={testId}
|
|
133
|
+
isDisabled={isDisabled}
|
|
117
134
|
>
|
|
118
135
|
<IconComponent
|
|
119
136
|
label={label}
|
|
120
137
|
size="medium"
|
|
121
|
-
color={
|
|
138
|
+
color={iconColor}
|
|
122
139
|
/>
|
|
123
140
|
{children}
|
|
124
141
|
</Pressable>
|
|
@@ -22,23 +22,29 @@ const styles = cssMap({
|
|
|
22
22
|
minHeight: '36px',
|
|
23
23
|
paddingLeft: token('space.150'),
|
|
24
24
|
paddingRight: token('space.150'),
|
|
25
|
-
|
|
25
|
+
'&:focus-visible': {
|
|
26
|
+
outlineOffset: token('space.negative.025'),
|
|
27
|
+
borderRadius: token('border.radius'),
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
enabled: {
|
|
26
31
|
'&:hover': {
|
|
27
32
|
backgroundColor: token('color.background.neutral.subtle.hovered'),
|
|
28
33
|
},
|
|
29
|
-
|
|
30
34
|
'&:active': {
|
|
31
35
|
backgroundColor: token('color.background.neutral.subtle.pressed'),
|
|
32
36
|
},
|
|
33
37
|
},
|
|
38
|
+
disabled: {
|
|
39
|
+
color: token('color.text.disabled'),
|
|
40
|
+
cursor: 'not-allowed',
|
|
41
|
+
},
|
|
34
42
|
selected: {
|
|
35
43
|
backgroundColor: token('color.background.selected'),
|
|
36
44
|
color: token('color.text.selected'),
|
|
37
|
-
|
|
38
45
|
'&:hover': {
|
|
39
46
|
backgroundColor: token('color.background.selected.hovered'),
|
|
40
47
|
},
|
|
41
|
-
|
|
42
48
|
'&:active': {
|
|
43
49
|
backgroundColor: token('color.background.selected.pressed'),
|
|
44
50
|
},
|
|
@@ -73,6 +79,7 @@ type ToolbarDropdownItemProps = {
|
|
|
73
79
|
isSelected?: boolean;
|
|
74
80
|
children?: React.ReactNode;
|
|
75
81
|
textStyle?: TextStyle;
|
|
82
|
+
isDisabled?: boolean;
|
|
76
83
|
};
|
|
77
84
|
|
|
78
85
|
export const ToolbarDropdownItem = ({
|
|
@@ -82,6 +89,7 @@ export const ToolbarDropdownItem = ({
|
|
|
82
89
|
isSelected,
|
|
83
90
|
children,
|
|
84
91
|
textStyle = 'normal',
|
|
92
|
+
isDisabled,
|
|
85
93
|
}: ToolbarDropdownItemProps) => {
|
|
86
94
|
return (
|
|
87
95
|
<DropdownItem
|
|
@@ -92,7 +100,6 @@ export const ToolbarDropdownItem = ({
|
|
|
92
100
|
component={({
|
|
93
101
|
children,
|
|
94
102
|
'data-testid': testId,
|
|
95
|
-
disabled,
|
|
96
103
|
draggable,
|
|
97
104
|
onClick,
|
|
98
105
|
onDragStart,
|
|
@@ -102,8 +109,11 @@ export const ToolbarDropdownItem = ({
|
|
|
102
109
|
}) => (
|
|
103
110
|
<Pressable
|
|
104
111
|
testId={testId}
|
|
105
|
-
xcss={cx(
|
|
106
|
-
|
|
112
|
+
xcss={cx(
|
|
113
|
+
styles.toolbarDropdownItem,
|
|
114
|
+
isDisabled ? styles.disabled : isSelected ? styles.selected : styles.enabled,
|
|
115
|
+
)}
|
|
116
|
+
isDisabled={isDisabled}
|
|
107
117
|
draggable={draggable}
|
|
108
118
|
onClick={onClick}
|
|
109
119
|
onDragStart={onDragStart}
|
|
@@ -11,6 +11,7 @@ type ToolbarDropdownMenuProps = {
|
|
|
11
11
|
label: string;
|
|
12
12
|
children?: ReactNode;
|
|
13
13
|
groupLocation?: ToolbarButtonGroupLocation;
|
|
14
|
+
isDisabled?: boolean;
|
|
14
15
|
};
|
|
15
16
|
|
|
16
17
|
export const ToolbarDropdownMenu = ({
|
|
@@ -18,6 +19,7 @@ export const ToolbarDropdownMenu = ({
|
|
|
18
19
|
label,
|
|
19
20
|
groupLocation,
|
|
20
21
|
children,
|
|
22
|
+
isDisabled,
|
|
21
23
|
}: ToolbarDropdownMenuProps) => {
|
|
22
24
|
return (
|
|
23
25
|
<DropdownMenu<HTMLButtonElement>
|
|
@@ -35,6 +37,7 @@ export const ToolbarDropdownMenu = ({
|
|
|
35
37
|
icon={icon}
|
|
36
38
|
label={label}
|
|
37
39
|
groupLocation={groupLocation}
|
|
40
|
+
isDisabled={isDisabled}
|
|
38
41
|
/>
|
|
39
42
|
)}
|
|
40
43
|
>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
4
|
+
|
|
5
|
+
type ToolbarTooltipProps = {
|
|
6
|
+
content: string;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ToolbarTooltip = ({ content, children }: ToolbarTooltipProps) => {
|
|
11
|
+
return (
|
|
12
|
+
<Tooltip content={content}>
|
|
13
|
+
{children}
|
|
14
|
+
</Tooltip>
|
|
15
|
+
);
|
|
16
|
+
};
|
package/tsconfig.app.json
CHANGED