Add Range component for input range selection
This commit is contained in:
24
src/components/Range.js
Normal file
24
src/components/Range.js
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user