From a6ef5aa9d7c1c11e8a08c913197168f36bd45d92 Mon Sep 17 00:00:00 2001 From: shahanneda Date: Sat, 3 Sep 2022 14:00:00 -0700 Subject: [PATCH] Added menu animation --- components/Header.module.css | 68 ++++++++++++++++++++++++++++++++++-- components/Header.tsx | 50 ++++++++++++++++---------- pages/samplePage.tsx | 1 - public/images/menuIcon.svg | 5 +++ 4 files changed, 102 insertions(+), 22 deletions(-) create mode 100644 public/images/menuIcon.svg diff --git a/components/Header.module.css b/components/Header.module.css index 2e78209..feeb6a4 100644 --- a/components/Header.module.css +++ b/components/Header.module.css @@ -1,11 +1,12 @@ -.wrapper { +.headerWrapper { display: flex; justify-content: space-between; align-items: center; padding: calc(10rem / 16) calc(100rem / 16) 0 calc(100rem / 16); } -.sideBar { + +.sideBarCommon { position: fixed; right: 0; top: 0; @@ -19,6 +20,44 @@ padding-right: calc(20rem / 16); } +.sideBarShown { + composes: sideBarCommon; + transition: transform 0.8s; + transform: translateX(0%); +} + +.sideBarHidden { + composes: sideBarCommon; + transition: transform 0.8s; + transform: translateX(100%); +} + +.backgroundTintCommon { + background-color: var(--label); + animation: fadeIn 1s; + position: fixed; + z-index: 99; + left: 0; + top: 0; + width: 100vw; + height: 100vh; +} + +.backgroundTintShow { + composes: backgroundTintCommon; + transition: opacity 0.8s; + opacity: 0.2; + visibility: visible; +} + +.backgroundTintHidden { + composes: backgroundTintCommon; + transition: opacity 0.8s, visibility 0.8s; + opacity: 0; + visibility: hidden; +} + + .menuHeader { margin-bottom: 0px; padding-left: calc(40rem / 16); @@ -27,6 +66,31 @@ color: var(--dark--secondary-heading); } + +.menuIcon { + background: none; + border: none; +} + +.menuIcon:hover { + opacity: 0.8; + cursor: pointer; +} + +@media screen and (max-width: 768px) { + .sideBarCommon { + width: 90vw; + } + + .menuHeader { + padding-left: calc(10rem / 16); + } + + .headerWrapper { + padding: calc(10rem / 16) calc(20rem / 16) 0 calc(20rem / 16); + } +} + .closeMenuButton { background: var(--primary-heading); padding: 0px calc(20rem / 16); diff --git a/components/Header.tsx b/components/Header.tsx index 1823345..1f6d096 100644 --- a/components/Header.tsx +++ b/components/Header.tsx @@ -1,35 +1,47 @@ import { sectionsData } from "data/routes"; import Link from "next/link"; -import React from "react"; +import React, { useState } from "react"; import styles from "./Header.module.css"; import Sections from "./Sections"; import Image from 'next/image'; export function Header() { + const [isShowingMenu, setIsShowingMenu] = useState(false); + return ( <> -
+

CS 2022

- +
-
-

Sections

-
- + + <> + + +
+

Sections

+
+ +
+
- -
+
{ + setIsShowingMenu(false); + }} /> + + ); } diff --git a/pages/samplePage.tsx b/pages/samplePage.tsx index 1d705e9..21db9c4 100644 --- a/pages/samplePage.tsx +++ b/pages/samplePage.tsx @@ -22,7 +22,6 @@ export default function SamplePage() { heading="What program are you in?" bodyText="There are a total of 106 respondents of the CS Class Profile. Interestingly, there are a huge number of students that are just in CS, partially due to the overwhelming number of people in CS as seen in the total demographics." > -
+ + + +