-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(design): clean up accordion component and update docs (#2800)
- The `initiallyActive` property has been deprecated in favor of `initiallyExpanded`. - `DaffAccordionItemContentDirective` has been deprecated. It's not necessary to have this directive.
- Loading branch information
Showing
14 changed files
with
139 additions
and
97 deletions.
There are no files selected for viewing
17 changes: 14 additions & 3 deletions
17
apps/design-land/src/app/accordion/accordion.component.html
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,7 +1,18 @@ | ||
<h1 daffArticleTitle>Accordion</h1> | ||
<p daffArticleLead>An accordion is a group of vertically stacked headings used to toggle the visibility of a section of content.</p> | ||
|
||
<h3>Types</h3> | ||
<p><code>daff-accordion-item</code> - An accordion that typically holds content.</p> | ||
<h2>Overview</h2> | ||
<p>Accordions are made up of <code><daff-accordion-item></code>s that can be expanded or collapsed to display large amounts of information. Accordions are helpful to shorten pages and reduce scrolling by hiding content that's not crucial to display at all times.</p> | ||
|
||
<h3>Content Accordion Item</h3> | ||
<h2>Supported Content Types</h2> | ||
<p>An accordion item can include a <code>[daffAccordionItemTitle]</code>, which provides a high level overview of the content. Any other content within an accordion item will be displayed as the primary content.</p> | ||
|
||
<p>By default, the accordion item includes a toggle icon at the end of the header to indicate if it's expanded or collapsed.</p> | ||
|
||
<h3>Setting an item to be expanded by default</h3> | ||
<p>An item content can be visibile on render by setting the <code>initiallyExpanded</code> property to <code>true</code> on <code><daff-accordion-item></code>.</p> | ||
|
||
<h2>Usage</h2> | ||
|
||
<h3>Basic Accordion</h3> | ||
<design-land-example-viewer-container example="basic-accordion"></design-land-example-viewer-container> |
11 changes: 0 additions & 11 deletions
11
apps/design-land/src/app/accordion/accordion.component.scss
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
# Accordion Component | ||
# Accordion | ||
An accordion is a group of vertically stacked headings used to toggle the visibility of a section of content. | ||
|
||
The accordion component is a useful component when you're trying to display chunks of content in a compact fashion. | ||
## Overview | ||
Accordions are made up of `<daff-accordion-item>`s that can be expanded or collapsed to display large amounts of information. Accordions are helpful to shorten pages and reduce scrolling by hiding content that's not crucial to display at all times. | ||
|
||
The accordion consists of a global `<daff-accordion>` parent with children `<daff-accordion-item>`s. | ||
## Supported Content Types | ||
An accordion item can include a `[daffAccordionItemTitle]`, which provides a high level overview of the content. Any other content within an accordion item will be displayed as the primary content. | ||
|
||
By default, the accordion item includes a toggle icon at the end of the header to indicate if it's expanded or collapsed. | ||
|
||
### Setting an item to be expanded by default | ||
An item content can be visibile on render by setting the `initiallyExpanded` property to `true` on `daff-accordion-item`. | ||
|
||
## Usage | ||
|
||
``` | ||
<daff-accordion> | ||
<daff-accordion-item initiallyActive="true"> | ||
<h3 daffAccordionItemTitle>Details</h3> | ||
<div daffAccordionItemContent> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo | ||
lacus ut sapien consectetur, et ultricies leo rutrum. Integer iaculis ultrices nunc, | ||
et maximus quam efficitur sed. Maecenas iaculis nisl neque, maximus sagittis libero sagittis eget. | ||
<a>Learn More.</a> | ||
</div> | ||
</daff-accordion-item> | ||
</daff-accordion> | ||
``` | ||
### Basic Accordion | ||
<design-land-example-viewer-container example="basic-accordion"></design-land-example-viewer-container> |
38 changes: 16 additions & 22 deletions
38
libs/design/accordion/examples/src/basic-accordion/basic-accordion.component.html
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,29 +1,23 @@ | ||
<daff-accordion> | ||
<daff-accordion-item initiallyActive="true"> | ||
<h3 daffAccordionItemTitle>Details</h3> | ||
<div daffAccordionItemContent> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo | ||
lacus ut sapien consectetur, et ultricies leo rutrum. Integer iaculis ultrices nunc, | ||
et maximus quam efficitur sed. Maecenas iaculis nisl neque, maximus sagittis libero sagittis eget. | ||
<a>Learn More.</a> | ||
</div> | ||
<daff-accordion-item [initiallyExpanded]="true"> | ||
<div daffAccordionItemTitle>This is the accordion item title</div> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo lacus ut sapien consectetur, et ultricies leo rutrum. Integer iaculis ultrices nunc, et maximus quam efficitur sed. | ||
<a href="/">Learn More.</a> | ||
</p> | ||
</daff-accordion-item> | ||
<daff-accordion-item> | ||
<h3 daffAccordionItemTitle>Details</h3> | ||
<div daffAccordionItemContent> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo | ||
lacus ut sapien consectetur, et ultricies leo rutrum. Integer iaculis ultrices nunc, | ||
et maximus quam efficitur sed. Maecenas iaculis nisl neque, maximus sagittis libero sagittis eget. | ||
<a>Learn More.</a> | ||
</div> | ||
<div daffAccordionItemTitle>This is the accordion item title</div> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo lacus ut sapien consectetur, et ultricies leo rutrum. Integer iaculis ultrices nunc, et maximus quam efficitur sed. | ||
<a href="/">Learn More.</a> | ||
</p> | ||
</daff-accordion-item> | ||
<daff-accordion-item> | ||
<h3 daffAccordionItemTitle>Details</h3> | ||
<div daffAccordionItemContent> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo | ||
lacus ut sapien consectetur, et ultricies leo rutrum. Integer iaculis ultrices nunc, | ||
et maximus quam efficitur sed. Maecenas iaculis nisl neque, maximus sagittis libero sagittis eget. | ||
<a>Learn More.</a> | ||
</div> | ||
<div daffAccordionItemTitle>This is the accordion item title</div> | ||
<p> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent commodo lacus ut sapien consectetur, et ultricies leo rutrum. Integer iaculis ultrices nunc, et maximus quam efficitur sed. | ||
<a href="/">Learn More.</a> | ||
</p> | ||
</daff-accordion-item> | ||
</daff-accordion> |
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
19 changes: 9 additions & 10 deletions
19
libs/design/accordion/src/accordion/accordion-item/accordion-item.component.html
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,12 +1,11 @@ | ||
<div class="daff-accordion-item__header" (click)="toggleActive()"> | ||
<button type="button" class="daff-accordion-item__header" | ||
(click)="toggleActive()" | ||
[attr.aria-expanded]="_open === true" | ||
[attr.aria-controls]="id"> | ||
<ng-content select="[daffAccordionItemTitle]"></ng-content> | ||
<span [hidden]="_open" daffSuffix> | ||
<fa-icon [icon]="faChevronDown"></fa-icon> | ||
</span> | ||
<span [hidden]="!_open" daffSuffix> | ||
<fa-icon [icon]="faChevronUp"></fa-icon> | ||
</span> | ||
</div> | ||
<div [@openAccordion]="_animationState"> | ||
<ng-content></ng-content> | ||
</button> | ||
<div [@openAccordion]="_animationState" [id]="id"> | ||
<div class="daff-accordion-item__content"> | ||
<ng-content></ng-content> | ||
</div> | ||
</div> |
55 changes: 40 additions & 15 deletions
55
libs/design/accordion/src/accordion/accordion-item/accordion-item.component.scss
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,40 +1,65 @@ | ||
@use '../../../../scss/typography' as t; | ||
@use '../../../../scss/interactions'; | ||
@use '../../../../scss/layout'; | ||
|
||
.daff-accordion-item { | ||
$root: &; | ||
display: block; | ||
padding: 15px 0; | ||
width: 100%; | ||
|
||
@include layout.breakpoint(tablet) { | ||
padding: 30px 0; | ||
} | ||
|
||
&__header { | ||
@include interactions.clickable; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
width: 100%; | ||
gap: 8px; | ||
background: none; | ||
border: none; | ||
inline-size: 100%; | ||
margin: 0; | ||
padding: 16px; | ||
position: relative; | ||
|
||
.daff-suffix { | ||
margin: 0 10px; | ||
&::after { | ||
content: ''; | ||
position: absolute; | ||
top: 48%; | ||
right: 2px; | ||
display: inline-block; | ||
border-right: 2px solid currentColor; | ||
border-bottom: 2px solid currentColor; | ||
width: 8px; | ||
height: 8px; | ||
transform: translateY(-50%) rotate(45deg); | ||
transition: transform 150ms; | ||
} | ||
} | ||
|
||
&.open { | ||
#{$root}__header { | ||
&:after { | ||
top: 56%; | ||
transform: translateY(-50%) rotate(225deg); | ||
} | ||
} | ||
} | ||
|
||
&__title { | ||
@include t.embolden; | ||
@include t.uppercase; | ||
font-size: 1rem; | ||
font-weight: 500; | ||
inline-size: 100%; | ||
margin: 0; | ||
padding: 0 32px 0 0; | ||
text-align: start; | ||
} | ||
|
||
&__content { | ||
padding-top: 15px; | ||
padding: 0 16px 16px; | ||
|
||
> p { | ||
margin: 0 0 16px; | ||
|
||
@include layout.breakpoint(tablet) { | ||
padding-top: 30px; | ||
&:last-child { | ||
margin: 0; | ||
} | ||
} | ||
} | ||
} |
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
1 change: 0 additions & 1 deletion
1
libs/design/accordion/src/accordion/accordion/accordion.component.html
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
libs/design/accordion/src/accordion/accordion/accordion.component.scss
This file was deleted.
Oops, something went wrong.
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