Skip to content

Commit 95fca23

Browse files
committed
docs: move css part docs inline
1 parent af09f53 commit 95fca23

File tree

15 files changed

+129
-68
lines changed

15 files changed

+129
-68
lines changed

.changeset/cold-tools-follow.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@patternfly/elements": patch
3+
---
4+
5+
Use inline slot documentation instead of JSDoc
6+

elements/pf-accordion/pf-accordion-header.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ export class PfAccordionHeaderChangeEvent extends Event {
3030

3131
/**
3232
* Accordion Header
33-
* @csspart text - inline element containing the heading text or slotted heading content
34-
* @csspart accents - container for accents within the header
35-
* @csspart icon - caret icon
36-
* @slot
37-
* We expect the light DOM of the pf-accordion-header to be a heading level tag (h1, h2, h3, h4, h5, h6)
38-
* @slot accents
39-
* These elements will appear inline with the accordion header, between the header and the chevron
40-
* (or after the chevron and header in disclosure mode).
4133
* @fires {AccordionHeaderChangeEvent} change - when the open panels change
4234
* @cssprop {<color>} [--pf-c-accordion__toggle--Color=var(--pf-global--Color--100, #151515)]
4335
* Sets the font color for the accordion header.
@@ -136,12 +128,21 @@ export class PfAccordionHeader extends LitElement {
136128
class="toggle"
137129
@click="${this.#onClick}"
138130
aria-expanded="${String(!!this.expanded) as 'true' | 'false'}">
131+
<!-- summary: inline element containing the heading text or slotted heading content -->
139132
<span part="text">${headingText ?? html`
133+
<!-- summary: A heading level tag (h1, h2, h3, h4, h5, h6) -->
140134
<slot></slot>`}
141135
</span>
136+
<!-- summary: container for accents within the header -->
142137
<span part="accents" ?hidden="${this.#slots.isEmpty('accents')}">
138+
<!-- summary: Header accent elements like tag or icon
139+
description: |
140+
These elements will appear inline with the accordion header,
141+
between the header and the chevron
142+
(or after the chevron and header in disclosure mode). -->
143143
<slot name="accents"></slot>
144144
</span>
145+
<!-- summary: caret icon -->
145146
<pf-icon part="icon"
146147
class="icon"
147148
size="lg"

elements/pf-back-to-top/pf-back-to-top.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import styles from './pf-back-to-top.css';
1414
* The **back to top** component is a shortcut that allows users to quickly navigate to the top of a lengthy content page.
1515
* @summary A shortcut that allows users to quickly navigate to the top of a lengthy content page.
1616
* @alias Back to Top
17-
* @csspart trigger - The `<a>` or `<pf-button>` element
1817
* @cssprop {<length>} [--pf-c-back-to-top--Right=3rem`]
1918
* @cssprop {<length>} [--pf-c-back-to-top--Bottom=1.5rem`]
2019
* @cssprop [--pf-c-back-to-top--c-button--BoxShadow=0 0.75rem 0.75rem -0.5rem rgba(3, 3, 3, 0.18)]
@@ -109,7 +108,11 @@ export class PfBackToTop extends LitElement {
109108

110109
if (this.href) {
111110
return html`
112-
<a href="${this.href}" ?hidden="${!this.#visible}" part="trigger" aria-label="${ifDefined(this.#ariaLabel)}">
111+
<!-- The \`<a>\` or \`<pf-button>\` element -->
112+
<a href="${this.href}"
113+
?hidden="${!this.#visible}"
114+
part="trigger"
115+
aria-label="${ifDefined(this.#ariaLabel)}">
113116
<!-- Contains the prefix icon to display before the link or button. -->
114117
<slot name="icon"></slot>
115118
<!-- Text to display inside the link or button. -->
@@ -119,6 +122,7 @@ export class PfBackToTop extends LitElement {
119122
`;
120123
} else {
121124
return html`
125+
<!-- The \`<a>\` or \`<pf-button>\` element -->
122126
<pf-button
123127
icon="${ifDefined(this.icon)}"
124128
icon-set="${ifDefined(this.iconSet)}"

elements/pf-banner/pf-banner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export type BannerVariant = (
3535
* @cssprop {<color>} [--pf-c-banner--m-warning--BackgroundColor=#f0ab00]
3636
* @cssprop [--pf-c-banner--m-sticky--ZIndex=300]
3737
* @cssprop [--pf-c-banner--m-sticky--BoxShadow=0 0.5rem 0.5rem -0.375rem rgba(3, 3, 3, 0.18)]
38-
* @csspart container - The container of the banner
3938
*/
4039
@customElement('pf-banner')
4140
export class PfBanner extends LitElement {
@@ -63,6 +62,7 @@ export class PfBanner extends LitElement {
6362
const { variant, icon } = this;
6463
const hasIcon = !!icon || this.#slots.hasSlotted('icon');
6564
return html`
65+
<!-- The container of the banner -->
6666
<div id="container" part="container"
6767
class=${classMap({ hasIcon, [variant ?? '']: !!variant })}>
6868
<!-- Contains the labels's icon, e.g. web-icon-alert-success. -->

elements/pf-card/pf-card.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import style from './pf-card.css';
1515
* like card views, or for positioning content on a page.
1616
* @summary Gives a preview of information in a small layout
1717
* @alias Card
18-
* @csspart header - The container for *header* content
19-
* @csspart body - The container for *body* content
20-
* @csspart footer - The container for *footer* content
2118
* @cssprop {<color>} [--pf-c-card--BackgroundColor=#ffffff]
2219
* @cssprop {<color>} [--pf-c-card--BoxShadow=0 0.0625rem 0.125rem 0 rgba(3, 3, 3, 0.12), 0 0 0.125rem 0 rgba(3, 3, 3, 0.06)]
2320
* @cssprop {<color>} [--pf-c-card--size-compact__body--FontSize=.875rem]
@@ -74,24 +71,40 @@ export class PfCard extends LitElement {
7471
render(): TemplateResult<1> {
7572
return html`
7673
<article>
74+
<!-- summary: The container for *header* content -->
7775
<header id="header"
7876
part="header"
7977
class="${classMap({ empty: this.#slots.isEmpty('header') })}">
80-
<!-- When included, defines the contents of a card. Card headers can contain images as well as the title of a card and an actions menu represented by the right-aligned kebab. In most cases, your card should include a header. The only exceptions are when cards being used as a layout element to create a white background behind other content. -->
78+
<!-- summary: When included, defines the contents of a card.
79+
description: |
80+
Card headers can contain images as well as the title of a card and an actions menu
81+
represented by the right-aligned kebab. In most cases, your card should include a
82+
header. The only exceptions are when cards being used as a layout element to
83+
create a white background behind other content.
84+
-->
8185
<slot name="header"></slot>
82-
<!-- Communicates the title of a card if it's not included in the header. If a card will be utilized as a selectable and clickable card, the title needs to be made as a linked text to trigger action and indicate interaction. -->
86+
<!-- summary: Communicates the title of a card if it's not included in the header.
87+
description: |
88+
If a card will be utilized as a selectable and clickable card, the title
89+
needs to be made as a linked text to trigger action and indicate interaction.
90+
-->
8391
<slot id="title" name="title" ?hidden="${this.#slots.isEmpty('title')}"></slot>
8492
</header>
93+
<!-- summary: The container for *body* content -->
8594
<div id="body"
8695
part="body"
8796
class="${classMap({ empty: this.#slots.isEmpty(null) })}">
88-
<!-- Body. Provides details about the item. A card body can include any combination of static text and/or active content. -->
97+
<!-- summary: Body. Provides details about the item.
98+
description: |
99+
A card body can include any combination of static text and/or active content.
100+
-->
89101
<slot></slot>
90102
</div>
103+
<!-- summary: The container for *footer* content -->
91104
<footer id="footer"
92105
part="footer"
93106
class="${classMap({ empty: this.#slots.isEmpty('footer') })}">
94-
<!-- Contains external links, actions, or static text at the bottom of a card. -->
107+
<!-- summary: Contains external links, actions, or static text at the bottom of a card. -->
95108
<slot name="footer"></slot>
96109
</footer>
97110
</article>

elements/pf-chip/pf-chip.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export class PfChipRemoveEvent extends Event {
1818
* @alias Chip
1919
* @fires {ChipRemoveEvent} remove - Fires when chip is removed
2020
* @fires {Event} click - when close button is clicked
21-
* @csspart text - container for chip text
2221
* @cssprop [--pf-c-chip--PaddingTop=var(--pf-global--spacer--xs, 0.25rem)]
2322
* @cssprop [--pf-c-chip--PaddingRight=var(--pf-global--spacer--sm, 0.5rem)]
2423
* @cssprop [--pf-c-chip--PaddingBottom=var(--pf-global--spacer--xs, 0.25rem)]
@@ -64,13 +63,15 @@ export class PfChip extends LitElement {
6463
render(): TemplateResult<1> {
6564
return this.overflowChip ? html`
6665
<button id="outer">
66+
<!-- container for chip text -->
6767
<span part="text">
6868
<!-- chip text -->
6969
<slot></slot>
7070
</span>
7171
</button>
7272
` : html`
7373
<div id="outer">
74+
<!-- container for chip text -->
7475
<span id="chip-text" part="text">
7576
<!-- chip text -->
7677
<slot></slot>

elements/pf-dropdown/pf-dropdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export class PfDropdownSelectEvent extends Event {
3232
* A **dropdown** presents a menu of actions or links in a constrained space that
3333
* will trigger a process or navigate to a new location.
3434
* @alias Dropdown
35-
* @csspart menu - The dropdown menu wrapper
3635
* @cssprop {<length>} [--pf-c-dropdown__menu--PaddingTop=0.5rem] Dropdown top padding
3736
* @cssprop {<length>} [--pf-c-tooltip__content--PaddingRight=0.5rem] Dropdown right padding
3837
* @cssprop {<length>} [--pf-c-dropdown__menu--ZIndex=200] Dropdown z-index
@@ -116,6 +115,7 @@ export class PfDropdown extends LitElement {
116115
@focusout="${this.#onMenuFocusout}"
117116
@keydown="${this.#onMenuKeydown}"
118117
@click="${this.#onSelect}">
118+
<!-- The dropdown menu wrapper -->
119119
<pf-dropdown-menu id="menu" part="menu" ?disabled="${disabled}">
120120
<!-- Must contain one or more \`<pf-dropdown-item>\` or \`<pf-dropdown-group>\` -->
121121
<slot></slot>

elements/pf-icon/pf-icon.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export class IconResolveError extends ErrorEvent {
3939
* @alias Icon
4040
* @fires load - Fired when an icon is loaded and rendered
4141
* @fires error - Fired when an icon fails to load
42-
* @csspart fallback - Container for the fallback (i.e. slotted) content
4342
* @cssprop {<length>} --pf-icon--size - size of the icon
4443
*/
4544
@customElement('pf-icon')
@@ -203,8 +202,13 @@ export class PfIcon extends LitElement {
203202
render(): TemplateResult<1> {
204203
const content = this.content ?? '';
205204
return html`
206-
<div id="container" aria-hidden="true">${content}<span part="fallback"
207-
?hidden=${!!content}><!-- Slotted content is used as a fallback in case the icon doesn't load --><slot></slot>
205+
<div id="container" aria-hidden="true">${content}<!--
206+
summary: Container for the fallback (i.e. slotted) content
207+
-->
208+
<span part="fallback"
209+
?hidden=${!!content}><!--
210+
summary: Slotted content is used as a fallback in case the icon doesn't load
211+
--><slot></slot>
208212
</span>
209213
</div>
210214
`;

elements/pf-label/pf-label.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,6 @@ export class LabelCloseEvent extends Event {
6969
* @cssprop {<color>} [--pf-c-label--m-orange__icon--Color=#ec7a08]
7070
* @cssprop {<color>} [--pf-c-label--m-red__icon--Color=#c9190b]
7171
* @cssprop {<color>} [--pf-c-label--m-gold__icon--Color=#f0ab00]
72-
* @csspart icon - container for the label icon
73-
* @csspart close-button - container for removable labels' close button
7472
* @cssprop {<length>} [--pf-c-label--m-compact--PaddingTop=0]
7573
* @cssprop {<length>} [--pf-c-label--m-compact--PaddingRight=0.5rem]
7674
* @cssprop {<length>} [--pf-c-label--m-compact--PaddingBottom=0]
@@ -137,14 +135,19 @@ export class PfLabel extends LitElement {
137135
truncated,
138136
[variant ?? '']: !!variant,
139137
[color ?? '']: !!color })}">
140-
<!-- Contains the labels's icon, e.g. web-icon-alert-success. -->
138+
<!-- slot:
139+
summary: Contains the labels's icon, e.g. web-icon-alert-success.
140+
part:
141+
summary: container for the label icon
142+
-->
141143
<slot name="icon" part="icon">
142144
<pf-icon ?hidden="${!icon}"
143145
size="sm"
144146
.icon="${this.icon || undefined as unknown as string}"></pf-icon>
145147
</slot>
146-
<!-- Must contain the text for the label. -->
148+
<!-- summary: Must contain the text for the label. -->
147149
<slot id="text"></slot>
150+
<!-- summary: container for removable labels' close button -->
148151
<span part="close-button" ?hidden=${!this.removable}>
149152
<pf-button plain
150153
@click="${this.#onClickClose}"

elements/pf-modal/pf-modal.ts

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,6 @@ export class ModalOpenEvent extends ComposedEvent {
4141
* @alias Modal
4242
* @fires {ModalOpenEvent} open - Fires when a user clicks on the trigger or manually opens a modal.
4343
* @fires {ModalCloseEvent} close - Fires when either a user clicks on either the close button or the overlay or manually closes a modal.
44-
* @csspart overlay - The modal overlay which lies under the dialog and above the page body
45-
* @csspart dialog - The dialog element
46-
* @csspart content - The container for the dialog content
47-
* @csspart header - The container for the optional dialog header
48-
* @csspart description - The container for the optional dialog description in the header
49-
* @csspart close-button - The modal's close button
50-
* @csspart footer - Actions footer container
5144
* @cssprop {<length>} [--pf-c-modal-box--ZIndex=500]
5245
* @cssprop {<length>} [--pf-c-modal-box--Width=calc(100 - 2rem)] - Width of the modal
5346
* @cssprop {<length>} [--pf-c-modal-box--MaxWidth=calc(100 - 2rem)] - Max width of the modal
@@ -122,7 +115,9 @@ export class PfModal extends LitElement implements HTMLDialogElement {
122115

123116
return html`
124117
<section ?hidden=${!this.open}>
118+
<!-- summary: The modal overlay which lies under the dialog and above the page body -->
125119
<div id="overlay" part="overlay" ?hidden=${!this.open}></div>
120+
<!-- summary: The dialog element -->
126121
<div id="dialog"
127122
part="dialog"
128123
tabindex="0"
@@ -131,21 +126,34 @@ export class PfModal extends LitElement implements HTMLDialogElement {
131126
aria-label=${ifDefined(headerLabel)}
132127
?hidden="${!this.open}">
133128
<div id="container">
129+
<!-- summary: The container for the dialog content -->
134130
<div id="content" part="content" class=${classMap({ hasHeader, hasDescription, hasFooter })}>
131+
<!-- summary: The container for the optional dialog header -->
135132
<header part="header">
136-
<!-- The header is an optional slot that appears at the top of the modal window. It should be a header tag (h2-h6). -->
133+
<!-- summary: Heading tag
134+
description: |
135+
The header is an optional slot that appears at the top of the modal window.
136+
It should be a heading tag (h2-h6). -->
137137
<slot name="header"></slot>
138+
<!-- summary: The container for the optional dialog description in the header -->
138139
<div part="description" ?hidden=${!hasDescription}>
139140
<slot name="description"></slot>
140141
</div>
141142
</header>
142-
<!-- The default slot can contain any type of content. When the header is not present this unnamed slot appear at the top of the modal window (to the left of the close button). Otherwise it will appear beneath the header. -->
143+
<!--
144+
summary: Modal dialog content
145+
description: |
146+
The default slot can contain any type of content. When the header is not present,
147+
this unnamed slot appear at the top of the modal window (to the left of the close
148+
button). Otherwise it will appear beneath the header. -->
143149
<slot></slot>
150+
<!-- summary: Actions footer container -->
144151
<footer ?hidden=${!hasFooter} part="footer">
145-
<!-- Optional footer content. Good place to put action buttons. -->
152+
<!-- summary: Optional footer content. Good place to put action buttons. -->
146153
<slot name="footer"></slot>
147154
</footer>
148155
</div>
156+
<!-- summary: The modal's close button -->
149157
<button id="close-button"
150158
part="close-button"
151159
aria-label="Close dialog"

0 commit comments

Comments
 (0)