Skip to content

Commit 51a9e1f

Browse files
authored
feat(Icon): add style prop (#2406)
1 parent 28c3239 commit 51a9e1f

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

src/components/Icon/Icon.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as React from 'react';
22

3-
import type {QAProps} from '../types';
3+
import type {DOMProps, QAProps} from '../types';
44
import {block} from '../utils/cn';
55
import {a11yHiddenSvgProps} from '../utils/svg';
66

@@ -22,21 +22,23 @@ interface IconComposition {
2222
prefix?: string;
2323
}
2424

25-
export interface IconProps extends QAProps {
25+
export interface IconProps extends QAProps, DOMProps {
2626
data: IconData;
2727
width?: number | string;
2828
height?: number | string;
2929
size?: number | string;
3030
fill?: string;
3131
stroke?: string;
32-
className?: string;
3332
}
3433

3534
const b = block('icon');
3635

3736
export const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttributes<SVGSVGElement>> &
3837
IconComposition = React.forwardRef<SVGSVGElement, IconProps>(
39-
({data, width, height, size, className, fill = 'currentColor', stroke = 'none', qa}, ref) => {
38+
(
39+
{data, width, height, size, className, style, fill = 'currentColor', stroke = 'none', qa},
40+
ref,
41+
) => {
4042
// This component supports four different ways to load and use icons:
4143
// - svg-react-loader
4244
// - svg-sprite-loader
@@ -95,6 +97,7 @@ export const Icon: React.ForwardRefExoticComponent<IconProps & React.RefAttribut
9597
width: w,
9698
height: h,
9799
className: b(null, className),
100+
style,
98101
fill,
99102
stroke,
100103
'data-qa': qa,

src/components/Icon/README-ru.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ import CheckIcon from './check.svg';
6060
| fill | Атрибут `fill` для SVG. | `string` | `"currentColor"` |
6161
| stroke | Атрибут `stroke` для SVG. | `string` | `"none"` |
6262
| className | Пользовательский CSS-класс корневого элемента. | `string` | |
63+
| style | Пользовательские стили для корневого элемента. | `CSSProperties` | |

src/components/Icon/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,4 @@ import CheckIcon from './check.svg';
6060
| fill | `fill` SVG attribute | `string` | `"currentColor"` |
6161
| stroke | `stroke` SVG attribute | `string` | `"none"` |
6262
| className | Custom CSS class for the root element | `string` | |
63+
| style | Custom styles for the root element | `CSSProperties` | |

src/components/Icon/__stories__/Icon.stories.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const meta: Meta<typeof Icon> = {
1414
options: Object.keys(icons),
1515
mapping: icons,
1616
},
17+
style: {
18+
control: 'object',
19+
},
1720
},
1821
args: {
1922
data: 'Gear',
@@ -41,6 +44,10 @@ type Story = StoryObj<typeof Icon>;
4144
export const Default: Story = {};
4245

4346
export const Size: Story = {
47+
args: {
48+
style: {},
49+
},
50+
4451
render: (args) => (
4552
<Showcase>
4653
<Icon {...args} size={16} />

0 commit comments

Comments
 (0)