-
Notifications
You must be signed in to change notification settings - Fork 1
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
+451
−13
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
710594c
OV-13: + create svg icons logic
JKaypa bd262ca
OV-13: + create side bar component
JKaypa 7057630
OV-13: + export components
JKaypa ca68a7c
OV-13: + export icon component
JKaypa 423aed2
OV-50: * update user card and extract user circle component
JKaypa 738bec9
OV-50: * update side bar component
JKaypa 79c883d
OV-13: * update code review
JKaypa 037263e
Merge branch 'task/OV-13-add-side-bar-component' into task/OV-50-inte…
JKaypa 55f0c22
OV-62: + create avatar layout component
JKaypa c6c19ec
OV-62: * update dots component
JKaypa c7b1a3c
OV-13: - remove icons from components to common directory
JKaypa b7b4588
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa 1f61db8
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa 705769b
OV-13: * update folder structure and code as reviewed
JKaypa b71f4ec
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa 0b3eeda
OV-62: * update code base regarding reviews
JKaypa 117974d
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa dac6f0f
OV-13: * change side-bar to sidebar names
JKaypa 31beb61
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa cfea637
OV-62: - remove create avatar from components
JKaypa 3887708
OV-62: + add new text variant
JKaypa fb2c99b
OV-62: + add my-avatar route
JKaypa 18744f9
OV-62: + create my avatar page
JKaypa ae474ec
OV-62: + add my avatar page to route system
JKaypa 3337f4e
OV-62: * change name to my avatar
JKaypa 7bdd20b
OV-13: * change sidebar item
JKaypa 5b3fd86
OV-13: - remove size.enum.ts
JKaypa 8465d15
OV-13: * merge next
JKaypa d69d13f
Merge branch 'task/OV-13-add-side-bar-component' into task/OV-62-crea…
JKaypa 6e81e1b
OV-62: * update sidebar
JKaypa 4c2fded
OV-62: + integrate sidebar to my avatar page
JKaypa ddf0544
OV-13: * update sidebar
JKaypa 646420f
OV-62: + add my avatar item
JKaypa 2afb10e
OV-62: * adjustemts
JKaypa f07ed07
OV-13: * remove heigh
JKaypa 774dc40
OV-13: * minor fixes
JKaypa 73a83ae
Merge branch 'next' of https://github.com/BinaryStudioAcademy/bsa-202…
JKaypa 8d2d5ed
OV-62: * merge
JKaypa 14e3bfa
OV-13: + add icon converter and update sidebar icons
JKaypa cf4ee6b
OV-13: * merging
JKaypa 38b9ce4
OV-13: * update height
JKaypa d481914
OV-62: * merge
JKaypa abfb4c0
OV-13: * merge next
JKaypa dfc31a0
OV-13: * modified component name
JKaypa cd13620
Merge branch 'task/OV-62-create-avatar-page' into task/OV-13-add-side…
JKaypa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
frontend/src/bundles/common/components/sidebar/components/components.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { SidebarItem } from './sidebar-item/sidebar-item.js'; |
45 changes: 45 additions & 0 deletions
45
frontend/src/bundles/common/components/sidebar/components/sidebar-item/sidebar-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
onClick?: () => void; | ||
}; | ||
|
||
const SidebarItem = ({ | ||
icon, | ||
isCollapsed, | ||
label, | ||
bg = 'none', | ||
color = 'white', | ||
onClick = (): 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={onClick} | ||
> | ||
{icon} | ||
{isCollapsed ? '' : label} | ||
</Box> | ||
); | ||
}; | ||
|
||
export { SidebarItem }; |
132 changes: 132 additions & 0 deletions
132
frontend/src/bundles/common/components/sidebar/sidebar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { | ||
Box, | ||
Flex, | ||
Icon, | ||
IconButton, | ||
Link, | ||
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 { IconName } from '~/bundles/common/icons/icons.js'; | ||
import { type ValueOf } from '~/bundles/common/types/types.js'; | ||
import { UserAvatar, UserCard } from '~/bundles/users/components/components.js'; | ||
|
||
import { SidebarItem } from './components/components.js'; | ||
|
||
type Properties = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const Sidebar = ({ children }: Properties): JSX.Element => { | ||
const [isCollapsed, setIsCollapsed] = useState(false); | ||
const { pathname } = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
const handleToggle = useCallback( | ||
(): void => setIsCollapsed(!isCollapsed), | ||
[isCollapsed], | ||
); | ||
|
||
const activeButtonPage = (page: ValueOf<typeof AppRoute>): string => { | ||
return pathname === page ? 'background.600' : ''; | ||
}; | ||
|
||
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="100%"> | ||
<Flex | ||
w={isCollapsed ? '60px' : '270px'} | ||
bg="background.900" | ||
height="calc(100vh - 75px)" | ||
position="fixed" | ||
flexDirection="column" | ||
justifyContent="space-between" | ||
p="10px" | ||
pb="20px" | ||
> | ||
<IconButton | ||
aria-label={isCollapsed ? 'expand' : 'collapse'} | ||
icon={ | ||
<Icon | ||
as={ | ||
isCollapsed | ||
? IconName.ARROW_RIGHT | ||
: IconName.ARROW_LEFT | ||
} | ||
/> | ||
} | ||
onClick={handleToggle} | ||
justifyContent={isCollapsed ? 'center' : 'flex-end'} | ||
variant="icon" | ||
/> | ||
<Box mb="30px"> | ||
{/* ToDo: Add this username value dynamically */} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. create ticket for it |
||
{isCollapsed ? <UserAvatar username="FN" /> : <UserCard />} | ||
</Box> | ||
<Box> | ||
<Link to={AppRoute.ROOT}> | ||
<SidebarItem | ||
bg={activeButtonPage(AppRoute.ROOT)} | ||
icon={ | ||
<Icon | ||
as={IconName.HOME} | ||
boxSize={5} | ||
color={activeIconPage(AppRoute.ROOT)} | ||
/> | ||
} | ||
isCollapsed={isCollapsed} | ||
label="Home" | ||
/> | ||
</Link> | ||
<Link to={AppRoute.MY_AVATAR}> | ||
<SidebarItem | ||
bg={activeButtonPage(AppRoute.MY_AVATAR)} | ||
icon={ | ||
<Icon | ||
as={IconName.AVATAR} | ||
boxSize={5} | ||
color={activeIconPage(AppRoute.MY_AVATAR)} | ||
/> | ||
} | ||
isCollapsed={isCollapsed} | ||
label="My Avatar" | ||
/> | ||
</Link> | ||
</Box> | ||
<Spacer /> | ||
<SidebarItem | ||
color="brand.secondary.600" | ||
icon={ | ||
<Icon | ||
as={IconName.LOG_OUT} | ||
boxSize={5} | ||
color="brand.secondary.600" | ||
/> | ||
} | ||
isCollapsed={isCollapsed} | ||
label={'log out'} | ||
onClick={handleLogOut} | ||
/> | ||
</Flex> | ||
<Box flex="1" ml={isCollapsed ? '60px' : '270px'}> | ||
{children} | ||
</Box> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export { Sidebar }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
frontend/src/bundles/common/icons/helper/icon-conversion.helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { | ||
faCircleUser, | ||
faHouse, | ||
faRightFromBracket, | ||
} from '@fortawesome/free-solid-svg-icons'; | ||
|
||
import { iconConverter } from './icon-converter.helper.js'; | ||
|
||
const HouseIcon = iconConverter(faHouse); | ||
const RightFromBracketIcon = iconConverter(faRightFromBracket); | ||
const CircleUserIcon = iconConverter(faCircleUser); | ||
|
||
export { CircleUserIcon, HouseIcon, RightFromBracketIcon }; |
20 changes: 20 additions & 0 deletions
20
frontend/src/bundles/common/icons/helper/icon-converter.helper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { | ||
type ComponentWithAs, | ||
type IconProps, | ||
createIcon, | ||
} from '@chakra-ui/react'; | ||
import { type IconDefinition } from '@fortawesome/free-solid-svg-icons'; | ||
|
||
const iconConverter = ( | ||
faIcon: IconDefinition, | ||
): ComponentWithAs<'svg', IconProps> => { | ||
const { icon, iconName } = faIcon; | ||
|
||
return createIcon({ | ||
displayName: iconName, | ||
viewBox: `0 0 ${icon[0]} ${icon[1]}`, | ||
d: `${icon[4]}`, | ||
}); | ||
}; | ||
|
||
export { iconConverter }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
frontend/src/bundles/my-avatar/components/circles/circles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Circle } from '~/bundles/common/components/components.js'; | ||
|
||
const Circles = (): JSX.Element => { | ||
return ( | ||
<Circle | ||
size="271px" | ||
border="solid 1px" | ||
borderColor="background.50" | ||
position="absolute" | ||
left="-71%" | ||
top="-270%" | ||
> | ||
<Circle size="159px" border="solid 1px" borderColor="background.50"> | ||
<Circle | ||
size="113px" | ||
border="solid 1px" | ||
borderColor="background.50" | ||
/> | ||
</Circle> | ||
</Circle> | ||
); | ||
}; | ||
|
||
export { Circles }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { Circles } from './circles/circles.js'; | ||
export { CreateAvatar } from './create-avatar/create-avatar.js'; | ||
export { Dots } from './dots/dots.js'; |
24 changes: 24 additions & 0 deletions
24
frontend/src/bundles/my-avatar/components/create-avatar/create-avatar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { Box, Button, Flex } from '~/bundles/common/components/components.js'; | ||
|
||
import { Circles, Dots } from '../components.js'; | ||
|
||
const CreateAvatar = (): JSX.Element => { | ||
return ( | ||
<Flex | ||
bg="white" | ||
h="215px" | ||
borderRadius="lg" | ||
justify="center" | ||
align="center" | ||
overflow="hidden" | ||
> | ||
<Box w="222px" position="relative"> | ||
<Circles /> | ||
<Dots /> | ||
<Button label="Create Avatar" /> | ||
</Box> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export { CreateAvatar }; |
4 changes: 4 additions & 0 deletions
4
frontend/src/bundles/my-avatar/components/dots/constants/constants.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const SIZE = '3px'; | ||
const COLOR = 'background.600'; | ||
|
||
export { COLOR, SIZE }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create ticket for it