-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathtemplateIcons.js
More file actions
45 lines (42 loc) · 1.4 KB
/
templateIcons.js
File metadata and controls
45 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const comments = `
/*
THIS FILE IS GENERATED BY ICON BUILD TOOL
DO NOT EDIT IT MANUAL
Docs in @kaspersky/hexa-ui-icons package
*/
`
/**
* template
* @param componentName - The component name
* @param props - The properties
* @param interfaces - All necessary interfaces (typescript)
* @param imports - All necessary imports
* @param exports - The export of the component
* @param jsx - The JSX part of the component
* @returns A built-in template-tag function to create template
*/
const propTypesTemplate = (
{ componentName, jsx },
{ tpl }
) => {
const iconName = componentName.replace('Svg', '')
return tpl`
${comments}
import React, { type ComponentProps, type SVGProps } from 'react'
// @ts-ignore
import { resolveColorToken } from '../helpers/resolveColorToken'
import type { ITestIds } from './index'
const Icon = React.forwardRef<SVGSVGElement, SVGProps<SVGSVGElement>>((props, ref) => ${jsx})
type CustomComponentProps = ComponentProps<typeof Icon> & ITestIds
const _CustomComponent = React.memo(
React.forwardRef<SVGSVGElement, CustomComponentProps>((props, ref) => {
const { klId, testId, ...otherProps } = props
return <Icon kl-id={klId} data-testid={testId} ref={ref} {...otherProps} />
})
)
const ${iconName} = _CustomComponent
${iconName}.displayName = '${iconName}'
export default ${iconName}
`
}
module.exports = propTypesTemplate