@patternfly/react-core 5.0.0-alpha.63 → 5.0.0-alpha.65
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 +10 -0
- package/dist/esm/components/Sidebar/Sidebar.d.ts +2 -0
- package/dist/esm/components/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/esm/components/Sidebar/Sidebar.js +2 -2
- package/dist/esm/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/esm/components/Sidebar/SidebarContent.d.ts +2 -0
- package/dist/esm/components/Sidebar/SidebarContent.d.ts.map +1 -1
- package/dist/esm/components/Sidebar/SidebarContent.js +2 -2
- package/dist/esm/components/Sidebar/SidebarContent.js.map +1 -1
- package/dist/esm/components/Sidebar/SidebarPanel.d.ts +2 -0
- package/dist/esm/components/Sidebar/SidebarPanel.d.ts.map +1 -1
- package/dist/esm/components/Sidebar/SidebarPanel.js +2 -2
- package/dist/esm/components/Sidebar/SidebarPanel.js.map +1 -1
- package/dist/js/components/Sidebar/Sidebar.d.ts +2 -0
- package/dist/js/components/Sidebar/Sidebar.d.ts.map +1 -1
- package/dist/js/components/Sidebar/Sidebar.js +2 -2
- package/dist/js/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/js/components/Sidebar/SidebarContent.d.ts +2 -0
- package/dist/js/components/Sidebar/SidebarContent.d.ts.map +1 -1
- package/dist/js/components/Sidebar/SidebarContent.js +2 -2
- package/dist/js/components/Sidebar/SidebarContent.js.map +1 -1
- package/dist/js/components/Sidebar/SidebarPanel.d.ts +2 -0
- package/dist/js/components/Sidebar/SidebarPanel.d.ts.map +1 -1
- package/dist/js/components/Sidebar/SidebarPanel.js +2 -2
- package/dist/js/components/Sidebar/SidebarPanel.js.map +1 -1
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +2 -2
- package/src/components/MenuToggle/examples/MenuToggle.md +85 -78
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonAction.tsx +10 -11
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckbox.tsx +4 -17
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckboxWithText.tsx +10 -11
- package/src/components/MenuToggle/examples/MenuToggleTypeahead.tsx +35 -0
- package/src/components/Sidebar/Sidebar.tsx +4 -1
- package/src/components/Sidebar/SidebarContent.tsx +12 -1
- package/src/components/Sidebar/SidebarPanel.tsx +4 -0
- package/src/components/Sidebar/__tests__/Sidebar.test.tsx +5 -0
- package/src/components/Sidebar/__tests__/SidebarContent.test.tsx +5 -0
- package/src/components/Sidebar/__tests__/SidebarPanel.test.tsx +6 -1
- package/src/components/Sidebar/examples/Sidebar.md +12 -0
- package/src/components/Sidebar/examples/SidebarBorder.tsx +24 -0
- package/src/components/Sidebar/examples/SidebarPaddingContent.tsx +25 -0
- package/src/components/Sidebar/examples/SidebarPaddingPanel.tsx +24 -0
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonActionPrimary.tsx +0 -58
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonActionSecondary.tsx +0 -58
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckboxPrimary.tsx +0 -55
- package/src/components/MenuToggle/examples/MenuToggleSplitButtonCheckboxSecondary.tsx +0 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.65",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^17 || ^18",
|
|
71
71
|
"react-dom": "^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "30672fcc0c5cb9f955dcec4249deb8363a739f87"
|
|
74
74
|
}
|
|
@@ -11,10 +11,13 @@ import './MenuToggle.css'
|
|
|
11
11
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
12
12
|
import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon';
|
|
13
13
|
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
14
|
+
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
14
15
|
|
|
15
16
|
## Examples
|
|
16
17
|
|
|
17
|
-
### Collapsed
|
|
18
|
+
### Collapsed toggle
|
|
19
|
+
|
|
20
|
+
A toggle is collapsed until it is selected by a user.
|
|
18
21
|
|
|
19
22
|
```ts
|
|
20
23
|
import React from 'react';
|
|
@@ -24,7 +27,9 @@ import { MenuToggle } from '@patternfly/react-core';
|
|
|
24
27
|
|
|
25
28
|
```
|
|
26
29
|
|
|
27
|
-
### Expanded
|
|
30
|
+
### Expanded toggle
|
|
31
|
+
|
|
32
|
+
When a user selects a toggle, it becomes expanded and is styled with a blue underline. To flag expanded toggles, and apply expanded styling, use the `isExpanded` property .
|
|
28
33
|
|
|
29
34
|
```ts
|
|
30
35
|
import React from 'react';
|
|
@@ -34,7 +39,9 @@ import { MenuToggle } from '@patternfly/react-core';
|
|
|
34
39
|
|
|
35
40
|
```
|
|
36
41
|
|
|
37
|
-
### Disabled
|
|
42
|
+
### Disabled toggle
|
|
43
|
+
|
|
44
|
+
To disable the selection and expansion of a toggle, use the `isDisabled` property.
|
|
38
45
|
|
|
39
46
|
```ts
|
|
40
47
|
import React from 'react';
|
|
@@ -44,7 +51,9 @@ import { MenuToggle } from '@patternfly/react-core';
|
|
|
44
51
|
|
|
45
52
|
```
|
|
46
53
|
|
|
47
|
-
###
|
|
54
|
+
### With a badge
|
|
55
|
+
|
|
56
|
+
To display a count of selected items in a toggle, use the `badge` property.
|
|
48
57
|
|
|
49
58
|
```ts
|
|
50
59
|
import React from 'react';
|
|
@@ -54,7 +63,9 @@ import { MenuToggle, Badge } from '@patternfly/react-core';
|
|
|
54
63
|
|
|
55
64
|
```
|
|
56
65
|
|
|
57
|
-
###
|
|
66
|
+
### With icons
|
|
67
|
+
|
|
68
|
+
To add a recognizable icon to a menu toggle, use the `icon` property. The following example adds a `CogIcon` to the toggle.
|
|
58
69
|
|
|
59
70
|
```ts
|
|
60
71
|
import React from 'react';
|
|
@@ -62,21 +73,33 @@ import { MenuToggle } from '@patternfly/react-core';
|
|
|
62
73
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
63
74
|
|
|
64
75
|
<React.Fragment>
|
|
65
|
-
<MenuToggle variant="primary">
|
|
66
|
-
<MenuToggle
|
|
67
|
-
|
|
68
|
-
</MenuToggle>{' '}
|
|
69
|
-
<MenuToggle variant="primary" isExpanded>
|
|
70
|
-
Expanded
|
|
71
|
-
</MenuToggle>{' '}
|
|
72
|
-
<MenuToggle variant="primary" isDisabled>
|
|
73
|
-
Disabled
|
|
74
|
-
</MenuToggle>
|
|
76
|
+
<MenuToggle icon={<CogIcon />} variant="primary">Icon</MenuToggle>{' '}
|
|
77
|
+
<MenuToggle icon={<CogIcon />} variant="secondary">Icon</MenuToggle>{' '}
|
|
78
|
+
<MenuToggle icon={<CogIcon />} variant="secondary" isDisabled>Icon</MenuToggle>
|
|
75
79
|
</React.Fragment>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### With avatar and text
|
|
76
83
|
|
|
84
|
+
You can also pass images into the `icon` property. The following example passes in an `<Avatar>` component with an `imgAvatar`.
|
|
85
|
+
|
|
86
|
+
This can be used alongside a text label that provides more context for the image.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import React from 'react';
|
|
90
|
+
import { MenuToggle, Avatar } from '@patternfly/react-core';
|
|
91
|
+
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
92
|
+
|
|
93
|
+
<React.Fragment>
|
|
94
|
+
<MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />}>Ned Username</MenuToggle>{' '}
|
|
95
|
+
<MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />} isExpanded>Ned Username</MenuToggle>{' '}
|
|
96
|
+
<MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />} isDisabled>Ned Username</MenuToggle>
|
|
97
|
+
</React.Fragment>
|
|
77
98
|
```
|
|
78
99
|
|
|
79
|
-
###
|
|
100
|
+
### Variant styles
|
|
101
|
+
|
|
102
|
+
Variant styling can be applied to menu toggles. In the following example, the toggle uses primary styling by passing `variant="primary"` into the `<MenuToggle>` component. Additional variant options include “default”, “plain”, “plainText”, “secondary”, and “typeahead”.
|
|
80
103
|
|
|
81
104
|
```ts
|
|
82
105
|
import React from 'react';
|
|
@@ -84,21 +107,22 @@ import { MenuToggle } from '@patternfly/react-core';
|
|
|
84
107
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
85
108
|
|
|
86
109
|
<React.Fragment>
|
|
87
|
-
<MenuToggle variant="
|
|
88
|
-
|
|
89
|
-
Icon
|
|
90
|
-
</MenuToggle>{' '}
|
|
91
|
-
<MenuToggle variant="secondary" isExpanded>
|
|
110
|
+
<MenuToggle variant="primary">Collapsed</MenuToggle>{' '}
|
|
111
|
+
<MenuToggle variant="primary" isExpanded>
|
|
92
112
|
Expanded
|
|
93
113
|
</MenuToggle>{' '}
|
|
94
|
-
<MenuToggle variant="
|
|
114
|
+
<MenuToggle variant="primary" isDisabled>
|
|
95
115
|
Disabled
|
|
96
116
|
</MenuToggle>
|
|
97
117
|
</React.Fragment>
|
|
98
118
|
|
|
99
119
|
```
|
|
100
120
|
|
|
101
|
-
### Plain
|
|
121
|
+
### Plain toggle with icon
|
|
122
|
+
|
|
123
|
+
To apply plain styling to a menu toggle with an icon, pass in `variant="plain"`. This will remove the default bottom border and caret. You may pass in an `icon` to serve as the menu toggle. The following example passes in an `EllipsisVIcon`.
|
|
124
|
+
|
|
125
|
+
If the toggle does not have any visible text content, use the `aria-label` property to provide an accessible name.
|
|
102
126
|
|
|
103
127
|
```ts
|
|
104
128
|
import React from 'react';
|
|
@@ -108,16 +132,18 @@ import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-ico
|
|
|
108
132
|
<React.Fragment>
|
|
109
133
|
<MenuToggle variant="plain" aria-label="plain kebab">
|
|
110
134
|
<EllipsisVIcon />
|
|
111
|
-
</MenuToggle>
|
|
135
|
+
</MenuToggle>{' '}
|
|
112
136
|
<MenuToggle variant="plain" isExpanded aria-label="plain expanded kebab">
|
|
113
137
|
<EllipsisVIcon />
|
|
114
|
-
</MenuToggle>
|
|
138
|
+
</MenuToggle>{' '}
|
|
115
139
|
<MenuToggle variant="plain" isDisabled aria-label="disabled kebab">
|
|
116
140
|
<EllipsisVIcon />
|
|
117
141
|
</MenuToggle>
|
|
118
142
|
</React.Fragment>
|
|
119
143
|
```
|
|
120
|
-
### Plain with text
|
|
144
|
+
### Plain toggle with text label
|
|
145
|
+
|
|
146
|
+
To apply plain styling to a menu toggle with a text label, pass in `variant="plainText"`. Unlike the “plain” variant, “plainText” adds a caret pointing down in the toggle.
|
|
121
147
|
|
|
122
148
|
```ts
|
|
123
149
|
import React from 'react';
|
|
@@ -126,80 +152,48 @@ import { MenuToggle } from '@patternfly/react-core';
|
|
|
126
152
|
<React.Fragment>
|
|
127
153
|
<MenuToggle variant="plainText" isDisabled aria-label="Disabled plain menu toggle">
|
|
128
154
|
Disabled
|
|
129
|
-
</MenuToggle>
|
|
130
|
-
|
|
155
|
+
</MenuToggle>{' '}
|
|
131
156
|
<MenuToggle variant="plainText" aria-label="Plain menu toggle">
|
|
132
157
|
Custom text
|
|
133
|
-
</MenuToggle>
|
|
158
|
+
</MenuToggle>{' '}
|
|
134
159
|
<MenuToggle variant="plainText" isExpanded aria-label="Expanded plain menu toggle">
|
|
135
160
|
Custom text (expanded)
|
|
136
161
|
</MenuToggle>
|
|
137
162
|
</React.Fragment>
|
|
138
163
|
```
|
|
139
164
|
|
|
140
|
-
### Split button
|
|
141
|
-
|
|
142
|
-
```ts file='MenuToggleSplitButtonCheckbox.tsx'
|
|
143
|
-
```
|
|
165
|
+
### Split button toggle with checkbox
|
|
144
166
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
```ts file='MenuToggleSplitButtonCheckboxWithText.tsx'
|
|
148
|
-
```
|
|
167
|
+
To add an action button or other control to a menu toggle, use a split button. A `<MenuToggle>` can be rendered as a split button by adding a `splitButtonOptions` object. Elements to be displayed before the toggle button must be included in the `items` property of `splitButtonOptions`.
|
|
149
168
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
```ts file='MenuToggleSplitButtonCheckboxPrimary.tsx'
|
|
153
|
-
```
|
|
169
|
+
The following example shows a split button with a `<MenuToggleCheckbox>`.
|
|
154
170
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
```ts file='MenuToggleSplitButtonCheckboxSecondary.tsx'
|
|
158
|
-
```
|
|
171
|
+
Variant styling can be applied to split button toggles to adjust their appearance for different scenarios. Both "primary" and "secondary" variants can be used with split button toggles.
|
|
159
172
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
```ts file='MenuToggleSplitButtonAction.tsx'
|
|
173
|
+
```ts file='MenuToggleSplitButtonCheckbox.tsx'
|
|
163
174
|
```
|
|
164
175
|
|
|
165
|
-
### Split button
|
|
166
|
-
|
|
167
|
-
```ts file='MenuToggleSplitButtonActionPrimary.tsx'
|
|
168
|
-
```
|
|
176
|
+
### Split button toggle with text label
|
|
169
177
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
```ts file='
|
|
178
|
+
To display text in a split button menu toggle, add a label to the `items` property of `splitButtonOptions`.
|
|
179
|
+
|
|
180
|
+
```ts file='MenuToggleSplitButtonCheckboxWithText.tsx'
|
|
173
181
|
```
|
|
174
182
|
|
|
175
|
-
###
|
|
183
|
+
### Split button toggle with action
|
|
176
184
|
|
|
177
|
-
|
|
178
|
-
import React from 'react';
|
|
179
|
-
import { MenuToggle, Avatar } from '@patternfly/react-core';
|
|
180
|
-
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
185
|
+
To add an action to a split button, pass `variant='action'` into `splitButtonOptions` and add a `<MenuToggleAction>` to the `items` property of `splitButtonOptions`.
|
|
181
186
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
</React.Fragment>
|
|
187
|
+
Actions may be used with primary and secondary toggle variants.
|
|
188
|
+
|
|
189
|
+
```ts file='MenuToggleSplitButtonAction.tsx'
|
|
186
190
|
```
|
|
187
191
|
|
|
188
|
-
###
|
|
192
|
+
### Full height toggle
|
|
189
193
|
|
|
190
|
-
|
|
191
|
-
import React from 'react';
|
|
192
|
-
import { MenuToggle, Avatar } from '@patternfly/react-core';
|
|
193
|
-
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
194
|
+
A full height toggle fills the height of its parent. To flag a full height toggle, use the `isFullHeight` property.
|
|
194
195
|
|
|
195
|
-
|
|
196
|
-
<MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />}>Ned Username</MenuToggle>{' '}
|
|
197
|
-
<MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />} isExpanded>Ned Username</MenuToggle>{' '}
|
|
198
|
-
<MenuToggle icon={<Avatar src={imgAvatar} alt="avatar" />} isDisabled>Ned Username</MenuToggle>
|
|
199
|
-
</React.Fragment>
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### Full height
|
|
196
|
+
In the following example, the toggle fills the size of the "80px" `<div>` element that it is within.
|
|
203
197
|
|
|
204
198
|
```ts
|
|
205
199
|
import React from 'react';
|
|
@@ -212,7 +206,11 @@ import { MenuToggle } from '@patternfly/react-core';
|
|
|
212
206
|
</div>
|
|
213
207
|
```
|
|
214
208
|
|
|
215
|
-
### Full width
|
|
209
|
+
### Full width toggle
|
|
210
|
+
|
|
211
|
+
A full width toggle fills the width of its parent. To flag a full width toggle, use the `isFullWidth` property.
|
|
212
|
+
|
|
213
|
+
In the following example, the toggle fills the width of its parent as the window size changes.
|
|
216
214
|
|
|
217
215
|
```ts
|
|
218
216
|
import React from 'react';
|
|
@@ -226,3 +224,12 @@ const fullWidth: React.FunctionComponent = () => {
|
|
|
226
224
|
);
|
|
227
225
|
}
|
|
228
226
|
```
|
|
227
|
+
|
|
228
|
+
### Typeahead toggle
|
|
229
|
+
|
|
230
|
+
To create a typeahead toggle, pass in `variant="typeahead"` to the `<MenuToggle>`. Then, pass a `<TextInputGroup>` component as a child of the `<MenuToggle>`.
|
|
231
|
+
|
|
232
|
+
To create a multiple typeahead toggle, pass a `<TextInputGroup>` component implemented like the [text input group's filter example](/components/text-input-group#filters) as a child of `<MenuToggle>`.
|
|
233
|
+
|
|
234
|
+
```ts file='MenuToggleTypeahead.tsx'
|
|
235
|
+
```
|
|
@@ -4,16 +4,10 @@ import { MenuToggleAction, MenuToggle } from '@patternfly/react-core';
|
|
|
4
4
|
export const MenuToggleSplitButtonAction: React.FunctionComponent = () => (
|
|
5
5
|
<React.Fragment>
|
|
6
6
|
<MenuToggle
|
|
7
|
-
isDisabled
|
|
8
7
|
splitButtonOptions={{
|
|
9
8
|
variant: 'action',
|
|
10
9
|
items: [
|
|
11
|
-
<MenuToggleAction
|
|
12
|
-
id="split-button-action-disabled-example-with-toggle-button"
|
|
13
|
-
key="split-action-disabled"
|
|
14
|
-
aria-label="Action"
|
|
15
|
-
isDisabled
|
|
16
|
-
>
|
|
10
|
+
<MenuToggleAction id="split-button-action-example-with-toggle-button" key="split-action" aria-label="Action">
|
|
17
11
|
Action
|
|
18
12
|
</MenuToggleAction>
|
|
19
13
|
]
|
|
@@ -21,10 +15,15 @@ export const MenuToggleSplitButtonAction: React.FunctionComponent = () => (
|
|
|
21
15
|
aria-label="Menu toggle with action split button"
|
|
22
16
|
/>{' '}
|
|
23
17
|
<MenuToggle
|
|
18
|
+
variant="primary"
|
|
24
19
|
splitButtonOptions={{
|
|
25
20
|
variant: 'action',
|
|
26
21
|
items: [
|
|
27
|
-
<MenuToggleAction
|
|
22
|
+
<MenuToggleAction
|
|
23
|
+
id="split-button-action-primary-example-with-toggle-button"
|
|
24
|
+
key="split-action-primary"
|
|
25
|
+
aria-label="Action"
|
|
26
|
+
>
|
|
28
27
|
Action
|
|
29
28
|
</MenuToggleAction>
|
|
30
29
|
]
|
|
@@ -32,13 +31,13 @@ export const MenuToggleSplitButtonAction: React.FunctionComponent = () => (
|
|
|
32
31
|
aria-label="Menu toggle with action split button"
|
|
33
32
|
/>{' '}
|
|
34
33
|
<MenuToggle
|
|
35
|
-
|
|
34
|
+
variant="secondary"
|
|
36
35
|
splitButtonOptions={{
|
|
37
36
|
variant: 'action',
|
|
38
37
|
items: [
|
|
39
38
|
<MenuToggleAction
|
|
40
|
-
id="split-button-action-
|
|
41
|
-
key="split-action-
|
|
39
|
+
id="split-button-action-secondary-example-with-toggle-button"
|
|
40
|
+
key="split-action-secondary"
|
|
42
41
|
aria-label="Action"
|
|
43
42
|
>
|
|
44
43
|
Action
|
|
@@ -4,35 +4,22 @@ import { MenuToggleCheckbox, MenuToggle } from '@patternfly/react-core';
|
|
|
4
4
|
export const MenuToggleSplitButtonCheckbox: React.FunctionComponent = () => (
|
|
5
5
|
<React.Fragment>
|
|
6
6
|
<MenuToggle
|
|
7
|
-
isDisabled
|
|
8
7
|
splitButtonOptions={{
|
|
9
|
-
items: [
|
|
10
|
-
<MenuToggleCheckbox
|
|
11
|
-
id="split-button-checkbox-disabled-example"
|
|
12
|
-
key="split-checkbox-disabled"
|
|
13
|
-
aria-label="Select all"
|
|
14
|
-
isDisabled
|
|
15
|
-
/>
|
|
16
|
-
]
|
|
8
|
+
items: [<MenuToggleCheckbox id="split-button-checkbox-example" key="split-checkbox" aria-label="Select all" />]
|
|
17
9
|
}}
|
|
18
10
|
aria-label="Menu toggle with checkbox split button"
|
|
19
11
|
/>{' '}
|
|
20
12
|
<MenuToggle
|
|
13
|
+
variant="primary"
|
|
21
14
|
splitButtonOptions={{
|
|
22
15
|
items: [<MenuToggleCheckbox id="split-button-checkbox-example" key="split-checkbox" aria-label="Select all" />]
|
|
23
16
|
}}
|
|
24
17
|
aria-label="Menu toggle with checkbox split button"
|
|
25
18
|
/>{' '}
|
|
26
19
|
<MenuToggle
|
|
27
|
-
|
|
20
|
+
variant="secondary"
|
|
28
21
|
splitButtonOptions={{
|
|
29
|
-
items: [
|
|
30
|
-
<MenuToggleCheckbox
|
|
31
|
-
id="split-button-checkbox-expanded-example"
|
|
32
|
-
key="split-checkbox-expanded"
|
|
33
|
-
aria-label="Select all"
|
|
34
|
-
/>
|
|
35
|
-
]
|
|
22
|
+
items: [<MenuToggleCheckbox id="split-button-checkbox-example" key="split-checkbox" aria-label="Select all" />]
|
|
36
23
|
}}
|
|
37
24
|
aria-label="Menu toggle with checkbox split button"
|
|
38
25
|
/>
|
|
@@ -4,14 +4,12 @@ import { MenuToggleCheckbox, MenuToggle } from '@patternfly/react-core';
|
|
|
4
4
|
export const MenuToggleSplitButtonCheckboxWithText: React.FunctionComponent = () => (
|
|
5
5
|
<React.Fragment>
|
|
6
6
|
<MenuToggle
|
|
7
|
-
isDisabled
|
|
8
7
|
splitButtonOptions={{
|
|
9
8
|
items: [
|
|
10
9
|
<MenuToggleCheckbox
|
|
11
|
-
id="split-button-checkbox-with-text-
|
|
12
|
-
key="split-checkbox-with-text
|
|
10
|
+
id="split-button-checkbox-with-text-example"
|
|
11
|
+
key="split-checkbox-with-text"
|
|
13
12
|
aria-label="Select all"
|
|
14
|
-
isDisabled
|
|
15
13
|
>
|
|
16
14
|
10 selected
|
|
17
15
|
</MenuToggleCheckbox>
|
|
@@ -20,33 +18,34 @@ export const MenuToggleSplitButtonCheckboxWithText: React.FunctionComponent = ()
|
|
|
20
18
|
aria-label="Menu toggle with checkbox split button and text"
|
|
21
19
|
/>{' '}
|
|
22
20
|
<MenuToggle
|
|
21
|
+
variant="primary"
|
|
23
22
|
splitButtonOptions={{
|
|
24
23
|
items: [
|
|
25
24
|
<MenuToggleCheckbox
|
|
26
|
-
id="split-button-checkbox-
|
|
27
|
-
key="split-checkbox-
|
|
25
|
+
id="split-button-checkbox-primary-example"
|
|
26
|
+
key="split-checkbox-primary"
|
|
28
27
|
aria-label="Select all"
|
|
29
28
|
>
|
|
30
29
|
10 selected
|
|
31
30
|
</MenuToggleCheckbox>
|
|
32
31
|
]
|
|
33
32
|
}}
|
|
34
|
-
aria-label="
|
|
33
|
+
aria-label="Primary menu toggle with checkbox split button"
|
|
35
34
|
/>{' '}
|
|
36
35
|
<MenuToggle
|
|
37
|
-
|
|
36
|
+
variant="secondary"
|
|
38
37
|
splitButtonOptions={{
|
|
39
38
|
items: [
|
|
40
39
|
<MenuToggleCheckbox
|
|
41
|
-
id="split-button-checkbox-
|
|
42
|
-
key="split-checkbox-
|
|
40
|
+
id="split-button-checkbox-secondary-example"
|
|
41
|
+
key="split-checkbox-secondary"
|
|
43
42
|
aria-label="Select all"
|
|
44
43
|
>
|
|
45
44
|
10 selected
|
|
46
45
|
</MenuToggleCheckbox>
|
|
47
46
|
]
|
|
48
47
|
}}
|
|
49
|
-
aria-label="
|
|
48
|
+
aria-label="Secondary menu toggle with checkbox split button"
|
|
50
49
|
/>
|
|
51
50
|
</React.Fragment>
|
|
52
51
|
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MenuToggle, TextInputGroup, TextInputGroupMain, TextInputGroupUtilities, Button } from '@patternfly/react-core';
|
|
3
|
+
import TimesIcon from '@patternfly/react-icons/dist/esm/icons/times-icon';
|
|
4
|
+
|
|
5
|
+
export const MenuToggleTypeahead: React.FunctionComponent = () => {
|
|
6
|
+
const [inputValue, setInputValue] = React.useState<string>('');
|
|
7
|
+
|
|
8
|
+
const onTextInputChange = (_event: React.FormEvent<HTMLInputElement>, value: string) => {
|
|
9
|
+
setInputValue(value);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<MenuToggle
|
|
14
|
+
variant="typeahead"
|
|
15
|
+
isFullWidth
|
|
16
|
+
>
|
|
17
|
+
<TextInputGroup isPlain>
|
|
18
|
+
<TextInputGroupMain
|
|
19
|
+
value={inputValue}
|
|
20
|
+
onChange={onTextInputChange}
|
|
21
|
+
id="typeahead-select-input"
|
|
22
|
+
autoComplete="off"
|
|
23
|
+
/>
|
|
24
|
+
|
|
25
|
+
<TextInputGroupUtilities>
|
|
26
|
+
{!!inputValue && (
|
|
27
|
+
<Button variant="plain" onClick={() => setInputValue('')} aria-label="Clear input value">
|
|
28
|
+
<TimesIcon aria-hidden />
|
|
29
|
+
</Button>
|
|
30
|
+
)}
|
|
31
|
+
</TextInputGroupUtilities>
|
|
32
|
+
</TextInputGroup>
|
|
33
|
+
</MenuToggle>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -12,6 +12,8 @@ export interface SidebarProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
12
12
|
hasGutter?: boolean;
|
|
13
13
|
/** Removes the background color. */
|
|
14
14
|
hasNoBackground?: boolean;
|
|
15
|
+
/** Adds a border between the panel and content. */
|
|
16
|
+
hasBorder?: boolean;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
export const Sidebar: React.FunctionComponent<SidebarProps> = ({
|
|
@@ -21,6 +23,7 @@ export const Sidebar: React.FunctionComponent<SidebarProps> = ({
|
|
|
21
23
|
isPanelRight = false,
|
|
22
24
|
hasGutter,
|
|
23
25
|
hasNoBackground,
|
|
26
|
+
hasBorder,
|
|
24
27
|
...props
|
|
25
28
|
}: SidebarProps) => (
|
|
26
29
|
<div
|
|
@@ -34,7 +37,7 @@ export const Sidebar: React.FunctionComponent<SidebarProps> = ({
|
|
|
34
37
|
)}
|
|
35
38
|
{...props}
|
|
36
39
|
>
|
|
37
|
-
<div className={styles.sidebarMain}>{children}</div>
|
|
40
|
+
<div className={css(styles.sidebarMain, hasBorder && styles.modifiers.border)}>{children}</div>
|
|
38
41
|
</div>
|
|
39
42
|
);
|
|
40
43
|
Sidebar.displayName = 'Sidebar';
|
|
@@ -6,15 +6,26 @@ export interface SidebarContentProps extends React.HTMLProps<HTMLDivElement> {
|
|
|
6
6
|
children: React.ReactNode;
|
|
7
7
|
/** Removes the background color. */
|
|
8
8
|
hasNoBackground?: boolean;
|
|
9
|
+
/** Adds padding to the content. */
|
|
10
|
+
hasPadding?: boolean;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
13
|
export const SidebarContent: React.FunctionComponent<SidebarContentProps> = ({
|
|
12
14
|
className,
|
|
13
15
|
children,
|
|
14
16
|
hasNoBackground,
|
|
17
|
+
hasPadding,
|
|
15
18
|
...props
|
|
16
19
|
}: SidebarContentProps) => (
|
|
17
|
-
<div
|
|
20
|
+
<div
|
|
21
|
+
className={css(
|
|
22
|
+
styles.sidebarContent,
|
|
23
|
+
hasNoBackground && styles.modifiers.noBackground,
|
|
24
|
+
hasPadding && styles.modifiers.padding,
|
|
25
|
+
className
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
>
|
|
18
29
|
{children}
|
|
19
30
|
</div>
|
|
20
31
|
);
|
|
@@ -19,6 +19,8 @@ export interface SidebarPanelProps extends Omit<React.HTMLProps<HTMLDivElement>,
|
|
|
19
19
|
variant?: 'default' | 'sticky' | 'static';
|
|
20
20
|
/** Removes the background color. */
|
|
21
21
|
hasNoBackground?: boolean;
|
|
22
|
+
/** Adds padding to the panel. */
|
|
23
|
+
hasPadding?: boolean;
|
|
22
24
|
/** Sets the panel width at various breakpoints. Default is 250px when the orientation is split. */
|
|
23
25
|
width?: {
|
|
24
26
|
default?: 'default' | 'width_25' | 'width_33' | 'width_50' | 'width_66' | 'width_75' | 'width_100';
|
|
@@ -35,6 +37,7 @@ export const SidebarPanel: React.FunctionComponent<SidebarPanelProps> = ({
|
|
|
35
37
|
children,
|
|
36
38
|
variant = 'default',
|
|
37
39
|
hasNoBackground,
|
|
40
|
+
hasPadding,
|
|
38
41
|
width,
|
|
39
42
|
...props
|
|
40
43
|
}: SidebarPanelProps) => (
|
|
@@ -43,6 +46,7 @@ export const SidebarPanel: React.FunctionComponent<SidebarPanelProps> = ({
|
|
|
43
46
|
styles.sidebarPanel,
|
|
44
47
|
variant !== 'default' && styles.modifiers[variant],
|
|
45
48
|
hasNoBackground && styles.modifiers.noBackground,
|
|
49
|
+
hasPadding && styles.modifiers.padding,
|
|
46
50
|
formatBreakpointMods(width, styles),
|
|
47
51
|
className
|
|
48
52
|
)}
|
|
@@ -36,6 +36,11 @@ test('Renders with class name pf-m-no-background when hasNoBackground prop is pa
|
|
|
36
36
|
expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-no-background');
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
test('Renders with class name pf-m-border when hasBorder prop is passed', () => {
|
|
40
|
+
render(<Sidebar hasBorder>Test</Sidebar>);
|
|
41
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-border');
|
|
42
|
+
});
|
|
43
|
+
|
|
39
44
|
test('Renders with class name pf-m-stack when "stack" is passed to orientation prop', () => {
|
|
40
45
|
render(<Sidebar orientation="stack">Test</Sidebar>);
|
|
41
46
|
expect(screen.getByText('Test').parentElement).toHaveClass('pf-m-stack');
|
|
@@ -27,6 +27,11 @@ test('Renders with class name pf-m-no-background when hasNoBackground prop is pa
|
|
|
27
27
|
expect(screen.getByText('Test')).toHaveClass('pf-m-no-background');
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
+
test('Renders with class name pf-m-padding when hasPadding prop is passed', () => {
|
|
31
|
+
render(<SidebarContent hasPadding>Test</SidebarContent>);
|
|
32
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-padding');
|
|
33
|
+
});
|
|
34
|
+
|
|
30
35
|
test('Renders with inherited element props spread to the component', () => {
|
|
31
36
|
render(<SidebarContent aria-label="Test label">Test</SidebarContent>);
|
|
32
37
|
expect(screen.getByText('Test')).toHaveAccessibleName('Test label');
|
|
@@ -37,7 +37,12 @@ test('Renders with class name pf-m-no-background when hasNoBackground prop is pa
|
|
|
37
37
|
expect(screen.getByText('Test')).toHaveClass('pf-m-no-background');
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
test('Renders with class name pf-m-padding when hasPadding prop is passed', () => {
|
|
41
|
+
render(<SidebarPanel hasPadding>Test</SidebarPanel>);
|
|
42
|
+
expect(screen.getByText('Test')).toHaveClass('pf-m-padding');
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
['width_25', 'width_33', 'width_50', 'width_66', 'width_75', 'width_100'].forEach((widthType) => {
|
|
41
46
|
test(`Renders with appropriate class names when ${widthType} is passed to each breakpoint of width prop`, () => {
|
|
42
47
|
render(
|
|
43
48
|
<SidebarPanel
|
|
@@ -32,3 +32,15 @@ A `tabIndex` should be added to the `Sidebar` when there is scrollable content i
|
|
|
32
32
|
A `tabIndex` should be added to the `Sidebar` when there is scrollable content in order for the overflow content to be accessible by keyboard.
|
|
33
33
|
```ts file="./SidebarResponsivePanel.tsx"
|
|
34
34
|
```
|
|
35
|
+
|
|
36
|
+
### Border
|
|
37
|
+
```ts file="./SidebarBorder.tsx"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Padding on panel
|
|
41
|
+
```ts file="./SidebarPaddingPanel.tsx"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Padding on content
|
|
45
|
+
```ts file="./SidebarPaddingContent.tsx"
|
|
46
|
+
```
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Sidebar, SidebarContent, SidebarPanel } from '@patternfly/react-core';
|
|
3
|
+
|
|
4
|
+
export const SidebarBorder: React.FunctionComponent = () => (
|
|
5
|
+
<Sidebar hasBorder hasGutter>
|
|
6
|
+
<SidebarPanel>Sidebar panel</SidebarPanel>
|
|
7
|
+
<SidebarContent>
|
|
8
|
+
<p>
|
|
9
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dapibus nulla id augue dictum commodo.
|
|
10
|
+
Donec mollis arcu massa, sollicitudin venenatis est rutrum vitae. Integer pulvinar ligula at augue mollis, ac
|
|
11
|
+
pulvinar arcu semper. Maecenas nisi lorem, malesuada ac lectus nec, porta pretium neque. Ut convallis libero sit
|
|
12
|
+
amet metus mattis, vel facilisis lorem malesuada. Duis consectetur ante sit amet magna efficitur, a interdum leo
|
|
13
|
+
vulputate.
|
|
14
|
+
</p>
|
|
15
|
+
<p>
|
|
16
|
+
Praesent at odio nec sapien ultrices tincidunt in non mauris. Orci varius natoque penatibus et magnis dis
|
|
17
|
+
parturient montes, nascetur ridiculus mus. Duis consectetur nisl quis facilisis faucibus. Sed eu bibendum risus.
|
|
18
|
+
Suspendisse porta euismod tortor, at elementum odio suscipit sed. Cras eget ultrices urna, ac feugiat lectus.
|
|
19
|
+
Integer a pharetra velit, in imperdiet mi. Phasellus vel hendrerit velit. Vestibulum ut augue vitae erat
|
|
20
|
+
vulputate bibendum a ut magna.
|
|
21
|
+
</p>
|
|
22
|
+
</SidebarContent>
|
|
23
|
+
</Sidebar>
|
|
24
|
+
);
|