@@ -51,16 +51,15 @@ const argv = yargs.command('$0 <input>', '', yargs => {
51
51
function template ( babel , opts , { imports, componentName, props, jsx, exports } ) {
52
52
const header = `// DO NOT EDIT. This file was generated by running \`npm run generate\`.` ;
53
53
54
- const libImports = `${ opts . colorProp ? "import { Colors } from '../../essentials ';" : '' } ` ;
54
+ const libImports = `${ opts . colorProp ? "import { getSemanticValue } from '../../utils/cssVariables ';" : '' } ` ;
55
55
56
56
const typeDef = `type Props = ${ opts . colorProp ? 'IconProps' : "Omit<IconProps, 'color'>" } ;` ;
57
57
58
58
const name = generate ( componentName ) . code ;
59
59
const nameDecl = `${ name } : React.FC<Props>` ;
60
60
61
- const defaultProps = `${ name } .defaultProps = {
62
- ${ opts . colorProp ? 'color: Colors.AUTHENTIC_BLUE_900' : '' }
63
- };` ;
61
+ const iconProps = opts . colorProp ? "({ size = 'medium', color = getSemanticValue('icon-primary-default'), ...rest})" :
62
+ "({ size = 'medium', ...props})" ;
64
63
65
64
return babel . template . smart ( { plugins : [ 'typescript' ] } ) . ast `
66
65
${ header }
@@ -73,16 +72,15 @@ function template(babel, opts, { imports, componentName, props, jsx, exports })
73
72
74
73
${ typeDef }
75
74
76
- const ${ nameDecl } : FC = ({ size = 'medium', ...props}: IconProps) => {
75
+ const ${ nameDecl } : FC = ${ iconProps } => {
76
+ ${ opts . colorProp ? 'const props = {...rest, color}' : '' }
77
77
const sizePx = (Number.isFinite(size as number)) ? size : get(\`iconSizes.\${size}\`)(props) || get('iconSizes.medium')(props);
78
-
78
+
79
79
return (
80
80
${ jsx }
81
81
);
82
82
};
83
83
84
- ${ defaultProps }
85
-
86
84
${ exports } ` ;
87
85
}
88
86
@@ -163,7 +161,8 @@ for (let file of getSvgSources(argv.input, { recursive: argv.recursive })) {
163
161
svgProps : { width : '{sizePx}' , height : '{sizePx}' } ,
164
162
replaceAttrValues : colorProp
165
163
? {
166
- [ Colors . AUTHENTIC_BLUE_900 ] : 'currentColor'
164
+ // replace default color for the source svg icons (see assets/icons folder)
165
+ [ '#001E3E' ] : 'currentColor'
167
166
}
168
167
: { } ,
169
168
...additionalConfig
0 commit comments