forked from Nutlope/roomGPT
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToggle.tsx
55 lines (52 loc) · 1.62 KB
/
Toggle.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import { Switch } from "@headlessui/react";
function classNames(...classes: string[]) {
return classes.filter(Boolean).join(" ");
}
export interface ToggleProps extends React.HTMLAttributes<HTMLDivElement> {
sideBySide: boolean;
setSideBySide: (sideBySide: boolean) => void;
}
export default function Toggle({
sideBySide,
setSideBySide,
...props
}: ToggleProps) {
return (
<Switch.Group as="div" {...props}>
<div className="flex items-center">
<span
className={`text-sm mr-3 font-medium ${
!sideBySide ? "text-white" : "text-gray-500"
}`}
>
Side by Side
</span>
<Switch
checked={sideBySide}
onChange={setSideBySide}
className={classNames(
sideBySide ? "bg-blue-600" : "bg-gray-200",
"relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none "
)}
>
<span
aria-hidden="true"
className={classNames(
sideBySide ? "translate-x-5" : "translate-x-0",
"pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
)}
/>
</Switch>
<Switch.Label as="span" className="ml-3">
<span
className={`text-sm font-medium ${
sideBySide ? "text-white" : "text-gray-500"
} `}
>
Compare
</span>
</Switch.Label>
</div>
</Switch.Group>
);
}