"use client"; import clsx from "clsx"; import Link from "next/link"; import { HtmlHTMLAttributes, PropsWithChildren } from "react"; import { useSwitchControlContext } from "./switch-control-context"; import styles from "./switch-control.module.css"; export interface ControlProps extends PropsWithChildren, HtmlHTMLAttributes { label: string; value: string; checked?: boolean; defaultChecked?: boolean; disabled?: boolean; icon?: JSX.Element; href?: string; onClick?: () => void; } const Control = ({ label, value, checked, defaultChecked, disabled, icon, href, ...rest }: ControlProps) => { const { name, size } = useSwitchControlContext(); const sharedClassNames = clsx(styles.control, { [styles.icon]: !!icon, [styles.text]: !icon, [styles.small]: size === "small", [styles.large]: size === "large", [styles.disabled]: disabled, [styles.checked]: checked, }); if (href && !icon) { return ( {label} ); } return ( ); }; export default Control;