Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"tslib": "^2.8.1"
},
"devDependencies": {
"@patternfly/patternfly": "6.5.0-prerelease.11",
"@patternfly/patternfly": "6.5.0-prerelease.12",
"case-anything": "^3.1.2",
"css": "^3.0.0",
"fs-extra": "^11.3.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/react-core/src/components/Drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export interface DrawerProps extends React.HTMLProps<HTMLDivElement> {
isExpanded?: boolean;
/** Indicates if the content element and panel element are displayed side by side. */
isInline?: boolean;
/** @beta Indicates if the drawer will have pill styles */
isPill?: boolean;
/** Indicates if the drawer will always show both content and panel. */
isStatic?: boolean;
/** Position of the drawer panel. left and right are deprecated, use start and end instead. */
Expand Down Expand Up @@ -50,6 +52,7 @@ export const Drawer: React.FunctionComponent<DrawerProps> = ({
children,
isExpanded = false,
isInline = false,
isPill = false,
isStatic = false,
position = 'end',
onExpand = () => {},
Expand All @@ -65,6 +68,7 @@ export const Drawer: React.FunctionComponent<DrawerProps> = ({
styles.drawer,
isExpanded && styles.modifiers.expanded,
isInline && styles.modifiers.inline,
isPill && styles.modifiers.pill,
isStatic && styles.modifiers.static,
(position === 'left' || position === 'start') && styles.modifiers.panelLeft,
position === 'bottom' && styles.modifiers.panelBottom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import {
DrawerPanelContent,
DrawerColorVariant
} from '../';
import { render } from '@testing-library/react';
import { screen, render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { KeyTypes } from '../../../helpers';
import styles from '@patternfly/react-styles/css/components/Drawer/drawer';

jest.mock('../../../helpers/GenerateId/GenerateId');

Expand Down Expand Up @@ -162,3 +163,27 @@ test('Resizeable DrawerPanelContent can be wrapped in a context without causing

expect(consoleError).not.toHaveBeenCalled();
});

test(`Renders with ${styles.modifiers.pill} class when specified`, () => {
const panelContent = (
<DrawerPanelContent>
<DrawerHead>
<span>drawer-panel</span>
<DrawerActions>
<DrawerCloseButton />
</DrawerActions>
</DrawerHead>
<DrawerPanelBody>drawer-panel</DrawerPanelBody>
</DrawerPanelContent>
);

render(
<Drawer data-testid="drawer" isExpanded={true} position="left" isPill>
<DrawerContent panelContent={panelContent}>
<DrawerContentBody>Drawer content text</DrawerContentBody>
</DrawerContent>
</Drawer>
);

expect(screen.getByTestId('drawer')).toHaveClass(styles.modifiers.pill);
});
13 changes: 13 additions & 0 deletions packages/react-core/src/components/Drawer/examples/Drawer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ propComponents:
]
section: components
---

import { Fragment, useRef, useState } from 'react';
import accessibility from '@patternfly/react-styles/css/utilities/Accessibility/accessibility';

Expand Down Expand Up @@ -143,3 +144,15 @@ To customize which element receives focus when the drawer panel expands, use the
```ts file="./DrawerFocusTrap.tsx"

```

### Pill

```ts file="./DrawerBasicPill.tsx"

```

### Pill inline

```ts file="./DrawerPillInline.tsx"

```
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Fragment, useRef, useState } from 'react';
import {
Drawer,
DrawerPanelContent,
DrawerContent,
DrawerContentBody,
DrawerHead,
DrawerActions,
DrawerCloseButton,
Button
} from '@patternfly/react-core';

export const DrawerBasicPill: React.FunctionComponent = () => {
const [isExpanded, setIsExpanded] = useState(false);
const drawerRef = useRef<HTMLDivElement>(undefined);

const onExpand = () => {
drawerRef.current && drawerRef.current.focus();
};

const onClick = () => {
setIsExpanded(!isExpanded);
};

const onCloseClick = () => {
setIsExpanded(false);
};

const panelContent = (
<DrawerPanelContent>
<DrawerHead>
<span tabIndex={isExpanded ? 0 : -1} ref={drawerRef}>
Drawer panel header
</span>
<DrawerActions>
<DrawerCloseButton onClick={onCloseClick} />
</DrawerActions>
</DrawerHead>
</DrawerPanelContent>
);

const drawerContent =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';

return (
<Fragment>
<Button aria-expanded={isExpanded} onClick={onClick}>
Toggle drawer
</Button>
<Drawer isExpanded={isExpanded} isPill onExpand={onExpand}>
<DrawerContent panelContent={panelContent}>
<DrawerContentBody>{drawerContent}</DrawerContentBody>
</DrawerContent>
</Drawer>
</Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Fragment, useRef, useState } from 'react';
import {
Drawer,
DrawerPanelContent,
DrawerContent,
DrawerContentBody,
DrawerHead,
DrawerActions,
DrawerCloseButton,
Button
} from '@patternfly/react-core';

export const DrawerBasicPill: React.FunctionComponent = () => {
const [isExpanded, setIsExpanded] = useState(false);
const drawerRef = useRef<HTMLDivElement>(undefined);

const onExpand = () => {
drawerRef.current && drawerRef.current.focus();
};

const onClick = () => {
setIsExpanded(!isExpanded);
};

const onCloseClick = () => {
setIsExpanded(false);
};

const panelContent = (
<DrawerPanelContent>
<DrawerHead>
<span tabIndex={isExpanded ? 0 : -1} ref={drawerRef}>
Drawer panel header
</span>
<DrawerActions>
<DrawerCloseButton onClick={onCloseClick} />
</DrawerActions>
</DrawerHead>
</DrawerPanelContent>
);

const drawerContent =
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus pretium est a porttitor vehicula. Quisque vel commodo urna. Morbi mattis rutrum ante, id vehicula ex accumsan ut. Morbi viverra, eros vel porttitor facilisis, eros purus aliquet erat,nec lobortis felis elit pulvinar sem. Vivamus vulputate, risus eget commodo eleifend, eros nibh porta quam, vitae lacinia leo libero at magna. Maecenas aliquam sagittis orci, et posuere nisi ultrices sit amet. Aliquam ex odio, malesuada sed posuere quis, pellentesque at mauris. Phasellus venenatis massa ex, eget pulvinar libero auctor pretium. Aliquam erat volutpat. Duis euismod justo in quam ullamcorper, in commodo massa vulputate.';

return (
<Fragment>
<Button aria-expanded={isExpanded} onClick={onClick}>
Toggle drawer
</Button>
<Drawer isExpanded={isExpanded} isPill isInline onExpand={onExpand}>
<DrawerContent panelContent={panelContent}>
<DrawerContentBody>{drawerContent}</DrawerContentBody>
</DrawerContent>
</Drawer>
</Fragment>
);
};
2 changes: 1 addition & 1 deletion packages/react-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"test:a11y": "patternfly-a11y --config patternfly-a11y.config"
},
"dependencies": {
"@patternfly/patternfly": "6.5.0-prerelease.11",
"@patternfly/patternfly": "6.5.0-prerelease.12",
"@patternfly/react-charts": "workspace:^",
"@patternfly/react-code-editor": "workspace:^",
"@patternfly/react-core": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-icons/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@fortawesome/free-brands-svg-icons": "^5.15.4",
"@fortawesome/free-regular-svg-icons": "^5.15.4",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@patternfly/patternfly": "6.5.0-prerelease.11",
"@patternfly/patternfly": "6.5.0-prerelease.12",
"fs-extra": "^11.3.0",
"tslib": "^2.8.1"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-styles/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"clean": "rimraf dist css"
},
"devDependencies": {
"@patternfly/patternfly": "6.5.0-prerelease.11",
"@patternfly/patternfly": "6.5.0-prerelease.12",
"change-case": "^5.4.4",
"fs-extra": "^11.3.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/react-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"devDependencies": {
"@adobe/css-tools": "^4.4.4",
"@patternfly/patternfly": "6.5.0-prerelease.11",
"@patternfly/patternfly": "6.5.0-prerelease.12",
"fs-extra": "^11.3.0"
}
}
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4516,10 +4516,10 @@ __metadata:
languageName: node
linkType: hard

"@patternfly/patternfly@npm:6.5.0-prerelease.11":
version: 6.5.0-prerelease.11
resolution: "@patternfly/patternfly@npm:6.5.0-prerelease.11"
checksum: 10c0/2a65b577ea6ec57c1065856e7606333697948e6db53fca84e19df6ce130894f9a9feea479eff1a14525645961206d41a1bef8414e5ccbbbb85591a67b778d0e2
"@patternfly/patternfly@npm:6.5.0-prerelease.12":
version: 6.5.0-prerelease.12
resolution: "@patternfly/patternfly@npm:6.5.0-prerelease.12"
checksum: 10c0/a07d7ccbde0bdcdfa03877678ee73c741f1dc6774c0fe96db24e308f637e68035684bf3758e6acf3e2c51c46f27d320eff2189e85bfdeb0c9104dd18d33ae771
languageName: node
linkType: hard

Expand Down Expand Up @@ -4617,7 +4617,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@patternfly/react-core@workspace:packages/react-core"
dependencies:
"@patternfly/patternfly": "npm:6.5.0-prerelease.11"
"@patternfly/patternfly": "npm:6.5.0-prerelease.12"
"@patternfly/react-icons": "workspace:^"
"@patternfly/react-styles": "workspace:^"
"@patternfly/react-tokens": "workspace:^"
Expand All @@ -4638,7 +4638,7 @@ __metadata:
resolution: "@patternfly/react-docs@workspace:packages/react-docs"
dependencies:
"@patternfly/documentation-framework": "npm:^6.28.9"
"@patternfly/patternfly": "npm:6.5.0-prerelease.11"
"@patternfly/patternfly": "npm:6.5.0-prerelease.12"
"@patternfly/patternfly-a11y": "npm:5.1.0"
"@patternfly/react-charts": "workspace:^"
"@patternfly/react-code-editor": "workspace:^"
Expand Down Expand Up @@ -4678,7 +4678,7 @@ __metadata:
"@fortawesome/free-brands-svg-icons": "npm:^5.15.4"
"@fortawesome/free-regular-svg-icons": "npm:^5.15.4"
"@fortawesome/free-solid-svg-icons": "npm:^5.15.4"
"@patternfly/patternfly": "npm:6.5.0-prerelease.11"
"@patternfly/patternfly": "npm:6.5.0-prerelease.12"
fs-extra: "npm:^11.3.0"
tslib: "npm:^2.8.1"
peerDependencies:
Expand Down Expand Up @@ -4763,7 +4763,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@patternfly/react-styles@workspace:packages/react-styles"
dependencies:
"@patternfly/patternfly": "npm:6.5.0-prerelease.11"
"@patternfly/patternfly": "npm:6.5.0-prerelease.12"
change-case: "npm:^5.4.4"
fs-extra: "npm:^11.3.0"
languageName: unknown
Expand Down Expand Up @@ -4805,7 +4805,7 @@ __metadata:
resolution: "@patternfly/react-tokens@workspace:packages/react-tokens"
dependencies:
"@adobe/css-tools": "npm:^4.4.4"
"@patternfly/patternfly": "npm:6.5.0-prerelease.11"
"@patternfly/patternfly": "npm:6.5.0-prerelease.12"
fs-extra: "npm:^11.3.0"
languageName: unknown
linkType: soft
Expand Down
Loading