Updateing Docs
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
// components/Radio.js
|
||||
import { $html } from "sigpro";
|
||||
import { val, joinClass } from "../core/utils.js";
|
||||
import { val, ui } from "../core/utils.js";
|
||||
|
||||
/** RADIO */
|
||||
/**
|
||||
* Radio component
|
||||
*
|
||||
* daisyUI classes used:
|
||||
* - radio, radio-primary, radio-secondary, radio-accent
|
||||
* - radio-info, radio-success, radio-warning, radio-error
|
||||
* - radio-xs, radio-sm, radio-md, radio-lg
|
||||
* - label, label-text, cursor-pointer, justify-start, gap-3
|
||||
* - tooltip, tooltip-top, tooltip-bottom, tooltip-left, tooltip-right
|
||||
*/
|
||||
export const Radio = (props) => {
|
||||
const { label, tooltip, value, inputValue, name, ...rest } = props;
|
||||
const { class: className, label, tooltip, value, inputValue, name, ...rest } = props;
|
||||
|
||||
const radioEl = $html("input", {
|
||||
...rest,
|
||||
type: "radio",
|
||||
name: name,
|
||||
class: joinClass("radio", props.class),
|
||||
class: ui('radio', className),
|
||||
checked: () => val(value) === inputValue,
|
||||
onclick: () => {
|
||||
if (typeof value === "function") value(inputValue);
|
||||
@@ -18,8 +28,10 @@ export const Radio = (props) => {
|
||||
|
||||
if (!label && !tooltip) return radioEl;
|
||||
|
||||
return $html("label", { class: "label cursor-pointer justify-start gap-3" }, [
|
||||
const layout = $html("label", { class: "label cursor-pointer justify-start gap-3" }, [
|
||||
radioEl,
|
||||
label ? $html("span", { class: "label-text" }, label) : null,
|
||||
]);
|
||||
|
||||
return tooltip ? $html("div", { class: "tooltip", "data-tip": tooltip }, layout) : layout;
|
||||
};
|
||||
Reference in New Issue
Block a user