mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-02 07:03:45 +00:00
Co-authored-by: GitHub Action <action@github.com> Co-authored-by: Adam <2363879+adamdotdevin@users.noreply.github.com>
33 lines
1007 B
TypeScript
33 lines
1007 B
TypeScript
import { Button as Kobalte } from "@kobalte/core/button"
|
|
import { type ComponentProps, splitProps } from "solid-js"
|
|
import { Icon, IconProps } from "./icon"
|
|
|
|
export interface IconButtonProps extends ComponentProps<typeof Kobalte> {
|
|
icon: IconProps["name"]
|
|
size?: "normal" | "large"
|
|
iconSize?: IconProps["size"]
|
|
variant?: "primary" | "secondary" | "ghost"
|
|
}
|
|
|
|
export function IconButton(props: ComponentProps<"button"> & IconButtonProps) {
|
|
const [split, rest] = splitProps(props, ["variant", "size", "iconSize", "class", "classList"])
|
|
return (
|
|
<Kobalte
|
|
{...rest}
|
|
data-component="icon-button"
|
|
data-size={split.size || "normal"}
|
|
data-variant={split.variant || "secondary"}
|
|
classList={{
|
|
...(split.classList ?? {}),
|
|
[split.class ?? ""]: !!split.class,
|
|
}}
|
|
>
|
|
<Icon
|
|
data-slot="icon-button-icon"
|
|
name={props.icon}
|
|
size={split.iconSize ?? (split.size === "large" ? "normal" : "small")}
|
|
/>
|
|
</Kobalte>
|
|
)
|
|
}
|