mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-09 02:09:12 +00:00
26 lines
790 B
TypeScript
26 lines
790 B
TypeScript
import type { Component, JSX } from "solid-js"
|
|
import { createMemo, splitProps } from "solid-js"
|
|
import sprite from "./provider-icons/sprite.svg"
|
|
import { iconNames, type IconName } from "./provider-icons/types"
|
|
|
|
export type ProviderIconProps = JSX.SVGElementTags["svg"] & {
|
|
id: string
|
|
}
|
|
|
|
export const ProviderIcon: Component<ProviderIconProps> = (props) => {
|
|
const [local, rest] = splitProps(props, ["id", "class", "classList"])
|
|
const resolved = createMemo(() => (iconNames.includes(local.id as IconName) ? local.id : "synthetic"))
|
|
return (
|
|
<svg
|
|
data-component="provider-icon"
|
|
{...rest}
|
|
classList={{
|
|
...(local.classList ?? {}),
|
|
[local.class ?? ""]: !!local.class,
|
|
}}
|
|
>
|
|
<use href={`${sprite}#${resolved()}`} />
|
|
</svg>
|
|
)
|
|
}
|