Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
chore: suppress errors output to the console by Icon
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Dec 2, 2022
1 parent a257b1d commit bd9dc50
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/atoms/Icon/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type Props = {
style?: CSSProperties;
role?: AriaRole;
notransition?: boolean;
transitionDuration?: string;
onClick?: () => void;
} & AriaAttributes;

Expand All @@ -32,6 +33,7 @@ const Icon: React.FC<Props> = ({
size,
role,
notransition,
transitionDuration,
onClick,
...props
}) => {
Expand Down Expand Up @@ -63,13 +65,19 @@ const Icon: React.FC<Props> = ({
<StyledSvg
className={className}
src={src}
style={style}
role={role}
color={color}
stroke={stroke}
size={sizeStr}
notransition={notransition}
onClick={onClick}
style={{
...style,
// To prevent annoying errors from being output to the console, specify transitions without Emotion.
transitionDuration:
!notransition && !style?.transitionDuration
? transitionDuration || "0.3s"
: style?.transitionDuration,
}}
{...aria}
/>
);
Expand All @@ -85,7 +93,6 @@ const StyledSvg = styled(SVG)<{
color?: string;
stroke?: string;
size?: string;
notransition?: boolean;
}>`
font-size: 0;
display: inline-block;
Expand All @@ -94,7 +101,6 @@ const StyledSvg = styled(SVG)<{
color: ${({ color }) => color};
${({ stroke }) => `stroke: ${stroke};`}
transition-property: color, background;
${({ notransition }) => (!notransition ? "transition-duration: 0.3s;" : undefined)}
`;

export default memo(Icon);

0 comments on commit bd9dc50

Please sign in to comment.