feat: add sideBar active(#36)
Some checks failed
it-academy/dry-wash-pl/pipeline/head This commit looks good
it-academy/dry-wash-pl/pipeline/pr-main There was a failure building this commit

This commit is contained in:
Ильназ 2024-11-23 18:34:53 +03:00
parent a63304b5e4
commit 9eb0080d13

View File

@ -1,10 +1,14 @@
import { Box, Button, Heading, VStack } from '@chakra-ui/react'; import { Box, Button, Heading, VStack, Divider } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { Divider } from '@chakra-ui/react'; import { useLocation, Link } from 'react-router-dom';
import i18next from 'i18next'; import i18next from 'i18next';
import { Link } from 'react-router-dom';
const Sidebar = () => ( const Sidebar = () => {
const location = useLocation();
const isActive = (keyword: string) => location.pathname.includes(keyword);
return (
<Box <Box
borderRight='1px solid black' borderRight='1px solid black'
bg='gray.50' bg='gray.50'
@ -23,8 +27,8 @@ const Sidebar = () => (
as={Link} as={Link}
to='orders' to='orders'
w='100%' w='100%'
colorScheme='green' colorScheme={isActive('orders') ? 'green' : 'blue'}
variant='ghost' variant={isActive('orders') ? 'solid' : 'ghost'}
> >
{i18next.t(`dry-wash.arm.master.sideBar.title.orders`)} {i18next.t(`dry-wash.arm.master.sideBar.title.orders`)}
</Button> </Button>
@ -33,14 +37,15 @@ const Sidebar = () => (
as={Link} as={Link}
to='masters' to='masters'
w='100%' w='100%'
colorScheme='green' colorScheme={isActive('masters') ? 'green' : 'blue'}
variant='ghost' variant={isActive('masters') ? 'solid' : 'ghost'}
> >
{i18next.t(`dry-wash.arm.master.sideBar.title.master`)} {i18next.t(`dry-wash.arm.master.sideBar.title.master`)}
</Button> </Button>
<Divider /> <Divider />
</VStack> </VStack>
</Box> </Box>
); );
};
export default Sidebar; export default Sidebar;