fix: qwik output (#134)

This commit is contained in:
Manu MA 2023-04-20 10:54:51 +02:00 committed by GitHub
parent b5fc47abb6
commit 87e9970220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,6 +79,18 @@ export function ${name}(props: SVGProps<SVGSVGElement>) {
return prettierCode(code, 'babel-ts')
}
export function SvgToQwik(svg: string, name: string, snippet: boolean) {
let code = `
export function ${name}(props: QwikIntrinsicElements['svg'], key: string) {
return (
${ClearSvg(svg, false).replace(/<svg (.*?)>/, '<svg $1 {...props} key={key}>')}
)
}`
code = snippet ? code : `import type { QwikIntrinsicElements } from '@builder.io/qwik'\n${code}\nexport default ${name}`
return prettierCode(code, 'babel-ts')
}
export function SvgToVue(svg: string, name: string, isTs?: boolean) {
const contet = `
<template>
@ -128,7 +140,7 @@ export async function getIconSnippet(icon: string, type: string, snippet = true,
case 'tsx':
return SvgToTSX(await getSvg(icon, undefined, color), toComponentName(icon), snippet)
case 'qwik':
return SvgToTSX(await getSvg(icon, undefined, color), toComponentName(icon), snippet, false)
return SvgToQwik(await getSvg(icon, undefined, color), toComponentName(icon), snippet)
case 'vue':
return SvgToVue(await getSvg(icon, undefined, color), toComponentName(icon))
case 'vue-ts':