mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
Compare commits
3 Commits
2af89d3578
...
ab16011b25
| Author | SHA1 | Date | |
|---|---|---|---|
| ab16011b25 | |||
| 204b13c445 | |||
| f28f171d3b |
@@ -15,6 +15,7 @@ export const parseReactSvgContent = async ({
|
||||
.replace("<svg", "<svg {...props}")
|
||||
.replace(/class="/g, 'className="')
|
||||
.replace(/clip-rule="/g, 'clipRule="')
|
||||
.replace(/clip-path="/g, 'clipPath="')
|
||||
.replace(/fill-rule="/g, 'fillRule="')
|
||||
.replace(/stroke-width="/g, 'strokeWidth="')
|
||||
.replace(/stroke-linecap="/g, 'strokeLinecap="')
|
||||
@@ -28,8 +29,8 @@ export const parseReactSvgContent = async ({
|
||||
let structuredCode = "";
|
||||
if (typescript) {
|
||||
structuredCode =
|
||||
`import * as React from 'react';\n\n` +
|
||||
`const ${componentName} = (props: React.SVGProps<SVGSVGElement>) => (\n ${reactifiedSvg}\n);\n\n` +
|
||||
`import type { SVGProps } from "react";\n\n` +
|
||||
`const ${componentName} = (props: SVGProps<SVGSVGElement>) => (\n ${reactifiedSvg}\n);\n\n` +
|
||||
`export { ${componentName} };`;
|
||||
} else {
|
||||
structuredCode = `const ${componentName} = (props) => (\n ${reactifiedSvg}\n);\n\nexport { ${componentName} };`;
|
||||
|
||||
Reference in New Issue
Block a user