|
1
|
import { Switch } from "@medusajs/ui" |
|
2
|
import clsx from "clsx" |
|
3
|
import React from "react" |
|
4
|
|
|
5
|
export const Toggle = ({ |
|
6
|
className, |
|
7
|
...props |
|
8
|
}: React.ComponentProps<typeof Switch>) => { |
|
9
|
return ( |
|
10
|
<Switch |
|
11
|
{...props} |
|
12
|
className={clsx( |
|
13
|
className, |
|
14
|
"bg-ui-bg-switch-off hover:bg-ui-bg-switch-off-hover data-[state=unchecked]:hover:after:bg-switch-off-hover-gradient", |
|
15
|
"before:shadow-details-switch-background focus-visible:shadow-details-switch-background-focus data-[state=checked]:bg-ui-bg-interactive", |
|
16
|
"disabled:!bg-ui-bg-disabled group relative inline-flex items-center rounded-full outline-none transition-all before:absolute", |
|
17
|
"before:inset-0 before:rounded-full before:content-[''] after:absolute after:inset-0 after:rounded-full after:content-['']", |
|
18
|
"disabled:cursor-not-allowed", |
|
19
|
|
|
20
|
props.size !== "small" && |
|
21
|
"h-[18px] w-[32px] [&_span]:h-[14px] [&_span]:w-[14px]", |
|
22
|
"[&_span]:bg-medusa-fg-on-color [&_span]:shadow-details-switch-handle [&_span]:group-disabled:bg-ui-fg-disabled [&_span]:pointer-events-none", |
|
23
|
"[&_span]:rounded-full [&_span]:group-disabled:shadow-none [&_span]:transition-transform", |
|
24
|
"[&_span]:data-[state=checked]:translate-x-docs_1 [&_span]:data-[state=unchecked]:translate-x-docs_0.125" |
|
25
|
)} |
|
26
|
/> |
|
27
|
) |
|
28
|
} |