-
Notifications
You must be signed in to change notification settings - Fork 256
Progress Bar Migration #6488
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
Progress Bar Migration #6488
Changes from all commits
5ff2d5e
1494f10
d932c79
7f3554a
fdb2e62
9228b0c
2fb63dc
6cf4a49
2fdda30
374bb9d
b4214ce
aed7a8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@spectrum-web-components/progress-bar': patch | ||
| --- | ||
|
|
||
| **docs(progress-bar):** Added deprecation notices to `<sp-progress-bar>` ahead of the Spectrum 2 migration. | ||
|
|
||
| The `label`, `side-label`, and `progress` properties are now marked `@deprecated` and emit `window.__swc.DEBUG` warnings pointing to their `<swc-progress-bar>` replacements (`label` slot, `label-position="side"`, and `value`). Runtime behavior is unchanged when debug validation is disabled. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@adobe/spectrum-wc': minor | ||
| --- | ||
|
|
||
| **feat(progress-bar):** Added `<swc-progress-bar>`, the Spectrum 2 migration of Progress Bar. | ||
|
|
||
| Renames from `<sp-progress-bar>`: `progress` becomes `value`, `side-label` becomes `label-position="side"`, the `label` string attribute becomes a `label` named slot, and `--mod-progressbar-*` custom properties become `--swc-linear-progress-*`. The default `size` is now `'m'`. | ||
|
|
||
| New in Spectrum 2: `min-value` / `max-value` for arbitrary numeric ranges, `static-color="black"`, `value-label`, a `formatOptions` property, `accessible-label`, and a `description` slot. `over-background` is removed in favor of `static-color="white"`, and `role="progressbar"` plus the `aria-value*` attributes now live on an internal element rather than the host. See the Progress Bar migration guide for full upgrade steps. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -168,29 +168,6 @@ describe('ProgressBar', () => { | |
| consoleWarnStub.restore(); | ||
| }); | ||
|
|
||
| it('warns in Dev Mode when accessible attributes are not leveraged', async () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is a duplicate in the file, so I removed it |
||
| const el = await fixture<ProgressBar>(html` | ||
| <sp-progress-bar progress="50"></sp-progress-bar> | ||
| `); | ||
|
|
||
| await elementUpdated(el); | ||
|
|
||
| const spyCall = consoleWarnStub.getCall(0); | ||
| expect( | ||
| (spyCall.args[0] as string).includes('accessible'), | ||
| 'confirm accessibility-centric message' | ||
| ).to.be.true; | ||
| expect( | ||
| spyCall.args[spyCall.args.length - 1], | ||
| 'confirm `data` shape' | ||
| ).to.deep.equal({ | ||
| data: { | ||
| localName: 'sp-progress-bar', | ||
| type: 'accessibility', | ||
| level: 'default', | ||
| }, | ||
| }); | ||
| }); | ||
| it('resolves a language (en-US)', async () => { | ||
| const [languageContext] = createLanguageContext('en-US'); | ||
| const test = await fixture(html` | ||
|
|
@@ -270,13 +247,18 @@ describe('ProgressBar', () => { | |
| 'confirm deprecated over-background warning' | ||
| ).to.be.true; | ||
|
|
||
| const spyCall = consoleWarnStub.getCall(0); | ||
| const spyCall = consoleWarnStub | ||
| .getCalls() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The tests were breaking because the warnStub no longer has just one warning with the introduction of the additional deprecation warnings. |
||
| .find((call: { args: unknown[] }) => | ||
| (call.args[0] as string)?.includes('over-background') | ||
| ); | ||
| expect(spyCall, 'over-background warning emitted').to.not.be.undefined; | ||
| expect( | ||
| (spyCall.args[0] as string).includes('deprecated'), | ||
| (spyCall!.args[0] as string).includes('deprecated'), | ||
| 'confirm deprecated over-background warning' | ||
| ).to.be.true; | ||
| expect( | ||
| spyCall.args[spyCall.args.length - 1], | ||
| spyCall!.args[spyCall!.args.length - 1], | ||
| 'confirm `data` shape' | ||
| ).to.deep.equal({ | ||
| data: { | ||
|
|
@@ -294,13 +276,21 @@ describe('ProgressBar', () => { | |
| await elementUpdated(el); | ||
|
|
||
| expect(consoleWarnStub.called).to.be.true; | ||
| const spyCall = consoleWarnStub.getCall(0); | ||
| const spyCall = consoleWarnStub.getCalls().find( | ||
| (call: { args: unknown[] }) => | ||
| ( | ||
| call.args[call.args.length - 1] as { | ||
| data?: { type?: string }; | ||
| } | ||
| )?.data?.type === 'accessibility' | ||
| ); | ||
| expect(spyCall, 'accessibility warning emitted').to.not.be.undefined; | ||
| expect( | ||
| (spyCall.args[0] as string).includes('accessible'), | ||
| (spyCall!.args[0] as string).includes('accessible'), | ||
| 'confirm accessibility-centric message' | ||
| ).to.be.true; | ||
| expect( | ||
| spyCall.args[spyCall.args.length - 1], | ||
| spyCall!.args[spyCall!.args.length - 1], | ||
| 'confirm `data` shape' | ||
| ).to.deep.equal({ | ||
| data: { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /** | ||
| * 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 { property } from 'lit/decorators.js'; | ||
|
|
||
| import { SpectrumElement } from '@adobe/spectrum-wc-core/element/index.js'; | ||
| import { | ||
| LINEAR_PROGRESS_VALID_SIZES, | ||
| LinearProgressMixin, | ||
| SizedMixin, | ||
| } from '@adobe/spectrum-wc-core/mixins/index.js'; | ||
|
|
||
| /** | ||
| * A non-focusable, read-only bar that shows task progress (0–100, or a custom | ||
| * range) or an indeterminate loading animation when completion time is unknown. | ||
| * Implements the WAI-ARIA `progressbar` role on the shadow `.swc-LinearProgress` | ||
| * element (the host carries no ARIA). | ||
| * | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The a11y analysis requires role="progressbar" on the host, but this puts it on the shadow |
||
| * @attribute {ElementSize} size - The size of the progress bar. | ||
| */ | ||
| export abstract class ProgressBarBase extends LinearProgressMixin( | ||
| SizedMixin(SpectrumElement, { | ||
| validSizes: LINEAR_PROGRESS_VALID_SIZES, | ||
| defaultSize: 'm', | ||
| }) | ||
| ) { | ||
| /** | ||
| * The size of the progress bar. | ||
| * | ||
| * @default m | ||
| */ | ||
| declare public size: (typeof LINEAR_PROGRESS_VALID_SIZES)[number]; | ||
|
|
||
| // ───────────────────────────────────────── | ||
| // PROGRESS-BAR-SPECIFIC PROPERTIES | ||
| // ───────────────────────────────────────── | ||
|
|
||
| /** | ||
| * When true, the bar runs a looping fill animation and all four | ||
| * `aria-value*` attributes are omitted from the DOM. The visible | ||
| * value text is also omitted. | ||
| * | ||
| * @default false | ||
| */ | ||
| @property({ type: Boolean, reflect: true }) | ||
| public indeterminate = false; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
|
|
||
| // Progress bar has no variant types — it uses a single accent fill. | ||
| // Shared linear-progress types (LinearProgressSize, LinearProgressStaticColor, | ||
| // LinearProgressLabelPosition, LinearProgressInterface) are re-exported from | ||
| // the mixin for consumer convenience. | ||
| export type { | ||
| LinearProgressInterface, | ||
| LinearProgressLabelPosition, | ||
| LinearProgressSize, | ||
| LinearProgressStaticColor, | ||
| } from '@adobe/spectrum-wc-core/mixins/index.js'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /** | ||
| * 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. | ||
| */ | ||
| export * from './ProgressBar.base.js'; | ||
| export * from './ProgressBar.types.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous instructions stated "When adding deprecation notices to 1st-gen, restrict changes to: (1) .....", which was really more just a guardrail in how to add notices, but it wasn't explicit about needing to add the deprecation warning. I didn't find the skill prompts I used (in the migration skill cheat sheet canvas) prompting claude to add the deprecation notice.