Skip to content

Commit

Permalink
fix: fix wrapper component props
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Jun 18, 2024
1 parent a7731fe commit 06b543b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/varlet-icon-builder/src/commands/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,8 @@ export default defineComponent({
setup(props) {
const style = computed(() => ({
display: 'inline-block',
width: typeof props.size === 'number' ? \`\${props.size}px\` : props.size,
height: typeof props.size === 'number' ? \`\${props.size}px\` : props.size,
color: props.color,
'--x-icon-size': typeof props.size === 'number' ? \`\${props.size}px\` : props.size,
}))
return {
Expand All @@ -150,8 +149,8 @@ export default class ${wrapperComponentName} {
static name: string
$props: {
size: string | number
color: string
size?: string | number
color?: string
}
}`,
)
Expand Down Expand Up @@ -199,8 +198,12 @@ export function injectSvgCurrentColor(content: string) {
.replace(/stroke="(?!none).+?"/g, 'stroke="currentColor"')
}

export function injectSvgStyle(content: string) {
return content.replace('<svg', '<svg style="width: var(--x-icon-size); height: var(--x-icon-size)"')
}

export function compileSvgToVueSfc(name: string, content: string) {
content = injectSvgCurrentColor(content.match(/<svg (.|\n|\r)*/)?.[0] ?? '')
content = injectSvgStyle(injectSvgCurrentColor(content.match(/<svg (.|\n|\r)*/)?.[0] ?? ''))
return `\
<template>
${content}
Expand Down

0 comments on commit 06b543b

Please sign in to comment.