Skip to content
Merged
Show file tree
Hide file tree
Changes from 77 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 May 14, 2026
09cd821
chore: scaffold core package
rise-erpelding May 14, 2026
bba2e18
chore: scaffold swc package
rise-erpelding May 14, 2026
87bdc5e
chore: add Chevron300Icon for xl accordion
rise-erpelding May 14, 2026
570c138
chore: set up storybook story
rise-erpelding May 14, 2026
6e71c8d
chore: commit preview.ts updates
rise-erpelding May 14, 2026
bc7bf87
feat: implement AccordionItem API and render template
rise-erpelding May 14, 2026
f94b6ce
feat: implement Accordion API and propagation
rise-erpelding May 15, 2026
3a4454b
feat: implement open and toggle logic
rise-erpelding May 15, 2026
16dc689
feat: wire up dynamic heading levels
rise-erpelding May 15, 2026
9b7ebc4
feat: implement disabled item functionality
rise-erpelding May 15, 2026
e2ce2a7
fix: handle space keyboard behavior (SWC-1487)
rise-erpelding May 15, 2026
24dd4bf
refactor: address missing migration-setup items
rise-erpelding May 15, 2026
5d4c209
refactor: rename methods, align file names
rise-erpelding May 15, 2026
56ad095
refactor: typing, heading rendering, sizing
rise-erpelding May 18, 2026
fee852f
refactor: move toggle() into base, smooth a11y behavior
rise-erpelding May 18, 2026
e8ed70d
refactor: use assignedItems() helper
rise-erpelding May 18, 2026
f2d5056
test: add a11y tests
rise-erpelding May 18, 2026
12da5fc
docs: add a11y docs
rise-erpelding May 18, 2026
65b949b
fix: freeze accordion open state when disabled
rise-erpelding May 18, 2026
c8033e6
feat: 1st-gen deprecation warnings/tests
rise-erpelding May 18, 2026
737bd62
docs: jsdoc comments
rise-erpelding May 18, 2026
1975d7e
chore(accordion): full fidelity feature update
miwha-adobe May 18, 2026
f0a99ee
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe May 18, 2026
c6495a5
chore: changeset
rise-erpelding May 19, 2026
329b428
fix: revert 1st-gen refactor work
rise-erpelding May 19, 2026
c6341e3
chore(accordion): defer tests, deprecations, and changeset to part two
rise-erpelding May 19, 2026
4b9fc09
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe May 19, 2026
057a70a
docs(accordion): refine planning docs (#6269)
rise-erpelding May 14, 2026
bede72f
chore: scaffold core package
rise-erpelding May 14, 2026
79b82b3
chore: scaffold swc package
rise-erpelding May 14, 2026
8c69ece
chore: add Chevron300Icon for xl accordion
rise-erpelding May 14, 2026
cb55ae1
chore: set up storybook story
rise-erpelding May 14, 2026
8c61687
chore: commit preview.ts updates
rise-erpelding May 14, 2026
629c233
feat: implement AccordionItem API and render template
rise-erpelding May 14, 2026
176c95a
feat: implement Accordion API and propagation
rise-erpelding May 15, 2026
5896710
feat: implement open and toggle logic
rise-erpelding May 15, 2026
7318895
feat: wire up dynamic heading levels
rise-erpelding May 15, 2026
1221bee
feat: implement disabled item functionality
rise-erpelding May 15, 2026
d4d945d
fix: handle space keyboard behavior (SWC-1487)
rise-erpelding May 15, 2026
b26f30f
refactor: address missing migration-setup items
rise-erpelding May 15, 2026
4ee7d20
refactor: rename methods, align file names
rise-erpelding May 15, 2026
885c98a
refactor: typing, heading rendering, sizing
rise-erpelding May 18, 2026
e2cb7d3
refactor: move toggle() into base, smooth a11y behavior
rise-erpelding May 18, 2026
365577a
refactor: use assignedItems() helper
rise-erpelding May 18, 2026
12d5760
test: add a11y tests
rise-erpelding May 18, 2026
e10e351
docs: add a11y docs
rise-erpelding May 18, 2026
b16028b
fix: freeze accordion open state when disabled
rise-erpelding May 18, 2026
b102a88
feat: 1st-gen deprecation warnings/tests
rise-erpelding May 18, 2026
b9b7d88
docs: jsdoc comments
rise-erpelding May 18, 2026
cf3c2a5
chore: changeset
rise-erpelding May 19, 2026
c940abb
fix: revert 1st-gen refactor work
rise-erpelding May 19, 2026
e63c363
chore(accordion): defer tests, deprecations, and changeset to part two
rise-erpelding May 19, 2026
a7c9f25
fix(accordion): update css font
miwha-adobe May 20, 2026
306207c
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe May 20, 2026
e8dc485
fix: class selectors
rise-erpelding May 20, 2026
68495e1
Merge remote-tracking branch 'origin/swc-1857-1858-1859' into swc-186…
miwha-adobe May 21, 2026
f741213
feat: set up accordion file structure, API, and a11y (#6300)
rise-erpelding May 21, 2026
1fc9f47
fix(accordion): address PR review feedback on CSS and stories
miwha-adobe May 21, 2026
1e2b65c
Merge remote-tracking branch 'origin/swc-1854/accordion-migration' in…
miwha-adobe May 21, 2026
8963629
fix(accordion): restore row wrapper and register swc-button in stories
miwha-adobe May 21, 2026
ae634d4
fix(accordion): change ceiling amount to spacing-300
miwha-adobe May 22, 2026
c934067
fix(accordion): fix token names for header and content sections
miwha-adobe May 22, 2026
ce1afd9
fix: move private custom properties from accordion-item :host
rise-erpelding May 26, 2026
75b114e
fix: adjust .swc-AccordionItem-header custom properties
rise-erpelding May 26, 2026
141d203
fix: adjust content inline padding custom properties
rise-erpelding May 26, 2026
920ec0c
chore: update preview.ts and migration plan
rise-erpelding May 26, 2026
99506f9
feat: spacing on direct actions
rise-erpelding May 27, 2026
cd6b6c1
docs: improve ai skill
rise-erpelding May 27, 2026
ad9eeb3
fix: use <p>s in stories and account for their margin
rise-erpelding May 27, 2026
2a2a19f
docs: add cssprops to jsdocs
rise-erpelding May 27, 2026
7e2e0c4
chore: rename custom props for accordion item
rise-erpelding May 27, 2026
ae2ccb9
feat: handle panel animation
rise-erpelding May 27, 2026
fb3d42f
fix: use better selectors
rise-erpelding May 28, 2026
b9e63b3
docs: docs updates
rise-erpelding May 28, 2026
9a53700
fix: handle quiet and corner radius tokens
rise-erpelding May 28, 2026
ea68fc7
chore: update migration plan
rise-erpelding May 28, 2026
d46f00c
chore(accordion): merge swc-1854/accordion-migration into full-fidelity
rise-erpelding May 29, 2026
b3f64f3
fix: feedback fixes
rise-erpelding May 29, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ai/rules/code-conformance.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ Reference: [Linting tools](../../CONTRIBUTOR-DOCS/02_style-guide/03_linting-tool
- Forced-colors media query is present and correct (if applicable)
- High-contrast and other media queries are sorted to the bottom of the file
- No hard-coded values where design tokens are available
- Every class selector in CSS files (`.swc-*`) has a matching `class="..."` in the component's `render()` method; orphaned selectors mean styles are silently dead. Cross-check both directions: CSS → template and template → CSS. Use `grep -oE '\.[a-z][a-zA-Z-]+'` on the CSS and `grep -oE 'class="[^"]*"'` on the TypeScript to produce lists to compare.

## Test files

Expand Down
2 changes: 2 additions & 0 deletions .ai/skills/migration-styling/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,6 @@ Common case: confirming that subcomponent class names follow the single-hyphen s

If a rename is needed, make the template change first, confirm the component still renders correctly in Storybook, then write the CSS.

**Step 3b — Audit `:host` for visual styles.** After aligning class names, scan every declaration you plan to put on `:host` against Rule 1 of the tldr. Ask for each property: is this layout-participation (how the host fits into its parent's flow) or visual (how the component looks)? If a visual style has no internal wrapper to move it to, add one to `render()` before writing CSS.

**Step 4 — Execute the phase.** Follow **[Phase 5: Styling](../../../CONTRIBUTOR-DOCS/03_project-planning/02_workstreams/02_2nd-gen-component-migration/02_step-by-step/01_washing-machine-workflow.md#phase-5-styling)** in the washing machine workflow doc — it covers what to do, what to check, common problems, and the quality gate for this phase.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,17 @@

### 1. `:host` vs Component Class

Put only layout-participation styles on `:host`. Put actual visuals on `.swcComponentName` or internal parts.
Put layout-participation styles on `:host` (`display`, `inline-size`, `min-*`/`max-*`, `position`, custom property definitions). Put visual styles on `.swc-ComponentName` or an internal part.

Two non-obvious cases to flag explicitly:

- **`padding` on `:host`** — feels like layout but is visual spacing; move it to the internal class.
- **`cursor: pointer`** — do not set it anywhere; the project relies on browser defaults.

Also check that `display: flex` or `display: grid` on `:host` is actually laying out **direct children of `:host`**, not internal children already wrapped inside a container element. Flex/grid properties (`flex: 1 1 auto`, `align-self`) only activate when their **immediate parent** is the flex/grid container — if the element is inside a wrapper div, the flex context must be on that wrapper, not on `:host`.

**`:host:has()` is unreliable across browsers.** Safari and Firefox do not consistently support `:has()` relative to a shadow host boundary. Move all `:has()` selectors to the internal wrapper: `.swc-Component:has(...)` instead of `:host:has(...)`. Custom properties cascade identically either way. See [01_component-css#state-implementation-patterns](../../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/01_component-css.md#state-implementation-patterns).

→ See [01_component-css](../../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/01_component-css.md)

### 2. Stylesheet Order
Expand Down Expand Up @@ -124,4 +134,7 @@ Keep selector specificity at or below `(0,1,0)`. If you need a compounded select
### 7. Forced colors

Only add `@media (forced-colors: active)` if browser defaults are not conveying correct semantic intent, and always put it at the end of the component stylesheet.

Semantic HTML elements (`<button>`, `<input>`, `<a>`) get correct forced-colors treatment automatically — `ButtonText`, focus `Highlight`, disabled `GrayText` — without any CSS override. Only non-semantic elements (a decorative `<div>` or a `<span>` using `background-color` as a visual indicator) need explicit overrides. Do not carry over forced-colors rules from 1st-gen Spectrum CSS without first verifying the 2nd-gen component uses non-semantic markup that requires them.

→ See [01_component-css#forced-colors-requirements](../../../../CONTRIBUTOR-DOCS/02_style-guide/01_css/01_component-css.md#forced-colors-requirements)
2 changes: 1 addition & 1 deletion 1st-gen/tools/base/src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* The version of the 1st-gen Spectrum Web Components library.
*/
export const version = '1.12.0';
export const version = '1.12.1';

/**
* The version of the core base package.
Expand Down
208 changes: 208 additions & 0 deletions 2nd-gen/packages/core/components/accordion/Accordion.base.ts
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 2nd-gen/packages/core/components/accordion/Accordion.types.ts
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';
Loading
Loading