Skip to content

Commit

Permalink
chore: styles updated and moved to story.scss
Browse files Browse the repository at this point in the history
  • Loading branch information
2nikhiltom committed Feb 29, 2024
1 parent e743025 commit 3e8be93
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
41 changes: 20 additions & 21 deletions packages/react/src/components/Accordion/Accordion.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/* eslint-disable no-console */

import React from 'react';
import './story.scss';
import {
default as Accordion,
AccordionItem,
Expand All @@ -16,8 +17,6 @@ import {
import Button from '../Button';
import ButtonSet from '../ButtonSet';
import mdx from './Accordion.mdx';
import { usePrefix } from '../../internal/usePrefix';

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

export default {
Expand Down Expand Up @@ -73,27 +72,27 @@ export const Default = () => (

export const Controlled = () => {
const [expandAll, setExpandAll] = React.useState(false);
const prefix = usePrefix();
return (
<>
<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>
<ButtonSet className={'controlled-accordion-btnset'}>
<Button
className={'controlled-accordion-btn'}
onClick={() => {
expandAll === true ? setExpandAll(1) : setExpandAll(true);
}}>
Click to expand all
</Button>
<Button
className={'controlled-accordion-btn'}
onClick={() => {
expandAll || expandAll === null
? setExpandAll(false)
: setExpandAll(null);
}}>
Click to collapse all
</Button>
</ButtonSet>

<Accordion>
<AccordionItem title="Section 1 title" open={expandAll}>
<p>
Expand Down
14 changes: 14 additions & 0 deletions packages/react/src/components/Accordion/story.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// Copyright IBM Corp. 2016, 2023
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

.controlled-accordion-btnset {
padding-block-end: 0.5rem;
}

.controlled-accordion-btnset .controlled-accordion-btn {
max-inline-size: 13.25rem;
}
6 changes: 0 additions & 6 deletions packages/styles/scss/components/accordion/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,3 @@ $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 3e8be93

Please sign in to comment.