@atlaskit/editor-toolbar 0.0.0 → 0.0.2
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 +18 -0
- package/examples/toolbar/examples/ExampleManuallyComposedToolbar.tsx +472 -193
- package/package.json +6 -5
- package/src/ui/ToolbarButton.tsx +27 -10
- package/src/ui/ToolbarDropdownDivider.tsx +17 -0
- package/src/ui/ToolbarDropdownItem.tsx +67 -43
- package/src/ui/ToolbarDropdownItemSection.tsx +19 -0
- package/src/ui/ToolbarDropdownMenu.tsx +3 -0
- package/src/ui/ToolbarNestedDropdownMenu.tsx +43 -0
- package/src/ui/ToolbarTooltip.tsx +12 -0
- package/src/ui/icons/AICasualIcon.tsx +2 -0
- package/src/ui/icons/AIChangeToneIcon.tsx +2 -0
- package/src/ui/icons/AIChatIcon.tsx +1 -1
- package/src/ui/icons/AIHeartIcon.tsx +2 -0
- package/src/ui/icons/AILengthenIcon.tsx +2 -0
- package/src/ui/icons/AIProfessionalIcon.tsx +2 -0
- package/src/ui/icons/AIShortenIcon.tsx +2 -0
- package/src/ui/icons/AISpellcheckIcon.tsx +2 -0
- package/src/ui/icons/AITranslateIcon.tsx +2 -0
- package/src/ui/icons/ClearFormattingIcon.tsx +2 -0
- package/src/ui/icons/NestedDropdownRightIcon.tsx +22 -0
- package/tsconfig.app.json +3 -0
- package/tsconfig.dev.json +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1 +1,19 @@
|
|
|
1
1
|
# @atlaskit/editor-toolbar
|
|
2
|
+
|
|
3
|
+
## 0.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#189216](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/189216)
|
|
8
|
+
[`b4ba899b6cf55`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/b4ba899b6cf55) -
|
|
9
|
+
[ux] ED-28546 add nested flyouts to ui primitive library
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
|
|
12
|
+
## 0.0.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [#187668](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/187668)
|
|
17
|
+
[`83251dd8644c4`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/83251dd8644c4) -
|
|
18
|
+
[ux] [ED-28537] add support for tooltips, disabled states and hover states for new toolbar package
|
|
19
|
+
- Updated dependencies
|
|
@@ -1,15 +1,25 @@
|
|
|
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';
|
|
7
8
|
import { AddIcon } from '../../../src/ui/icons/AddIcon';
|
|
8
9
|
import { AIAdjustLengthIcon } from '../../../src/ui/icons/AIAdjustLengthIcon';
|
|
10
|
+
import { AICasualIcon } from '../../../src/ui/icons/AICasualIcon';
|
|
11
|
+
import { AIChangeToneIcon } from '../../../src/ui/icons/AIChangeToneIcon';
|
|
9
12
|
import { AIChatIcon } from '../../../src/ui/icons/AIChatIcon';
|
|
10
13
|
import { AICommandIcon } from '../../../src/ui/icons/AICommandIcon';
|
|
14
|
+
import { AIHeartIcon } from '../../../src/ui/icons/AIHeartIcon';
|
|
15
|
+
import { AILenghtenIcon } from '../../../src/ui/icons/AILengthenIcon';
|
|
16
|
+
import { AIBriefcaseIcon } from '../../../src/ui/icons/AIProfessionalIcon';
|
|
17
|
+
import { AIShortenIcon } from '../../../src/ui/icons/AIShortenIcon';
|
|
18
|
+
import { AISpellcheckIcon } from '../../../src/ui/icons/AISpellcheckIcon';
|
|
19
|
+
import { AITranslateIcon } from '../../../src/ui/icons/AITranslateIcon';
|
|
11
20
|
import { AppsIcon } from '../../../src/ui/icons/AppsIcon';
|
|
12
21
|
import { BoldIcon } from '../../../src/ui/icons/BoldIcon';
|
|
22
|
+
import { ClearFormattingIcon } from '../../../src/ui/icons/ClearFormattingIcon';
|
|
13
23
|
import { CommentIcon } from '../../../src/ui/icons/CommentIcon';
|
|
14
24
|
import { HeadingFiveIcon } from '../../../src/ui/icons/HeadingFiveIcon';
|
|
15
25
|
import { HeadingFourIcon } from '../../../src/ui/icons/HeadingFourIcon';
|
|
@@ -22,6 +32,7 @@ import { LinkIcon } from '../../../src/ui/icons/LinkIcon';
|
|
|
22
32
|
import { ListBulletedIcon } from '../../../src/ui/icons/ListBulletedIcon';
|
|
23
33
|
import { ListNumberedIcon } from '../../../src/ui/icons/ListNumberedIcon';
|
|
24
34
|
import { MoreItemsIcon } from '../../../src/ui/icons/MoreItemsIcon';
|
|
35
|
+
import { NestedDropdownRightIcon } from '../../../src/ui/icons/NestedDropdownRightIcon';
|
|
25
36
|
import { PinIcon } from '../../../src/ui/icons/PinIcon';
|
|
26
37
|
import { PinnedIcon } from '../../../src/ui/icons/PinnedIcon';
|
|
27
38
|
import { QuoteIcon } from '../../../src/ui/icons/QuoteIcon';
|
|
@@ -31,10 +42,14 @@ import { Toolbar } from '../../../src/ui/Toolbar';
|
|
|
31
42
|
import { ToolbarButton } from '../../../src/ui/ToolbarButton';
|
|
32
43
|
import { ToolbarButtonGroup } from '../../../src/ui/ToolbarButtonGroup';
|
|
33
44
|
import { ToolbarDivider } from '../../../src/ui/ToolbarDivider';
|
|
45
|
+
import { ToolbarDropdownDivider } from '../../../src/ui/ToolbarDropdownDivider';
|
|
34
46
|
import { ToolbarDropdownItem } from '../../../src/ui/ToolbarDropdownItem';
|
|
47
|
+
import { ToolbarDropdownItemSection } from '../../../src/ui/ToolbarDropdownItemSection';
|
|
35
48
|
import { ToolbarDropdownMenu } from '../../../src/ui/ToolbarDropdownMenu';
|
|
36
49
|
import { ToolbarKeyboardShortcutHint } from '../../../src/ui/ToolbarKeyboardShortcutHint';
|
|
50
|
+
import { ToolbarNestedDropdownMenu } from '../../../src/ui/ToolbarNestedDropdownMenu';
|
|
37
51
|
import { ToolbarSection } from '../../../src/ui/ToolbarSection';
|
|
52
|
+
import { ToolbarTooltip } from '../../../src/ui/ToolbarTooltip';
|
|
38
53
|
|
|
39
54
|
import { useExampleToolbarState } from './useExampleToolbarState';
|
|
40
55
|
|
|
@@ -52,37 +67,182 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
52
67
|
lastAction,
|
|
53
68
|
} = useExampleToolbarState();
|
|
54
69
|
|
|
70
|
+
const [isRovoDisabled, setIsRovoDisabled] = useState(false);
|
|
71
|
+
const toggleRovoButton = () => {
|
|
72
|
+
setIsRovoDisabled(!isRovoDisabled);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const [isAdjustLengthDisabled, setIsAdjustLengthDisabled] = useState(false);
|
|
76
|
+
const toggleAdjustLengthButton = () => {
|
|
77
|
+
setIsAdjustLengthDisabled(!isAdjustLengthDisabled);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const [isTextStylesDisabled, setIsTextStylesDisabled] = useState(false);
|
|
81
|
+
const toggleTextStylesButton = () => {
|
|
82
|
+
setIsTextStylesDisabled(!isTextStylesDisabled);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const [isImproveWritingDisabled, setIsImproveWritingDisabled] = useState(false);
|
|
86
|
+
const toggleImproveWritingButton = () => {
|
|
87
|
+
setIsImproveWritingDisabled(!isImproveWritingDisabled);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const [isBoldDisabled, setIsBoldDisabled] = useState(false);
|
|
91
|
+
const toggleBoldStyle = () => {
|
|
92
|
+
setIsBoldDisabled(!isBoldDisabled);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
const [isItalicDisabled, setIsItalicDisabled] = useState(false);
|
|
96
|
+
const toggleItalicStyle = () => {
|
|
97
|
+
setIsItalicDisabled(!isItalicDisabled);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const [isTextColorDisabled, setIsTextColorDisabled] = useState(false);
|
|
101
|
+
const toggleTextColorButton = () => {
|
|
102
|
+
setIsTextColorDisabled(!isTextColorDisabled);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const [isBulletedListDisabled, setIsBulletedListDisabled] = useState(false);
|
|
106
|
+
const toggleBulletedListButton = () => {
|
|
107
|
+
setIsBulletedListDisabled(!isBulletedListDisabled);
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const [isNumberedListDisabled, setIsNumberedListDisabled] = useState(false);
|
|
111
|
+
const toggleNumberedListButton = () => {
|
|
112
|
+
setIsNumberedListDisabled(!isNumberedListDisabled);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const [isLinkDisabled, setIsLinkDisabled] = useState(false);
|
|
116
|
+
const toggleLinkButton = () => {
|
|
117
|
+
setIsLinkDisabled(!isLinkDisabled);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const [isCommentDisabled, setIsCommentDisabled] = useState(false);
|
|
121
|
+
const toggleCommentButton = () => {
|
|
122
|
+
setIsCommentDisabled(!isCommentDisabled);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const [isCreateJiraWorkItemDisabled, setIsCreateJiraWorkItemDisabled] = useState(false);
|
|
126
|
+
const toggleCreateJiraWorkItemButton = () => {
|
|
127
|
+
setIsCreateJiraWorkItemDisabled(!isCreateJiraWorkItemDisabled);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const [isAppsAndExtensionsDisabled, setIsAppsAndExtensionsDisabled] = useState(false);
|
|
131
|
+
const toggleAppsAndExtensionsButton = () => {
|
|
132
|
+
setIsAppsAndExtensionsDisabled(!isAppsAndExtensionsDisabled);
|
|
133
|
+
};
|
|
134
|
+
|
|
55
135
|
return (
|
|
56
136
|
<>
|
|
57
137
|
<Toolbar label="Editor Toolbar">
|
|
58
138
|
<ToolbarSection>
|
|
59
139
|
<ToolbarButtonGroup>
|
|
60
|
-
<
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
</ToolbarButton>
|
|
68
|
-
<ToolbarDropdownMenu icon={MoreItemsIcon} label="More formatting" groupLocation="end">
|
|
69
|
-
<ToolbarDropdownItem
|
|
70
|
-
elemBefore={<AIAdjustLengthIcon label="Adjust length" />}
|
|
71
|
-
onClick={onClick('Adjust length')}
|
|
140
|
+
<ToolbarTooltip content="Ask Rovo">
|
|
141
|
+
<ToolbarButton
|
|
142
|
+
icon={AIChatIcon}
|
|
143
|
+
label="Ask Rovo"
|
|
144
|
+
onClick={onClick('Ask Rovo')}
|
|
145
|
+
groupLocation="start"
|
|
146
|
+
isDisabled={isRovoDisabled}
|
|
72
147
|
>
|
|
73
|
-
|
|
74
|
-
</
|
|
148
|
+
Ask Rovo
|
|
149
|
+
</ToolbarButton>
|
|
150
|
+
</ToolbarTooltip>
|
|
151
|
+
<ToolbarDropdownMenu icon={MoreItemsIcon} label="More formatting" groupLocation="end">
|
|
152
|
+
<ToolbarDropdownItemSection>
|
|
153
|
+
<ToolbarNestedDropdownMenu
|
|
154
|
+
elemBefore={<AIAdjustLengthIcon label="Adjust length" />}
|
|
155
|
+
text="Adjust length"
|
|
156
|
+
elemAfter={<NestedDropdownRightIcon label={'Choose desired tone'}/>}
|
|
157
|
+
isDisabled={isAdjustLengthDisabled}
|
|
158
|
+
>
|
|
159
|
+
<ToolbarDropdownItemSection>
|
|
160
|
+
<ToolbarDropdownItem
|
|
161
|
+
elemBefore={<AIShortenIcon label="Make shorter" />}
|
|
162
|
+
onClick={onClick('Make shorter')}
|
|
163
|
+
>
|
|
164
|
+
Make shorter
|
|
165
|
+
</ToolbarDropdownItem>
|
|
166
|
+
<ToolbarDropdownItem
|
|
167
|
+
elemBefore={<AILenghtenIcon label="Make longer" />}
|
|
168
|
+
onClick={onClick('Make longer')}
|
|
169
|
+
>
|
|
170
|
+
Make longer
|
|
171
|
+
</ToolbarDropdownItem>
|
|
172
|
+
</ToolbarDropdownItemSection>
|
|
173
|
+
</ToolbarNestedDropdownMenu>
|
|
174
|
+
<ToolbarNestedDropdownMenu
|
|
175
|
+
elemBefore={<AIChangeToneIcon label="Change tone" />}
|
|
176
|
+
text="Change tone"
|
|
177
|
+
elemAfter={<NestedDropdownRightIcon label={'Choose desired tone'}/>}
|
|
178
|
+
>
|
|
179
|
+
<ToolbarDropdownItemSection>
|
|
180
|
+
<ToolbarDropdownItem
|
|
181
|
+
elemBefore={<AIBriefcaseIcon label="More professional" />}
|
|
182
|
+
onClick={onClick('More professional')}
|
|
183
|
+
>
|
|
184
|
+
More professional
|
|
185
|
+
</ToolbarDropdownItem>
|
|
186
|
+
<ToolbarDropdownItem
|
|
187
|
+
elemBefore={<AICasualIcon label="More casual" />}
|
|
188
|
+
onClick={onClick('More casual')}
|
|
189
|
+
>
|
|
190
|
+
More casual
|
|
191
|
+
</ToolbarDropdownItem>
|
|
192
|
+
<ToolbarDropdownItem
|
|
193
|
+
elemBefore={<AIHeartIcon label="More empathetic" />}
|
|
194
|
+
onClick={onClick('More empathetic')}
|
|
195
|
+
>
|
|
196
|
+
More empathetic
|
|
197
|
+
</ToolbarDropdownItem>
|
|
198
|
+
</ToolbarDropdownItemSection>
|
|
199
|
+
</ToolbarNestedDropdownMenu>
|
|
200
|
+
<ToolbarDropdownItem
|
|
201
|
+
elemBefore={<AISpellcheckIcon label="Fix spelling and grammar" />}
|
|
202
|
+
onClick={onClick('Fix spelling and grammar')}
|
|
203
|
+
>
|
|
204
|
+
Fix spelling and grammar
|
|
205
|
+
</ToolbarDropdownItem>
|
|
206
|
+
<ToolbarNestedDropdownMenu
|
|
207
|
+
elemBefore={<AITranslateIcon label="Translate" />}
|
|
208
|
+
text="Translate"
|
|
209
|
+
elemAfter={<NestedDropdownRightIcon label={'Choose language option'}/>}
|
|
210
|
+
>
|
|
211
|
+
<ToolbarDropdownItemSection>
|
|
212
|
+
<ToolbarDropdownItem
|
|
213
|
+
elemBefore={<AITranslateIcon label="Language 1" />}
|
|
214
|
+
onClick={onClick('Language 1')}
|
|
215
|
+
>
|
|
216
|
+
Language 1
|
|
217
|
+
</ToolbarDropdownItem>
|
|
218
|
+
<ToolbarDropdownItem
|
|
219
|
+
elemBefore={<AITranslateIcon label="Language 2" />}
|
|
220
|
+
onClick={onClick('More casual')}
|
|
221
|
+
>
|
|
222
|
+
Language 2
|
|
223
|
+
</ToolbarDropdownItem>
|
|
224
|
+
<ToolbarDropdownItem
|
|
225
|
+
elemBefore={<AITranslateIcon label="Language 3" />}
|
|
226
|
+
onClick={onClick('Language 3')}
|
|
227
|
+
>
|
|
228
|
+
Language 3
|
|
229
|
+
</ToolbarDropdownItem>
|
|
230
|
+
</ToolbarDropdownItemSection>
|
|
231
|
+
</ToolbarNestedDropdownMenu>
|
|
232
|
+
</ToolbarDropdownItemSection>
|
|
75
233
|
</ToolbarDropdownMenu>
|
|
76
234
|
</ToolbarButtonGroup>
|
|
77
|
-
|
|
78
235
|
<ToolbarButtonGroup>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
236
|
+
<ToolbarTooltip content="Improve writing">
|
|
237
|
+
<ToolbarButton
|
|
238
|
+
icon={AICommandIcon}
|
|
239
|
+
label="Improve writing"
|
|
240
|
+
onClick={onClick('Improve writing')}
|
|
241
|
+
isDisabled={isImproveWritingDisabled}
|
|
242
|
+
>
|
|
243
|
+
Improve writing
|
|
244
|
+
</ToolbarButton>
|
|
245
|
+
</ToolbarTooltip>
|
|
86
246
|
</ToolbarButtonGroup>
|
|
87
247
|
</ToolbarSection>
|
|
88
248
|
|
|
@@ -90,185 +250,223 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
90
250
|
|
|
91
251
|
<ToolbarSection>
|
|
92
252
|
<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"
|
|
115
|
-
>
|
|
116
|
-
Normal text
|
|
117
|
-
</ToolbarDropdownItem>
|
|
118
|
-
<ToolbarDropdownItem
|
|
119
|
-
elemBefore={<HeadingOneIcon label="Heading One" />}
|
|
120
|
-
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥1" />}
|
|
121
|
-
onClick={onClick('Heading one', onSetTextStyle('heading1'))}
|
|
122
|
-
isSelected={textStyle === 'heading1'}
|
|
123
|
-
textStyle="heading1"
|
|
124
|
-
>
|
|
125
|
-
Heading 1
|
|
126
|
-
</ToolbarDropdownItem>
|
|
127
|
-
<ToolbarDropdownItem
|
|
128
|
-
elemBefore={<HeadingTwoIcon label="Heading Two" />}
|
|
129
|
-
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥2" />}
|
|
130
|
-
onClick={onClick('Heading two', onSetTextStyle('heading2'))}
|
|
131
|
-
isSelected={textStyle === 'heading2'}
|
|
132
|
-
textStyle="heading2"
|
|
133
|
-
>
|
|
134
|
-
Heading 2
|
|
135
|
-
</ToolbarDropdownItem>
|
|
136
|
-
<ToolbarDropdownItem
|
|
137
|
-
elemBefore={<HeadingThreeIcon label="Heading Three" />}
|
|
138
|
-
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥3" />}
|
|
139
|
-
onClick={onClick('Heading three', onSetTextStyle('heading3'))}
|
|
140
|
-
isSelected={textStyle === 'heading3'}
|
|
141
|
-
textStyle="heading3"
|
|
142
|
-
>
|
|
143
|
-
Heading 3
|
|
144
|
-
</ToolbarDropdownItem>
|
|
145
|
-
<ToolbarDropdownItem
|
|
146
|
-
elemBefore={<HeadingFourIcon label="Heading Four" />}
|
|
147
|
-
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥4" />}
|
|
148
|
-
onClick={onClick('Heading four', onSetTextStyle('heading4'))}
|
|
149
|
-
isSelected={textStyle === 'heading4'}
|
|
150
|
-
textStyle="heading4"
|
|
253
|
+
<ToolbarTooltip content="Text styles">
|
|
254
|
+
<ToolbarDropdownMenu
|
|
255
|
+
icon={
|
|
256
|
+
{
|
|
257
|
+
none: TextIcon,
|
|
258
|
+
normal: TextIcon,
|
|
259
|
+
heading1: HeadingOneIcon,
|
|
260
|
+
heading2: HeadingTwoIcon,
|
|
261
|
+
heading3: HeadingThreeIcon,
|
|
262
|
+
heading4: HeadingFourIcon,
|
|
263
|
+
heading5: HeadingFiveIcon,
|
|
264
|
+
heading6: HeadingSixIcon,
|
|
265
|
+
quote: QuoteIcon,
|
|
266
|
+
}[textStyle]
|
|
267
|
+
}
|
|
268
|
+
label="Text styles"
|
|
269
|
+
isDisabled={isTextStylesDisabled}
|
|
151
270
|
>
|
|
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
|
-
|
|
271
|
+
<ToolbarDropdownItemSection>
|
|
272
|
+
<ToolbarDropdownItem
|
|
273
|
+
elemBefore={<TextIcon label="Normal text" />}
|
|
274
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥0" />}
|
|
275
|
+
onClick={onClick('Normal text', onSetTextStyle('normal'))}
|
|
276
|
+
isSelected={textStyle === 'normal'}
|
|
277
|
+
textStyle="normal"
|
|
278
|
+
>
|
|
279
|
+
Normal text
|
|
280
|
+
</ToolbarDropdownItem>
|
|
281
|
+
<ToolbarDropdownItem
|
|
282
|
+
elemBefore={<HeadingOneIcon label="Heading One" />}
|
|
283
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥1" />}
|
|
284
|
+
onClick={onClick('Heading one', onSetTextStyle('heading1'))}
|
|
285
|
+
isSelected={textStyle === 'heading1'}
|
|
286
|
+
textStyle="heading1"
|
|
287
|
+
>
|
|
288
|
+
Heading 1
|
|
289
|
+
</ToolbarDropdownItem>
|
|
290
|
+
<ToolbarDropdownItem
|
|
291
|
+
elemBefore={<HeadingTwoIcon label="Heading Two" />}
|
|
292
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥2" />}
|
|
293
|
+
onClick={onClick('Heading two', onSetTextStyle('heading2'))}
|
|
294
|
+
isSelected={textStyle === 'heading2'}
|
|
295
|
+
textStyle="heading2"
|
|
296
|
+
>
|
|
297
|
+
Heading 2
|
|
298
|
+
</ToolbarDropdownItem>
|
|
299
|
+
<ToolbarDropdownItem
|
|
300
|
+
elemBefore={<HeadingThreeIcon label="Heading Three" />}
|
|
301
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥3" />}
|
|
302
|
+
onClick={onClick('Heading three', onSetTextStyle('heading3'))}
|
|
303
|
+
isSelected={textStyle === 'heading3'}
|
|
304
|
+
textStyle="heading3"
|
|
305
|
+
>
|
|
306
|
+
Heading 3
|
|
307
|
+
</ToolbarDropdownItem>
|
|
308
|
+
<ToolbarDropdownItem
|
|
309
|
+
elemBefore={<HeadingFourIcon label="Heading Four" />}
|
|
310
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥4" />}
|
|
311
|
+
onClick={onClick('Heading four', onSetTextStyle('heading4'))}
|
|
312
|
+
isSelected={textStyle === 'heading4'}
|
|
313
|
+
textStyle="heading4"
|
|
314
|
+
>
|
|
315
|
+
Heading 4
|
|
316
|
+
</ToolbarDropdownItem>
|
|
317
|
+
<ToolbarDropdownItem
|
|
318
|
+
elemBefore={<HeadingFiveIcon label="Heading Five" />}
|
|
319
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥5" />}
|
|
320
|
+
onClick={onClick('Heading five', onSetTextStyle('heading5'))}
|
|
321
|
+
isSelected={textStyle === 'heading5'}
|
|
322
|
+
textStyle="heading5"
|
|
323
|
+
>
|
|
324
|
+
Heading 5
|
|
325
|
+
</ToolbarDropdownItem>
|
|
326
|
+
<ToolbarDropdownItem
|
|
327
|
+
elemBefore={<HeadingSixIcon label="Heading Six" />}
|
|
328
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥6" />}
|
|
329
|
+
onClick={onClick('Heading six', onSetTextStyle('heading6'))}
|
|
330
|
+
isSelected={textStyle === 'heading6'}
|
|
331
|
+
textStyle="heading6"
|
|
332
|
+
>
|
|
333
|
+
Heading 6
|
|
334
|
+
</ToolbarDropdownItem>
|
|
335
|
+
<ToolbarDropdownItem
|
|
336
|
+
elemBefore={<QuoteIcon label="Quote" />}
|
|
337
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⌥9" />}
|
|
338
|
+
onClick={onClick('Quote', onSetTextStyle('quote'))}
|
|
339
|
+
isSelected={textStyle === 'quote'}
|
|
340
|
+
textStyle="normal"
|
|
341
|
+
>
|
|
342
|
+
Quote
|
|
343
|
+
</ToolbarDropdownItem>
|
|
344
|
+
</ToolbarDropdownItemSection>
|
|
345
|
+
</ToolbarDropdownMenu>
|
|
346
|
+
</ToolbarTooltip>
|
|
182
347
|
</ToolbarButtonGroup>
|
|
183
348
|
|
|
184
349
|
<ToolbarButtonGroup>
|
|
185
|
-
<
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
350
|
+
<ToolbarTooltip content={formatting.italic && !formatting.bold ? 'Italic' : 'Bold'}>
|
|
351
|
+
<ToolbarButton
|
|
352
|
+
icon={formatting.italic && !formatting.bold ? ItalicIcon : BoldIcon}
|
|
353
|
+
label={formatting.italic && !formatting.bold ? 'Italic' : 'Bold'}
|
|
354
|
+
onClick={onClick(
|
|
355
|
+
formatting.italic && !formatting.bold ? 'Italic' : 'Bold',
|
|
356
|
+
onToggleFormatting(formatting.italic && !formatting.bold ? 'italic' : 'bold'),
|
|
357
|
+
)}
|
|
358
|
+
groupLocation="start"
|
|
359
|
+
isSelected={formatting.bold || formatting.italic}
|
|
360
|
+
isDisabled={formatting.italic ? isItalicDisabled : isBoldDisabled}
|
|
361
|
+
/>
|
|
362
|
+
</ToolbarTooltip>
|
|
195
363
|
<ToolbarDropdownMenu icon={MoreItemsIcon} label="More formatting" groupLocation="end">
|
|
196
|
-
<
|
|
364
|
+
<ToolbarDropdownItemSection>
|
|
365
|
+
<ToolbarDropdownItem
|
|
197
366
|
elemBefore={<BoldIcon label="Bold" />}
|
|
198
367
|
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘B" />}
|
|
199
368
|
onClick={onClick('Bold', onToggleFormatting('bold'))}
|
|
200
369
|
isSelected={formatting.bold}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
370
|
+
isDisabled={isBoldDisabled}
|
|
371
|
+
>
|
|
372
|
+
Bold
|
|
373
|
+
</ToolbarDropdownItem>
|
|
374
|
+
<ToolbarDropdownItem
|
|
375
|
+
elemBefore={<ItalicIcon label="Italic" />}
|
|
376
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘I" />}
|
|
377
|
+
onClick={onClick('Italic', onToggleFormatting('italic'))}
|
|
378
|
+
isSelected={formatting.italic}
|
|
379
|
+
isDisabled={isItalicDisabled}
|
|
380
|
+
>
|
|
381
|
+
Italic
|
|
382
|
+
</ToolbarDropdownItem>
|
|
383
|
+
</ToolbarDropdownItemSection>
|
|
384
|
+
<ToolbarDropdownDivider/>
|
|
385
|
+
<ToolbarDropdownItemSection>
|
|
386
|
+
<ToolbarDropdownItem
|
|
387
|
+
elemBefore={<ClearFormattingIcon label="Clear formatting" />}
|
|
388
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘\" />}
|
|
389
|
+
onClick={onClick('Clear formatting')}
|
|
390
|
+
>
|
|
391
|
+
Clear formatting
|
|
392
|
+
</ToolbarDropdownItem>
|
|
393
|
+
</ToolbarDropdownItemSection>
|
|
212
394
|
</ToolbarDropdownMenu>
|
|
213
395
|
</ToolbarButtonGroup>
|
|
214
396
|
|
|
215
397
|
<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')}
|
|
398
|
+
<ToolbarTooltip content="Text color">
|
|
399
|
+
<ToolbarDropdownMenu
|
|
400
|
+
icon={({ label, color, shouldRecommendSmallIcon, size, spacing, testId }) => (
|
|
401
|
+
<ColorIndicatorWrapper color={token('color.border.accent.blue')}>
|
|
402
|
+
<TextColorIcon
|
|
403
|
+
label={label}
|
|
404
|
+
color={color}
|
|
405
|
+
shouldRecommendSmallIcon={shouldRecommendSmallIcon}
|
|
406
|
+
size={size}
|
|
407
|
+
spacing={spacing}
|
|
408
|
+
testId={testId}
|
|
409
|
+
/>
|
|
410
|
+
</ColorIndicatorWrapper>
|
|
411
|
+
)}
|
|
412
|
+
label="Text color"
|
|
413
|
+
isDisabled={isTextColorDisabled}
|
|
234
414
|
>
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
415
|
+
<ToolbarDropdownItemSection>
|
|
416
|
+
<ToolbarDropdownItem
|
|
417
|
+
elemBefore={<TextIcon label="Text color" />}
|
|
418
|
+
onClick={onClick('Text color')}
|
|
419
|
+
>
|
|
420
|
+
Text color
|
|
421
|
+
</ToolbarDropdownItem>
|
|
422
|
+
</ToolbarDropdownItemSection>
|
|
423
|
+
</ToolbarDropdownMenu>
|
|
424
|
+
</ToolbarTooltip>
|
|
238
425
|
</ToolbarButtonGroup>
|
|
239
426
|
|
|
240
427
|
<ToolbarButtonGroup>
|
|
241
|
-
<
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
listOrAlignment === 'numbered' ?
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
428
|
+
<ToolbarTooltip
|
|
429
|
+
content={listOrAlignment === 'numbered' ? 'Numbered list' : 'Bulleted list'}
|
|
430
|
+
>
|
|
431
|
+
<ToolbarButton
|
|
432
|
+
icon={listOrAlignment === 'numbered' ? ListNumberedIcon : ListBulletedIcon}
|
|
433
|
+
label={listOrAlignment === 'numbered' ? 'Numbered list' : 'Bulleted list'}
|
|
434
|
+
onClick={onClick(
|
|
435
|
+
listOrAlignment === 'numbered' ? 'Numbered list' : 'Bulleted list',
|
|
436
|
+
onToggleListOrAlignment(listOrAlignment === 'numbered' ? 'numbered' : 'bulleted'),
|
|
437
|
+
)}
|
|
438
|
+
groupLocation="start"
|
|
439
|
+
isSelected={listOrAlignment !== 'none'}
|
|
440
|
+
isDisabled={
|
|
441
|
+
listOrAlignment === 'numbered' ? isNumberedListDisabled : isBulletedListDisabled
|
|
442
|
+
}
|
|
443
|
+
/>
|
|
444
|
+
</ToolbarTooltip>
|
|
251
445
|
<ToolbarDropdownMenu
|
|
252
446
|
icon={MoreItemsIcon}
|
|
253
447
|
label="Lists, indentation and alignment"
|
|
254
448
|
groupLocation="end"
|
|
255
449
|
>
|
|
256
|
-
<
|
|
450
|
+
<ToolbarDropdownItemSection>
|
|
451
|
+
<ToolbarDropdownItem
|
|
257
452
|
elemBefore={<ListBulletedIcon label="Bulleted list" />}
|
|
258
453
|
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⇧8" />}
|
|
259
454
|
onClick={onClick('Bulleted list', onToggleListOrAlignment('bulleted'))}
|
|
260
455
|
isSelected={listOrAlignment === 'bulleted'}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
456
|
+
isDisabled={isBulletedListDisabled}
|
|
457
|
+
>
|
|
458
|
+
Bulleted list
|
|
459
|
+
</ToolbarDropdownItem>
|
|
460
|
+
<ToolbarDropdownItem
|
|
461
|
+
elemBefore={<ListNumberedIcon label="Numbered list" />}
|
|
462
|
+
elemAfter={<ToolbarKeyboardShortcutHint shortcut="⌘⇧7" />}
|
|
463
|
+
onClick={onClick('Numbered list', onToggleListOrAlignment('numbered'))}
|
|
464
|
+
isSelected={listOrAlignment === 'numbered'}
|
|
465
|
+
isDisabled={isNumberedListDisabled}
|
|
466
|
+
>
|
|
467
|
+
Numbered list
|
|
468
|
+
</ToolbarDropdownItem>
|
|
469
|
+
</ToolbarDropdownItemSection>
|
|
272
470
|
</ToolbarDropdownMenu>
|
|
273
471
|
</ToolbarButtonGroup>
|
|
274
472
|
</ToolbarSection>
|
|
@@ -277,7 +475,14 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
277
475
|
|
|
278
476
|
<ToolbarSection>
|
|
279
477
|
<ToolbarButtonGroup>
|
|
280
|
-
<
|
|
478
|
+
<ToolbarTooltip content="Link">
|
|
479
|
+
<ToolbarButton
|
|
480
|
+
icon={LinkIcon}
|
|
481
|
+
label="Link"
|
|
482
|
+
onClick={onClick('Link')}
|
|
483
|
+
isDisabled={isLinkDisabled}
|
|
484
|
+
/>
|
|
485
|
+
</ToolbarTooltip>
|
|
281
486
|
</ToolbarButtonGroup>
|
|
282
487
|
</ToolbarSection>
|
|
283
488
|
|
|
@@ -285,7 +490,14 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
285
490
|
|
|
286
491
|
<ToolbarSection>
|
|
287
492
|
<ToolbarButtonGroup>
|
|
288
|
-
<
|
|
493
|
+
<ToolbarTooltip content="Comment">
|
|
494
|
+
<ToolbarButton
|
|
495
|
+
icon={CommentIcon}
|
|
496
|
+
label="Comment"
|
|
497
|
+
onClick={onClick('Comment')}
|
|
498
|
+
isDisabled={isCommentDisabled}
|
|
499
|
+
/>
|
|
500
|
+
</ToolbarTooltip>
|
|
289
501
|
</ToolbarButtonGroup>
|
|
290
502
|
</ToolbarSection>
|
|
291
503
|
|
|
@@ -293,14 +505,23 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
293
505
|
|
|
294
506
|
<ToolbarSection>
|
|
295
507
|
<ToolbarButtonGroup>
|
|
296
|
-
<
|
|
297
|
-
<
|
|
298
|
-
|
|
299
|
-
|
|
508
|
+
<ToolbarTooltip content="Apps and extensions">
|
|
509
|
+
<ToolbarDropdownMenu
|
|
510
|
+
icon={AppsIcon}
|
|
511
|
+
label="Apps and extensions"
|
|
512
|
+
isDisabled={isAppsAndExtensionsDisabled}
|
|
300
513
|
>
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
514
|
+
<ToolbarDropdownItemSection>
|
|
515
|
+
<ToolbarDropdownItem
|
|
516
|
+
elemBefore={<AddIcon label="Create Jira work item" />}
|
|
517
|
+
onClick={onClick('Create Jira work item')}
|
|
518
|
+
isDisabled={isCreateJiraWorkItemDisabled}
|
|
519
|
+
>
|
|
520
|
+
Create Jira work item
|
|
521
|
+
</ToolbarDropdownItem>
|
|
522
|
+
</ToolbarDropdownItemSection>
|
|
523
|
+
</ToolbarDropdownMenu>
|
|
524
|
+
</ToolbarTooltip>
|
|
304
525
|
</ToolbarButtonGroup>
|
|
305
526
|
</ToolbarSection>
|
|
306
527
|
|
|
@@ -308,14 +529,18 @@ export const ExampleManuallyComposedToolbar = () => {
|
|
|
308
529
|
|
|
309
530
|
<ToolbarSection>
|
|
310
531
|
<ToolbarButtonGroup>
|
|
311
|
-
<
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
pinning === 'pinned' ?
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
532
|
+
<ToolbarTooltip
|
|
533
|
+
content={pinning === 'pinned' ? 'Unpin the toolbar' : 'Pin the toolbar at the top'}
|
|
534
|
+
>
|
|
535
|
+
<ToolbarButton
|
|
536
|
+
icon={pinning === 'pinned' ? PinnedIcon : PinIcon}
|
|
537
|
+
label={pinning === 'pinned' ? 'Unpin toolbar' : 'Pin toolbar'}
|
|
538
|
+
onClick={onClick(
|
|
539
|
+
pinning === 'pinned' ? 'Unpin toolbar' : 'Pin toolbar',
|
|
540
|
+
onTogglePinning,
|
|
541
|
+
)}
|
|
542
|
+
/>
|
|
543
|
+
</ToolbarTooltip>
|
|
319
544
|
</ToolbarButtonGroup>
|
|
320
545
|
</ToolbarSection>
|
|
321
546
|
</Toolbar>
|
|
@@ -331,6 +556,60 @@ List/Align: ${listOrAlignment}
|
|
|
331
556
|
Pinning: ${pinning}
|
|
332
557
|
`}
|
|
333
558
|
</Box>
|
|
559
|
+
<Box>
|
|
560
|
+
<div>
|
|
561
|
+
Disable Rovo Button
|
|
562
|
+
<Toggle onChange={toggleRovoButton} />
|
|
563
|
+
</div>
|
|
564
|
+
<div>
|
|
565
|
+
Disable Adjust Length Button
|
|
566
|
+
<Toggle onChange={toggleAdjustLengthButton} />
|
|
567
|
+
</div>
|
|
568
|
+
<div>
|
|
569
|
+
Disable Improve Writing Button
|
|
570
|
+
<Toggle onChange={toggleImproveWritingButton} />
|
|
571
|
+
</div>
|
|
572
|
+
<div>
|
|
573
|
+
Disable Text Styles
|
|
574
|
+
<Toggle onChange={toggleTextStylesButton} />
|
|
575
|
+
</div>
|
|
576
|
+
<div>
|
|
577
|
+
Disable Bold Formatting
|
|
578
|
+
<Toggle onChange={toggleBoldStyle} />
|
|
579
|
+
</div>
|
|
580
|
+
<div>
|
|
581
|
+
Disable Italic Formatting
|
|
582
|
+
<Toggle onChange={toggleItalicStyle} />
|
|
583
|
+
</div>
|
|
584
|
+
<div>
|
|
585
|
+
Disable Text Color
|
|
586
|
+
<Toggle onChange={toggleTextColorButton} />
|
|
587
|
+
</div>
|
|
588
|
+
<div>
|
|
589
|
+
Disable Bulleted List
|
|
590
|
+
<Toggle onChange={toggleBulletedListButton} />
|
|
591
|
+
</div>
|
|
592
|
+
<div>
|
|
593
|
+
Disable Numbered List
|
|
594
|
+
<Toggle onChange={toggleNumberedListButton} />
|
|
595
|
+
</div>
|
|
596
|
+
<div>
|
|
597
|
+
Disable Link
|
|
598
|
+
<Toggle onChange={toggleLinkButton} />
|
|
599
|
+
</div>
|
|
600
|
+
<div>
|
|
601
|
+
Disable Comment
|
|
602
|
+
<Toggle onChange={toggleCommentButton} />
|
|
603
|
+
</div>
|
|
604
|
+
<div>
|
|
605
|
+
Disable Apps and Extensions
|
|
606
|
+
<Toggle onChange={toggleAppsAndExtensionsButton} />
|
|
607
|
+
</div>
|
|
608
|
+
<div>
|
|
609
|
+
Disable Create Jira Work Item
|
|
610
|
+
<Toggle onChange={toggleCreateJiraWorkItemButton} />
|
|
611
|
+
</div>
|
|
612
|
+
</Box>
|
|
334
613
|
</>
|
|
335
614
|
);
|
|
336
615
|
};
|
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.2",
|
|
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.3.0",
|
|
30
|
+
"@atlaskit/icon": "^27.7.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,21 @@ 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
|
|
115
|
+
? ICON_COLOR.disabled
|
|
116
|
+
: isSelected
|
|
117
|
+
? ICON_COLOR.selected
|
|
118
|
+
: ICON_COLOR.default;
|
|
99
119
|
return (
|
|
100
120
|
<Pressable
|
|
101
121
|
ref={ref}
|
|
102
122
|
xcss={cx(
|
|
103
123
|
styles.button,
|
|
104
|
-
isSelected
|
|
124
|
+
isDisabled ? styles.disabled : isSelected ? styles.selected : styles.enabled,
|
|
105
125
|
groupLocation === 'start' && styles.groupStart,
|
|
106
126
|
groupLocation === 'middle' && styles.groupMiddle,
|
|
107
127
|
groupLocation === 'end' && styles.groupEnd,
|
|
@@ -114,12 +134,9 @@ export const ToolbarButton = forwardRef(
|
|
|
114
134
|
onBlur={onBlur}
|
|
115
135
|
onFocus={onFocus}
|
|
116
136
|
testId={testId}
|
|
137
|
+
isDisabled={isDisabled}
|
|
117
138
|
>
|
|
118
|
-
<IconComponent
|
|
119
|
-
label={label}
|
|
120
|
-
size="medium"
|
|
121
|
-
color={isSelected ? token('color.icon.selected') : token('color.icon.subtle')}
|
|
122
|
-
/>
|
|
139
|
+
<IconComponent label={label} size="medium" color={iconColor} />
|
|
123
140
|
{children}
|
|
124
141
|
</Pressable>
|
|
125
142
|
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cssMap } from '@atlaskit/css';
|
|
4
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
5
|
+
import { token } from '@atlaskit/tokens';
|
|
6
|
+
|
|
7
|
+
const styles = cssMap({
|
|
8
|
+
divider: {
|
|
9
|
+
borderBottomColor: token('color.border'),
|
|
10
|
+
borderBottomStyle: 'solid',
|
|
11
|
+
borderBottomWidth: token('border.width'),
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export const ToolbarDropdownDivider = () => {
|
|
16
|
+
return <Box xcss={styles.divider} />;
|
|
17
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import React, { type ReactNode } from 'react';
|
|
1
|
+
import React, { type ReactNode, forwardRef, type Ref } from 'react';
|
|
2
2
|
|
|
3
3
|
import { cssMap, cx } from '@atlaskit/css';
|
|
4
4
|
import { DropdownItem } from '@atlaskit/dropdown-menu';
|
|
5
|
+
import type { CustomItemComponentProps } from '@atlaskit/menu/types';
|
|
5
6
|
import { Box, Pressable } from '@atlaskit/primitives/compiled';
|
|
6
7
|
import { token } from '@atlaskit/tokens';
|
|
7
8
|
|
|
@@ -22,23 +23,29 @@ const styles = cssMap({
|
|
|
22
23
|
minHeight: '36px',
|
|
23
24
|
paddingLeft: token('space.150'),
|
|
24
25
|
paddingRight: token('space.150'),
|
|
25
|
-
|
|
26
|
+
'&:focus-visible': {
|
|
27
|
+
outlineOffset: token('space.negative.025'),
|
|
28
|
+
borderRadius: token('border.radius'),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
enabled: {
|
|
26
32
|
'&:hover': {
|
|
27
33
|
backgroundColor: token('color.background.neutral.subtle.hovered'),
|
|
28
34
|
},
|
|
29
|
-
|
|
30
35
|
'&:active': {
|
|
31
36
|
backgroundColor: token('color.background.neutral.subtle.pressed'),
|
|
32
37
|
},
|
|
33
38
|
},
|
|
39
|
+
disabled: {
|
|
40
|
+
color: token('color.text.disabled'),
|
|
41
|
+
cursor: 'not-allowed',
|
|
42
|
+
},
|
|
34
43
|
selected: {
|
|
35
44
|
backgroundColor: token('color.background.selected'),
|
|
36
45
|
color: token('color.text.selected'),
|
|
37
|
-
|
|
38
46
|
'&:hover': {
|
|
39
47
|
backgroundColor: token('color.background.selected.hovered'),
|
|
40
48
|
},
|
|
41
|
-
|
|
42
49
|
'&:active': {
|
|
43
50
|
backgroundColor: token('color.background.selected.pressed'),
|
|
44
51
|
},
|
|
@@ -66,13 +73,48 @@ const styles = cssMap({
|
|
|
66
73
|
},
|
|
67
74
|
});
|
|
68
75
|
|
|
76
|
+
export type CustomDropdownMenuItemButtonProps = CustomItemComponentProps & {
|
|
77
|
+
'aria-haspopup'?: boolean;
|
|
78
|
+
'aria-disabled'?: boolean;
|
|
79
|
+
'aria-pressed'?: boolean;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const CustomDropdownMenuItemButton = forwardRef<HTMLButtonElement, CustomDropdownMenuItemButtonProps>(({
|
|
83
|
+
children,
|
|
84
|
+
'data-testid': testId,
|
|
85
|
+
'aria-haspopup': ariaHasPopup,
|
|
86
|
+
'aria-disabled': ariaDisabled,
|
|
87
|
+
'aria-pressed': ariaPressed,
|
|
88
|
+
onClick,
|
|
89
|
+
tabIndex,
|
|
90
|
+
}, ref) =>
|
|
91
|
+
<Pressable
|
|
92
|
+
testId={testId}
|
|
93
|
+
xcss={cx(styles.toolbarDropdownItem, ariaDisabled ? styles.disabled : ariaPressed ? styles.selected : styles.enabled)}
|
|
94
|
+
onClick={onClick}
|
|
95
|
+
tabIndex={tabIndex}
|
|
96
|
+
aria-haspopup={ariaHasPopup}
|
|
97
|
+
aria-expanded={ariaHasPopup ? ariaPressed ? true : false : undefined}
|
|
98
|
+
aria-pressed={ariaPressed}
|
|
99
|
+
aria-disabled={ariaDisabled}
|
|
100
|
+
ref={ref}
|
|
101
|
+
>
|
|
102
|
+
{children}
|
|
103
|
+
</Pressable>
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
69
107
|
type ToolbarDropdownItemProps = {
|
|
70
|
-
onClick:
|
|
108
|
+
onClick?: (e: React.MouseEvent | React.KeyboardEvent) => void;
|
|
71
109
|
elemBefore?: ReactNode;
|
|
72
110
|
elemAfter?: ReactNode;
|
|
73
111
|
isSelected?: boolean;
|
|
74
112
|
children?: React.ReactNode;
|
|
75
113
|
textStyle?: TextStyle;
|
|
114
|
+
isDisabled?: boolean;
|
|
115
|
+
hasNestedDropdownMenu?: boolean;
|
|
116
|
+
triggerRef?: Ref<HTMLButtonElement>
|
|
117
|
+
testId?: string;
|
|
76
118
|
};
|
|
77
119
|
|
|
78
120
|
export const ToolbarDropdownItem = ({
|
|
@@ -82,40 +124,22 @@ export const ToolbarDropdownItem = ({
|
|
|
82
124
|
isSelected,
|
|
83
125
|
children,
|
|
84
126
|
textStyle = 'normal',
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
testId={testId}
|
|
105
|
-
xcss={cx(styles.toolbarDropdownItem, isSelected && styles.selected)}
|
|
106
|
-
isDisabled={disabled}
|
|
107
|
-
draggable={draggable}
|
|
108
|
-
onClick={onClick}
|
|
109
|
-
onDragStart={onDragStart}
|
|
110
|
-
onMouseDown={onMouseDown}
|
|
111
|
-
tabIndex={tabIndex}
|
|
112
|
-
ref={ref}
|
|
113
|
-
>
|
|
114
|
-
{children}
|
|
115
|
-
</Pressable>
|
|
116
|
-
)}
|
|
117
|
-
>
|
|
118
|
-
<Box xcss={styles[textStyle]}>{children}</Box>
|
|
119
|
-
</DropdownItem>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
127
|
+
isDisabled,
|
|
128
|
+
hasNestedDropdownMenu,
|
|
129
|
+
triggerRef,
|
|
130
|
+
testId,
|
|
131
|
+
}: ToolbarDropdownItemProps) =>
|
|
132
|
+
<DropdownItem
|
|
133
|
+
onClick={onClick}
|
|
134
|
+
elemBefore={elemBefore}
|
|
135
|
+
elemAfter={elemAfter}
|
|
136
|
+
isSelected={isSelected}
|
|
137
|
+
isDisabled={isDisabled}
|
|
138
|
+
aria-haspopup={hasNestedDropdownMenu}
|
|
139
|
+
aria-pressed={isSelected}
|
|
140
|
+
ref={triggerRef}
|
|
141
|
+
component={CustomDropdownMenuItemButton}
|
|
142
|
+
testId={testId}
|
|
143
|
+
>
|
|
144
|
+
<Box xcss={styles[textStyle]}>{children}</Box>
|
|
145
|
+
</DropdownItem>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { cssMap } from '@atlaskit/css';
|
|
4
|
+
import { Box } from '@atlaskit/primitives/compiled';
|
|
5
|
+
|
|
6
|
+
const styles = cssMap({
|
|
7
|
+
container: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flexDirection: 'column',
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
type ToolbarDropdownItemSectionProps = {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const ToolbarDropdownItemSection = ({ children }: ToolbarDropdownItemSectionProps) => {
|
|
18
|
+
return <Box xcss={styles.container}>{children}</Box>;
|
|
19
|
+
};
|
|
@@ -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,43 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import DropdownMenu from '@atlaskit/dropdown-menu';
|
|
4
|
+
|
|
5
|
+
import { ToolbarDropdownItem } from './ToolbarDropdownItem';
|
|
6
|
+
|
|
7
|
+
type ToolbarNestedDropdownMenuProps = {
|
|
8
|
+
elemBefore: ReactNode;
|
|
9
|
+
elemAfter: ReactNode;
|
|
10
|
+
text?: string;
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
isDisabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const ToolbarNestedDropdownMenu = ({
|
|
16
|
+
elemBefore,
|
|
17
|
+
text,
|
|
18
|
+
elemAfter,
|
|
19
|
+
children,
|
|
20
|
+
isDisabled,
|
|
21
|
+
}: ToolbarNestedDropdownMenuProps) => {
|
|
22
|
+
return (
|
|
23
|
+
<DropdownMenu<HTMLButtonElement>
|
|
24
|
+
placement="right-start"
|
|
25
|
+
trigger={(triggerProps) => (
|
|
26
|
+
<ToolbarDropdownItem
|
|
27
|
+
elemBefore={elemBefore}
|
|
28
|
+
elemAfter={elemAfter}
|
|
29
|
+
isSelected={triggerProps.isSelected}
|
|
30
|
+
onClick={triggerProps.onClick}
|
|
31
|
+
testId={triggerProps.testId}
|
|
32
|
+
triggerRef={triggerProps.triggerRef}
|
|
33
|
+
hasNestedDropdownMenu={true}
|
|
34
|
+
isDisabled={isDisabled}
|
|
35
|
+
>
|
|
36
|
+
{text}
|
|
37
|
+
</ToolbarDropdownItem>
|
|
38
|
+
)}
|
|
39
|
+
>
|
|
40
|
+
{children}
|
|
41
|
+
</DropdownMenu>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
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 <Tooltip content={content}>{children}</Tooltip>;
|
|
12
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import Icon from '@atlaskit/icon/core/chevron-right';
|
|
4
|
+
|
|
5
|
+
import { type IconComponent } from '../../types';
|
|
6
|
+
|
|
7
|
+
export const NestedDropdownRightIcon: IconComponent = ({
|
|
8
|
+
label,
|
|
9
|
+
testId,
|
|
10
|
+
color,
|
|
11
|
+
shouldRecommendSmallIcon,
|
|
12
|
+
spacing,
|
|
13
|
+
}) => (
|
|
14
|
+
<Icon
|
|
15
|
+
label={label}
|
|
16
|
+
testId={testId}
|
|
17
|
+
color={color}
|
|
18
|
+
shouldRecommendSmallIcon={shouldRecommendSmallIcon}
|
|
19
|
+
spacing={spacing}
|
|
20
|
+
size="small"
|
|
21
|
+
/>
|
|
22
|
+
);
|
package/tsconfig.app.json
CHANGED