update from cdrl

This commit is contained in:
2026-07-15 11:20:47 -04:00
parent 0f9f42be5a
commit f1745b8a1b
8 changed files with 195 additions and 353 deletions

View File

@@ -1,4 +1,4 @@
import { JSX, JSXElement } from "solid-js";
import { JSX, JSXElement, splitProps } from "solid-js";
import { Icon } from "./Icons.tsx";
export const BUTTON_COLOR_NEUTRAL = "neutral";
@@ -63,37 +63,36 @@ interface ButtonUIProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
}
export function ButtonUI(props: ButtonUIProps) {
const hasText = () => props.text !== undefined ? !!props.text : !props.icon;
const [local, buttonProps] = splitProps(props, ["text", "icon", "outline", "color", "small", "class", "type", "children"]);
const hasText = () => local.text !== undefined ? !!local.text : !local.icon;
const cls = () => {
let c = BASE;
if (props.outline) {
c += " " + OUTLINE_BASE + " " + (OUTLINE_COLORS[props.color!] || OUTLINE_COLORS["neutral"]);
if (local.outline) {
c += " " + OUTLINE_BASE + " " + (OUTLINE_COLORS[local.color!] || OUTLINE_COLORS["neutral"]);
} else {
c += " " + (COLORS[props.color!] || COLORS["neutral"]);
c += " " + (COLORS[local.color!] || COLORS["neutral"]);
}
if (props.small) {
c += props.icon ? " py-1 px-3" : " py-1 px-4";
} else if (props.icon && !hasText()) {
if (local.small) {
c += local.icon ? " py-1 px-3" : " py-1 px-4";
} else if (local.icon && !hasText()) {
c += " py-2 px-3";
} else if (props.icon) {
} else if (local.icon) {
c += " py-2 px-5";
} else {
c += " py-2 px-8";
}
if (local.class) c += " " + local.class;
return c;
};
return (
<button
type={props.type || "button"}
onclick={(e) => typeof props.onclick === "function" && props.onclick(e)}
onmousedown={(e) => typeof props.onmousedown === "function" && props.onmousedown(e)}
disabled={props.disabled}
title={props.title}
type={local.type || "button"}
class={cls()}
{...buttonProps}
>
{props.children}
{local.children}
</button>
);
}