Skip to content

Commit a5175b0

Browse files
committed
feat(Data list): Add isNoPlainOnGlass prop to add pf-m-no-plain modifier to the data list
1 parent 641c888 commit a5175b0

File tree

6 files changed

+28
-18
lines changed

6 files changed

+28
-18
lines changed

packages/react-core/src/components/DataList/DataList.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export enum DataListWrapModifier {
1919
}
2020

2121
export interface DataListProps extends React.HTMLProps<HTMLUListElement> {
22-
/** Content rendered inside the DataList list */
22+
/** Content rendered inside the data list list */
2323
children?: React.ReactNode;
2424
/** Additional classes added to the DataList list */
2525
className?: string;
@@ -33,6 +33,8 @@ export interface DataListProps extends React.HTMLProps<HTMLUListElement> {
3333
isCompact?: boolean;
3434
/** @beta Flag indicating if DataList should have plain styling with a transparent background */
3535
isPlain?: boolean;
36+
/** @beta Flag to prevent the data list from automatically applying plain styling when glass theme is enabled. */
37+
isNoPlainOnGlass?: boolean;
3638
/** Specifies the grid breakpoints */
3739
gridBreakpoint?: 'none' | 'always' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
3840
/** Determines which wrapping modifier to apply to the DataList */
@@ -62,6 +64,7 @@ export const DataListBase: React.FunctionComponent<DataListProps> = ({
6264
selectedDataListItemId = '',
6365
isCompact = false,
6466
isPlain = false,
67+
isNoPlainOnGlass = false,
6568
gridBreakpoint = 'md',
6669
wrapModifier = null,
6770
onSelectableRowChange,
@@ -88,6 +91,7 @@ export const DataListBase: React.FunctionComponent<DataListProps> = ({
8891
styles.dataList,
8992
isCompact && styles.modifiers.compact,
9093
isPlain && styles.modifiers.plain,
94+
isNoPlainOnGlass && styles.modifiers.noPlain,
9195
gridBreakpointClasses[gridBreakpoint],
9296
wrapModifier && styles.modifiers[wrapModifier],
9397
className

packages/react-core/src/components/DataList/DataListAction.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import styles from '@patternfly/react-styles/css/components/DataList/data-list';
33
import { formatBreakpointMods } from '../../helpers/util';
44

55
export interface DataListActionProps extends Omit<React.HTMLProps<HTMLDivElement>, 'children'> {
6-
/** Content rendered as DataList Action (e.g <Button> or <Dropdown>) */
6+
/** Content rendered as data list action (e.g <Button> or <Dropdown>) */
77
children: React.ReactNode;
8-
/** Additional classes added to the DataList Action */
8+
/** Additional classes added to the data list action */
99
className?: string;
10-
/** Identify the DataList toggle number */
10+
/** Identify the data list toggle number */
1111
id: string;
12-
/** Adds accessible text to the DataList Action */
12+
/** Adds accessible text to the data list action */
1313
'aria-labelledby': string;
14-
/** Adds accessible text to the DataList Action */
14+
/** Adds accessible text to the data list action */
1515
'aria-label': string;
1616
/** What breakpoints to hide/show the data list action */
1717
visibility?: {

packages/react-core/src/components/DataList/DataListCell.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { DataListWrapModifier } from './DataList';
55
import { Tooltip } from '../Tooltip';
66

77
export interface DataListCellProps extends Omit<React.HTMLProps<HTMLDivElement>, 'width'> {
8-
/** Content rendered inside the DataList cell */
8+
/** Content rendered inside the data list cell */
99
children?: React.ReactNode;
10-
/** Additional classes added to the DataList cell */
10+
/** Additional classes added to the data list cell */
1111
className?: string;
12-
/** Width (from 1-5) to the DataList cell */
12+
/** Width (from 1-5) to the data list cell */
1313
width?: 1 | 2 | 3 | 4 | 5;
14-
/** Enables the body Content to fill the height of the card */
14+
/** Enables the body content to fill the height of the card */
1515
isFilled?: boolean;
1616
/** Aligns the cell content to the right of its parent. */
1717
alignRight?: boolean;
18-
/** Set to true if the cell content is an Icon */
18+
/** Set to true if the cell content is an icon */
1919
isIcon?: boolean;
20-
/** Determines which wrapping modifier to apply to the DataListCell */
20+
/** Determines which wrapping modifier to apply to the data list cell */
2121
wrapModifier?: DataListWrapModifier | 'nowrap' | 'truncate' | 'breakWord';
2222
}
2323

packages/react-core/src/components/DataList/DataListItemCells.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { css } from '@patternfly/react-styles';
22
import styles from '@patternfly/react-styles/css/components/DataList/data-list';
33

44
export interface DataListItemCellsProps extends React.HTMLProps<HTMLDivElement> {
5-
/** Additional classes added to the DataList item Content Wrapper. Children should be one ore more <DataListCell> nodes */
5+
/** Additional classes added to the data list item content wrapper. Children should be one ore more <DataListCell> nodes */
66
className?: string;
77
/** Array of <DataListCell> nodes that are rendered one after the other. */
88
dataListCells?: React.ReactNode;

packages/react-core/src/components/DataList/DataListToggle.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ import styles from '@patternfly/react-styles/css/components/DataList/data-list';
44
import { Button, ButtonProps, ButtonVariant } from '../Button';
55

66
export interface DataListToggleProps extends React.HTMLProps<HTMLDivElement> {
7-
/** Additional classes added to the DataList cell */
7+
/** Additional classes added to the data list cell */
88
className?: string;
9-
/** Flag to show if the expanded content of the DataList item is visible */
9+
/** Flag to show if the expanded content of the data list item is visible */
1010
isExpanded?: boolean;
11-
/** Identify the DataList toggle number */
11+
/** Identify the data list toggle number */
1212
id: string;
1313
/** Id for the row */
1414
rowid?: string;
15-
/** Adds accessible text to the DataList toggle */
15+
/** Adds accessible text to the data list toggle */
1616
'aria-labelledby'?: string;
17-
/** Adds accessible text to the DataList toggle */
17+
/** Adds accessible text to the data list toggle */
1818
'aria-label'?: string;
1919
/** Allows users of some screen readers to shift focus to the controlled element. Should be used when the controlled contents are not adjacent to the toggle that controls them. */
2020
'aria-controls'?: string;

packages/react-core/src/components/DataList/__tests__/DataList.test.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import '@testing-library/jest-dom';
12
import { render, screen } from '@testing-library/react';
23
import userEvent from '@testing-library/user-event';
34

@@ -77,6 +78,11 @@ test(`Renders with class ${styles.modifiers.plain} when isPlain is true`, () =>
7778
expect(screen.getByLabelText('list')).toHaveClass(styles.modifiers.plain);
7879
});
7980

81+
test(`Renders with ${styles.modifiers.noPlain} when isNoPlainOnGlass is true`, () => {
82+
render(<DataList aria-label="list" isNoPlainOnGlass />);
83+
expect(screen.getByLabelText('list')).toHaveClass(styles.modifiers.noPlain);
84+
});
85+
8086
test('Renders with a hidden input to improve a11y when onSelectableRowChange is passed', () => {
8187
render(
8288
<DataList aria-label="this is a simple list" onSelectableRowChange={() => {}}>

0 commit comments

Comments
 (0)