@patternfly/react-core 4.192.6 → 4.192.7
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 +8 -0
- package/dist/esm/components/Masthead/Masthead.d.ts.map +1 -1
- package/dist/esm/components/Masthead/Masthead.js +6 -2
- package/dist/esm/components/Masthead/Masthead.js.map +1 -1
- package/dist/esm/components/Nav/Nav.d.ts +4 -2
- package/dist/esm/components/Nav/Nav.d.ts.map +1 -1
- package/dist/esm/components/Nav/Nav.js +2 -1
- package/dist/esm/components/Nav/Nav.js.map +1 -1
- package/dist/esm/components/Nav/NavList.d.ts +2 -8
- package/dist/esm/components/Nav/NavList.d.ts.map +1 -1
- package/dist/esm/components/Nav/NavList.js +4 -7
- package/dist/esm/components/Nav/NavList.js.map +1 -1
- package/dist/esm/components/Page/Page.d.ts +14 -0
- package/dist/esm/components/Page/Page.d.ts.map +1 -1
- package/dist/esm/components/Page/Page.js +31 -16
- package/dist/esm/components/Page/Page.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js +3 -1
- package/dist/esm/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js +7 -1
- package/dist/esm/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/esm/components/Page/PageSidebar.d.ts +1 -0
- package/dist/esm/components/Page/PageSidebar.d.ts.map +1 -1
- package/dist/esm/components/Page/PageSidebar.js +3 -2
- package/dist/esm/components/Page/PageSidebar.js.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/Toolbar.js +3 -2
- package/dist/esm/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarContent.js +3 -2
- package/dist/esm/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js +2 -1
- package/dist/esm/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarItem.js +3 -2
- package/dist/esm/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js +8 -5
- package/dist/esm/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/esm/helpers/util.d.ts +16 -8
- package/dist/esm/helpers/util.d.ts.map +1 -1
- package/dist/esm/helpers/util.js +53 -7
- package/dist/esm/helpers/util.js.map +1 -1
- package/dist/js/components/Masthead/Masthead.d.ts.map +1 -1
- package/dist/js/components/Masthead/Masthead.js +6 -2
- package/dist/js/components/Masthead/Masthead.js.map +1 -1
- package/dist/js/components/Nav/Nav.d.ts +4 -2
- package/dist/js/components/Nav/Nav.d.ts.map +1 -1
- package/dist/js/components/Nav/Nav.js +3 -2
- package/dist/js/components/Nav/Nav.js.map +1 -1
- package/dist/js/components/Nav/NavList.d.ts +2 -8
- package/dist/js/components/Nav/NavList.d.ts.map +1 -1
- package/dist/js/components/Nav/NavList.js +4 -7
- package/dist/js/components/Nav/NavList.js.map +1 -1
- package/dist/js/components/Page/Page.d.ts +14 -0
- package/dist/js/components/Page/Page.d.ts.map +1 -1
- package/dist/js/components/Page/Page.js +34 -19
- package/dist/js/components/Page/Page.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.d.ts.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.js +3 -1
- package/dist/js/components/Page/PageHeaderToolsGroup.js.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsItem.d.ts.map +1 -1
- package/dist/js/components/Page/PageHeaderToolsItem.js +6 -1
- package/dist/js/components/Page/PageHeaderToolsItem.js.map +1 -1
- package/dist/js/components/Page/PageSidebar.d.ts +1 -0
- package/dist/js/components/Page/PageSidebar.d.ts.map +1 -1
- package/dist/js/components/Page/PageSidebar.js +4 -3
- package/dist/js/components/Page/PageSidebar.js.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/js/components/Toolbar/Toolbar.js +3 -2
- package/dist/js/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarContent.js +3 -2
- package/dist/js/components/Toolbar/ToolbarContent.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarGroup.js +2 -1
- package/dist/js/components/Toolbar/ToolbarGroup.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarItem.js +3 -2
- package/dist/js/components/Toolbar/ToolbarItem.js.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.d.ts.map +1 -1
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js +7 -4
- package/dist/js/components/Toolbar/ToolbarToggleGroup.js.map +1 -1
- package/dist/js/helpers/util.d.ts +16 -8
- package/dist/js/helpers/util.d.ts.map +1 -1
- package/dist/js/helpers/util.js +55 -8
- package/dist/js/helpers/util.js.map +1 -1
- package/dist/umd/react-core.css +913 -913
- package/dist/umd/react-core.js +420 -347
- package/dist/umd/react-core.min.css +72 -72
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +5 -5
- package/src/components/Masthead/Masthead.tsx +23 -16
- package/src/components/Masthead/__tests__/__snapshots__/Masthead.test.tsx.snap +11 -11
- package/src/components/Nav/Nav.tsx +4 -2
- package/src/components/Nav/NavList.tsx +4 -7
- package/src/components/Page/Page.tsx +49 -16
- package/src/components/Page/PageHeaderToolsGroup.tsx +16 -5
- package/src/components/Page/PageHeaderToolsItem.tsx +20 -14
- package/src/components/Page/PageSidebar.tsx +3 -3
- package/src/components/Page/__tests__/Generated/__snapshots__/Page.test.tsx.snap +2 -0
- package/src/components/Page/__tests__/__snapshots__/Page.test.tsx.snap +18 -9
- package/src/components/Toolbar/Toolbar.tsx +44 -39
- package/src/components/Toolbar/ToolbarContent.tsx +45 -40
- package/src/components/Toolbar/ToolbarGroup.tsx +19 -14
- package/src/components/Toolbar/ToolbarItem.tsx +30 -19
- package/src/components/Toolbar/ToolbarToggleGroup.tsx +60 -53
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/Toolbar.test.tsx.snap +3 -43
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarContent.test.tsx.snap +3 -7
- package/src/components/Toolbar/__tests__/Generated/__snapshots__/ToolbarItem.test.tsx.snap +3 -8
- package/src/demos/Page/Page.md +92 -43
- package/src/helpers/util.ts +61 -12
package/src/demos/Page/Page.md
CHANGED
|
@@ -11,6 +11,7 @@ import imgBrand from '@patternfly/react-core/src/demos/examples/pfColorLogo.svg'
|
|
|
11
11
|
import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
|
|
12
12
|
import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
|
|
13
13
|
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
14
|
+
import LightbulbIcon from '@patternfly/react-icons/dist/esm/icons/lightbulb-icon';
|
|
14
15
|
|
|
15
16
|
- All but the last example set the `isManagedSidebar` prop on the Page component to have the sidebar automatically close for smaller screen widths. You can also manually control this behavior by not adding the `isManagedSidebar` prop and instead:
|
|
16
17
|
|
|
@@ -38,6 +39,7 @@ import {
|
|
|
38
39
|
ButtonVariant,
|
|
39
40
|
Card,
|
|
40
41
|
CardBody,
|
|
42
|
+
Checkbox,
|
|
41
43
|
Divider,
|
|
42
44
|
Dropdown,
|
|
43
45
|
DropdownGroup,
|
|
@@ -66,13 +68,21 @@ import {
|
|
|
66
68
|
Toolbar,
|
|
67
69
|
ToolbarContent,
|
|
68
70
|
ToolbarGroup,
|
|
69
|
-
ToolbarItem
|
|
71
|
+
ToolbarItem,
|
|
72
|
+
Drawer,
|
|
73
|
+
DrawerPanelContent,
|
|
74
|
+
DrawerContent,
|
|
75
|
+
DrawerContentBody,
|
|
76
|
+
DrawerHead,
|
|
77
|
+
DrawerActions,
|
|
78
|
+
DrawerCloseButton,
|
|
70
79
|
} from '@patternfly/react-core';
|
|
71
80
|
import { css } from '@patternfly/react-styles';
|
|
72
81
|
import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
|
|
73
82
|
import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
|
|
74
83
|
import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
|
|
75
84
|
import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
|
|
85
|
+
import LightbulbIcon from '@patternfly/react-icons/dist/esm/icons/lightbulb-icon';
|
|
76
86
|
import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
|
|
77
87
|
import imgBrand from './imgBrand.svg';
|
|
78
88
|
import imgAvatar from './imgAvatar.svg';
|
|
@@ -84,7 +94,8 @@ class PageLayoutGrouped extends React.Component {
|
|
|
84
94
|
isDropdownOpen: false,
|
|
85
95
|
isKebabDropdownOpen: false,
|
|
86
96
|
isFullKebabDropdownOpen: false,
|
|
87
|
-
activeItem: 0
|
|
97
|
+
activeItem: 0,
|
|
98
|
+
isDrawerExpanded: false
|
|
88
99
|
};
|
|
89
100
|
this.onDropdownToggle = isDropdownOpen => {
|
|
90
101
|
this.setState({
|
|
@@ -127,10 +138,23 @@ class PageLayoutGrouped extends React.Component {
|
|
|
127
138
|
isFullKebabDropdownOpen: !this.state.isFullKebabDropdownOpen
|
|
128
139
|
});
|
|
129
140
|
};
|
|
141
|
+
|
|
142
|
+
this.onDrawerToggle = () => {
|
|
143
|
+
const isDrawerExpanded = !this.state.isDrawerExpanded;
|
|
144
|
+
this.setState({
|
|
145
|
+
isDrawerExpanded
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
this.onDrawerClose = () => {
|
|
150
|
+
this.setState({
|
|
151
|
+
isDrawerExpanded: false
|
|
152
|
+
});
|
|
153
|
+
};
|
|
130
154
|
}
|
|
131
155
|
|
|
132
156
|
render() {
|
|
133
|
-
const { isDropdownOpen, isKebabDropdownOpen, activeItem, isFullKebabDropdownOpen } = this.state;
|
|
157
|
+
const { isDropdownOpen, isKebabDropdownOpen, activeItem, isFullKebabDropdownOpen, isDrawerExpanded } = this.state;
|
|
134
158
|
|
|
135
159
|
const PageNav = (
|
|
136
160
|
<Nav variant="tertiary" onSelect={this.onNavSelect} aria-label="Nav">
|
|
@@ -198,6 +222,11 @@ class PageLayoutGrouped extends React.Component {
|
|
|
198
222
|
alignment={{ default: 'alignRight' }}
|
|
199
223
|
spacer={{ default: 'spacerNone', md: 'spacerMd' }}
|
|
200
224
|
>
|
|
225
|
+
<ToolbarItem>
|
|
226
|
+
<Button aria-label="Toggle drawer" variant={ButtonVariant.plain} onClick={this.onDrawerToggle}>
|
|
227
|
+
<LightbulbIcon color={isDrawerExpanded ? 'yellow' : 'currentColor'} />
|
|
228
|
+
</Button>
|
|
229
|
+
</ToolbarItem>
|
|
201
230
|
<ToolbarItem>
|
|
202
231
|
<Button aria-label="Notifications" variant={ButtonVariant.plain}>
|
|
203
232
|
<AttentionBellIcon />
|
|
@@ -283,47 +312,67 @@ class PageLayoutGrouped extends React.Component {
|
|
|
283
312
|
</Breadcrumb>
|
|
284
313
|
);
|
|
285
314
|
|
|
315
|
+
const panelContent = (
|
|
316
|
+
<DrawerPanelContent isResizable>
|
|
317
|
+
<DrawerHead>
|
|
318
|
+
<span tabIndex={isDrawerExpanded ? 0 : -1}>
|
|
319
|
+
drawer-panel
|
|
320
|
+
</span>
|
|
321
|
+
<DrawerActions>
|
|
322
|
+
<DrawerCloseButton onClick={this.onDrawerClose} />
|
|
323
|
+
</DrawerActions>
|
|
324
|
+
</DrawerHead>
|
|
325
|
+
</DrawerPanelContent>
|
|
326
|
+
);
|
|
327
|
+
|
|
328
|
+
const Sidebar = <PageSidebar nav="Navigation" />;
|
|
329
|
+
|
|
286
330
|
return (
|
|
287
|
-
<
|
|
288
|
-
<
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
<
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
331
|
+
<Drawer isExpanded={isDrawerExpanded} isInline onExpand={this.onExpand}>
|
|
332
|
+
<DrawerContent panelContent={panelContent}>
|
|
333
|
+
<DrawerContentBody>
|
|
334
|
+
<Page
|
|
335
|
+
header={Header}
|
|
336
|
+
breadcrumb={PageBreadcrumb}
|
|
337
|
+
sidebar={Sidebar}
|
|
338
|
+
tertiaryNav={PageNav}
|
|
339
|
+
isManagedSidebar
|
|
340
|
+
isTertiaryNavWidthLimited
|
|
341
|
+
isBreadcrumbWidthLimited
|
|
342
|
+
skipToContent={PageSkipToContent}
|
|
343
|
+
mainContainerId={pageId}
|
|
344
|
+
isTertiaryNavGrouped
|
|
345
|
+
isBreadcrumbGrouped
|
|
346
|
+
additionalGroupedContent={
|
|
347
|
+
<PageSection variant={PageSectionVariants.light}>
|
|
348
|
+
<TextContent>
|
|
349
|
+
<Text component="h1">Main title</Text>
|
|
350
|
+
<Text component="p">
|
|
351
|
+
Body text should be Overpass Regular at 16px. It should have leading of 24px because <br />
|
|
352
|
+
of its relative line height of 1.5.
|
|
353
|
+
</Text>
|
|
354
|
+
</TextContent>
|
|
355
|
+
</PageSection>
|
|
356
|
+
}
|
|
357
|
+
groupProps={{
|
|
358
|
+
sticky: 'top'
|
|
359
|
+
}}
|
|
360
|
+
>
|
|
361
|
+
<PageSection>
|
|
362
|
+
<Gallery hasGutter>
|
|
363
|
+
{Array.apply(0, Array(20)).map((x, i) => (
|
|
364
|
+
<GalleryItem key={i}>
|
|
365
|
+
<Card>
|
|
366
|
+
<CardBody>This is a card</CardBody>
|
|
367
|
+
</Card>
|
|
368
|
+
</GalleryItem>
|
|
369
|
+
))}
|
|
370
|
+
</Gallery>
|
|
371
|
+
</PageSection>
|
|
372
|
+
</Page>
|
|
373
|
+
</DrawerContentBody>
|
|
374
|
+
</DrawerContent>
|
|
375
|
+
</Drawer>
|
|
327
376
|
);
|
|
328
377
|
}
|
|
329
378
|
}
|
package/src/helpers/util.ts
CHANGED
|
@@ -262,6 +262,16 @@ export const setBreakpointCssVars = (
|
|
|
262
262
|
{}
|
|
263
263
|
);
|
|
264
264
|
|
|
265
|
+
export interface Mods {
|
|
266
|
+
default?: string;
|
|
267
|
+
sm?: string;
|
|
268
|
+
md?: string;
|
|
269
|
+
lg?: string;
|
|
270
|
+
xl?: string;
|
|
271
|
+
'2xl'?: string;
|
|
272
|
+
'3xl'?: string;
|
|
273
|
+
}
|
|
274
|
+
|
|
265
275
|
/**
|
|
266
276
|
* This function is a helper for turning arrays of breakpointMod objects for data toolbar and flex into classes
|
|
267
277
|
*
|
|
@@ -269,25 +279,64 @@ export const setBreakpointCssVars = (
|
|
|
269
279
|
* @param {any} styles The appropriate styles object for the component
|
|
270
280
|
*/
|
|
271
281
|
export const formatBreakpointMods = (
|
|
272
|
-
mods:
|
|
273
|
-
default?: string;
|
|
274
|
-
sm?: string;
|
|
275
|
-
md?: string;
|
|
276
|
-
lg?: string;
|
|
277
|
-
xl?: string;
|
|
278
|
-
'2xl'?: string;
|
|
279
|
-
'3xl'?: string;
|
|
280
|
-
},
|
|
282
|
+
mods: Mods,
|
|
281
283
|
styles: any,
|
|
282
|
-
stylePrefix: string = ''
|
|
283
|
-
|
|
284
|
-
|
|
284
|
+
stylePrefix: string = '',
|
|
285
|
+
breakpoint?: 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'
|
|
286
|
+
) => {
|
|
287
|
+
if (!mods) {
|
|
288
|
+
return '';
|
|
289
|
+
}
|
|
290
|
+
if (breakpoint) {
|
|
291
|
+
if (breakpoint in mods) {
|
|
292
|
+
return styles.modifiers[toCamel(`${stylePrefix}${mods[breakpoint as keyof Mods]}`)];
|
|
293
|
+
}
|
|
294
|
+
// the current breakpoint is not specified in mods, so we try to find the next nearest
|
|
295
|
+
const breakpointsOrder = ['2xl', 'xl', 'lg', 'md', 'sm', 'default'];
|
|
296
|
+
const breakpointsIndex = breakpointsOrder.indexOf(breakpoint);
|
|
297
|
+
for (let i = breakpointsIndex; i < breakpointsOrder.length; i++) {
|
|
298
|
+
if (breakpointsOrder[i] in mods) {
|
|
299
|
+
return styles.modifiers[toCamel(`${stylePrefix}${mods[breakpointsOrder[i] as keyof Mods]}`)];
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return '';
|
|
303
|
+
}
|
|
304
|
+
return Object.entries(mods || {})
|
|
285
305
|
.map(([breakpoint, mod]) => `${stylePrefix}${mod}${breakpoint !== 'default' ? `-on-${breakpoint}` : ''}`)
|
|
286
306
|
.map(toCamel)
|
|
287
307
|
.map(mod => mod.replace(/-?(\dxl)/gi, (_res, group) => `_${group}`))
|
|
288
308
|
.map(modifierKey => styles.modifiers[modifierKey])
|
|
289
309
|
.filter(Boolean)
|
|
290
310
|
.join(' ');
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Return the breakpoint for the given width
|
|
315
|
+
*
|
|
316
|
+
* @param {number | null} width The width to check
|
|
317
|
+
* @returns {'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl'} The breakpoint
|
|
318
|
+
*/
|
|
319
|
+
export const getBreakpoint = (width: number): 'default' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' => {
|
|
320
|
+
if (width === null) {
|
|
321
|
+
return null;
|
|
322
|
+
}
|
|
323
|
+
if (width >= 1450) {
|
|
324
|
+
return '2xl';
|
|
325
|
+
}
|
|
326
|
+
if (width >= 1200) {
|
|
327
|
+
return 'xl';
|
|
328
|
+
}
|
|
329
|
+
if (width >= 992) {
|
|
330
|
+
return 'lg';
|
|
331
|
+
}
|
|
332
|
+
if (width >= 768) {
|
|
333
|
+
return 'md';
|
|
334
|
+
}
|
|
335
|
+
if (width >= 576) {
|
|
336
|
+
return 'sm';
|
|
337
|
+
}
|
|
338
|
+
return 'default';
|
|
339
|
+
};
|
|
291
340
|
|
|
292
341
|
const camelize = (s: string) =>
|
|
293
342
|
s
|