mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
chore: reduce code for icons
This commit is contained in:
@@ -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}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user