UI/components/button: fixup props splitting
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { type JSX } from "solid-js";
|
import { splitProps, type JSX } from "solid-js";
|
||||||
import cx from "classnames";
|
import cx from "classnames";
|
||||||
|
|
||||||
type Variants = "dark" | "light";
|
type Variants = "dark" | "light";
|
||||||
@@ -45,32 +45,31 @@ interface ButtonProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
|
|||||||
class?: string;
|
class?: string;
|
||||||
}
|
}
|
||||||
export const Button = (props: ButtonProps) => {
|
export const Button = (props: ButtonProps) => {
|
||||||
const {
|
const [local, other] = splitProps(props, [
|
||||||
children,
|
"children",
|
||||||
variant = "dark",
|
"variant",
|
||||||
size = "default",
|
"size",
|
||||||
startIcon,
|
"startIcon",
|
||||||
endIcon,
|
"endIcon",
|
||||||
class: extraClass = "",
|
"class",
|
||||||
...buttonProps
|
]);
|
||||||
} = props;
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
class={cx(
|
class={cx(
|
||||||
extraClass,
|
local.class,
|
||||||
// Layout
|
// Layout
|
||||||
"inline-flex items-center flex-shrink gap-2 justify-center",
|
"inline-flex items-center flex-shrink gap-2 justify-center",
|
||||||
// Styles
|
// Styles
|
||||||
"border border-solid",
|
"border border-solid",
|
||||||
sizePaddings[size],
|
sizePaddings[local.size || "default"],
|
||||||
// Colors
|
// Colors
|
||||||
variantColors[variant],
|
variantColors[local.variant || "dark"],
|
||||||
)}
|
)}
|
||||||
{...buttonProps}
|
{...other}
|
||||||
>
|
>
|
||||||
<span class="h-4">{startIcon}</span>
|
<span class="h-4">{local.startIcon}</span>
|
||||||
<span>{children}</span>
|
<span>{local.children}</span>
|
||||||
<span class="h-4">{endIcon}</span>
|
<span class="h-4">{local.endIcon}</span>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user