From 8fd234ea4c22d1a5503ab23d66be8757b92a1cf0 Mon Sep 17 00:00:00 2001 From: Natxo <1172351+natxocc@users.noreply.github.com> Date: Tue, 31 Mar 2026 12:13:58 +0200 Subject: [PATCH] Add Dropdown component for UI --- src/components/Dropdown.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/components/Dropdown.js diff --git a/src/components/Dropdown.js b/src/components/Dropdown.js new file mode 100644 index 0000000..b12d108 --- /dev/null +++ b/src/components/Dropdown.js @@ -0,0 +1,37 @@ +import { $html } from "sigpro"; +import { val } from "../core/utils.js"; + +/** DROPDOWN */ +export const Dropdown = (props, children) => { + const { label, icon, ...rest } = props; + + return $html( + "div", + { + ...rest, + class: () => `dropdown ${val(props.class) || props.class || ""}`, + }, + [ + $html( + "div", + { + tabindex: 0, + role: "button", + class: "btn m-1 flex items-center gap-2", + }, + [ + icon ? (typeof icon === "function" ? icon() : icon) : null, + label ? (typeof label === "function" ? label() : label) : null + ], + ), + $html( + "ul", + { + tabindex: 0, + class: "dropdown-content z-[50] menu p-2 shadow bg-base-100 rounded-box min-w-max border border-base-300", + }, + [typeof children === "function" ? children() : children], + ), + ], + ); +};