42 lines
925 B
Plaintext
42 lines
925 B
Plaintext
---
|
|
import { cn } from '../lib/cn'
|
|
|
|
import type { HTMLAttributes } from 'astro/types'
|
|
|
|
type Props = HTMLAttributes<'div'> & {
|
|
name: string
|
|
options: {
|
|
value: HTMLAttributes<'input'>['value']
|
|
label: string
|
|
}[]
|
|
selectedValue?: string | null
|
|
}
|
|
|
|
const { name, options, selectedValue, class: className, ...rest } = Astro.props
|
|
---
|
|
|
|
<div
|
|
class={cn(
|
|
'bg-night-500 divide-night-700 flex divide-x-2 overflow-hidden rounded-md text-[0.6875rem]',
|
|
className
|
|
)}
|
|
{...rest}
|
|
>
|
|
{
|
|
options.map((option) => (
|
|
<label>
|
|
<input
|
|
type="radio"
|
|
name={name}
|
|
value={option.value}
|
|
checked={selectedValue === option.value}
|
|
class="peer hidden"
|
|
/>
|
|
<span class="peer-checked:bg-night-400 inline-block cursor-pointer px-1.5 py-0.5 text-white peer-checked:text-green-500">
|
|
{option.label}
|
|
</span>
|
|
</label>
|
|
))
|
|
}
|
|
</div>
|