Skip to content

Commit

Permalink
BREAKING CHANGE(web-react): Remove size prop from Icon in favor o…
Browse files Browse the repository at this point in the history
…f `boxSize` #DS-647

## Migration Guide

Instead of the `size` prop, use `boxSize` in `Icon` component.

- `<Icon size="333" …>` → `<Icon boxSize="333" …>`

Please refer back to this guide or reach out to our team
if you encounter any issues during migration.
  • Loading branch information
crishpeen authored and literat committed Jul 21, 2023
1 parent bef2d7a commit f19f8bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 32 deletions.
26 changes: 4 additions & 22 deletions packages/web-react/src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { useDeprecationMessage, useIcon, useStyleProps } from '../../hooks';
import { useIcon, useStyleProps } from '../../hooks';
import { IconProps } from '../../types';

const defaultProps = {
Expand All @@ -8,28 +8,10 @@ const defaultProps = {
};

export const Icon = (props: IconProps): JSX.Element => {
const {
boxSize,
name,
title,
/** @deprecated Will be removed in the next major version. */
size,
ariaHidden,
...restProps
} = props;
const { boxSize, name, title, ariaHidden, ...restProps } = props;
let icon = useIcon(name);
const { styleProps, props: otherProps } = useStyleProps(restProps);

useDeprecationMessage({
method: 'property',
trigger: !!size,
componentName: 'Icon',
propertyProps: {
deprecatedName: 'size',
newName: 'boxSize',
},
});

if (title) {
icon = `<title>${title}</title>${icon}`;
}
Expand All @@ -40,8 +22,8 @@ export const Icon = (props: IconProps): JSX.Element => {
<svg
viewBox="0 0 24 24"
fill="none"
width={size || boxSize}
height={size || boxSize}
width={boxSize}
height={boxSize}
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: icon }}
aria-hidden={ariaHidden}
Expand Down
13 changes: 5 additions & 8 deletions packages/web-react/src/components/Icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,10 @@ import icons from '@lmc-eu/spirit-icons/icons';

## Available props

| Name | Type | Required | Description |
| --------- | -------- | -------- | ---------------------------------------------------------------------------------- |
| `boxSize` | `number` | no | Size of the icon, default `24` |
| `name` | `string` | yes | Name of the icon |
| `size` | `number` | no | [**DEPRECATED**][deprecated] in favor of `boxSize`; Size of the icon, default `24` |
| `title` | `string` | no | Title of the icon |
| Name | Type | Required | Description |
| --------- | -------- | -------- | ------------------------------ |
| `boxSize` | `number` | no | Size of the icon, default `24` |
| `name` | `string` | yes | Name of the icon |
| `title` | `string` | no | Title of the icon |

For more details about Icons see [Spirit Icons](https://github.com/lmc-eu/spirit-design-system/blob/main/packages/icons/README.md) package.

[deprecated]: https://github.com/lmc-eu/spirit-design-system/tree/main/packages/web-react/README.md#deprecations
2 changes: 0 additions & 2 deletions packages/web-react/src/types/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ export interface IconProps extends StyleProps, ChildrenProps, React.SVGAttribute
boxSize?: number;
/** Name of the icon */
name: string;
/** Deprecated: Will be removed in the next major version; Size of the icon */
size?: number;
/** Title of the icon */
title?: string;
}

0 comments on commit f19f8bb

Please sign in to comment.