Updateing Docs
This commit is contained in:
@@ -1,37 +1,30 @@
|
||||
// components/Button.js
|
||||
import { $html } from "sigpro";
|
||||
import { val, joinClass } from "../core/utils.js";
|
||||
import { ui, val, getIcon } from "../core/utils.js";
|
||||
|
||||
/** BUTTON */
|
||||
/**
|
||||
* Button component
|
||||
*
|
||||
* daisyUI classes used:
|
||||
* - btn, btn-primary, btn-secondary, btn-accent, btn-ghost
|
||||
* - btn-info, btn-success, btn-warning, btn-error, btn-neutral
|
||||
* - btn-xs, btn-sm, btn-md, btn-lg, btn-xl
|
||||
* - btn-outline, btn-soft, btn-dash, btn-link
|
||||
* - btn-circle, btn-square, btn-wide, btn-block
|
||||
* - btn-active, btn-disabled
|
||||
*/
|
||||
export const Button = (props, children) => {
|
||||
const { badge, badgeClass, tooltip, icon, loading, ...rest } = props;
|
||||
const { class: className, loading, icon, ...rest } = props;
|
||||
|
||||
const btn = $html(
|
||||
"button",
|
||||
{
|
||||
...rest,
|
||||
class: joinClass("btn", props.class)
|
||||
},
|
||||
[
|
||||
() => (val(loading) ? $html("span", { class: "loading loading-spinner" }) : null),
|
||||
icon ? $html("span", { class: "mr-1" }, icon) : null,
|
||||
children,
|
||||
]
|
||||
);
|
||||
const iconEl = getIcon(icon);
|
||||
|
||||
let out = btn;
|
||||
|
||||
if (badge) {
|
||||
out = $html("div", { class: "indicator" }, [
|
||||
$html(
|
||||
"span",
|
||||
{ class: joinClass("indicator-item badge", badgeClass || "badge-secondary") },
|
||||
badge
|
||||
),
|
||||
out,
|
||||
]);
|
||||
}
|
||||
|
||||
return tooltip
|
||||
? $html("div", { class: "tooltip", "data-tip": tooltip }, out)
|
||||
: out;
|
||||
};
|
||||
return $html("button", {
|
||||
...rest,
|
||||
class: ui('btn', className),
|
||||
disabled: () => val(loading) || val(props.disabled),
|
||||
}, () => [
|
||||
val(loading) && $html("span", { class: "loading loading-spinner" }),
|
||||
iconEl,
|
||||
children
|
||||
].filter(Boolean));
|
||||
};
|
||||
Reference in New Issue
Block a user