|
1
|
import clsx from "clsx" |
|
2
|
import React from "react" |
|
3
|
|
|
4
|
export type RadioItemProps = React.DetailedHTMLProps< |
|
5
|
React.InputHTMLAttributes<HTMLInputElement>, |
|
6
|
HTMLInputElement |
|
7
|
> & { |
|
8
|
checked?: boolean |
|
9
|
} |
|
10
|
|
|
11
|
export const RadioItem = ({ className, checked, ...props }: RadioItemProps) => { |
|
12
|
return ( |
|
13
|
<div className="p-[3px] flex justify-center items-center relative"> |
|
14
|
<input |
|
15
|
type="radio" |
|
16
|
className={clsx( |
|
17
|
"appearance-none bg-medusa-bg-component shadow-borders-base dark:shadow-border-base-dark", |
|
18
|
"w-[14px] h-[14px] rounded-full", |
|
19
|
"focus:shadow-borders-interactive-with-focus disabled:opacity-50", |
|
20
|
"checked:!bg-medusa-bg-interactive checked:!shadow-borders-interactive-with-shadow", |
|
21
|
!checked && "hover:bg-medusa-bg-component-hover", |
|
22
|
className |
|
23
|
)} |
|
24
|
checked={checked} |
|
25
|
{...props} |
|
26
|
/> |
|
27
|
{checked && ( |
|
28
|
<span |
|
29
|
className={clsx( |
|
30
|
"w-[6px] h-[6px] bg-medusa-bg-base dark:bg-medusa-fg-on-color absolute top-1/2 left-1/2 rounded-full", |
|
31
|
"-translate-x-1/2 -translate-y-1/2 shadow-details-contrast-on-bg-interactive" |
|
32
|
)} |
|
33
|
data-testid="radio-item-checked-indicator" |
|
34
|
/> |
|
35
|
)} |
|
36
|
</div> |
|
37
|
) |
|
38
|
} |