Skip to content

Instantly share code, notes, and snippets.

@alanfoandrade
Last active August 22, 2021 17:55
Show Gist options
  • Save alanfoandrade/eca5febd718a195f21ebdbbd46813a6e to your computer and use it in GitHub Desktop.
Save alanfoandrade/eca5febd718a195f21ebdbbd46813a6e to your computer and use it in GitHub Desktop.
SideBar Chakra component
import {
Box,
Drawer,
DrawerBody,
DrawerCloseButton,
DrawerContent,
DrawerHeader,
DrawerOverlay,
useBreakpointValue,
} from '@chakra-ui/react';
import { useSidebarDrawer } from '../../hooks/sidebarDrawer';
import { SidebarNav } from './SidebarNav';
export const Sidebar = (): JSX.Element => {
const { isOpen, onClose } = useSidebarDrawer();
const isDrawerSidebar = useBreakpointValue({
base: true,
lg: false,
});
if (isDrawerSidebar) {
return (
<Drawer isOpen={isOpen} placement="left" onClose={onClose}>
<DrawerOverlay>
<DrawerContent>
<DrawerCloseButton mt="6" />
<DrawerHeader>Navegação</DrawerHeader>
<DrawerBody>
<SidebarNav />
</DrawerBody>
</DrawerContent>
</DrawerOverlay>
</Drawer>
);
}
return (
<Box as="aside" p="8" bg="white">
<SidebarNav />
</Box>
);
};
import { Box, Stack, Text } from '@chakra-ui/react';
import { ReactNode } from 'react';
interface INavSectionProps {
title: string;
children: ReactNode;
}
export const NavSection: React.FC<INavSectionProps> = ({ title, children }) => (
<Box>
<Text fontWeight="bold" color="gray.500" fontSize="sm">
{title}
</Text>
<Stack spacing="4" mt="8" align="stretch">
{children}
</Stack>
</Box>
);
import { Stack } from '@chakra-ui/react';
import {
RiBuilding2Line,
RiBuilding4Line,
RiClipboardLine,
RiContactsLine,
RiDashboardLine,
RiFilmLine,
RiHomeWifiLine,
RiSuitcaseLine,
RiTeamLine,
} from 'react-icons/ri';
import { NavLink } from './NavLink';
import { NavSection } from './NavSection';
export const SidebarNav = (): JSX.Element => (
<Stack spacing="12" align="flex-start" minWidth="170px">
<NavSection title="GERAL">
<NavLink icon={RiDashboardLine} to="/dashboard">
Dashboard
</NavLink>
</NavSection>
<NavSection title="PROPRIEDADES">
<NavLink icon={RiBuilding2Line} to="/ventures">
Empreendimentos
</NavLink>
<NavLink icon={RiHomeWifiLine} to="/leads">
Leads
</NavLink>
<NavLink icon={RiClipboardLine} to="/appointments">
Atendimentos
</NavLink>
<NavLink icon={RiBuilding4Line} to="/properties">
Imóveis
</NavLink>
</NavSection>
<NavSection title="ADMINISTRATIVO">
<NavLink icon={RiSuitcaseLine} to="/property-owners">
Proprietários
</NavLink>
<NavLink icon={RiContactsLine} to="/brokers">
Corretores
</NavLink>
<NavLink icon={RiTeamLine} to="/teams">
Times
</NavLink>
<NavLink icon={RiFilmLine} to="/medias">
Tipos de mídia
</NavLink>
</NavSection>
</Stack>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment