-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(accordion): implements styles and finishes a11y features
- Loading branch information
1 parent
11801c3
commit e777282
Showing
8 changed files
with
138 additions
and
31 deletions.
There are no files selected for viewing
53 changes: 52 additions & 1 deletion
53
packages/forma-36-react-components/src/components/Accordion/Accordion.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,59 @@ | ||
@import 'settings/colors'; | ||
@import 'settings/typography'; | ||
@import 'settings/transitions'; | ||
@import 'settings/dimensions'; | ||
|
||
.Accordion { | ||
display: inline-block; | ||
box-sizing: border-box; | ||
padding: 0; | ||
margin: 0; | ||
list-style: none; | ||
|
||
& li { | ||
border-bottom: 1px solid var(--color-element-mid); | ||
|
||
&:first-child { | ||
border-top: 1px solid var(--color-element-mid); | ||
} | ||
} | ||
} | ||
|
||
.Accordion--start { | ||
& .AccordionHeader svg { | ||
min-width: 9px; /* necessary to algin the chevron properly */ | ||
margin-right: var(--spacing-xs); | ||
} | ||
} | ||
|
||
.Accordion--end { | ||
& .AccordionHeader { | ||
flex-direction: row-reverse; | ||
justify-content: space-between; | ||
} | ||
} | ||
|
||
.AccordionHeader { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
border: 0; | ||
padding: 1rem; | ||
background-color: transparent; | ||
font-family: var(--font-stack-primary); | ||
font-size: var(--font-size-l); | ||
font-weight: var(--font-weight-demi-bold); | ||
line-height: var(--line-height-default); | ||
color: var(--color-text-base); | ||
width: 100%; | ||
cursor: pointer; | ||
transition: background-color var(--transition-duration-default) | ||
var(--transition-easing-default); | ||
|
||
&:hover { | ||
background-color: var(--color-element-lightest); | ||
} | ||
&:focus { | ||
outline: none; | ||
background-color: var(--color-element-lightest); | ||
} | ||
} |
54 changes: 46 additions & 8 deletions
54
packages/forma-36-react-components/src/components/Accordion/Accordion.stories.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,56 @@ | ||
import React from 'react'; | ||
import { storiesOf } from '@storybook/react'; | ||
import { text } from '@storybook/addon-knobs'; | ||
import { text, select } from '@storybook/addon-knobs'; | ||
|
||
import Accordion from './Accordion'; | ||
import AccordionItem from './AccordionItem'; | ||
import Typography from '../Typography/Typography'; | ||
import Paragraph from '../Typography/Paragraph'; | ||
import notes from './README.md'; | ||
|
||
storiesOf('(alpha))|Accordion', module) | ||
.addParameters({ | ||
propTypes: Accordion['__docgenInfo'], | ||
}) | ||
.add('default', () => ( | ||
<Accordion className={text('className', '')}> | ||
<AccordionItem /> | ||
<AccordionItem /> | ||
<AccordionItem /> | ||
</Accordion> | ||
)); | ||
.add( | ||
'default', | ||
() => ( | ||
<Accordion | ||
align={select('Align', ['start', 'end'], Accordion.defaultProps.align)} | ||
> | ||
<AccordionItem title={text('First accordion title', 'First accordion')}> | ||
<Typography> | ||
<Paragraph> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | ||
enim ad minim veniam, quis nostrud exercitation ullamco laboris | ||
nisi ut aliquip ex ea commodo consequat. | ||
</Paragraph> | ||
</Typography> | ||
</AccordionItem> | ||
<AccordionItem | ||
title={text('Second accordion title', 'Second accordion')} | ||
> | ||
<Typography> | ||
<Paragraph> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | ||
enim ad minim veniam, quis nostrud exercitation ullamco laboris | ||
nisi ut aliquip ex ea commodo consequat. | ||
</Paragraph> | ||
</Typography> | ||
</AccordionItem> | ||
<AccordionItem title={text('Third accordion title', 'Third accordion')}> | ||
<Typography> | ||
<Paragraph> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut | ||
enim ad minim veniam, quis nostrud exercitation ullamco laboris | ||
nisi ut aliquip ex ea commodo consequat. | ||
</Paragraph> | ||
</Typography> | ||
</AccordionItem> | ||
</Accordion> | ||
), | ||
{ notes }, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 3 additions & 6 deletions
9
...ages/forma-36-react-components/src/components/Accordion/AccordionPanel/AccordionPanel.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
@import 'settings/colors'; | ||
@import 'settings/typography'; | ||
@import 'settings/transitions'; | ||
@import 'settings/dimensions'; | ||
|
||
.AccordionPanel { | ||
box-sizing: border-box; | ||
overflow: hidden; | ||
padding: 0 var(--spacing-m); | ||
height: 0; | ||
/* max-height: 0; */ | ||
/* transition: all 1s ease-in-out; */ | ||
} | ||
|
||
.AccordionPanel--expanded { | ||
padding: 0 var(--spacing-m) var(--spacing-m); | ||
height: auto; | ||
/* max-height: 600px; */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.