astro-reactive-form/packages/form/components/controls/RadioGroup.astro
Ayo Ayco 3d361fcb5b
refactor: form package cleanup (#135)
* refactor: form package cleanup

* refactor: organize components folder
2022-10-23 23:04:40 +02:00

31 lines
511 B
Text

---
/**
* RADIO GROUP COMPONENT
*/
import type { Radio } from 'common/types';
export interface Props {
control: Radio;
}
const { control } = Astro.props;
const options = control.value.map((option) => {
if (typeof option === 'string') {
return {
label: option,
value: option,
};
}
return option;
});
---
{
options.map((option) => (
<div class="radio-option">
<input type="radio" name={control.name} value={option.value} checked={option.checked} />{' '}
{option.label}
</div>
))
}