Commit c68058de authored by Truong Le's avatar Truong Le
Browse files

fix(icon-component): export and add color prop

parent 392547f2
Pipeline #3436 passed with stages
in 51 seconds
import React, { Fragment } from "react";
import React, { CSSProperties, Fragment } from "react";
import { CarbonIconType } from "@carbon/icons-react";
import IconModule from "@common/constants";
import { Color } from "@interfaces/INews";
interface Props {
name: string;
size?: 16 | 20 | 24 | 32 | "16" | "20" | "24" | "32";
color?: Color;
}
const Icon: React.FC<Props> = ({ name, size = 20 }) => {
const Icon: React.FC<Props> = ({ name, size = 20, color }) => {
const Comp = (IconModule as Record<string, CarbonIconType>)[
name
] as CarbonIconType;
return <Fragment>{Comp ? <Comp size={size} /> : null}</Fragment>;
const inlineStyle: CSSProperties = color ? { color } : {};
return (
<Fragment>
{Comp ? <Comp style={inlineStyle} size={size} /> : null}
</Fragment>
);
};
export default Icon;
......@@ -13,6 +13,7 @@ import Grid from "@components/Grid";
import HeroBox from "@components/HeroBox";
import { HeroSection } from "@components/HeroSection";
import { HorizontalNewsCard } from "@components/HorizontalNewsCard";
import Icon from "@components/Icon";
import { ImageSlider } from "@components/ImageSlider";
import Image from "@components/Image";
import { Logo } from "@components/Logo";
......@@ -44,6 +45,7 @@ export {
HeroBox,
HeroSection,
HorizontalNewsCard,
Icon,
ImageSlider,
Image,
Header,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment