Skip to content

Commit 0a3b37e

Browse files
author
Kubit
committed
Add id prop to Icon
1 parent 1c983b7 commit 0a3b37e

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

src/components/icon/iconStandAlone.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { IIconComplex, IIconStandAlone } from './types';
99

1010
const IconComplexComponent = (
1111
{
12+
id,
1213
color,
1314
height,
1415
width,
@@ -27,7 +28,6 @@ const IconComplexComponent = (
2728

2829
React.useEffect(() => {
2930
(async () => {
30-
// eslint-disable-next-line n/no-unsupported-features/node-builtins
3131
const res = await fetch(icon);
3232
let response = '';
3333
if (res) {
@@ -51,6 +51,7 @@ const IconComplexComponent = (
5151
aria-label={altText}
5252
dangerouslySetInnerHTML={{ __html: svgContent }}
5353
data-testid={dataTestId}
54+
id={id}
5455
role={emptyAltText ? ROLES.NONE : ROLES.IMG}
5556
twistAnimationTransformValue={twistAnimationTransformValue}
5657
/>
@@ -61,6 +62,7 @@ export const IconComplex = React.forwardRef(IconComplexComponent);
6162

6263
const IconStandAloneComponent = (
6364
{
65+
id,
6466
linearIcon,
6567
icon,
6668
altText,
@@ -89,6 +91,7 @@ const IconStandAloneComponent = (
8991
emptyAltText={isEmptyAltText}
9092
height={height}
9193
icon={icon}
94+
id={id}
9295
moveRound={rotate}
9396
transitionDuration={transitionDuration}
9497
twistAnimationTransformValue={twistAnimationTransformValue}
@@ -108,6 +111,7 @@ const IconStandAloneComponent = (
108111
alt={altText}
109112
aria-hidden={isEmptyAltText}
110113
data-testid={dataTestId}
114+
id={id}
111115
loading="lazy"
112116
src={icon}
113117
/>
@@ -124,6 +128,7 @@ const IconStandAloneComponent = (
124128
aria-hidden={isEmptyAltText}
125129
aria-label={altText}
126130
data-testid={dataTestId}
131+
id={id}
127132
role={isEmptyAltText ? ROLES.NONE : ROLES.IMG}
128133
twistAnimationTransformValue={twistAnimationTransformValue}
129134
/>

src/components/icon/stories/argtypes.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ export const argtypes = (): ArgTypesReturn => {
1515
category: CATEGORY_CONTROL.ACCESIBILITY,
1616
},
1717
},
18+
id: {
19+
description: 'id for icon',
20+
type: { name: 'string' },
21+
control: { type: 'text' },
22+
table: {
23+
type: {
24+
summary: 'string',
25+
},
26+
category: CATEGORY_CONTROL.MODIFIERS,
27+
},
28+
},
1829
icon: {
1930
type: { name: 'string', required: true },
2031
control: { type: 'select' },

src/components/icon/types/icon.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IconTypes } from '@/types/index';
22

33
export interface IIconComplex {
4+
id?: string;
45
color?: string;
56
height?: string;
67
width?: string;
@@ -21,6 +22,7 @@ type IconAriaAttributes = Pick<
2122
>;
2223

2324
export interface IIconStandAlone extends IconAriaAttributes {
25+
id?: string;
2426
altText?: string;
2527
color?: string;
2628
height?: string;

0 commit comments

Comments
 (0)