Skip to content

Commit

Permalink
refactor(controlled-accordion): changes button styles
Browse files Browse the repository at this point in the history
  • Loading branch information
2nikhiltom committed Feb 27, 2024
1 parent c6b4187 commit e743025
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
35 changes: 21 additions & 14 deletions packages/react/src/components/Accordion/Accordion.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import {
AccordionSkeleton,
} from '../Accordion';
import Button from '../Button';
import ButtonSet from '../ButtonSet';
import mdx from './Accordion.mdx';
import { usePrefix } from '../../internal/usePrefix';

import { WithLayer } from '../../../.storybook/templates/WithLayer';

Expand Down Expand Up @@ -71,22 +73,27 @@ export const Default = () => (

export const Controlled = () => {
const [expandAll, setExpandAll] = React.useState(false);
const prefix = usePrefix();
return (
<>
<Button
onClick={() => {
expandAll === true ? setExpandAll(1) : setExpandAll(true);
}}>
Click to expand all
</Button>
<Button
onClick={() => {
expandAll || expandAll === null
? setExpandAll(false)
: setExpandAll(null);
}}>
Click to collapse all
</Button>
<div className={`${prefix}--controlled__accordion`}>
<ButtonSet>
<Button
onClick={() => {
expandAll === true ? setExpandAll(1) : setExpandAll(true);
}}>
Click to expand all
</Button>
<Button
onClick={() => {
expandAll || expandAll === null
? setExpandAll(false)
: setExpandAll(null);
}}>
Click to collapse all
</Button>
</ButtonSet>
</div>
<Accordion>
<AccordionItem title="Section 1 title" open={expandAll}>
<p>
Expand Down
6 changes: 6 additions & 0 deletions packages/styles/scss/components/accordion/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -305,3 +305,9 @@ $content-padding: 0 0 0 $spacing-05 !default;
inline-size: calc(100% + 32px);
inset-inline-start: -1rem;
}

//controlled-accordion
.#{$prefix}--controlled__accordion .#{$prefix}--btn-set .#{$prefix}--btn {
inline-size: 100%;
max-inline-size: 13.25rem;
}

0 comments on commit e743025

Please sign in to comment.