bake canonical build harness (deterministic /ship for forks) [dashboard]

This commit is contained in:
vibeasite-bot
2026-08-22 05:56:06 +01:00
parent 9d37692dc6
commit bbf19c07f9
77 changed files with 6513 additions and 363 deletions
+21 -25
View File
@@ -1,31 +1,27 @@
import * as React from "react";
import * as SwitchPrimitives from "@radix-ui/react-switch";
import { cn } from "@/lib/utils";
export interface SwitchProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "onChange"> {
checked?: boolean;
defaultChecked?: boolean;
onCheckedChange?: (checked: boolean) => void;
}
export const Switch = ({ className, checked: controlled, defaultChecked, onCheckedChange, ...props }: SwitchProps) => {
const [internal, setInternal] = React.useState(!!defaultChecked);
const checked = controlled ?? internal;
return (
<button
type="button"
role="switch"
aria-checked={checked}
onClick={() => { setInternal(!checked); onCheckedChange?.(!checked); }}
const Switch = React.forwardRef<
React.ElementRef<typeof SwitchPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>
>(({ className, ...props }, ref) => (
<SwitchPrimitives.Root
className={cn(
"peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50",
className,
)}
{...props}
ref={ref}
>
<SwitchPrimitives.Thumb
className={cn(
"relative inline-flex h-6 w-11 items-center rounded-full transition-colors",
checked ? "bg-indigo-600" : "bg-slate-300",
className
"pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0",
)}
{...props}
>
<span className={cn("inline-block h-4 w-4 transform rounded-full bg-white transition-transform", checked ? "translate-x-6" : "translate-x-1")} />
</button>
);
};
/>
</SwitchPrimitives.Root>
));
Switch.displayName = SwitchPrimitives.Root.displayName;
export default Switch;
export { Switch };