Skip to content

Commit

Permalink
feat(accordion): add size variants to Accordion (#7038)
Browse files Browse the repository at this point in the history
Co-authored-by: jeanservaas <43144260+jeanservaas@users.noreply.github.com>
  • Loading branch information
tw15egan and jeanservaas authored Oct 15, 2020
1 parent f84982b commit 30ce66c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/components/src/components/accordion/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@
}
}

// Size styles
.#{$prefix}--accordion--xl .#{$prefix}--accordion__heading {
min-height: rem(48px);
}

.#{$prefix}--accordion--sm .#{$prefix}--accordion__heading {
min-height: rem(32px);
padding: rem(5px) 0;
}

// Disabled styles
.#{$prefix}--accordion__heading[disabled] {
color: $disabled-02;
Expand Down
9 changes: 9 additions & 0 deletions packages/react/__tests__/__snapshots__/PublicAPI-test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ Map {
"disabled": Object {
"type": "bool",
},
"size": Object {
"args": Array [
Array [
"sm",
"xl",
],
],
"type": "oneOf",
},
},
},
"AccordionItem" => Object {
Expand Down
9 changes: 9 additions & 0 deletions packages/react/src/components/Accordion/Accordion-story.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,18 @@ const props = {
onHeadingClick: action('onHeadingClick'),
};

const sizes = {
'Extra large size (xl)': 'xl',
'Default size': undefined,
'Small size (sm)': 'sm',
};

export const playground = () => (
<Accordion
disabled={boolean('Disable entire Accordion (disabled)', false)}
size={
select('Accordion heading size (size)', sizes, undefined) || undefined
}
align={select(
'Accordion heading alignment (align)',
['start', 'end'],
Expand Down
7 changes: 7 additions & 0 deletions packages/react/src/components/Accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ function Accordion({
children,
className: customClassName,
disabled,
size,
...rest
}) {
const className = cx(`${prefix}--accordion`, customClassName, {
[`${prefix}--accordion--${align}`]: align,
[`${prefix}--accordion--${size}`]: size,
});
return (
<ul className={className} {...rest}>
Expand Down Expand Up @@ -57,6 +59,11 @@ Accordion.propTypes = {
* Specify whether an individual AccordionItem should be disabled
*/
disabled: PropTypes.bool,

/**
* Specify the size of the Accordion. Currently supports either `sm` or `xl` as an option.
*/
size: PropTypes.oneOf(['sm', 'xl']),
};

export default Accordion;

0 comments on commit 30ce66c

Please sign in to comment.