-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
APP-17219 web component accordion (#401)
- Loading branch information
Showing
13 changed files
with
823 additions
and
4 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@getflip/swirl-components": minor | ||
"@getflip/swirl-components-angular": minor | ||
"@getflip/swirl-components-react": minor | ||
--- | ||
|
||
Add swirl-accordion and swirl-accordion-item components |
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
142 changes: 142 additions & 0 deletions
142
packages/swirl-components/src/components/swirl-accordion-item/swirl-accordion-item.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 |
---|---|---|
@@ -0,0 +1,142 @@ | ||
@import "../../styles/media-queries.css"; | ||
|
||
:host { | ||
display: block; | ||
|
||
& * { | ||
box-sizing: border-box; | ||
} | ||
|
||
&(:last-child) .accordion-item { | ||
border-bottom: 0.0625rem solid var(--s-border-default); | ||
} | ||
} | ||
|
||
.accordion-item { | ||
display: grid; | ||
align-content: start; | ||
border-top: 0.0625rem solid var(--s-border-default); | ||
transition: grid-template-rows 0.15s; | ||
grid-template-rows: auto 0fr; | ||
will-change: grid-template-rows; | ||
|
||
@media (prefers-reduced-motion) { | ||
transition: none; | ||
} | ||
} | ||
|
||
.accordion-item--expanded { | ||
grid-template-rows: auto 1fr; | ||
|
||
& .accordion-item__content { | ||
padding-top: var(--s-space-16); | ||
padding-bottom: var(--s-space-16); | ||
animation: accordion-overflow 0.01s; | ||
animation-delay: 0.15s; | ||
animation-fill-mode: forwards; | ||
|
||
@media (--from-desktop-without-touch) { | ||
padding-top: var(--s-space-8); | ||
} | ||
} | ||
} | ||
|
||
.accordion-item__heading { | ||
margin: 0; | ||
padding: 0; | ||
font-size: var(--s-font-size-base); | ||
font-weight: var(--s-font-weight-semibold); | ||
|
||
@media (--from-desktop-without-touch) { | ||
font-size: var(--s-font-size-sm); | ||
} | ||
} | ||
|
||
.accordion-item__toggle { | ||
display: flex; | ||
width: 100%; | ||
padding: 0; | ||
padding-top: var(--s-space-16); | ||
padding-bottom: var(--s-space-16); | ||
align-items: center; | ||
border: none; | ||
color: var(--s-text-default); | ||
background-color: var(--s-surface-default); | ||
font: inherit; | ||
line-height: var(--s-line-height-lg); | ||
text-align: start; | ||
cursor: pointer; | ||
gap: var(--s-space-16); | ||
|
||
&:hover { | ||
background-color: var(--s-surface-hovered); | ||
} | ||
|
||
&:active { | ||
background-color: var(--s-surface-pressed); | ||
} | ||
|
||
&:disabled { | ||
color: var(--s-text-disabled); | ||
background-color: var(--s-surface-default); | ||
cursor: default; | ||
|
||
& .text { | ||
color: var(--s-text-disabled); | ||
} | ||
} | ||
|
||
&:focus:not(:focus-visible) { | ||
outline: none; | ||
} | ||
|
||
&:focus-visible { | ||
outline-color: var(--s-focus-default); | ||
} | ||
|
||
@media (--from-desktop-without-touch) { | ||
line-height: var(--s-line-height-sm); | ||
} | ||
} | ||
|
||
.accordion-item__toggle-text { | ||
flex-grow: 1; | ||
} | ||
|
||
.accordion-item__icon { | ||
display: inline-flex; | ||
padding-right: var(--s-space-8); | ||
flex-shrink: 0; | ||
} | ||
|
||
.accordion-item__content { | ||
overflow: hidden; | ||
padding-top: 0; | ||
padding-bottom: 0; | ||
transition: padding-top 0.15s, padding-bottom 0.15s; | ||
animation: accordion-display 0.01s; | ||
animation-delay: 0.15s; | ||
animation-fill-mode: forwards; | ||
|
||
@media (prefers-reduced-motion) { | ||
transition: none; | ||
} | ||
} | ||
|
||
@keyframes accordion-overflow { | ||
from { | ||
overflow: hidden; | ||
} | ||
to { | ||
overflow: visible; | ||
} | ||
} | ||
|
||
@keyframes accordion-display { | ||
from { | ||
display: block; | ||
} | ||
to { | ||
display: none; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...s/swirl-components/src/components/swirl-accordion-item/swirl-accordion-item.mdx
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Controls, Canvas, Meta, Story } from "@storybook/addon-docs"; | ||
import * as Stories from "./swirl-accordion-item.stories"; | ||
|
||
<Meta title="Components/SwirlAccordionItem" /> | ||
|
||
# SwirlAccordionItem | ||
|
||
The SwirlAccordionItem component is used to provide a collapsible section of | ||
content. It is always contained within a | ||
[SwirlAccordion](?path=/docs/components-swirlaccordion--docs) component. | ||
|
||
- **[Figma Design Specs](https://www.figma.com/file/iRHiAFsHxnzux8gQ9EjlZe/Swirl-Components?node-id=5488%3A32622&mode=dev)** | ||
- **[Source Code](https://github.com/flip-corp/swirl/tree/main/packages/swirl-components/src/components/swirl-accordion-item)** | ||
|
||
## Usage | ||
|
||
<Canvas of={Stories.SwirlAccordionItem} sourceState="shown"></Canvas> | ||
|
||
<Controls of={Stories.SwirlAccordionItem} /> | ||
|
||
## Theming | ||
|
||
| Variable | Usage | | ||
| -------------------- | ----------------- | | ||
| `--s-border-default` | Separator color | | ||
| `--s-text-subdued` | Description color | | ||
|
||
## Accessibility | ||
|
||
See [SwirlAccordion](?path=/docs/components-swirlaccordion--docs). |
Oops, something went wrong.