Skip to content

Commit 601c687

Browse files
sirineJconnor-baer
andauthored
Remove deprecated icons (#3744)
* delete deprecated icons * rename flag files * replace deprecated icons internally * refactor build file * change icons eslint rule to error * lint * add changeset * keep deleted icons in manifest with inactive flag * Update .changeset/better-impalas-open.md Co-authored-by: Connor Bär <connor-baer@users.noreply.github.com> * Update .changeset/fancy-weeks-dance.md Co-authored-by: Connor Bär <connor-baer@users.noreply.github.com> --------- Co-authored-by: Connor Bär <connor-baer@users.noreply.github.com>
1 parent 45fc2c8 commit 601c687

373 files changed

Lines changed: 1305 additions & 1909 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/better-impalas-open.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
"@sumup-oss/circuit-ui": major
3+
---
4+
5+
Removed the following deprecated icons:
6+
7+
| icon | replacement |
8+
|-------------------|------------------------------------|
9+
| AddItems | Add, Items |
10+
| Copy | CopyPaste |
11+
| SumUpLogo | SumupLogo (`sumup-oss/circuit-ui)` |
12+
| SumUpLogomark | SumupLogo (`sumup-oss/circuit-ui) |
13+
| Apm | AlternativePaymentMethod |
14+
| EmailChat | Email |
15+
| phone_chat | Phone |
16+
| PhoneChat | Mobile |
17+
| ColorCorrection | ColorPicker |
18+
| CookiePreferences | Cookie |
19+
| Customize | Customise |
20+
| Favorite | Favourite |
21+
| NoSim | NoSimcard |
22+
| PrintFailed | PrinterFailed |
23+
| Unfavorite | Unfavourite |
24+
| Contractors | Contractor |
25+
| notify_circle | Notify |
26+
| general_settings | Settings |
27+
| gift_card | GiftCards |
28+
| payment_link | PaymentLinks |
29+
| refer | ReferAFriend, Reward |
30+
| sales | Receipt |
31+
| messenger | FacebookMessenger |
32+
|
33+
34+
Use the `no-deprecated-icons` ESLint rule to automatically apply the replacements.

.changeset/fancy-weeks-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sumup-oss/icons": major
3+
---
4+
5+
Removed the deprecated Country Flag icons. Use the [Flag](https://circuit.sumup.com/?path=/docs/components-flag--docs) component instead or load the icon with its URL using the [`getIconUrl()`](https://circuit.sumup.com/?path=/docs/packages-icons--docs#load-from-a-url) helper.

.changeset/lovely-bears-deny.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sumup-oss/icons": major
3+
---
4+
5+
Removed the deprecated Card Scheme icons. Use the new CardScheme component instead or load the icon with its URL using the [`getIconUrl()`](https://circuit.sumup.com/?path=/docs/packages-icons--docs#load-from-a-url) helper.

.changeset/thin-grapes-take.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sumup-oss/icons": major
3+
---
4+
5+
Remove the deprecated Payment Method icons. Use the new PaymentMethod component instead or load the icon with its URL using the [`getIconUrl()`](https://circuit.sumup.com/?path=/docs/packages-icons--docs#load-from-a-url) helper.

.storybook/components/Icons.tsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function Icons() {
125125
},
126126
);
127127
const matchesSize = size === 'all' || size === icon.size;
128-
return matchesKeyword && matchesSize;
128+
return !icon.inactive && matchesKeyword && matchesSize;
129129
}) as IconsManifest['icons'];
130130

131131
return (
@@ -189,7 +189,7 @@ export function Icons() {
189189
);
190190
}
191191

192-
const DEPRECATED_CATEGORIES = ['Card scheme', 'Payment method'];
192+
const URL_ONLY_CATEGORIES = ['Flag', 'Payment method', 'Card scheme'];
193193

194194
function Icon({
195195
icon,
@@ -208,6 +208,7 @@ function Icon({
208208
) as keyof typeof iconComponents;
209209
// eslint-disable-next-line import-x/namespace
210210
const IconComponent = iconComponents[componentName] as IconComponentType;
211+
const isFlag = icon.category === 'Flag';
211212

212213
const copyIconURL = () => {
213214
const iconURL = `https://circuit.sumup.com/icons/v2/${icon.name}_${icon.size}.svg`;
@@ -246,16 +247,21 @@ function Icon({
246247
});
247248
};
248249

250+
const flagDimensions = {
251+
height: scale === 'one-x' ? 15 : 30,
252+
width: scale === 'one-x' ? 20 : 40,
253+
};
254+
249255
return (
250256
<div className={classes.wrapper}>
251257
<div className={clsx(classes['icon-wrapper'], classes[scale])}>
252-
{icon.skipComponentFile ? (
258+
{URL_ONLY_CATEGORIES.includes(icon.category) ? (
253259
<img
254-
src={getIconURL(icon.name)}
260+
src={getIconURL(icon.name, icon.size)}
261+
className={classes.icon}
255262
aria-labelledby={id}
256263
alt={icon.name}
257-
height={scale === 'one-x' ? 15 : 30}
258-
width={scale === 'one-x' ? 20 : 40}
264+
{...(isFlag ? flagDimensions : {})}
259265
/>
260266
) : (
261267
<IconComponent
@@ -303,18 +309,17 @@ function Icon({
303309
Copy URL
304310
</IconButton>
305311
)}
306-
{!icon.skipComponentFile &&
307-
!DEPRECATED_CATEGORIES.includes(icon.category) && (
308-
<IconButton
309-
variant="tertiary"
310-
size="s"
311-
// @ts-expect-error ReactIcon is a React component
312-
icon={ReactIcon}
313-
onClick={copyIconReactName}
314-
>
315-
Copy React component name
316-
</IconButton>
317-
)}
312+
{!URL_ONLY_CATEGORIES.includes(icon.category) && (
313+
<IconButton
314+
variant="tertiary"
315+
size="s"
316+
// @ts-expect-error ReactIcon is a React component
317+
icon={ReactIcon}
318+
onClick={copyIconReactName}
319+
>
320+
Copy React component name
321+
</IconButton>
322+
)}
318323
</div>
319324
</div>
320325
);

.storybook/components/Theme.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { useEffect, useState, type ComponentType } from 'react';
1717
import { ThemeProvider, useTheme } from '@emotion/react';
1818
import { Unstyled } from '@storybook/blocks';
1919
import { light, schema } from '@sumup-oss/design-tokens';
20-
import { SumUpLogomark } from '@sumup-oss/icons';
20+
import { Home } from '@sumup-oss/icons';
2121
import { Anchor } from '../../packages/circuit-ui/components/Anchor/Anchor.js';
2222
import { Body } from '../../packages/circuit-ui/components/Body/Body.js';
2323
import { Badge } from '../../packages/circuit-ui/components/Badge/Badge.js';
@@ -274,7 +274,7 @@ export function Typography({ name }: PreviewProps) {
274274

275275
export function IconSize({ name }: PreviewProps) {
276276
return (
277-
<SumUpLogomark
277+
<Home
278278
style={{
279279
width: `var(${name})`,
280280
height: `var(${name})`,

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export default defineConfig([
3737
'circuit-ui/no-deprecated-props': 'error',
3838
'circuit-ui/no-renamed-props': 'error',
3939
'circuit-ui/prefer-custom-properties': 'warn',
40-
'circuit-ui/no-deprecated-icons': 'warn',
40+
'circuit-ui/no-deprecated-icons': 'error',
4141
},
4242
},
4343
configs.browser,

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/circuit-ui/components/AutocompleteInput/components/Option/Option.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515

1616
import { describe, expect, it, vi } from 'vitest';
17-
import { Favorite } from '@sumup-oss/icons';
17+
import { Favourite } from '@sumup-oss/icons';
1818

1919
import { render, screen, userEvent } from '../../../../util/test-utils.js';
2020

@@ -35,7 +35,7 @@ const props: OptionProps = {
3535

3636
describe('Option', () => {
3737
it('should render with leading icon', () => {
38-
render(<Option {...props} image={Favorite} />);
38+
render(<Option {...props} image={Favourite} />);
3939

4040
expect(screen.getByText(props.label)).toBeVisible();
4141
expect(screen.getByText(description)).toBeVisible();

packages/circuit-ui/components/Select/Select.stories.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@
1414
*/
1515

1616
import { useState } from 'react';
17-
import {
18-
FlagDe,
19-
FlagUs,
20-
FlagFr,
21-
type IconComponentType,
22-
} from '@sumup-oss/icons';
2317

2418
import { Select, type SelectProps } from './Select.js';
2519
import { Stack } from '../../../../.storybook/components/index.js';
20+
import { Flag, type FlagProps } from '../Flag/Flag.js';
2621

2722
export default {
2823
title: 'Forms/Select',
@@ -50,12 +45,6 @@ const baseArgs = {
5045
],
5146
};
5247

53-
const flagIconMap: { [key: string]: IconComponentType<'16'> } = {
54-
DE: FlagDe,
55-
US: FlagUs,
56-
FR: FlagFr,
57-
};
58-
5948
export const Base = (args: SelectProps) => <Select {...args} />;
6049

6150
Base.args = baseArgs;
@@ -90,10 +79,16 @@ export const WithPrefix = (args: SelectProps) => {
9079
onChange={(event) => {
9180
setValue(event.target.value);
9281
}}
93-
renderPrefix={(props) => {
94-
const Icon = props.value && flagIconMap[props.value];
95-
return Icon ? <Icon {...props} aria-hidden="true" /> : null;
96-
}}
82+
renderPrefix={(props) =>
83+
props.value ? (
84+
<Flag
85+
{...props}
86+
alt=""
87+
countryCode={props.value as FlagProps['countryCode']}
88+
size="s"
89+
/>
90+
) : null
91+
}
9792
/>
9893
);
9994
};

0 commit comments

Comments
 (0)