/
githubmirror
/
Open-Assistant
Обзор
Документация
Войти
/
githubmirror
/
Open-Assistant
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
website/src/components/Buttons/LikertButtons.tsx
33 строки
885 B
CactiStaccingCrane
Add more contrast to the radio button border (#1762)
21 фев 2023, 11:25
Не верифицирован
21 фев 2023, 11:25
4fcc99a
Код
Авторство
О чём код?
import { Radio, RadioGroup } from "@chakra-ui/react"; import { PropsWithChildren } from "react"; export const LikertButtons = ({ isDisabled, count, onChange, "data-cy": dataCy, }: PropsWithChildren<{ isDisabled: boolean; count: number; onChange: (value: number) => void; "data-cy"?: string; }>) => { const valueMap = Object.fromEntries(Array.from({ length: count }, (_, idx) => [`${idx}`, idx / (count - 1)])); return ( <RadioGroup data-cy={dataCy} isDisabled={isDisabled} onChange={(value) => { onChange(valueMap[value]); }} style={{ display: "flex", justifyContent: "space-between" }} > {Object.keys(valueMap).map((value) => { return ( <Radio key={value} value={value} borderColor="gray.400" data-cy="radio-option" size="md" padding="0.6em" /> ); })} </RadioGroup> ); };