Skip to content
Open
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
8 changes: 8 additions & 0 deletions packages/react-core/src/components/Accordion/Accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export interface AccordionProps extends React.HTMLProps<HTMLDListElement> {
asDefinitionList?: boolean;
/** Flag to indicate the accordion had a border */
isBordered?: boolean;
/** Flag to prevent the accordion from automatically applying plain styling when glass theme is enabled. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we may want to add the beta flag here similar to what Katie did in her Table PR

isNoPlainOnGlass?: boolean;
/** Flag to add plain styling to the accordion. */
isPlain?: boolean;
/** Display size variant. */
displaySize?: 'default' | 'lg';
/** Sets the toggle icon position for all accordion toggles. */
Expand All @@ -28,6 +32,8 @@ export const Accordion: React.FunctionComponent<AccordionProps> = ({
headingLevel = 'h3',
asDefinitionList = true,
isBordered = false,
isNoPlainOnGlass = false,
isPlain = false,
displaySize = 'default',
togglePosition = 'end',
...props
Expand All @@ -38,6 +44,8 @@ export const Accordion: React.FunctionComponent<AccordionProps> = ({
className={css(
styles.accordion,
isBordered && styles.modifiers.bordered,
isNoPlainOnGlass && styles.modifiers.noPlain,
isPlain && styles.modifiers.plain,
togglePosition === 'start' && styles.modifiers.toggleStart,
displaySize === 'lg' && styles.modifiers.displayLg,
className
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@testing-library/jest-dom';
import { render, screen } from '@testing-library/react';

import { Accordion } from '../Accordion';
Expand Down Expand Up @@ -121,6 +122,30 @@ test('Renders with pf-m-bordered when isBordered=true', () => {
expect(screen.getByText('Test')).toHaveClass('pf-m-bordered');
});

test('Renders without class pf-m-no-plain by default', () => {
render(<Accordion>Test</Accordion>);

expect(screen.getByText('Test')).not.toHaveClass('pf-m-no-plain');
});

test('Renders with class pf-m-no-plain when isNoPlainOnGlass', () => {
render(<Accordion isNoPlainOnGlass>Test</Accordion>);

expect(screen.getByText('Test')).toHaveClass('pf-m-no-plain');
});

test('Renders without class pf-m-plain by default', () => {
render(<Accordion>Test</Accordion>);

expect(screen.getByText('Test')).not.toHaveClass('pf-m-plain');
});

test('Renders with class pf-m-plain when isPlain', () => {
render(<Accordion isPlain>Test</Accordion>);

expect(screen.getByText('Test')).toHaveClass('pf-m-plain');
});

test('Renders without pf-m-display-lg by default', () => {
render(<Accordion>Test</Accordion>);

Expand Down
Loading