2022-08-27 15:58:36 +02:00
|
|
|
import { Box, Flex, Stack, Spacer, Text, IconProps } from '@chakra-ui/react';
|
|
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
|
|
|
import { forwardRef } from 'react';
|
|
|
|
|
import type { MenuItem } from './index';
|
2022-07-27 20:22:45 +02:00
|
|
|
|
|
|
|
|
interface Props {
|
2022-07-29 17:58:13 +02:00
|
|
|
item: MenuItem;
|
2022-07-27 20:22:45 +02:00
|
|
|
index: number;
|
2022-07-28 16:40:48 +02:00
|
|
|
scrollIndex: number;
|
2022-07-27 20:22:45 +02:00
|
|
|
}
|
|
|
|
|
|
2022-07-28 16:40:48 +02:00
|
|
|
const ListItem = forwardRef<Array<HTMLDivElement | null>, Props>(({ item, index, scrollIndex }, ref) => {
|
2022-07-27 20:22:45 +02:00
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
bg="#25262B"
|
|
|
|
|
borderRadius="md"
|
|
|
|
|
tabIndex={index}
|
2022-08-02 10:59:46 +02:00
|
|
|
scrollMargin={2}
|
2022-07-27 20:22:45 +02:00
|
|
|
p={2}
|
|
|
|
|
height="60px"
|
|
|
|
|
key={`item-${index}`}
|
2022-08-27 15:58:36 +02:00
|
|
|
_focus={{ bg: '#373A40', outline: 'none' }}
|
2022-07-27 20:22:45 +02:00
|
|
|
ref={(element) => {
|
|
|
|
|
if (ref)
|
|
|
|
|
// @ts-ignore i cba
|
|
|
|
|
return (ref.current = [...ref.current, element]);
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-07-29 17:58:13 +02:00
|
|
|
<Flex alignItems="center" height="100%">
|
|
|
|
|
{item.icon && (
|
|
|
|
|
<FontAwesomeIcon
|
|
|
|
|
icon={item.icon}
|
|
|
|
|
fontSize={24}
|
|
|
|
|
color="#909296"
|
|
|
|
|
fixedWidth
|
|
|
|
|
style={{ marginRight: 20, marginLeft: 5 }}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
2022-07-31 12:54:40 +02:00
|
|
|
{Array.isArray(item.values) ? (
|
2022-07-29 17:58:13 +02:00
|
|
|
<Flex justifyContent="center" alignItems="center" width="100%">
|
|
|
|
|
<Stack spacing={1}>
|
|
|
|
|
<Text color="#909296" textTransform="uppercase" fontSize={12} verticalAlign="middle">
|
|
|
|
|
{item.label}
|
|
|
|
|
</Text>
|
2022-07-31 12:54:40 +02:00
|
|
|
<Text>{item.values[scrollIndex]}</Text>
|
2022-07-29 17:58:13 +02:00
|
|
|
</Stack>
|
|
|
|
|
<Spacer />
|
2022-07-30 10:10:07 +02:00
|
|
|
<Stack direction="row" spacing="sm" mr={3} justifyContent="center" alignItems="center">
|
2022-07-29 17:58:13 +02:00
|
|
|
<FontAwesomeIcon icon="chevron-left" fontSize={16} color="#909296" />
|
2022-07-30 10:10:07 +02:00
|
|
|
<Text color="#909296" textTransform="uppercase" fontSize={14}>
|
2022-07-31 12:54:40 +02:00
|
|
|
{scrollIndex + 1}/{item.values.length}
|
2022-07-30 10:10:07 +02:00
|
|
|
</Text>
|
2022-07-29 17:58:13 +02:00
|
|
|
<FontAwesomeIcon icon="chevron-right" fontSize={16} color="#909296" />
|
|
|
|
|
</Stack>
|
|
|
|
|
</Flex>
|
|
|
|
|
) : (
|
2022-07-29 17:17:06 +02:00
|
|
|
<Text>{item.label}</Text>
|
2022-07-29 17:58:13 +02:00
|
|
|
)}
|
|
|
|
|
</Flex>
|
2022-07-27 20:22:45 +02:00
|
|
|
</Box>
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default ListItem;
|