150600
This commit is contained in:
40
src/components/icons/icon.astro
Normal file
40
src/components/icons/icon.astro
Normal file
@@ -0,0 +1,40 @@
|
||||
---
|
||||
import { Icons } from './icons.ts'
|
||||
|
||||
interface Path {
|
||||
d: string
|
||||
class?: string
|
||||
}
|
||||
|
||||
const { name } = Astro.props
|
||||
|
||||
const icon = (Icons as any)[name] || {}
|
||||
|
||||
const paths: Path[] = icon.paths || [];
|
||||
---
|
||||
|
||||
{
|
||||
icon
|
||||
? (
|
||||
<svg
|
||||
class={icon.class}
|
||||
height={icon.height}
|
||||
viewBox={icon.viewBox}
|
||||
width={icon.width}
|
||||
fill={icon.fill}
|
||||
clip-rule={icon.clipRule}
|
||||
fill-rule={icon.fillRule}
|
||||
stroke={icon.stroke}
|
||||
stroke-width={icon.strokeWidth}
|
||||
stroke-linecap={icon.strokeLinecap}
|
||||
stroke-linejoin={icon.strokeLinejoin}
|
||||
><title>{icon.title}</title>
|
||||
{paths.map(path => (
|
||||
<path d={path.d} class={path.class || ''} />
|
||||
))}
|
||||
</svg>
|
||||
)
|
||||
: (
|
||||
'Icon not found'
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user