chore: reduce code for icons

This commit is contained in:
DarkSky
2022-08-12 01:42:17 +08:00
parent 40b617c429
commit d3b4906da9
135 changed files with 268 additions and 668 deletions

View File

@@ -100,19 +100,16 @@ module.exports = async function generateReactIcon(name, svgCode, customStyles) {
const colors = getColors(colorIdx);
return `
import { FC } from 'react';
// eslint-disable-next-line no-restricted-imports
import { SvgIcon } from '@mui/material';
// eslint-disable-next-line no-restricted-imports
import type { SvgIconProps } from '@mui/material';
import { SvgIcon, SvgIconProps } from '@mui/material';
export interface ${name}IconProps extends Omit<SvgIconProps, 'color'> {
${getColorsInterfaceProps(colors)}
}
export const ${name}Icon: FC<${name}IconProps> = ({ ${getRestColors(
export const ${name}Icon = ({ ${getRestColors(
colors
)}, style, ...props}) => {
)}, style, ...props}: ${name}IconProps) => {
const propsStyles = ${getPropNameToColorValue(colors)};
const customStyles = ${JSON.stringify(customStyles || {})};
const styles = {...propsStyles, ...customStyles, ...style}

View File

@@ -4,10 +4,6 @@ const { readdir, readFile, writeFile, exists } = require('fs/promises');
const { pascalCase, paramCase } = require('change-case');
const svgr = require('@svgr/core');
function isDuotone(name) {
return name.endsWith('Duotone');
}
async function optimizeSvg(folder) {
try {
const icons = await readdir(folder);