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
4 changes: 4 additions & 0 deletions packages/react-table/src/components/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export interface TableProps extends React.HTMLProps<HTMLTableElement>, OUIAProps
role?: string;
/** @beta Flag indicating if the table should have plain styling with a transparent background */
isPlain?: boolean;
/** @beta Flag indicating if the table should not have plain styling when in the glass theme */
isNoPlainOnGlass?: boolean;
/** If set to true, the table header sticks to the top of its container */
isStickyHeader?: boolean;
/** @hide Forwarded ref */
Expand Down Expand Up @@ -97,6 +99,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
borders = true,
isStickyHeader = false,
isPlain = false,
isNoPlainOnGlass = false,
gridBreakPoint = TableGridBreakpoint.gridMd,
'aria-label': ariaLabel,
role = 'grid',
Expand Down Expand Up @@ -226,6 +229,7 @@ const TableBase: React.FunctionComponent<TableProps> = ({
isStriped && styles.modifiers.striped,
isExpandable && styles.modifiers.expandable,
isPlain && styles.modifiers.plain,
isNoPlainOnGlass && styles.modifiers.noPlainOnGlass,
hasNoInset && stylesTreeView.modifiers.noInset,
isNested && 'pf-m-nested',
hasAnimations && styles.modifiers.animateExpand
Expand Down
30 changes: 30 additions & 0 deletions packages/react-table/src/components/Table/__tests__/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,33 @@ test(`Renders with class ${styles.modifiers.plain} when isPlain is true`, () =>

expect(screen.getByRole('grid', { name: 'Test table' })).toHaveClass(styles.modifiers.plain);
});

test(`Does not render with class ${styles.modifiers.plain} when isPlain is not defined`, () => {
render(<Table aria-label="Test table" />);

expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.plain);
});

test(`Does not render with class ${styles.modifiers.plain} when isPlain is false`, () => {
render(<Table isPlain={false} aria-label="Test table" />);

expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.plain);
});

test(`Renders with class ${styles.modifiers.noPlainOnGlass} when isNoPlainOnGlass is true`, () => {
render(<Table isNoPlainOnGlass aria-label="Test table" />);

expect(screen.getByRole('grid', { name: 'Test table' })).toHaveClass(styles.modifiers.noPlainOnGlass);
});

test(`Does not render with class ${styles.modifiers.noPlainOnGlass} when isNoPlainOnGlass is undefined`, () => {
render(<Table aria-label="Test table" />);

expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.noPlainOnGlass);
});

test(`Does not render with class ${styles.modifiers.noPlainOnGlass} when isNoPlainOnGlass is false`, () => {
render(<Table isNoPlainOnGlass={false} aria-label="Test table" />);

expect(screen.getByRole('grid', { name: 'Test table' })).not.toHaveClass(styles.modifiers.noPlainOnGlass);
});
Loading