/
githubmirror
/
tabler
Обзор
Документация
Войти
/
githubmirror
/
tabler
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
shared/ui/Icon.astro
27 строк
965 B
Paweł Kuna
Narrow component prop types, remove unused props and dead code (#2838)
10 авг 2026, 00:14
Не верифицирован
10 авг 2026, 00:14
4f7beec
Код
Авторство
О чём код?
--- 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}`} />}