Skip to content

Commit a7d3ea2

Browse files
committed
docs(accordion): enhance inline documentation
- Enhanced `accents` property JSDoc with semantic meaning explaining inline vs bottom positioning and usage guidelines - Enhanced default slot documentation in rh-accordion-header with detailed description of title text best practices - Added comprehensive JSDoc for `expanded` property explaining when and why to use it - Added inline comment for `container` part describing its semantic role This addresses the missing documentation identified in issue #2487. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Assisted-By: Claude <noreply@anthropic.com>
1 parent d9877e7 commit a7d3ea2

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

elements/rh-accordion/rh-accordion-header.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,15 @@ export class RhAccordionHeader extends LitElement {
8888
<span id="header-container" class="${classMap({ [accents ?? '']: !!accents })}">
8989
<!-- summary: inline element containing the heading text or slotted heading content -->
9090
<span id="header-text" part="text">
91-
<!-- summary: accordion toggle content -->
91+
<!-- summary: panel's title text or heading content
92+
description: |
93+
Contains the primary label that describes what content will be revealed when the panel expands.
94+
Title text should be written concisely (max 65 characters) so users know what to expect.
95+
Avoid writing titles that sound like calls to action - make it easy for users to understand
96+
the content within. Title text that is too long should be broken into separate sections, and
97+
text that is too vague may not help users understand the panel content.
98+
99+
@see [Title text](https://ux.redhat.com/elements/accordion/guidelines/#title-text) in Guidelines documentation -->
92100
<slot></slot>
93101
</span>
94102
<!-- summary: container for accents within the header -->

elements/rh-accordion/rh-accordion-panel.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ import styles from './rh-accordion-panel.css';
2121
export class RhAccordionPanel extends LitElement {
2222
static readonly styles = [styles];
2323

24+
/**
25+
* Sets the initial visibility state of the panel content.
26+
* When `true`, the panel is expanded and its content is visible.
27+
* When `false` (default), the panel is collapsed and its content is hidden.
28+
*
29+
* ## Usage guidelines
30+
* - Use to draw attention to important content that should be immediately visible
31+
* - Set on the first panel in a FAQ or help section to show the most common question
32+
* - Supports multiple panels being expanded simultaneously for content comparison
33+
* - Users can expand and collapse panels one at a time by default, or multiple panels
34+
* when implementing "Expand all" functionality
35+
*
36+
* By default, all panels are collapsed (expanded=false). Users expand panels by clicking
37+
* the header, which animates the caret icon and reveals the content.
38+
*
39+
* @see [Expanding and collapsing panels](https://ux.redhat.com/elements/accordion/guidelines/#expanding-and-collapsing-panels) in Guidelines documentation
40+
*/
2441
@property({ type: Boolean, reflect: true }) expanded = false;
2542

2643
@consume({ context, subscribe: true })
@@ -37,6 +54,12 @@ export class RhAccordionPanel extends LitElement {
3754
const { expanded } = this;
3855
const { large = false } = this.ctx ?? {};
3956
return html`
57+
<!-- summary: main wrapper region that contains the panel content
58+
description: |
59+
The container part represents the structural element that holds the panel's body content.
60+
It maintains the color scheme context to ensure proper text visibility and color contrast,
61+
and should match the color palette of the container it's in. This part defines the overall
62+
styling and boundaries for the panel's revealed content area. -->
4063
<div id="container"
4164
class="${classMap({ large, expanded, content: true })}"
4265
part="container"

elements/rh-accordion/rh-accordion.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,18 @@ export class RhAccordion extends LitElement {
7676
}
7777

7878
/**
79-
* Sets accordion header's accents position to inline or bottom
79+
* Positions the accent slot content relative to the panel's title.
80+
* The accent slot contains secondary information such as tags, badges, or other small elements.
81+
*
82+
* - `inline` (default) - Accents appear on the same line as the title
83+
* - `bottom` - Accents appear below the title
84+
*
85+
* ## Usage guidelines
86+
* - Use `inline` when accents are brief and horizontal space permits for both title and accents
87+
* - Use `bottom` when you have multiple accent elements or need more horizontal space for the title text
88+
* - Accent content represents secondary, supplementary information to the title
89+
*
90+
* @see [Accent slot](https://ux.redhat.com/elements/accordion/style/#accent-slot) in Style documentation
8091
*/
8192
@property({ attribute: true, reflect: true }) accents?: 'inline' | 'bottom';
8293

0 commit comments

Comments
 (0)