From 7c6ee5394cb9aaea1aa119d21e67c69689d2e8e5 Mon Sep 17 00:00:00 2001 From: Natxo <1172351+natxocc@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:13:12 +0200 Subject: [PATCH] Create Checkbox.js --- src/components/Checkbox.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/components/Checkbox.js diff --git a/src/components/Checkbox.js b/src/components/Checkbox.js new file mode 100644 index 0000000..863cba4 --- /dev/null +++ b/src/components/Checkbox.js @@ -0,0 +1,21 @@ +import { $html } from "sigpro"; +import { val } from "../core/utils.js"; + +/** CHECKBOX */ +export const Checkbox = (props) => { + const { value, tooltip, toggle, label, ...rest } = props; + + const checkEl = $html("input", { + ...rest, + type: "checkbox", + class: () => (val(toggle) ? "toggle" : "checkbox"), + checked: value + }); + + const layout = $html("label", { class: "label cursor-pointer justify-start gap-3" }, [ + checkEl, + label ? $html("span", { class: "label-text" }, label) : null, + ]); + + return tooltip ? $html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout; +};