From 79c883db7ea4208ceec59002f4d00a58613ca08c Mon Sep 17 00:00:00 2001 From: JKaypa Date: Thu, 22 Aug 2024 16:24:31 -0500 Subject: [PATCH] OV-13: * update code review --- .../components/icon/components/icons.tsx | 28 ------------------- .../common/components/icon/icon-map.ts | 7 ++--- .../common/components/icon/size.enum.ts | 2 +- .../libs/components/collapse-button-link.tsx | 3 +- .../libs/components/collapse-button.tsx | 12 ++++---- .../common/components/side-bar/side-bar.tsx | 28 +++++++++++-------- frontend/src/bundles/common/hooks/hooks.ts | 2 +- .../theme/styles/components.styles.ts | 6 ++++ 8 files changed, 34 insertions(+), 54 deletions(-) delete mode 100644 frontend/src/bundles/common/components/icon/components/icons.tsx diff --git a/frontend/src/bundles/common/components/icon/components/icons.tsx b/frontend/src/bundles/common/components/icon/components/icons.tsx deleted file mode 100644 index 107e67174..000000000 --- a/frontend/src/bundles/common/components/icon/components/icons.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import { type IconProps } from '@chakra-ui/react'; -import { type ReactElement } from 'react'; - -import { Icon } from '../../components.js'; - -const HomeIcon = (properties: IconProps): ReactElement => { - return ( - - - - ); -}; - -const LogOutIcon = (properties: IconProps): ReactElement => { - return ( - - - - ); -}; - -export { HomeIcon, LogOutIcon }; diff --git a/frontend/src/bundles/common/components/icon/icon-map.ts b/frontend/src/bundles/common/components/icon/icon-map.ts index ad4fb1768..f1bf962e4 100644 --- a/frontend/src/bundles/common/components/icon/icon-map.ts +++ b/frontend/src/bundles/common/components/icon/icon-map.ts @@ -1,10 +1,9 @@ import { ArrowLeftIcon, ArrowRightIcon } from '@chakra-ui/icons'; - -import { HomeIcon, LogOutIcon } from './components/icons.js'; +import { faHouse, faRightFromBracket } from '@fortawesome/free-solid-svg-icons'; const IconMap = { - HOME: HomeIcon, - LOG_OUT: LogOutIcon, + HOME: faHouse, + LOG_OUT: faRightFromBracket, ARROW_LEFT: ArrowLeftIcon, ARROW_RIGHT: ArrowRightIcon, } as const; diff --git a/frontend/src/bundles/common/components/icon/size.enum.ts b/frontend/src/bundles/common/components/icon/size.enum.ts index 4c3debdd1..cbf8ec4b0 100644 --- a/frontend/src/bundles/common/components/icon/size.enum.ts +++ b/frontend/src/bundles/common/components/icon/size.enum.ts @@ -1,5 +1,5 @@ const Size = { LG: 5, -}; +} as const; export { Size }; diff --git a/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button-link.tsx b/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button-link.tsx index a891c2e66..e06593c69 100644 --- a/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button-link.tsx +++ b/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button-link.tsx @@ -1,7 +1,6 @@ -import { useLocation } from 'react-router-dom'; - 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 { diff --git a/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button.tsx b/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button.tsx index 9663162ac..53c592f9c 100644 --- a/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button.tsx +++ b/frontend/src/bundles/common/components/side-bar/libs/components/collapse-button.tsx @@ -3,21 +3,21 @@ import { type ReactElement } from 'react'; import { Box } from '~/bundles/common/components/components.js'; type Properties = { - bg?: string; - color?: string; - handleClick?: () => void; icon: ReactElement; isCollapsed: boolean; label: string; + bg?: string; + color?: string; + handleClick?: () => void; }; const CollapseButton = ({ - bg = 'none', - color = 'white', - handleClick = (): void => {}, icon, isCollapsed, label, + bg = 'none', + color = 'white', + handleClick = (): void => {}, }: Properties): JSX.Element => { return ( { const { pathname } = useLocation(); const navigate = useNavigate(); - const toggle = useCallback( + const handleToggle = useCallback( (): void => setIsCollapsed(!isCollapsed), [isCollapsed], ); @@ -32,7 +37,7 @@ const SideBar = (): JSX.Element => { return pathname === page ? 'white' : 'background.600'; }; - const logOut = useCallback(() => { + const handleLogOut = useCallback(() => { //ToDo: log out user with token navigate(AppRoute.SIGN_IN); }, [navigate]); @@ -49,7 +54,6 @@ const SideBar = (): JSX.Element => { pb="20px" > { ) } - mb="10px" - onClick={toggle} - _active={{ bg: 'none' }} - _hover={{ bg: 'none' }} + onClick={handleToggle} justifyContent={isCollapsed ? 'center' : 'flex-end'} + variant="icon" /> @@ -86,14 +89,15 @@ const SideBar = (): JSX.Element => { color="brand.secondary.600" icon={ } isCollapsed={isCollapsed} label={'log out'} - handleClick={logOut} + handleClick={handleLogOut} /> ); diff --git a/frontend/src/bundles/common/hooks/hooks.ts b/frontend/src/bundles/common/hooks/hooks.ts index 2c429faa8..63a176ece 100644 --- a/frontend/src/bundles/common/hooks/hooks.ts +++ b/frontend/src/bundles/common/hooks/hooks.ts @@ -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'; diff --git a/frontend/src/framework/theme/styles/components.styles.ts b/frontend/src/framework/theme/styles/components.styles.ts index 070571443..5d74b2f26 100644 --- a/frontend/src/framework/theme/styles/components.styles.ts +++ b/frontend/src/framework/theme/styles/components.styles.ts @@ -85,6 +85,12 @@ const components = { color: colors.brand.secondary[300], }, }, + icon: { + color: colors.white, + bg: 'none', + _active: { bg: 'none' }, + _hover: { bg: 'none' }, + }, }, }, Link: {