Skip to content

Commit f854fa6

Browse files
feat(card): add isGlass prop (#12290)
* feat(card): add isGlass prop * Update packages/react-core/src/components/Card/Card.tsx Co-authored-by: Eric Olkowski <70952936+thatblindgeye@users.noreply.github.com> --------- Co-authored-by: Eric Olkowski <70952936+thatblindgeye@users.noreply.github.com>
1 parent 3401629 commit f854fa6

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export interface CardProps extends React.HTMLProps<HTMLElement>, OUIAProps {
3434
isFullHeight?: boolean;
3535
/** Modifies the card to include plain styling; this removes border and background */
3636
isPlain?: boolean;
37+
/** Modifies the card to include glass styling when glass theme is enabled */
38+
isGlass?: boolean;
3739
/** Flag indicating if a card is expanded. Modifies the card to be expandable. */
3840
isExpanded?: boolean;
3941
/** Card background color variant */
@@ -81,6 +83,7 @@ const CardBase: React.FunctionComponent<CardProps> = ({
8183
isLarge = false,
8284
isFullHeight = false,
8385
isPlain = false,
86+
isGlass = false,
8487
variant = 'default',
8588
ouiaId,
8689
ouiaSafe = true,
@@ -138,6 +141,7 @@ const CardBase: React.FunctionComponent<CardProps> = ({
138141
isLarge && styles.modifiers.displayLg,
139142
isFullHeight && styles.modifiers.fullHeight,
140143
isPlain && styles.modifiers.plain,
144+
isGlass && styles.modifiers.glass,
141145
variant === 'secondary' && styles.modifiers.secondary,
142146
getSelectableModifiers(),
143147
isDisabled && styles.modifiers.disabled,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ describe('Card', () => {
8686
expect(consoleWarnMock).toHaveBeenCalled();
8787
});
8888

89+
test('card with isGlass applied', () => {
90+
render(<Card isGlass>glass card</Card>);
91+
expect(screen.getByText('glass card')).toHaveClass('pf-m-glass');
92+
});
93+
8994
test('card with variant set to secondary ', () => {
9095
render(<Card variant="secondary">secondary card</Card>);
9196

0 commit comments

Comments
 (0)