Skip to content

Commit

Permalink
docs(accordion): updated docs (#1020)
Browse files Browse the repository at this point in the history
* docs(accordion): move responsive design content from Styles to Guidelines

* docs(accordion): started cleaning up accordion docs

* docs(accordion): updated accordion docs

* docs(accordion): updated docs

* docs(accordion): updated tables

* docs(accordion): Fixed broken image and extra image text

* docs(accordion): fixed paths on accessibility images

* docs(accordion): added kbd markup to accesisbility page's keyboard table

* docs(accordion): added palette one to teo example images on guidelines page

* docs(accordion): updated table column widths

* docs(accordion): updated spacers to shortcode

---------

Co-authored-by: marionnegp <mapatel@redhat.com>
  • Loading branch information
nikkimk and marionnegp committed Jun 5, 2023
1 parent 52f901f commit 1a569a2
Show file tree
Hide file tree
Showing 53 changed files with 333 additions and 211 deletions.
5 changes: 5 additions & 0 deletions .changeset/heavy-olives-search.md
@@ -0,0 +1,5 @@
---
"@rhds/elements": patch
---

`<rh-accordion>`: corrected and updated custom elements manifest
2 changes: 1 addition & 1 deletion docs/scss/components/_example.scss
Expand Up @@ -224,7 +224,7 @@ rh-alert + .example {
.section {
.example {
img {
max-width: var(--example-img-max-width, 100%);
width: auto;
max-height: var(--example-img-max-height, auto);
object-fit: contain;
overflow: hidden;
Expand Down
151 changes: 10 additions & 141 deletions elements/rh-accordion/docs/00-overview.md
@@ -1,11 +1,11 @@
{% section %}

## Overview
Accordions toggle the visibility of sections of content. They feature panels
that consist of a section text label and a caret icon that collapses or expands
to reveal more information.
{% endsection %}
{{ tagName | getElementDescription }}

{% example palette="light",
alt="An accordion with four collapsed panels and one expanded panel",
src="./accordion-sample-element.png" %}
{% endsection %}
{% section %}
## Sample component

Expand Down Expand Up @@ -63,9 +63,6 @@ to reveal more information.
</rh-accordion>

{% endsection %}

{% repoStatus type="Element" %}

{% section %}
## Demos
View a live version of this component and see how it can be customized.
Expand All @@ -74,139 +71,11 @@ to reveal more information.
View the `<rh-accordion>` demo in a new tab
{% endcta %}
{% endsection %}


<hr style="margin-block:var(--rh-space-5xl);">

{% section %}
## Usage

Accordions are used for organizing blocks of content into sections in a
contained space, like product information. This enables users to hide or reveal
information as needed without being directed to another page unless they select
an interactive element. Accordions are optimal components for comparing content
because a user can expand multiple panels simultaneously.

Accordions are great for organizing content while reducing page scrolling at the
same time, but a user could miss critical information if it’s hidden or if they
have to expand too many panels. Consider if an accordion really needs to be
used. If content is critical or if it requires more focus to read, don’t use an
accordion.

### Usage vs. Disclosure

Accordions need to have at least two section panels. If only one panel is
needed, use a [Disclosure]({{ '/elements/disclosure' | url }}) instead. Accordions are
Accordions are Accordions are Accordions are Accordions are are are are are
used to organize more important information whereas a disclosure is used to
store supplementary content that might not be a crucial part of the user
experience.

Accordions feature slightly different styles than a disclosure. Accordions have
the caret icon placed on the right after the section text label whereas a
disclosure has the caret icon positioned on the left before the section text
label.

<div class="multi-column--min-400-wide margin-top--4 margin-bottom--8">
{% example palette="light",
style="margin-block:var(--rh-space-2xl)",
class="centered margin-top--4 margin-bottom--4",
alt="Example of a collapsed accordion component",
src="./accordion-usage-1.svg" %}
{% example palette="light",
style="margin-block:var(--rh-space-2xl)",
class="centered margin-top--2 margin-bottom--2",
alt="Example of a collapsed disclosure",
src="./accordion-usage-2.svg" %}
</div>

## Label formatting

Section text labels should be written concisely and be representative of the
content within. Be mindful of lengthy character counts and how they’ll impact
the appearance of accordions, especially on smaller screens or if they’re
translated.

## Content area

When a panel is expanded, it contains a content area under the section text
label and the caret icon. It may contain the same elements that can also be used
in other sections of a page, like text, cards, images, etc. Text shouldn’t
exceed eight grid columns to maintain optimal readability.

{% endsection %}

<hr style="margin-block-end:var(--rh-space-5xl);">

{% section %}
## Best practices

Accordions require at least two panels. If only one panel is needed, use a
disclosure instead.

{% example palette="wrong",
style="margin-block:var(--rh-space-2xl)",
class="inline-flex centered margin-top--1 margin-bottom--1",
alt="Accordion with one collapsed panel",
src="./accordion-bestpractice-1.svg" %}

Text inside panels shouldn’t exceed eight grid columns to maintain optimal
readability.

{% example palette="wrong",
style="margin-block:var(--rh-space-2xl)",
class="inline-flex centered margin-top--1 margin-bottom--1",
alt="Accordion with one collapsed panel",
src="./accordion-bestpractice-2.svg" %}

{% endsection %}

{% section %}
## Behavior

### States

Accordions can be collapsed and expanded to hide or reveal information when
toggled. By default, they load with all panels collapsed (this can be
customized), allowing users to get a high-level overview of the content.

### Collapsing and expanding

Accordion panels can be collapsed or expanded by clicking on or tapping the
container where the section text label and the caret icon are positioned. When a
panel is collapsed, the caret icon points to the right. When a panel expands,
the caret icon rotates 90º and points down, revealing the content inside.

{% example palette="light",
style="margin-block:var(--rh-space-2xl)",
class="multi-column--min-300-wide margin-top--1 margin-bottom--1",
alt="Accordion with one panel expanded and cursors over the clickable zones",
src="./accordion-behavior-1.svg" %}

## Multiple panels

Multiple panels can be expanded simultaneously or they can stack. Expanding one
panel doesn’t collapse another which makes it easy to compare content in the
same view.

{% example palette="light",
style="margin-block:var(--rh-space-2xl)",
class="multi-column--min-300-wide margin-top--1 margin-bottom--1",
alt="Accordion with one panel expanded and cursors over the clickable zones",
src="./accordion-behavior-2.svg" %}

### Tab order

When the Tab key is pressed repeatedly, the focus indicator moves from top to
bottom. When a user expands a panel by pressing the *Enter* or *Space*
keys, any interactive elements inside are added to the tab order before the
focus indicator reaches the next panel.

{% example palette="light",
style="margin-block:var(--rh-space-2xl)",
class="multi-column--min-300-wide margin-top--1 margin-bottom--1",
alt="Accordion with one panel expanded and cursors over the clickable zones",
src="./accordion-behavior-3.svg" %}

## When to use
- When space is at a premium and content cannot be displayed all at once
- When you need to condense a large amount of related information into sections
- When you need a way for users to read or compare sections of content simultaneously
{% endsection %}

{% repoStatus type="Element" %}
137 changes: 91 additions & 46 deletions elements/rh-accordion/docs/10-style.md
@@ -1,70 +1,115 @@
{% section %}
## Style
## Style
Accordion panels include title text, a chevron icon, body text, and other content. When a panel is collapsed, only the top and bottom borders are visible. When a panel is expanded, all borders are visible including a thicker left border for emphasis.

Accordions can be used in light and dark themes. They consist of
vertically-stacked panels that are separated by a thin line when collapsed.
Every panel contains a section text label and a caret icon that rotates to
indicate if a panel is collapsed or expanded. When a panel is expanded, it
includes different styling that consists of an active border on the left and a
slight drop shadow, also used for a [Disclosure]({{ '/patterns/disclosure' | url
}}).
### Anatomy
{% example palette="light",
alt="Anatomy of an accordion with lots of annotations pointing to various parts",
src="../accordion-anatomy.png" %}

1) Collapsed panel
2) Expanded panel
3) Title
4) Panel header region
5) Caret
6) Emphasis
7) Content
8) Panel body region
{.example-notes}

### Sizes
There are two available sizes and the only difference is the title text size. You can use the Small size on large breakpoints, but not the Large size on small breakpoints due to the potential of long title text wrapping to more than two lines.

{% example palette="light",
width=872,
style="margin-block:var(--rh-space-2xl)",
alt="Expanded accordion panel with labels",
src="../accordion-style-1.svg" %}
alt="A large size accordion with text underneath saying ‘Large size’ and a small size accordion with text underneath saying ‘Small size’",
src="../accordion-sizes.png" %}

## Theme

## Theme
An accordion is available in both light and dark themes. The light theme expanded panel includes a box shadow, but the dark theme does not.
### Light theme
{% example palette="light",
width=872,
style="margin-block:var(--rh-space-2xl)",
alt="Expanded accordion panel with labels",
src="../accordion-theme-1.svg" %}
alt="Light theme accordion with an expanded panel",
src="../accordion-theme-light.png" %}

### Dark theme
{% example palette="darkest",
width=872,
style="margin-block:var(--rh-space-2xl)",
alt="Expanded accordion panel with labels",
src="../accordion-theme-2.svg" %}

{% endsection %}
alt="Dark theme accordion with an expanded panel",
src="../accordion-theme-dark.png" %}

{% section %}
## Responsive design
## Configuration
An expanded panel does not have a maximum height, but it may scroll if constrained by vertical space. The width of an accordion varies based on content and page layout. Title text and icons are horizontally aligned.

Accordions work well when used on both large and small screens.
{% example palette="light",
alt="How an accordion is constructed showing alignment, space, scrolling, and width details",
src="../accordion-configuration.png" %}

### Breakpoints
### Nested panels
Panels can be nested to help organize complex or granular sections of content.

Accordions can be used on smaller screens, but the limited screen space makes
content taller which might make users scroll more, so be careful about how much
content is included.
{% example palette="light",
alt="An accordion with an expanded panel and a nested expanded panel",
src="../accordion-nested-panels.png" %}

### Desktop
### Stacked panels
Multiple panels can be expanded simultaneously even when nested.

![Expanded accordion on tablet]({{ '../accordion-responsive-1.svg' | url }}) {style="margin-block:var(--rh-space-md);"}
{% example palette="light",
alt="An accordion with one collapsed panel on top and two stacked expanded panels below",
src="../accordion-stacked-panels.png" %}

### Tablet
## Space
{% example palette="light",
alt="Accordion spacing within panels and in between elements like titles, body text, rules, and icons",
src="../accordion-space.png" %}

{% spacerTokensTable
headline="",
caption='',
headingLevel="4",
tokens="--rh-space-lg, --rh-space-xl, --rh-space-3xl" %}
{% endspacerTokensTable %}

## Interaction states
Interaction states are visual representations used to communicate the status of an element or pattern.

### Hover
{% example palette="light",
alt="Light theme accordion hover state examples",
src="../accordion-hover-theme-light.png" %}

![Expanded accordion on tablet]({{ '../accordion-responsive-2.svg' | url }}) {style="margin-block:var(--rh-space-md);--inline-img-max-width: 768px;"}
{% example palette="darkest",
alt="Dark theme accordion hover state example",
src="../accordion-hover-theme-dark.png" %}

### Mobile
| Property {style="width: 33%" } | Light theme {style="width: 33%" } | Dark theme |
| ------------------------------ | --------------------------------- | ---------- |
| Color - panel header | `#F2F2F2` | `#292929` |

![Expanded accordion on mobile]({{ '../accordion-responsive-3.svg' | url }}) {style="margin-block:var(--rh-space-md);--inline-img-max-width: 352px;"}
### Focus
{% example palette="light",
alt="Light theme accordion focus state examples",
src="../accordion-focus-theme-light.png" %}

{% endsection %}
{% example palette="darkest",
alt="Dark theme accordion focus state example",
src="../accordion-focus-theme-dark.png" %}

{% section %}
## Spacing
| Property {style="width: 33%" } | Light theme {style="width: 33%" } | Dark theme |
| ------------------------------ | --------------------------------- | ---------- |
| Color - panel header | `#F2F2F2` | `#292929` |
| Color - focus ring | `#0066CC` | `#73BCF7` |

Accordions use [PatternFly 4 spacers][spacers] to define spacing values between
elements.

![Accordion with spacers]({{ '../accordion-spacing-1.svg' | url }}) {style="margin-block-start:var(--rh-space-2xl);"}
### Active
{% example palette="light",
alt="Light theme accordion active state examples",
src="../accordion-active-theme-light.png" %}

![Nested accordion with spacers]({{ '../accordion-spacing-2.svg' | url }}) {style="margin-block:var(--rh-space-3xl);"}
{% example palette="darkest",
alt="Dark theme accordion active state example",
src="../accordion-active-theme-dark.png" %}

[spacers]: https://www.patternfly.org/v4/guidelines/spacers
{% endsection %}
| Property {style="width: 33%" } | Light theme {style="width: 33%" } | Dark theme |
| ------------------------------ | --------------------------------- | ---------- |
| Color - panel header | `#F2F2F2` | `#292929` |
| Color - focus ring | `#0066CC` | `#73BCF7` |

0 comments on commit 1a569a2

Please sign in to comment.