1 Star 0 Fork 196

right / zhufeng-react-assembly

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
index.tsx 929 Bytes
一键复制 编辑 原始数据 按行查看 历史
17779896606@163.com 提交于 2020-08-22 18:13 . 添加第四天的作业
import React from "react";
import styled from "styled-components";
import { icons } from "../shared/icons";
const Svg = styled.svg<IconProps>`
display: ${(props) => (props.block ? "block" : "inline-block")};
vertical-align: middle;
shape-rendering: inherit;
transform: translate3d(0, 0, 0);
`;
const Path = styled.path`
fill: ${(props) => props.color};
`;
export interface IconProps {
/** 图标名*/
icon: keyof typeof icons;
/** 是否块级元素 */
block?: boolean;
/** 颜色 */
color?: string;
}
export function Icon(props: IconProps) {
const { block, icon, color } = props;
return (
<Svg
viewBox="0 0 1024 1024"
width="20px"
height="20px"
block={block}
{...props}
>
<Path d={icons[icon]} color={color} />
</Svg>
);
}
Icon.defaultProps = {
block: false,
color: "black",
};
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/r_ight/zhufeng-react-assembly.git
git@gitee.com:r_ight/zhufeng-react-assembly.git
r_ight
zhufeng-react-assembly
zhufeng-react-assembly
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891