Spaces:
Configuration error
Configuration error
File size: 3,648 Bytes
7bbd534 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
'use client';
import React, { PropsWithChildren } from 'react';
// chakra imports
import {
Box,
Flex,
Drawer,
DrawerBody,
Icon,
useColorModeValue,
DrawerOverlay,
useDisclosure,
DrawerContent,
DrawerCloseButton,
} from '@chakra-ui/react';
import Content from '@/components/sidebar/components/Content';
import {
renderThumb,
renderTrack,
renderView,
} from '@/components/scrollbar/Scrollbar';
import { Scrollbars } from 'react-custom-scrollbars-2';
import { IoMenuOutline } from 'react-icons/io5';
import { IRoute } from '@/types/navigation';
import { isWindowAvailable } from '@/utils/navigation';
export interface SidebarProps extends PropsWithChildren {
routes: IRoute[];
[x: string]: any;
}
function Sidebar(props: SidebarProps) {
const { routes, setApiKey } = props;
// this is for the rest of the collapses
let variantChange = '0.2s linear';
let shadow = useColorModeValue(
'14px 17px 40px 4px rgba(112, 144, 176, 0.08)',
'unset',
);
// Chakra Color Mode
let sidebarBg = useColorModeValue('white', 'navy.800');
let sidebarRadius = '14px';
let sidebarMargins = '0px';
// SIDEBAR
return (
<Box display={{ base: 'none', xl: 'block' }} position="fixed" minH="100%">
<Box
bg={sidebarBg}
transition={variantChange}
w="285px"
ms={{
sm: '16px',
}}
my={{
sm: '16px',
}}
h="calc(100vh - 32px)"
m={sidebarMargins}
borderRadius={sidebarRadius}
minH="100%"
overflowX="hidden"
boxShadow={shadow}
>
<Scrollbars
autoHide
renderTrackVertical={renderTrack}
renderThumbVertical={renderThumb}
renderView={renderView}
>
<Content setApiKey={setApiKey} routes={routes} />
</Scrollbars>
</Box>
</Box>
);
}
// FUNCTIONS
export function SidebarResponsive(props: { routes: IRoute[] }) {
let sidebarBackgroundColor = useColorModeValue('white', 'navy.800');
let menuColor = useColorModeValue('gray.400', 'white');
// // SIDEBAR
const { isOpen, onOpen, onClose } = useDisclosure();
const { routes } = props;
return (
<Flex display={{ sm: 'flex', xl: 'none' }} alignItems="center">
<Flex w="max-content" h="max-content" onClick={onOpen}>
<Icon
as={IoMenuOutline}
color={menuColor}
my="auto"
w="20px"
h="20px"
me="10px"
_hover={{ cursor: 'pointer' }}
/>
</Flex>
<Drawer
isOpen={isOpen}
onClose={onClose}
placement={
isWindowAvailable() && document.documentElement.dir === 'rtl'
? 'right'
: 'left'
}
>
<DrawerOverlay />
<DrawerContent
w="285px"
maxW="285px"
ms={{
sm: '16px',
}}
my={{
sm: '16px',
}}
borderRadius="16px"
bg={sidebarBackgroundColor}
>
<DrawerCloseButton
zIndex="3"
onClick={onClose}
_focus={{ boxShadow: 'none' }}
_hover={{ boxShadow: 'none' }}
/>
<DrawerBody maxW="285px" px="0rem" pb="0">
<Scrollbars
autoHide
renderTrackVertical={renderTrack}
renderThumbVertical={renderThumb}
renderView={renderView}
>
<Content routes={routes} />
</Scrollbars>
</DrawerBody>
</DrawerContent>
</Drawer>
</Flex>
);
}
// PROPS
export default Sidebar;
|