mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 21:27:06 +04:00
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
28 lines
965 B
Plaintext
28 lines
965 B
Plaintext
---
|
|
import icons from '@data/icons.json'
|
|
|
|
/** core/scss/ui/_icons.scss `.icon-{size}` modifier classes */
|
|
export type IconSize = 'sm' | 'md' | 'lg'
|
|
|
|
interface Props {
|
|
name: string
|
|
type?: 'outline' | 'filled'
|
|
class?: string | undefined
|
|
color?: string | undefined
|
|
size?: IconSize | undefined
|
|
inline?: boolean
|
|
}
|
|
|
|
const { name, type = 'outline', class: className, color, size, inline } = Astro.props
|
|
|
|
const icon = (icons as unknown as Record<string, { svg: Record<string, string> }>)[name]
|
|
|
|
const classes = ['icon', className, color && `text-${color}`, inline && 'icon-inline', size && `icon-${size}`].filter(Boolean).join(' ')
|
|
|
|
let svg = icon?.svg?.[type] ?? ''
|
|
svg = svg.replace(/<path stroke="none" d="M0 0h24v24H0z" fill="none"\s*\/>/, '')
|
|
svg = svg.replace(/class="[^"]+"/, `aria-hidden="true" focusable="false" class="${classes}"`)
|
|
---
|
|
|
|
{icon && <Fragment set:html={`<!-- Download SVG icon from http://tabler.io/icons/icon/${name} -->\n\t${svg}`} />}
|