Skip to content

Commit c9853de

Browse files
authored
feat(Table): update isPlain to apply no-plain when false (#12287)
* feat(Table): update isPlain to apply no-plain when false * add unit tests for new behavior * feat(Table): update to two prop approach * add warn for using both plain props at once * bump core for class name, remove warning
1 parent 779af06 commit c9853de

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

packages/react-table/src/components/Table/Table.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export interface TableProps extends React.HTMLProps<HTMLTableElement>, OUIAProps
5050
role?: string;
5151
/** @beta Flag indicating if the table should have plain styling with a transparent background */
5252
isPlain?: boolean;
53+
/** @beta Flag indicating if the table should not have plain styling when in the glass theme */
54+
isNoPlainOnGlass?: boolean;
5355
/** If set to true, the table header sticks to the top of its container */
5456
isStickyHeader?: boolean;
5557
/** @hide Forwarded ref */
@@ -97,6 +99,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
9799
borders = true,
98100
isStickyHeader = false,
99101
isPlain = false,
102+
isNoPlainOnGlass = false,
100103
gridBreakPoint = TableGridBreakpoint.gridMd,
101104
'aria-label': ariaLabel,
102105
role = 'grid',
@@ -226,6 +229,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
226229
isStriped && styles.modifiers.striped,
227230
isExpandable && styles.modifiers.expandable,
228231
isPlain && styles.modifiers.plain,
232+
isNoPlainOnGlass && styles.modifiers.noPlainOnGlass,
229233
hasNoInset && stylesTreeView.modifiers.noInset,
230234
isNested && 'pf-m-nested',
231235
hasAnimations && styles.modifiers.animateExpand

packages/react-table/src/components/Table/__tests__/Table.test.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,33 @@ test(`Renders with class ${styles.modifiers.plain} when isPlain is true`, () =>
156156

157157
expect(screen.getByRole('grid', { name: 'Test table' })).toHaveClass(styles.modifiers.plain);
158158
});
159+
160+
test(`Does not render with class ${styles.modifiers.plain} when isPlain is not defined`, () => {
161+
render(<Table aria-label="Test table" />);
162+
163+
expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.plain);
164+
});
165+
166+
test(`Does not render with class ${styles.modifiers.plain} when isPlain is false`, () => {
167+
render(<Table isPlain={false} aria-label="Test table" />);
168+
169+
expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.plain);
170+
});
171+
172+
test(`Renders with class ${styles.modifiers.noPlainOnGlass} when isNoPlainOnGlass is true`, () => {
173+
render(<Table isNoPlainOnGlass aria-label="Test table" />);
174+
175+
expect(screen.getByRole('grid', { name: 'Test table' })).toHaveClass(styles.modifiers.noPlainOnGlass);
176+
});
177+
178+
test(`Does not render with class ${styles.modifiers.noPlainOnGlass} when isNoPlainOnGlass is undefined`, () => {
179+
render(<Table aria-label="Test table" />);
180+
181+
expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.noPlainOnGlass);
182+
});
183+
184+
test(`Does not render with class ${styles.modifiers.noPlainOnGlass} when isNoPlainOnGlass is false`, () => {
185+
render(<Table isNoPlainOnGlass={false} aria-label="Test table" />);
186+
187+
expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.noPlainOnGlass);
188+
});

0 commit comments

Comments
 (0)