Skip to content

Commit

Permalink
Merge pull request #2403 from sasha-evidation/icons-allow-overriding-…
Browse files Browse the repository at this point in the history
…role

feat: allow overriding of role prop for icons
  • Loading branch information
Viraj-10 authored Aug 23, 2024
2 parents acf2372 + c18e7a6 commit 1b9084c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions packages/unstyled/icon/src/createIcon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ export function createIcon<IconProps>({
...props,
};

const { stroke = 'currentColor', color, ...resolvedProps } = finalProps;
const {
stroke = 'currentColor',
color,
role = 'img',
...resolvedProps
} = finalProps;
let type = resolvedProps.type;
if (type === undefined) {
type = 'svg';
Expand Down Expand Up @@ -93,7 +98,7 @@ export function createIcon<IconProps>({
<Root
{...resolvedProps}
{...colorProps}
role="img"
role={role}
ref={ref}
{...sizeProps}
{...sizeStyle}
Expand Down
9 changes: 7 additions & 2 deletions packages/unstyled/icon/src/createIcon/index.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ export function createIcon<IconProps>({
...props,
};

const { stroke = 'currentColor', color, ...resolvedProps } = finalProps;
const {
stroke = 'currentColor',
color,
role = 'img',
...resolvedProps
} = finalProps;
let type = resolvedProps.type;
if (type === undefined) {
type = 'svg';
Expand Down Expand Up @@ -92,7 +97,7 @@ export function createIcon<IconProps>({
<Root
{...resolvedProps}
{...colorProps}
role="img"
role={role}
ref={ref}
{...sizeProps}
{...sizeStyle}
Expand Down

0 comments on commit 1b9084c

Please sign in to comment.