mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* migrate from native select to the custom one * migrate popover radio filter to select component * migrate stats menu to select * migrate Sort component * screenshot updates
41 lines
969 B
TypeScript
41 lines
969 B
TypeScript
import type { UseRadioProps } from '@chakra-ui/react';
|
|
import { Box, useRadio, useColorModeValue } from '@chakra-ui/react';
|
|
import React from 'react';
|
|
|
|
import IconSvg from '../IconSvg';
|
|
|
|
interface Props extends UseRadioProps {
|
|
children: React.ReactNode;
|
|
}
|
|
|
|
const SelectOption = (props: Props) => {
|
|
const { getInputProps, getRadioProps } = useRadio(props);
|
|
|
|
const input = getInputProps();
|
|
const checkbox = getRadioProps();
|
|
const bgColorHover = useColorModeValue('blue.50', 'whiteAlpha.100');
|
|
|
|
return (
|
|
<Box
|
|
as="label"
|
|
px={ 4 }
|
|
py={ 2 }
|
|
cursor="pointer"
|
|
display="flex"
|
|
columnGap={ 2 }
|
|
alignItems="center"
|
|
_hover={{
|
|
bgColor: bgColorHover,
|
|
}}
|
|
>
|
|
{ props.isChecked ? <IconSvg name="check" boxSize={ 5 }/> : <Box boxSize={ 5 }/> }
|
|
<input { ...input }/>
|
|
<Box { ...checkbox }>
|
|
{ props.children }
|
|
</Box>
|
|
</Box>
|
|
);
|
|
};
|
|
|
|
export default React.memo(SelectOption);
|