Skip to content

Commit b0076a6

Browse files
committed
add isExpanded to CompassMainFooter
1 parent 33c168b commit b0076a6

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

packages/react-core/src/components/Compass/CompassMainFooter.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ interface CompassMainFooterProps extends Omit<React.HTMLProps<HTMLDivElement>, '
66
className?: string;
77
/** Main footer content */
88
children?: React.ReactNode;
9+
/** Indicates if the main footer is expanded */
10+
isExpanded?: boolean;
911
}
1012

1113
export const CompassMainFooter: React.FunctionComponent<CompassMainFooterProps> = ({
1214
className,
1315
children,
16+
isExpanded = true,
1417
...props
1518
}) => (
16-
<div className={css(`${styles.compass}__main-footer`, className)} {...props}>
19+
<div className={css(styles.compassMainFooter, isExpanded && 'pf-m-expanded', className)} {...props}>
1720
{children}
1821
</div>
1922
);

packages/react-core/src/components/Compass/__tests__/CompassMainFooter.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ test(`Renders with default ${styles.compassMainFooter} class`, () => {
2626
expect(screen.getByText('Test')).toHaveClass(styles.compassMainFooter);
2727
});
2828

29+
test(`Renders with pf-m-expanded class by default`, () => {
30+
render(<CompassMainFooter>Test</CompassMainFooter>);
31+
expect(screen.getByText('Test')).toHaveClass('pf-m-expanded');
32+
});
33+
34+
test(`Renders with pf-m-expanded class when isExpanded is true`, () => {
35+
render(<CompassMainFooter isExpanded>Test</CompassMainFooter>);
36+
expect(screen.getByText('Test')).toHaveClass('pf-m-expanded');
37+
});
38+
39+
test(`Renders without pf-m-expanded class when isExpanded is false`, () => {
40+
render(<CompassMainFooter isExpanded={false}>Test</CompassMainFooter>);
41+
expect(screen.getByText('Test')).not.toHaveClass('pf-m-expanded');
42+
});
43+
2944
test('Renders with additional props spread to the component', () => {
3045
render(<CompassMainFooter aria-label="Test label">Test</CompassMainFooter>);
3146
expect(screen.getByText('Test')).toHaveAccessibleName('Test label');

packages/react-core/src/components/Compass/__tests__/__snapshots__/CompassMainFooter.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`Matches the snapshot 1`] = `
44
<DocumentFragment>
55
<div
6-
class="pf-v6-c-compass__main-footer"
6+
class="pf-v6-c-compass__main-footer pf-m-expanded"
77
>
88
Custom children content
99
</div>

0 commit comments

Comments
 (0)