Add Range component for input range selection

This commit is contained in:
Natxo
2026-03-31 12:13:34 +02:00
committed by GitHub
parent 361101a463
commit 3dda7ef1e0

24
src/components/Range.js Normal file
View File

@@ -0,0 +1,24 @@
import { $html } from "sigpro";
import { val, joinClass } from "../core/utils.js";
/** RANGE */
export const Range = (props) => {
const { label, tooltip, value, ...rest } = props;
const rangeEl = $html("input", {
...rest,
type: "range",
class: joinClass("range", props.class),
value: value,
disabled: () => val(props.disabled)
});
if (!label && !tooltip) return rangeEl;
const layout = $html("div", { class: "flex flex-col gap-2" }, [
label ? $html("span", { class: "label-text" }, label) : null,
rangeEl
]);
return tooltip ? $html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout;
};