Skip to content

Commit

Permalink
fix(plasma-icons): fix IconRoot API
Browse files Browse the repository at this point in the history
  • Loading branch information
kayman233 committed Dec 29, 2023
1 parent bd23b00 commit f50598f
Show file tree
Hide file tree
Showing 1,028 changed files with 1,040 additions and 1,033 deletions.
2 changes: 1 addition & 1 deletion packages/plasma-icons/src/scalable/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ interface Props {
}

export const Icon: React.FC<Props> = ({ icon, size, color, className }) => {
return <IconRoot className={className} iconName={icon} size={size || 's'} color={color} />;
return <IconRoot className={className} icon={icon} size={size || 's'} color={color} />;
};

export const iconSectionsSet = {
Expand Down
17 changes: 12 additions & 5 deletions packages/plasma-icons/src/scalable/IconRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface IconProps {

interface IconRootProps extends IconProps {
size: IconSize;
iconName: IconSetUnionSize;
icon: React.FC<IconProps> | IconSetUnionSize;
}

const StyledRoot = styled.div<{ w: string }>`
Expand Down Expand Up @@ -70,16 +70,23 @@ const getIconComponent = (iconName: IconSetUnionSize, size: number) => {
);
};

export const IconRoot: React.FC<IconRootProps> = ({ iconName, size, color, className }) => {
export const IconRoot: React.FC<IconRootProps> = ({ icon: Icon, size, color, className }) => {
const c = color || primary;

const w = `${sizeMap[size].scale}rem`;

const IconComponent = getIconComponent(iconName, sizeMap[size].size);
if (typeof Icon === 'string') {
const IconComponent = getIconComponent(Icon, sizeMap[size].size);
return (
<StyledRoot w={w} className={className}>
{IconComponent && <IconComponent color={c} size={size} />}
</StyledRoot>
);
}

return (
<StyledRoot w={w} className={className}>
{IconComponent && <IconComponent color={c} size={size} />}
<StyledRoot aria-hidden w={w} className={className}>
<Icon color={c} size={size} />
</StyledRoot>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAccessibility: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="accessibility" />;
return <IconRoot className={className} size={size} color={color} icon="accessibility" />;
};
2 changes: 1 addition & 1 deletion packages/plasma-icons/src/scalable/Icons/IconAddFill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAddFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="addFill" />;
return <IconRoot className={className} size={size} color={color} icon="addFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAddOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="addOutline" />;
return <IconRoot className={className} size={size} color={color} icon="addOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAddSmileFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="addSmileFill" />;
return <IconRoot className={className} size={size} color={color} icon="addSmileFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAddSmileOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="addSmileOutline" />;
return <IconRoot className={className} size={size} color={color} icon="addSmileOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAlarmAddFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="alarmAddFill" />;
return <IconRoot className={className} size={size} color={color} icon="alarmAddFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAlarmAddOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="alarmAddOutline" />;
return <IconRoot className={className} size={size} color={color} icon="alarmAddOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAlarmCircleFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="alarmCircleFill" />;
return <IconRoot className={className} size={size} color={color} icon="alarmCircleFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAlarmCircleOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="alarmCircleOutline" />;
return <IconRoot className={className} size={size} color={color} icon="alarmCircleOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAlarmDoneFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="alarmDoneFill" />;
return <IconRoot className={className} size={size} color={color} icon="alarmDoneFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAlarmDoneOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="alarmDoneOutline" />;
return <IconRoot className={className} size={size} color={color} icon="alarmDoneOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAnimalFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="animalFill" />;
return <IconRoot className={className} size={size} color={color} icon="animalFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAnimalOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="animalOutline" />;
return <IconRoot className={className} size={size} color={color} icon="animalOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAntennaFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="antennaFill" />;
return <IconRoot className={className} size={size} color={color} icon="antennaFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAntennaOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="antennaOutline" />;
return <IconRoot className={className} size={size} color={color} icon="antennaOutline" />;
};
2 changes: 1 addition & 1 deletion packages/plasma-icons/src/scalable/Icons/IconAppleFill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAppleFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="appleFill" />;
return <IconRoot className={className} size={size} color={color} icon="appleFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAppleOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="appleOutline" />;
return <IconRoot className={className} size={size} color={color} icon="appleOutline" />;
};
2 changes: 1 addition & 1 deletion packages/plasma-icons/src/scalable/Icons/IconAppsFill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAppsFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="appsFill" />;
return <IconRoot className={className} size={size} color={color} icon="appsFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAppsOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="appsOutline" />;
return <IconRoot className={className} size={size} color={color} icon="appsOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowBarDown: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowBarDown" />;
return <IconRoot className={className} size={size} color={color} icon="arrowBarDown" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowBarUp: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowBarUp" />;
return <IconRoot className={className} size={size} color={color} icon="arrowBarUp" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowDiagLeftDown: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowDiagLeftDown" />;
return <IconRoot className={className} size={size} color={color} icon="arrowDiagLeftDown" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowDiagRightUp: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowDiagRightUp" />;
return <IconRoot className={className} size={size} color={color} icon="arrowDiagRightUp" />;
};
2 changes: 1 addition & 1 deletion packages/plasma-icons/src/scalable/Icons/IconArrowDown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowDown: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowDown" />;
return <IconRoot className={className} size={size} color={color} icon="arrowDown" />;
};
2 changes: 1 addition & 1 deletion packages/plasma-icons/src/scalable/Icons/IconArrowLeft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowLeft: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowLeft" />;
return <IconRoot className={className} size={size} color={color} icon="arrowLeft" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowRight: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowRight" />;
return <IconRoot className={className} size={size} color={color} icon="arrowRight" />;
};
2 changes: 1 addition & 1 deletion packages/plasma-icons/src/scalable/Icons/IconArrowUp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowUp: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowUp" />;
return <IconRoot className={className} size={size} color={color} icon="arrowUp" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideDownFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideDownFill" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideDownFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideDownOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideDownOutline" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideDownOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideForwardBack: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideForwardBack" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideForwardBack" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideLeftFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideLeftFill" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideLeftFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideLeftOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideLeftOutline" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideLeftOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideRightFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideRightFill" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideRightFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideRightOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideRightOutline" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideRightOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideTraceR: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideTraceR" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideTraceR" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideUpFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideUpFill" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideUpFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowWideUpOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowWideUpOutline" />;
return <IconRoot className={className} size={size} color={color} icon="arrowWideUpOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowsMove: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowsMove" />;
return <IconRoot className={className} size={size} color={color} icon="arrowsMove" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowsMoveHoriz: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowsMoveHoriz" />;
return <IconRoot className={className} size={size} color={color} icon="arrowsMoveHoriz" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconArrowsMoveVertical: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="arrowsMoveVertical" />;
return <IconRoot className={className} size={size} color={color} icon="arrowsMoveVertical" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAttentionCircleFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="attentionCircleFill" />;
return <IconRoot className={className} size={size} color={color} icon="attentionCircleFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAttentionCircleOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="attentionCircleOutline" />;
return <IconRoot className={className} size={size} color={color} icon="attentionCircleOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAttentionTriangleFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="attentionTriangleFill" />;
return <IconRoot className={className} size={size} color={color} icon="attentionTriangleFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconAttentionTriangleOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="attentionTriangleOutline" />;
return <IconRoot className={className} size={size} color={color} icon="attentionTriangleOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconBackspaceFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="backspaceFill" />;
return <IconRoot className={className} size={size} color={color} icon="backspaceFill" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconBackspaceOutline: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="backspaceOutline" />;
return <IconRoot className={className} size={size} color={color} icon="backspaceOutline" />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import React from 'react';
import { IconRoot, IconProps } from '../IconRoot';

export const IconBackwardFill: React.FC<IconProps> = ({ size = 's', color, className }) => {
return <IconRoot className={className} size={size} color={color} iconName="backwardFill" />;
return <IconRoot className={className} size={size} color={color} icon="backwardFill" />;
};
Loading

0 comments on commit f50598f

Please sign in to comment.