Skip to content

Commit

Permalink
OV-38: + reusable icon component
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanchousina committed Aug 22, 2024
1 parent 39a50f8 commit 21943da
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 23 deletions.
58 changes: 58 additions & 0 deletions frontend/src/bundles/home/components/video-card/icon-component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { Flex, Icon } from '@chakra-ui/react';
import { type IconDefinition } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

type Properties = {
icon: IconDefinition;
buttonSize: string;
iconSize: string;
horizontalPosition: 'left' | 'right';
horizontalPositionValue: string;
top: string;
transform?: string;
backgroundColor?: string;
borderRadius?: string;
};

const IconComponent: React.FC<Properties> = ({
icon,
buttonSize,
iconSize,
horizontalPosition,
horizontalPositionValue,
top,
transform = '',
backgroundColor = 'white',
borderRadius = '0',
}) => {
const isLeft = horizontalPosition === 'left';

return (
<Flex
position="absolute"
top={top}
right={isLeft ? 'auto' : horizontalPositionValue}
left={isLeft ? horizontalPositionValue : 'auto'}
transform={transform}
backgroundColor={backgroundColor}
borderRadius={borderRadius}
w={buttonSize}
h={buttonSize}
alignItems="center"
justifyContent="center"
opacity="0"
transition="opacity 0.3s ease"
_groupHover={{ opacity: 1 }}
>
<Icon
as={FontAwesomeIcon}
icon={icon}
height={iconSize}
width={iconSize}
color="background.600"
/>
</Flex>
);
};

export { IconComponent };
44 changes: 21 additions & 23 deletions frontend/src/bundles/home/components/video-card/video-card.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Box, Flex, Icon, Image, Text } from '@chakra-ui/react';
import { faPen } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Box, Flex, Image, Text } from '@chakra-ui/react';
import { faEllipsisVertical, faPen } from '@fortawesome/free-solid-svg-icons';

import photo from '~/assets/img/photo.png';

import { IconComponent } from './icon-component.js';

const VideoCard: React.FC = () => {
return (
<>
Expand All @@ -25,29 +26,26 @@ const VideoCard: React.FC = () => {
borderRadius="5px"
/>

<Flex
position="absolute"
<IconComponent
icon={faPen}
buttonSize="48px"
iconSize="20px"
horizontalPosition="left"
horizontalPositionValue="calc(50% - 12.5px)"
top="50%"
left="50%"
transform="translate(-50%, -50%)"
backgroundColor="white"
borderRadius="full"
w="48px"
h="48px"
alignItems="center"
justifyContent="center"
opacity="0"
transition="opacity 0.3s ease"
_groupHover={{ opacity: 1 }}
>
<Icon
as={FontAwesomeIcon}
icon={faPen}
height="20px"
width="20px"
color="background.600"
/>
</Flex>
/>

<IconComponent
icon={faEllipsisVertical}
buttonSize="20px"
iconSize="10px"
horizontalPosition="right"
horizontalPositionValue="5px"
top="5px"
borderRadius="2px"
/>
</Box>

<Box padding="7px 10px 5px 5px">
Expand Down

0 comments on commit 21943da

Please sign in to comment.