Skip to content
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

chore: remove thumbnail deprecated sizes #4760

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 1 addition & 25 deletions packages/thumbnail/src/Thumbnail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const validSizes = [
'900',
'1000',
];
export type ThumbnailSize = typeof validSizes[number];
export type ThumbnailSize = (typeof validSizes)[number];

const defaultSize = validSizes[6];

Expand Down Expand Up @@ -66,30 +66,6 @@ export class Thumbnail extends SpectrumElement {
}

public set size(value: ThumbnailSize) {
const deprecatedSizes = ['xxs', 'xs', 's', 'm', 'l'];
type DeprecatedThumbnailSize = typeof deprecatedSizes[number];
const managedSizes: Record<DeprecatedThumbnailSize, ThumbnailSize> = {
xxs: '100',
xs: '300',
s: '500',
m: '700',
l: '900',
};
const usesDeprecatedSize = deprecatedSizes.includes(value);
if (usesDeprecatedSize) {
if (window.__swc.DEBUG) {
window.__swc.warn(
this,
`The "size" attribute/property for <${this.localName}> no longer supports the value "${value}". Use one of the following values, instead:`,
'https://opensource.adobe.com/spectrum-web-components/components/thumbnail/#sizes',
{
level: 'deprecation',
issues: validSizes as unknown as string[],
}
);
}
value = managedSizes[value];
}
const size = (
validSizes.includes(value) ? value : defaultSize
) as ThumbnailSize;
Expand Down
26 changes: 0 additions & 26 deletions packages/thumbnail/test/thumbnail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,5 @@ describe('Thumbnail', () => {
window.__swc.verbose = false;
consoleWarnStub.restore();
});

it('warns in devMode when white/black variant is provided', async () => {
const el = await fixture<Thumbnail>(html`
<sp-thumbnail background="blue" size="xxs">
<img src=${thumbnail} alt="Woman crouching" />
</sp-thumbnail>
`);

await elementUpdated(el);
expect(consoleWarnStub.called).to.be.true;

const spyCall = consoleWarnStub.getCall(0);
expect(
(spyCall.args.at(0) as string).includes(
'no longer supports the value'
),
'confirm deprecated size warning'
).to.be.true;
expect(spyCall.args.at(-1), 'confirm `data` shape').to.deep.equal({
data: {
localName: 'sp-thumbnail',
type: 'api',
level: 'deprecation',
},
});
});
});
});
Loading