-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #720 from basedosdados/feat/user
Feat/user
- Loading branch information
Showing
10 changed files
with
2,088 additions
and
343 deletions.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { | ||
Box, | ||
Stack, | ||
HStack, | ||
VStack, | ||
Drawer, | ||
DrawerOverlay, | ||
DrawerContent, | ||
useDisclosure, | ||
Avatar, | ||
Text, | ||
Accordion, | ||
AccordionItem, | ||
|
@@ -15,16 +15,20 @@ import { | |
AccordionIcon, | ||
useBoolean, | ||
Divider, | ||
Image, | ||
Menu, | ||
MenuButton, | ||
MenuList, | ||
MenuItem | ||
} from "@chakra-ui/react"; | ||
import { useEffect, useRef, useState } from "react"; | ||
import { useRouter } from "next/router" | ||
import { MenuDropdown } from "./MenuDropdown"; | ||
import cookies from "js-cookie"; | ||
import { MenuDropdown } from "./MenuDropdown"; | ||
import { useCheckMobile } from "../../hooks/useCheckMobile.hook" | ||
import ControlledInput from "../atoms/ControlledInput"; | ||
import Link from "../atoms/Link"; | ||
import RoundedButton from "../atoms/RoundedButton"; | ||
import SectionText from "../atoms/SectionText"; | ||
|
||
import BDLogoProImage from "../../public/img/logos/bd_logo_pro"; | ||
import BDLogoEduImage from "../../public/img/logos/bd_logo_edu"; | ||
|
@@ -33,6 +37,7 @@ import FarBarsIcon from "../../public/img/icons/farBarsIcon"; | |
import SearchIcon from "../../public/img/icons/searchIcon"; | ||
import CrossIcon from "../../public/img/icons/crossIcon"; | ||
import RedirectIcon from "../../public/img/icons/redirectIcon"; | ||
import SettingsIcon from "../../public/img/icons/settingsIcon"; | ||
|
||
function MenuDrawer({ isOpen, onClose, links }) { | ||
return ( | ||
|
@@ -123,6 +128,266 @@ function MenuDrawer({ isOpen, onClose, links }) { | |
); | ||
} | ||
|
||
function MenuDrawerUser({ isOpen, onClose}) { | ||
const router = useRouter() | ||
|
||
const links = [ | ||
{name: "Perfil público", value: "profile"}, | ||
{name: "Conta", value: "account"}, | ||
{name: "Senha", value: "new_password"}, | ||
{name: "Planos e pagamento", value: "plans_and_payment"}, | ||
{name: "Acessos", value: "accesses"}, | ||
] | ||
|
||
return ( | ||
<Drawer isOpen={isOpen} onClose={onClose}> | ||
<DrawerOverlay backdropFilter="blur(2px)"/> | ||
<DrawerContent padding="16px"> | ||
<BDLogoImage | ||
widthImage="65px" | ||
heightImage="30px" | ||
marginBottom="24px" | ||
onClick={() => window.open("/", "_self")} | ||
/> | ||
|
||
<Stack spacing={0} justifyContent="center" alignItems="center" padding="16px 0" marginBottom="24px"> | ||
<Box | ||
width="48px" | ||
height="48px" | ||
borderRadius="50%" | ||
overflow="hidden" | ||
marginBottom="10px" | ||
> | ||
<Image | ||
display={{ base: "flex", lg: "none" }} | ||
alt="" | ||
width="100%" | ||
height="100%" | ||
src="https://basedosdados-static.s3.us-east-2.amazonaws.com/equipe/sem_foto.png" | ||
/> | ||
</Box> | ||
<Text | ||
color="#252A32" | ||
fontFamily="Ubuntu" | ||
fontSize="14px" | ||
fontWeight="400" | ||
lineHeight="27px" | ||
letterSpacing="0.3px" | ||
>Dadinho</Text> | ||
<Text | ||
color="#6F6F6F" | ||
fontFamily="Ubuntu" | ||
fontSize="14px" | ||
fontWeight="400" | ||
lineHeight="27px" | ||
letterSpacing="0.3px" | ||
>[email protected]</Text> | ||
</Stack> | ||
|
||
<Accordion allowToggle width="100%" defaultIndex={0}> | ||
<AccordionItem borderWidth="0 !important"> | ||
<AccordionButton | ||
padding="16px 0" | ||
_hover={{background: "none"}} | ||
justifyContent="space-between" | ||
> | ||
<Stack spacing={0} flexDirection="row" gap="8px"> | ||
<SettingsIcon fill="#D0D0D0" width="16px" height="16px"/> | ||
<Text | ||
fontSize="16px" | ||
fontFamily="Ubuntu" | ||
fontWeight="400" | ||
lineHeight="16px" | ||
letterSpacing="0.2px" | ||
color="#252A32" | ||
> | ||
Configurações | ||
</Text> | ||
</Stack> | ||
<AccordionIcon /> | ||
</AccordionButton> | ||
<AccordionPanel | ||
display="flex" | ||
flexDirection="column" | ||
gridGap="10px" | ||
padding="8px 0 0 24px" | ||
> | ||
{links.map((elm, index) => { | ||
return ( | ||
<Link | ||
key={index} | ||
color="#575757" | ||
fontSize="14px" | ||
fontFamily="Ubuntu" | ||
fontWeight="400" | ||
lineHeight="27px" | ||
letterSpacing="0.3px" | ||
onClick={() => { | ||
onClose() | ||
router.push({pathname: "/user/dev", query: elm.value})} | ||
} | ||
>{elm.name}</Link> | ||
) | ||
})} | ||
</AccordionPanel> | ||
</AccordionItem> | ||
</Accordion> | ||
</DrawerContent> | ||
</Drawer> | ||
) | ||
} | ||
|
||
function MenuUser ({ userData, onOpen, onClose }) { | ||
const timerRef = useRef() | ||
const [isOpenMenu, setIsOpenMenu] = useState(false) | ||
|
||
const btnMouseEnterEvent = () => { | ||
setIsOpenMenu(true) | ||
} | ||
const btnMouseLeaveEvent = () => { | ||
timerRef.current = setTimeout(() => { | ||
setIsOpenMenu(false) | ||
}, 100) | ||
} | ||
const menuListMouseEnterEvent = () => { | ||
clearTimeout(timerRef.current) | ||
timerRef.current = undefined | ||
setIsOpenMenu(true) | ||
} | ||
const menuListMouseLeaveEvent = () => { | ||
setIsOpenMenu(false) | ||
} | ||
|
||
if(useCheckMobile()) { | ||
return ( | ||
<Box | ||
cursor="pointer" | ||
position="fixed" | ||
right="24px" | ||
height="40px" | ||
width="40px" | ||
borderRadius="50%" | ||
overflow="hidden" | ||
display={{ base: "flex", lg: "none" }} | ||
onClick={() => onOpen()} | ||
> | ||
<Image | ||
display={{ base: "flex", lg: "none" }} | ||
alt="" | ||
width="100%" | ||
height="100%" | ||
src={userData?.picture ? userData.picture : "https://basedosdados-static.s3.us-east-2.amazonaws.com/equipe/sem_foto.png"} | ||
/> | ||
</Box> | ||
) | ||
} else { | ||
return ( | ||
<Menu | ||
isOpen={isOpenMenu} | ||
autoSelect={false} | ||
placement="bottom" | ||
> | ||
<MenuButton | ||
onClick={btnMouseEnterEvent} | ||
onMouseLeave={btnMouseLeaveEvent} | ||
> | ||
<Box | ||
height="40px" | ||
width="40px" | ||
borderRadius="50%" | ||
overflow="hidden" | ||
> | ||
<Image | ||
alt="" | ||
width="100%" | ||
height="100%" | ||
src={userData?.picture ? userData.picture : "https://basedosdados-static.s3.us-east-2.amazonaws.com/equipe/sem_foto.png"} | ||
/> | ||
</Box> | ||
</MenuButton> | ||
<MenuList | ||
width="260px" | ||
borderWidth={0} | ||
padding={0} | ||
boxShadow="0 1.6px 16px 0 rgba(100, 96, 103, 0.16)" | ||
onMouseEnter={menuListMouseEnterEvent} | ||
onMouseLeave={menuListMouseLeaveEvent} | ||
> | ||
<MenuItem | ||
display="flex" | ||
flexDirection="column" | ||
cursor="default" | ||
width="100%" | ||
textAlign="center" | ||
alignItems="center" | ||
padding="16px" | ||
_hover={{ backgroundColor: "transparent"}} | ||
> | ||
<Box | ||
height="48px" | ||
width="48px" | ||
borderRadius="50%" | ||
overflow="hidden" | ||
marginBottom="10px" | ||
> | ||
<Image | ||
alt="" | ||
width="100%" | ||
height="100%" | ||
display={{ base: "none", lg: "flex" }} | ||
src={userData?.picture ? userData.picture : "https://basedosdados-static.s3.us-east-2.amazonaws.com/equipe/sem_foto.png"} | ||
/> | ||
</Box> | ||
<Text | ||
color="#252A32" | ||
fontFamily="Ubuntu" | ||
fontSize="12px" | ||
fontWeight="400" | ||
lineHeight="16px" | ||
letterSpacing="0.3px" | ||
> | ||
Dadinho | ||
</Text> | ||
<Text | ||
color="#6F6F6F" | ||
fontFamily="Ubuntu" | ||
fontSize="12px" | ||
fontWeight="400" | ||
lineHeight="16px" | ||
letterSpacing="0.3px" | ||
> | ||
[email protected] | ||
</Text> | ||
</MenuItem> | ||
|
||
<MenuItem | ||
display="flex" | ||
flexDirection="row" | ||
alignItems="start" | ||
gap="8px" | ||
padding="16px" | ||
_hover={{ backgroundColor: "transparent", opacity: "0.6" }} | ||
onClick={() => window.open("/user/dev", "_self")} | ||
> | ||
<SettingsIcon fill="#D0D0D0" width="16px" height="16px"/> | ||
<Text | ||
color="#252A32" | ||
fontFamily="Ubuntu" | ||
fontSize="12px" | ||
fontWeight="400" | ||
lineHeight="16px" | ||
letterSpacing="0.3px" | ||
> | ||
Configurações | ||
</Text> | ||
</MenuItem> | ||
</MenuList> | ||
</Menu> | ||
) | ||
} | ||
|
||
} | ||
|
||
function SearchInput ({ status }) { | ||
const router = useRouter() | ||
const { query } = router | ||
|
@@ -321,20 +586,7 @@ function DesktopLinks({ links, position = false, path }) { | |
{!statusSearch && | ||
<HStack spacing={8} display={{ base: "none", lg: "flex" }}> | ||
{userData ? ( | ||
<HStack spacing={5}> | ||
<Avatar | ||
bg="#2B8C4D" | ||
name={userData?.firstName} | ||
src={userData.picture} | ||
/> | ||
<Link | ||
fontSize="14px" | ||
textTransform="capitalize" | ||
href={`/user/${userData.username}`} | ||
> | ||
{userData.username} | ||
</Link> | ||
</HStack> | ||
<MenuUser /> | ||
) : ( | ||
<> | ||
{/* <Link fontSize="15px" fontFamily="Ubuntu" fontWeight="400" letterSpacing="0.3px" href="/user/login"> | ||
|
@@ -344,7 +596,7 @@ function DesktopLinks({ links, position = false, path }) { | |
<RoundedButton height="35px" fontSize="15px" minWidth="110px"> | ||
Cadastrar | ||
</RoundedButton> | ||
</Link> */} | ||
</Link> | ||
</> | ||
)} | ||
</HStack> | ||
|
@@ -353,10 +605,11 @@ function DesktopLinks({ links, position = false, path }) { | |
); | ||
} | ||
|
||
export default function Menu({}) { | ||
export default function MenuNav({}) { | ||
const router = useRouter() | ||
const { route } = router | ||
const menuDisclosure = useDisclosure(); | ||
const menuDisclosure = useDisclosure() | ||
const menuUserMobile = useDisclosure() | ||
const divRef = useRef() | ||
const bannerRef = useRef() | ||
const [isScrollDown, setIsScrollDown] = useState(false) | ||
|
@@ -503,18 +756,12 @@ export default function Menu({}) { | |
/> | ||
</Link> | ||
|
||
<Avatar | ||
bg="#2B8C4D" | ||
color="#FFF" | ||
position="fixed" | ||
right="24px" | ||
height="40px" | ||
width="40px" | ||
display={{ base: "flex", lg: "none" }} | ||
src={userData?.picture} | ||
name={userData?.username} | ||
/> | ||
<DesktopLinks links={links} position={isScrollDown} path={route}/> | ||
|
||
{useCheckMobile() && userData && | ||
<MenuUser userData={userData} onOpen={menuUserMobile.onOpen} onClose={menuUserMobile.onClose}/> | ||
} | ||
<MenuDrawerUser isOpen={menuUserMobile.isOpen} onClose={menuUserMobile.onClose}/> | ||
</HStack> | ||
</Box> | ||
</> | ||
|
Oops, something went wrong.