Skip to content

Commit

Permalink
chore: remove thumbnail deprecated sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
rubencarvalho committed Sep 16, 2024
1 parent d667d08 commit 5917632
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
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',
},
});
});
});
});

0 comments on commit 5917632

Please sign in to comment.