-
Notifications
You must be signed in to change notification settings - Fork 249
chore(accordion): full fidelity feature update #6319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rise-erpelding
merged 79 commits into
swc-1854/accordion-migration
from
swc-1860-full-fidelity
May 29, 2026
Merged
Changes from 63 commits
Commits
Show all changes
79 commits
Select commit
Hold shift + click to select a range
432f56c
docs(accordion): refine planning docs (#6269)
rise-erpelding 09cd821
chore: scaffold core package
rise-erpelding bba2e18
chore: scaffold swc package
rise-erpelding 87bdc5e
chore: add Chevron300Icon for xl accordion
rise-erpelding 570c138
chore: set up storybook story
rise-erpelding 6e71c8d
chore: commit preview.ts updates
rise-erpelding bc7bf87
feat: implement AccordionItem API and render template
rise-erpelding f94b6ce
feat: implement Accordion API and propagation
rise-erpelding 3a4454b
feat: implement open and toggle logic
rise-erpelding 16dc689
feat: wire up dynamic heading levels
rise-erpelding 9b7ebc4
feat: implement disabled item functionality
rise-erpelding e2ce2a7
fix: handle space keyboard behavior (SWC-1487)
rise-erpelding 24dd4bf
refactor: address missing migration-setup items
rise-erpelding 5d4c209
refactor: rename methods, align file names
rise-erpelding 56ad095
refactor: typing, heading rendering, sizing
rise-erpelding fee852f
refactor: move toggle() into base, smooth a11y behavior
rise-erpelding e8ed70d
refactor: use assignedItems() helper
rise-erpelding f2d5056
test: add a11y tests
rise-erpelding 12da5fc
docs: add a11y docs
rise-erpelding 65b949b
fix: freeze accordion open state when disabled
rise-erpelding c8033e6
feat: 1st-gen deprecation warnings/tests
rise-erpelding 737bd62
docs: jsdoc comments
rise-erpelding 1975d7e
chore(accordion): full fidelity feature update
miwha-adobe f0a99ee
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe c6495a5
chore: changeset
rise-erpelding 329b428
fix: revert 1st-gen refactor work
rise-erpelding c6341e3
chore(accordion): defer tests, deprecations, and changeset to part two
rise-erpelding 4b9fc09
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe 057a70a
docs(accordion): refine planning docs (#6269)
rise-erpelding bede72f
chore: scaffold core package
rise-erpelding 79b82b3
chore: scaffold swc package
rise-erpelding 8c69ece
chore: add Chevron300Icon for xl accordion
rise-erpelding cb55ae1
chore: set up storybook story
rise-erpelding 8c61687
chore: commit preview.ts updates
rise-erpelding 629c233
feat: implement AccordionItem API and render template
rise-erpelding 176c95a
feat: implement Accordion API and propagation
rise-erpelding 5896710
feat: implement open and toggle logic
rise-erpelding 7318895
feat: wire up dynamic heading levels
rise-erpelding 1221bee
feat: implement disabled item functionality
rise-erpelding d4d945d
fix: handle space keyboard behavior (SWC-1487)
rise-erpelding b26f30f
refactor: address missing migration-setup items
rise-erpelding 4ee7d20
refactor: rename methods, align file names
rise-erpelding 885c98a
refactor: typing, heading rendering, sizing
rise-erpelding e2cb7d3
refactor: move toggle() into base, smooth a11y behavior
rise-erpelding 365577a
refactor: use assignedItems() helper
rise-erpelding 12d5760
test: add a11y tests
rise-erpelding e10e351
docs: add a11y docs
rise-erpelding b16028b
fix: freeze accordion open state when disabled
rise-erpelding b102a88
feat: 1st-gen deprecation warnings/tests
rise-erpelding b9b7d88
docs: jsdoc comments
rise-erpelding cf3c2a5
chore: changeset
rise-erpelding c940abb
fix: revert 1st-gen refactor work
rise-erpelding e63c363
chore(accordion): defer tests, deprecations, and changeset to part two
rise-erpelding a7c9f25
fix(accordion): update css font
miwha-adobe 306207c
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe e8dc485
fix: class selectors
rise-erpelding 68495e1
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe f741213
feat: set up accordion file structure, API, and a11y (#6300)
rise-erpelding 1fc9f47
fix(accordion): address PR review feedback on CSS and stories
miwha-adobe 1e2b65c
Merge remote-tracking branch 'origin/swc-1854/accordion-migration' in…
miwha-adobe 8963629
fix(accordion): restore row wrapper and register swc-button in stories
miwha-adobe ae634d4
fix(accordion): change ceiling amount to spacing-300
miwha-adobe c934067
fix(accordion): fix token names for header and content sections
miwha-adobe ce1afd9
fix: move private custom properties from accordion-item :host
rise-erpelding 75b114e
fix: adjust .swc-AccordionItem-header custom properties
rise-erpelding 141d203
fix: adjust content inline padding custom properties
rise-erpelding 920ec0c
chore: update preview.ts and migration plan
rise-erpelding 99506f9
feat: spacing on direct actions
rise-erpelding cd6b6c1
docs: improve ai skill
rise-erpelding ad9eeb3
fix: use <p>s in stories and account for their margin
rise-erpelding 2a2a19f
docs: add cssprops to jsdocs
rise-erpelding 7e2e0c4
chore: rename custom props for accordion item
rise-erpelding ae2ccb9
feat: handle panel animation
rise-erpelding fb3d42f
fix: use better selectors
rise-erpelding b9e63b3
docs: docs updates
rise-erpelding 9a53700
fix: handle quiet and corner radius tokens
rise-erpelding ea68fc7
chore: update migration plan
rise-erpelding d46f00c
chore(accordion): merge swc-1854/accordion-migration into full-fidelity
rise-erpelding b3f64f3
fix: feedback fixes
rise-erpelding File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
208 changes: 208 additions & 0 deletions
208
2nd-gen/packages/core/components/accordion/Accordion.base.ts
This file contains hidden or 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,208 @@ | ||
| /** | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import { PropertyValues } from 'lit'; | ||
| import { property } from 'lit/decorators.js'; | ||
|
|
||
| import { SpectrumElement } from '@spectrum-web-components/core/element/index.js'; | ||
| import { SizedMixin } from '@spectrum-web-components/core/mixins/index.js'; | ||
|
|
||
| import { | ||
| ACCORDION_VALID_SIZES, | ||
| type AccordionDensity, | ||
| type AccordionHeadingLevel, | ||
| type AccordionSize, | ||
| SWC_ACCORDION_ITEM_TOGGLE_EVENT, | ||
| } from './Accordion.types.js'; | ||
| import { AccordionItemBase } from './AccordionItem.base.js'; | ||
|
|
||
| /** | ||
| * Base class for accordion components. Manages item propagation, heading | ||
| * level, density, and the exclusive-open constraint. | ||
| * | ||
| * @attribute {boolean} allowMultiple - Reflected as `allow-multiple`. When set, | ||
| * multiple items may be open at the same time. | ||
| * @attribute {number} level - Heading level (2–6) applied to every item header. | ||
| * Values outside that range are clamped. | ||
| * @attribute {AccordionSize} size - Size applied to all items. | ||
| * @attribute {AccordionDensity} density - Vertical spacing between items. | ||
| * @attribute {boolean} quiet - Renders the accordion in its quiet visual variant. | ||
| * @attribute {boolean} disabled - Disables all items in the accordion. | ||
| * | ||
| * @slot - One or more `swc-accordion-item` elements. | ||
| */ | ||
| export abstract class AccordionBase extends SizedMixin(SpectrumElement, { | ||
| validSizes: ACCORDION_VALID_SIZES, | ||
| defaultSize: 'm', | ||
| }) { | ||
| // ────────────────── | ||
| // PUBLIC API | ||
| // ────────────────── | ||
|
|
||
| /** | ||
| * When set, multiple items may be open at the same time. By default only | ||
| * one item can be open. | ||
| */ | ||
| @property({ type: Boolean, reflect: true, attribute: 'allow-multiple' }) | ||
| public allowMultiple: boolean = false; | ||
|
|
||
| /** | ||
| * Heading level applied to every item header (2–6). Defaults to 3. | ||
| * Values outside that range are clamped. | ||
| */ | ||
| @property({ type: Number, reflect: true }) | ||
| public level: AccordionHeadingLevel = 3; | ||
|
|
||
| /** | ||
| * Size applied to all items. Defaults to `m`. | ||
| */ | ||
| declare public size: AccordionSize; | ||
|
|
||
| /** | ||
| * Controls vertical spacing between items. | ||
| * | ||
| * @default regular | ||
| */ | ||
| @property({ type: String, reflect: true }) | ||
| public density: AccordionDensity = 'regular'; | ||
|
|
||
| /** | ||
| * Renders the accordion in its quiet (no-border) visual variant. | ||
| */ | ||
| @property({ type: Boolean, reflect: true }) | ||
| public quiet: boolean = false; | ||
|
|
||
| /** | ||
| * Disables all items in the accordion. Individual items may also be | ||
| * disabled independently. | ||
| */ | ||
| @property({ type: Boolean, reflect: true }) | ||
| public disabled: boolean = false; | ||
|
|
||
| // ────────────────────── | ||
| // IMPLEMENTATION | ||
| // ────────────────────── | ||
|
|
||
| private assignedItems(): AccordionItemBase[] { | ||
| const slot = this.renderRoot?.querySelector('slot'); | ||
| if (!slot) { | ||
| return []; | ||
| } | ||
| return slot | ||
| .assignedElements({ flatten: true }) | ||
| .filter((el): el is AccordionItemBase => el instanceof AccordionItemBase); | ||
| } | ||
|
|
||
| private closeSiblingsOnOpen = (event: Event): void => { | ||
| if (this.disabled) { | ||
| event.preventDefault(); | ||
| return; | ||
| } | ||
| if (this.allowMultiple) { | ||
| return; | ||
| } | ||
| const toggling = event.target; | ||
| if (!(toggling instanceof AccordionItemBase)) { | ||
| return; | ||
| } | ||
| // Defer until after dispatch returns so that a canceled toggle (where the | ||
| // item reverts open back to false) does not incorrectly close siblings. | ||
| queueMicrotask(() => { | ||
| if (!toggling.open) { | ||
| return; | ||
| } | ||
| for (const item of this.assignedItems()) { | ||
| if (item !== toggling) { | ||
| item.open = false; | ||
| } | ||
| } | ||
| }); | ||
| }; | ||
|
|
||
| protected syncAccordionItems(): void { | ||
| for (const item of this.assignedItems()) { | ||
| item.setManagedHeading(this.level); | ||
| item.size = this.size; | ||
| item.setManagedParentDisabled(this.disabled); | ||
| } | ||
| } | ||
|
|
||
| private enforceExclusiveOpen(): void { | ||
| let foundOpen = false; | ||
| for (const item of this.assignedItems()) { | ||
| if (item.open) { | ||
| if (foundOpen) { | ||
| item.open = false; | ||
| } else { | ||
| foundOpen = true; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public override connectedCallback(): void { | ||
| super.connectedCallback(); | ||
| this.addEventListener( | ||
| SWC_ACCORDION_ITEM_TOGGLE_EVENT, | ||
| this.closeSiblingsOnOpen | ||
| ); | ||
| } | ||
|
|
||
| public override disconnectedCallback(): void { | ||
| super.disconnectedCallback(); | ||
| this.removeEventListener( | ||
| SWC_ACCORDION_ITEM_TOGGLE_EVENT, | ||
| this.closeSiblingsOnOpen | ||
| ); | ||
| } | ||
|
|
||
| protected override update(changedProperties: PropertyValues): void { | ||
| if (changedProperties.has('level')) { | ||
| const clamped = Math.min( | ||
| 6, | ||
| Math.max(2, this.level) | ||
| ) as AccordionHeadingLevel; | ||
| if (this.level !== clamped) { | ||
| this.level = clamped; | ||
| } | ||
| } | ||
| if ( | ||
| changedProperties.has('level') || | ||
| changedProperties.has('size') || | ||
| changedProperties.has('disabled') | ||
| ) { | ||
| this.syncAccordionItems(); | ||
| } | ||
| // changedProperties.get() returns the previous value; this fires only when | ||
| // disabled transitions from true → false (re-enable). | ||
| if ( | ||
| changedProperties.has('disabled') && | ||
| changedProperties.get('disabled') === true && | ||
| !this.allowMultiple | ||
| ) { | ||
| this.enforceExclusiveOpen(); | ||
| } | ||
| super.update(changedProperties); | ||
| } | ||
|
|
||
| protected override firstUpdated(changedProperties: PropertyValues): void { | ||
| super.firstUpdated(changedProperties); | ||
| if (window.__swc?.DEBUG && !this.hasAttribute('density')) { | ||
| window.__swc.warn( | ||
| this, | ||
| `<${this.localName}> should have an explicit "density" attribute set. Defaulting to "regular".`, | ||
| 'https://opensource.adobe.com/spectrum-web-components/components/accordion/', | ||
| { type: 'api', level: 'low' } | ||
| ); | ||
| } | ||
| } | ||
| } |
33 changes: 33 additions & 0 deletions
33
2nd-gen/packages/core/components/accordion/Accordion.types.ts
This file contains hidden or 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,33 @@ | ||
| /** | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import type { ElementSize } from '@spectrum-web-components/core/mixins/index.js'; | ||
|
|
||
| export const ACCORDION_VALID_SIZES = [ | ||
| 's', | ||
| 'm', | ||
| 'l', | ||
| 'xl', | ||
| ] as const satisfies readonly ElementSize[]; | ||
| export type AccordionSize = (typeof ACCORDION_VALID_SIZES)[number]; | ||
|
|
||
| export const ACCORDION_DENSITIES = ['compact', 'regular', 'spacious'] as const; | ||
| export type AccordionDensity = (typeof ACCORDION_DENSITIES)[number]; | ||
|
|
||
| export const ACCORDION_HEADING_LEVELS = [2, 3, 4, 5, 6] as const; | ||
| export type AccordionHeadingLevel = (typeof ACCORDION_HEADING_LEVELS)[number]; | ||
|
|
||
| export const SWC_ACCORDION_ITEM_TOGGLE_EVENT = 'swc-accordion-item-toggle'; | ||
| export const SWC_ACCORDION_ITEM_OPEN_EVENT = 'swc-open'; | ||
| export const SWC_ACCORDION_ITEM_CLOSE_EVENT = 'swc-close'; | ||
| export const SWC_ACCORDION_ITEM_AFTER_OPEN_EVENT = 'swc-after-open'; | ||
| export const SWC_ACCORDION_ITEM_AFTER_CLOSE_EVENT = 'swc-after-close'; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.