Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OV-13: Add-side-bar-component #49

Merged
merged 45 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
710594c
OV-13: + create svg icons logic
JKaypa Aug 22, 2024
bd262ca
OV-13: + create side bar component
JKaypa Aug 22, 2024
7057630
OV-13: + export components
JKaypa Aug 22, 2024
ca68a7c
OV-13: + export icon component
JKaypa Aug 22, 2024
423aed2
OV-50: * update user card and extract user circle component
JKaypa Aug 22, 2024
738bec9
OV-50: * update side bar component
JKaypa Aug 22, 2024
79c883d
OV-13: * update code review
JKaypa Aug 22, 2024
037263e
Merge branch 'task/OV-13-add-side-bar-component' into task/OV-50-inte…
JKaypa Aug 22, 2024
55f0c22
OV-62: + create avatar layout component
JKaypa Aug 26, 2024
c6c19ec
OV-62: * update dots component
JKaypa Aug 26, 2024
c7b1a3c
OV-13: - remove icons from components to common directory
JKaypa Aug 26, 2024
b7b4588
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa Aug 27, 2024
1f61db8
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa Aug 27, 2024
705769b
OV-13: * update folder structure and code as reviewed
JKaypa Aug 27, 2024
b71f4ec
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa Aug 27, 2024
0b3eeda
OV-62: * update code base regarding reviews
JKaypa Aug 27, 2024
117974d
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa Aug 27, 2024
dac6f0f
OV-13: * change side-bar to sidebar names
JKaypa Aug 28, 2024
31beb61
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa Aug 28, 2024
cfea637
OV-62: - remove create avatar from components
JKaypa Aug 28, 2024
3887708
OV-62: + add new text variant
JKaypa Aug 28, 2024
fb2c99b
OV-62: + add my-avatar route
JKaypa Aug 28, 2024
18744f9
OV-62: + create my avatar page
JKaypa Aug 28, 2024
ae474ec
OV-62: + add my avatar page to route system
JKaypa Aug 28, 2024
3337f4e
OV-62: * change name to my avatar
JKaypa Aug 28, 2024
7bdd20b
OV-13: * change sidebar item
JKaypa Aug 28, 2024
5b3fd86
OV-13: - remove size.enum.ts
JKaypa Aug 28, 2024
8465d15
OV-13: * merge next
JKaypa Aug 28, 2024
d69d13f
Merge branch 'task/OV-13-add-side-bar-component' into task/OV-62-crea…
JKaypa Aug 28, 2024
6e81e1b
OV-62: * update sidebar
JKaypa Aug 28, 2024
4c2fded
OV-62: + integrate sidebar to my avatar page
JKaypa Aug 28, 2024
ddf0544
OV-13: * update sidebar
JKaypa Aug 28, 2024
646420f
OV-62: + add my avatar item
JKaypa Aug 28, 2024
2afb10e
OV-62: * adjustemts
JKaypa Aug 29, 2024
f07ed07
OV-13: * remove heigh
JKaypa Aug 29, 2024
774dc40
OV-13: * minor fixes
JKaypa Aug 29, 2024
73a83ae
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa Aug 29, 2024
8d2d5ed
OV-62: * merge
JKaypa Aug 29, 2024
14e3bfa
OV-13: + add icon converter and update sidebar icons
JKaypa Aug 30, 2024
cf4ee6b
OV-13: * merging
JKaypa Aug 30, 2024
38b9ce4
OV-13: * update height
JKaypa Aug 30, 2024
d481914
OV-62: * merge
JKaypa Aug 30, 2024
abfb4c0
OV-13: * merge next
JKaypa Sep 2, 2024
dfc31a0
OV-13: * modified component name
JKaypa Sep 2, 2024
cd13620
Merge branch 'task/OV-62-create-avatar-page' into task/OV-13-add-side…
JKaypa Sep 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions frontend/src/bundles/common/components/components.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export { Button } from './button/button.js';
export { Header } from './header/header.js';
export { IconMap } from './icon/icon.js';
export { Input } from './input/input.js';
export { Link } from './link/link.js';
export { Loader } from './loader/loader.js';
export { Overlay } from './overlay/overlay.js';
export { RouterProvider } from './router-provider/router-provider.js';
export { SideBar } from './side-bar/side-bar.js';
export { VideoModal } from './video-modal/video-modal.js';
export { DownloadIcon } from '@chakra-ui/icons';
export { ViewIcon, ViewOffIcon } from '@chakra-ui/icons';
Expand All @@ -17,10 +19,12 @@ export {
FormControl,
FormErrorMessage,
Heading,
Icon,
IconButton,
InputGroup,
InputRightElement,
SimpleGrid,
Spacer,
Text,
VStack,
} from '@chakra-ui/react';
Expand Down
11 changes: 11 additions & 0 deletions frontend/src/bundles/common/components/icon/icon-map.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ArrowLeftIcon, ArrowRightIcon } from '@chakra-ui/icons';
import { faHouse, faRightFromBracket } from '@fortawesome/free-solid-svg-icons';

const IconMap = {
HOME: faHouse,
LOG_OUT: faRightFromBracket,
ARROW_LEFT: ArrowLeftIcon,
ARROW_RIGHT: ArrowRightIcon,
} as const;

export { IconMap };
2 changes: 2 additions & 0 deletions frontend/src/bundles/common/components/icon/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { IconMap } from './icon-map.js';
export { Size } from './size.enum.js';
5 changes: 5 additions & 0 deletions frontend/src/bundles/common/components/icon/size.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Size = {
LG: 5,
} as const;

export { Size };
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Link } from '~/bundles/common/components/components.js';
import { type AppRoute } from '~/bundles/common/enums/enums.js';
import { useLocation } from '~/bundles/common/hooks/hooks.js';
import { type ValueOf } from '~/bundles/common/types/types.js';

import {
type CollapseButtonProperties,
CollapseButton,
} from './collapse-button.js';

type Properties = Omit<CollapseButtonProperties, 'bg' | 'handleClick'> & {
to: ValueOf<typeof AppRoute>;
};

const CollapseButtonLink = ({
icon,
isCollapsed,
label,
to,
}: Properties): JSX.Element => {
const { pathname } = useLocation();

const activeButtonPage = (page: ValueOf<typeof AppRoute>): string => {
return pathname === page ? 'background.600' : '';
};

return (
<Link to={to}>
<CollapseButton
bg={activeButtonPage(to)}
icon={icon}
isCollapsed={isCollapsed}
label={label}
/>
</Link>
);
};

export { CollapseButtonLink };
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { type ReactElement } from 'react';

import { Box } from '~/bundles/common/components/components.js';

type Properties = {
icon: ReactElement;
isCollapsed: boolean;
label: string;
bg?: string;
color?: string;
handleClick?: () => void;
};

const CollapseButton = ({
icon,
isCollapsed,
label,
bg = 'none',
color = 'white',
handleClick = (): void => {},
}: Properties): JSX.Element => {
return (
<Box
as="button"
w="100%"
h="50px"
color={color}
display="flex"
justifyContent={isCollapsed ? 'center' : 'flex-start'}
alignItems="center"
gap="10px"
fontSize="1rem"
fontWeight="bold"
bg={bg}
borderRadius="10px"
p="10px"
onClick={handleClick}
>
{icon}
{isCollapsed ? '' : label}
</Box>
);
};

export { type Properties as CollapseButtonProperties, CollapseButton };
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { CollapseButton } from './collapse-button.js';
export { CollapseButtonLink } from './collapse-button-link.js';
111 changes: 111 additions & 0 deletions frontend/src/bundles/common/components/side-bar/side-bar.tsx
JKaypa marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

import {
Box,
Flex,
Icon,
IconButton,
IconMap,
Spacer,
} from '~/bundles/common/components/components.js';
import { AppRoute } from '~/bundles/common/enums/enums.js';
import {
useCallback,
useLocation,
useNavigate,
useState,
} from '~/bundles/common/hooks/hooks.js';
import { type ValueOf } from '~/bundles/common/types/types.js';
import { UserCard, UserCircle } from '~/bundles/users/components/components.js';

import { Size } from '../icon/icon.js';
import {
CollapseButton,
CollapseButtonLink,
} from './libs/components/components.js';

const SideBar = (): JSX.Element => {
const [isCollapsed, setIsCollapsed] = useState(false);
const { pathname } = useLocation();
const navigate = useNavigate();

const handleToggle = useCallback(
(): void => setIsCollapsed(!isCollapsed),
[isCollapsed],
);

const activeIconPage = (page: ValueOf<typeof AppRoute>): string => {
return pathname === page ? 'white' : 'background.600';
};

const handleLogOut = useCallback(() => {
//ToDo: log out user with token
navigate(AppRoute.SIGN_IN);
}, [navigate]);

return (
<Flex
w={isCollapsed ? '60px' : '260px'}
bg="background.900"
height="100vh"
position="fixed"
flexDirection="column"
justifyContent="space-between"
p="10px"
pb="20px"
>
<IconButton
aria-label={isCollapsed ? 'expand' : 'collapse'}
icon={
isCollapsed ? (
<Icon as={IconMap.ARROW_RIGHT} />
) : (
<Icon as={IconMap.ARROW_LEFT} />
)
}
JKaypa marked this conversation as resolved.
Show resolved Hide resolved
onClick={handleToggle}
justifyContent={isCollapsed ? 'center' : 'flex-end'}
variant="icon"
/>
o-nedashkivska marked this conversation as resolved.
Show resolved Hide resolved
<Box mb="30px">
{/* ToDo: Add this username value dynamically */}
{isCollapsed ? <UserCircle username="FN" /> : <UserCard />}
</Box>

<Box>
<CollapseButtonLink
icon={
<Icon
as={FontAwesomeIcon}
icon={IconMap.HOME}
boxSize={Size.LG}
color={activeIconPage('/')}
/>
}
label="Home"
to="/"
JKaypa marked this conversation as resolved.
Show resolved Hide resolved
isCollapsed={isCollapsed}
/>
</Box>

<Spacer />

<CollapseButton
color="brand.secondary.600"
icon={
<Icon
as={FontAwesomeIcon}
icon={IconMap.LOG_OUT}
boxSize={Size.LG}
color="brand.secondary.600"
/>
}
isCollapsed={isCollapsed}
label={'log out'}
handleClick={handleLogOut}
/>
</Flex>
);
};

export { SideBar };
2 changes: 1 addition & 1 deletion frontend/src/bundles/common/hooks/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export { useAppForm } from './use-app-form/use-app-form.hook.js';
export { useAppSelector } from './use-app-selector/use-app-selector.hook.js';
export { useField as useFormField } from 'formik';
export { useCallback, useEffect, useMemo, useState } from 'react';
export { useLocation } from 'react-router-dom';
export { useLocation, useNavigate } from 'react-router-dom';
1 change: 1 addition & 0 deletions frontend/src/bundles/users/components/components.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { UserCircle } from './user-card/components/user-circle.js';
export { UserCard } from './user-card/user-card.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Circle } from '~/bundles/common/components/components.js';

type Properties = {
username: string;
};

const UserCircle: React.FC<Properties> = ({ username }) => {
return (
<Circle
size="40px"
border="2px solid"
borderColor="brand.secondary.900"
color="brand.secondary.900"
>
{username}
</Circle>
);
};

export { UserCircle };
11 changes: 3 additions & 8 deletions frontend/src/bundles/users/components/user-card/user-card.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {
Button,
Circle,
Flex,
Text,
VStack,
} from '~/bundles/common/components/components.js';

import { UserCircle } from '../components.js';

const UserCard: React.FC = () => (
<VStack rounded="lg" bg="background.600" spacing="10px" p="15px 5px 10px">
<Flex
Expand All @@ -16,13 +17,7 @@ const UserCard: React.FC = () => (
pl="10px"
>
{/* TODO: replace Circle and Text content with dynamic values */}
<Circle
size="40px"
border="2px solid"
borderColor="brand.secondary.900"
>
FN
</Circle>
<UserCircle username="FN" />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it is an avatar)

<Text>Firstname Lastname</Text>
</Flex>
<Button label="Create video" />
Expand Down
6 changes: 6 additions & 0 deletions frontend/src/framework/theme/styles/components.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ const components = {
color: colors.brand.secondary[300],
},
},
icon: {
color: colors.white,
bg: 'none',
_active: { bg: 'none' },
_hover: { bg: 'none' },
},
},
},
Link: {
Expand Down
Loading