chore(close-button): add structure for s2 migration#6355
Conversation
|
📚 Branch Preview Links🔍 First Generation Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
7e643ab to
aa5ff5d
Compare
|
I implemented this close-button scaffold migration with the Cursor agent, then self-reviewed the diff once before marking it ready for review. A few things worth calling out for reviewers: • Cross400 / Cross500 icons — added so l and xl close-button sizes map to the right cross scale (not just Please flag anything that looks off in the scaffold or wiring |
2988c74 to
d84aed0
Compare
| * @internal | ||
| * Not part of the close-button public API. | ||
| */ | ||
| public override pending = false; | ||
|
|
||
| /** | ||
| * @internal | ||
| * Not part of the close-button public API. | ||
| */ | ||
| public override pendingLabel?: string; |
There was a problem hiding this comment.
Does this work? CEM will scan the Buttonbase properties first. Kindly verify this. Keeping it blocking for now!
There was a problem hiding this comment.
works with the plugin that i added. and here's the ticket for broader button base refractor work: https://jira.corp.adobe.com/browse/SWC-2250
There was a problem hiding this comment.
You can abstract the CloseButton required properties in an abstract class in button.base.ts which ButtonBase and CloseButtonBase should extend. This would keep the API surface cleaner even if future components extends ButtonBase.
// button.base.ts
export abstract class InteractiveButtonbase extends SizedMixin(
ObserveSlotText(ObserveSlotPresence(SpectrumElement, '[slot="icon"]'), ''),
{ validSizes: BUTTON_VALID_SIZES }
) {
static override shadowRootOptions: ShadowRootInit = {
...SpectrumElement.shadowRootOptions,
delegatesFocus: true,
};
/**
* Whether the button is disabled. Removes focusability and prevents
* interaction.
*/
@property({ type: Boolean, reflect: true })
public disabled: boolean = false;
/**
* Accessible label forwarded to the internal `<button>` element as
* `aria-label`. Required for icon-only buttons, which have no visible text.
*/
@property({ type: String, attribute: 'accessible-label' })
public accessibleLabel?: string;
protected get hasIcon(): boolean {
return this.slotContentIsPresent;
}
protected get hasLabel(): boolean {
return this.slotHasContent;
}
/**
* Resolves the accessible name for the button from `accessibleLabel` or
* visible text content. Returns `null` when no accessible name is
* determinable.
*
* @internal
*/
protected getResolvedAccessibleName(): string | null {
return this.accessibleLabel ?? (this.textContent?.trim() || null);
}
/**
* Returns the set of attributes that should be forwarded to the internal
* semantic `<button>` element, if not otherwise directly managed.
*
* @internal
*/
protected getForwardedButtonAttributes(): Record<
string,
string | boolean | undefined
> {
return {
disabled: this.disabled,
};
}
protected override update(changedProperties: PropertyValues): void {
super.update(changedProperties);
if (window.__swc?.DEBUG) {
if (this.hasIcon && !this.hasLabel && !this.accessibleLabel) {
window.__swc.warn(
this,
`<${this.localName}> with an icon and no label must have an "accessible-label" attribute to be accessible.`,
'https://opensource.adobe.com/spectrum-web-components/components/button/#icon-only',
{ issues: ['accessible-label'] }
);
}
}
}
export abstract class ButtonBase extends InteractiveButtonbase {
// pending attributes of button stays here
}
// CloseButton.base.ts
export abstract class CloseButtonBase extends InteractiveButtonbase { }
6670f9e to
58ebd82
Compare
|
CloseButtonBase initially extended ButtonBase, which owns full button semantics including pending / • CEM / Storybook controls (pending showed up on swc-close-button) Close-button is not a pending control (unlike swc-button), so that surface was wrong. First fix: @internal overrides on CloseButtonBase + a custom CEM internal-override-plugin to strip inherited Final fix (latest commit): structural split instead of doc/CEM patching: • SharedButtonBase — sizing, slots, disabled, accessible-label, accessible-name helpers (no pending) Close-button no longer needs @internal pending overrides or the CEM plugin → plugin removed. |
Scaffold 2nd-gen close-button in core and swc: CloseButtonBase with static-color and sizing, minimal render and CSS, Storybook stories, and placeholder tests. Wire core package exports and mark Setup complete in the migration status table. Co-authored-by: Cursor <cursoragent@cursor.com>
Wire close-button l/xl to spectrum-css UI icon paths instead of reusing Cross300. Co-authored-by: Cursor <cursoragent@cursor.com>
Rebase onto main with planning docs merged; tick Setup checklist and status table. Co-authored-by: Cursor <cursoragent@cursor.com>
…isible control Add size and icon tokens so Playwright can wait for swc-close-button in overview stories. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Drop pending wiring from the SWC template, mark inherited pending APIs @internal on CloseButton, hide them in Storybook, and document the scope in the migration plan. Co-authored-by: Cursor <cursoragent@cursor.com>
… MDX Restore public variant in CEM for components that redeclare it on the concrete class, while keeping pending hidden when only a descendant marks it @internal (ancestor ButtonBase must not undo CloseButtonBase). Co-authored-by: Cursor <cursoragent@cursor.com>
2nd-gen removes legacy APIs instead of shipping deprecated aliases. Use static-color only on swc-close-button; variant deprecation stays on 1st-gen sp-close-button per migration plan. Co-authored-by: Cursor <cursoragent@cursor.com>
Remove stray blank line after class opening brace so CI prettier check passes. Co-authored-by: Cursor <cursoragent@cursor.com>
…utton Extract shared button semantics into SharedButtonBase and move pending into PendingMixin on ButtonBase only. Close-button extends SharedButtonBase so pending stays off its public API without a CEM override plugin. Co-authored-by: Cursor <cursoragent@cursor.com>
12446ad to
b0368d9
Compare
Description
Phase 2 (Setup) of the
swc-close-button1st-gen → 2nd-gen washing machine migration. This PR scaffolds the component so it builds, registers, and appears in Storybook before API polish and S2 styling land in follow-up PRs.Core (
2nd-gen/packages/core/components/close-button/)CloseButton.types.ts—CLOSE_BUTTON_VALID_SIZES, static-color / variant typesCloseButton.base.ts— extends ButtonBase with close-button VALID_SIZES, static-color, and legacy variant(maps to static-color when set; full deprecation warnings deferred to Phase 3). Size uses shared SizedMixin
behavior from ButtonBase (default m, reflected on the host).
core/package.jsonSWC (
2nd-gen/packages/swc/components/close-button/)CloseButton.ts— inner<button type="button">, size-mapped cross icon, visually hidden default slot,aria-labelfrom resolved accessible nameclose-button.css— stub layout and visually hidden label styles (not S2 visual parity)swc-close-button.ts— element registrationDocs
Motivation and context
Close button migration is tracked under the 2nd-gen component workstream. Setup must land before Phase 3 (API / TypeScript) and Phase 5 (S2 CSS). This PR intentionally ships a minimal, buildable skeleton — not visual parity with Spectrum 2 closebutton CSS.
Related issue(s)
(#6322)
Screenshots (if appropriate)
N/A — stub styling only; no meaningful visual regression vs Spectrum 2
yet.
Author's checklist
m-web-components/blob/main/CONTRIBUTING.md) and
[PULL_REQUESTS](https://github.com/adobe/spectrum-web-components/blob
/main/PULL_REQUESTS.md) documents.
see: Aria Practices
Storybook + a11y snapshot; full coverage in Phase 6).
published.
(status table only).
Reviewer's checklist
number without a link
include
patch,minor, ormajorfeatureswriting
Manual review test cases
yarn buildfrom repo root (or2nd-genworkspace build forcore+swc).branch preview Storybook if available).
<swc-close-button accessible-label="Close">renders witha cross icon.
<button type="button">witharia-label="Close".sizetos,m,l, andxl; confirm thehost updates and the icon mapping changes
static-colortowhiteorblack; confirm classesswc-CloseButton--staticWhite/swc-CloseButton--staticBlackappearon the inner button (styling is stub-only).
Device review
Accessibility testing checklist
a visible focus indicator on the inner button (delegated focus).
activates (click handler / default button behavior).
disabledon the control; confirm the button is not reachablevia Tab and does not activate.
Close (from
accessible-labelor slotted text).disabledset, confirm the control is announced asunavailable/disabled.