From 7413338aba3eb7c0d1c66f6c8539b3ee5577de78 Mon Sep 17 00:00:00 2001 From: GivFNZ Date: Sat, 22 Feb 2025 12:00:38 -0300 Subject: [PATCH] feat: create drawer for responsive --- src/components/Drawer/styles.ts | 42 +++++++++++++++++++++++++ src/components/Header/index.tsx | 56 ++++++++++++++++++++------------- src/components/Header/styles.ts | 3 ++ 3 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 src/components/Drawer/styles.ts diff --git a/src/components/Drawer/styles.ts b/src/components/Drawer/styles.ts new file mode 100644 index 0000000..e648135 --- /dev/null +++ b/src/components/Drawer/styles.ts @@ -0,0 +1,42 @@ +import styled, { keyframes } from "styled-components"; + +export const Drawer = styled.button` +all: unset; +color: white; +cursor: pointer; +transition: color 0.3s; +display: none; + +&:hover { + color: ${props => props.theme.cream} +} +&::after { + content: "☰"; +} +@media(max-width: 640px){ + display: block; +} +` + +export const DrawerContainer = styled.div` + display: block; + position: fixed; + top: 0; + left: 0; + height: 100vh; + border-radius: 8px; + width: 200px; + background-color: ${(props) => props.theme["gray-800"]}; + animation-name: drawerAnimation; +` + +export const DrawerItem = styled.a` +text-decoration: none; +padding: 1rem; +display: block; +color: white; +cursor: pointer; +&:hover { + color: ${props => props.theme.cream} +} +` \ No newline at end of file diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index 68e4bf7..7b3b323 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -3,33 +3,47 @@ import { HeaderContainer, NavLink, HomeLink, LanguageSelector } from "./styles"; import { AvatarHeader } from "../Avatar/avatar"; import i18n from "../../utils/i18n"; import { t } from "i18next"; +import { Drawer, DrawerContainer, DrawerItem } from "../Drawer/styles"; +import { useState } from "react"; export default function Header() { const changeLanguage = (event: React.ChangeEvent) => { i18n.changeLanguage(event.target.value); localStorage.setItem("language", event.target.value); }; + const [openDrawer, setOpenDrawer] = useState(false); return ( - - - - - Giv's Website - - - - + <> + + + + + Giv's Website + + + + {openDrawer && + setOpenDrawer(false)}> + Giv's Website + {t("about")} + {t("contact")} + {t("projects")} + + } + + ) } \ No newline at end of file diff --git a/src/components/Header/styles.ts b/src/components/Header/styles.ts index b721121..e670d7d 100644 --- a/src/components/Header/styles.ts +++ b/src/components/Header/styles.ts @@ -23,6 +23,9 @@ export const NavLink = styled.a` &:hover { color: ${props => props.theme["cream"]}; } + @media(max-width: 640px){ + display: none; + } `; export const HeaderContainer = styled.div`