feat(react): Ability to customise strokeWidth (#38)

This commit is contained in:
John Letey
2020-06-28 15:27:24 +01:00
committed by GitHub
parent fc76ff2687
commit 3624f449f0
308 changed files with 1594 additions and 621 deletions

View File

@@ -39,6 +39,7 @@ import { FC, SVGAttributes } from "react";
interface Props extends SVGAttributes<SVGElement> {
color?: string;
size?: string | number;
width?: string | number;
}
type Icon = FC<Props>;
@@ -54,7 +55,12 @@ fs.writeFileSync(
const attrsToString = (attrs) => {
return Object.keys(attrs)
.map((key) => {
if (key === "width" || key === "height" || key === "stroke") {
if (
key === "width" ||
key === "height" ||
key === "stroke" ||
key === "strokeWidth"
) {
return key + "={" + attrs[key] + "}";
}
if (key === "rest") {
@@ -75,7 +81,7 @@ icons.forEach((i) => {
viewBox: "0 0 24 24",
fill: "none",
stroke: "color",
strokeWidth: 2,
strokeWidth: "width",
strokeLinecap: "round",
strokeLinejoin: "round",
rest: "...rest",
@@ -85,7 +91,7 @@ icons.forEach((i) => {
import React, { forwardRef } from "react";
import PropTypes from "prop-types";
const ${ComponentName} = forwardRef(({ color = "currentColor", size = 24, ...rest }, ref) => {
const ${ComponentName} = forwardRef(({ color = "currentColor", size = 24, width = 2, ...rest }, ref) => {
return (
<svg ref={ref} ${attrsToString(defaultAttrs)}>
${i.content}
@@ -99,6 +105,10 @@ icons.forEach((i) => {
PropTypes.string,
PropTypes.number
]),
width: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
]),
}
${ComponentName}.displayName = "${ComponentName}"