Header/Side Menu (#52)
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Shahan Nedadahandeh 2022-10-22 14:04:12 -04:00
parent fc2bf48706
commit bfa3e9960c
12 changed files with 4711 additions and 3791 deletions

View File

@ -15,8 +15,14 @@ module.exports = {
"plugin:react/recommended",
"plugin:prettier/recommended",
],
plugins: ["@typescript-eslint", "react", "react-hooks", "prettier"],
plugins: ["@typescript-eslint", "react", "react-hooks", "prettier", "unused-imports"],
rules: {
"no-unused-vars": "off",
"unused-imports/no-unused-imports": "error",
"unused-imports/no-unused-vars": [
"error",
{ "vars": "all", "varsIgnorePattern": "^_", "args": "after-used", "argsIgnorePattern": "^_" }
],
"prettier/prettier": ["error", { "endOfLine": "auto" }],
"import/first": "error",
"import/order": [

View File

@ -0,0 +1,137 @@
.headerWrapper {
display: flex;
justify-content: space-between;
align-items: center;
position: sticky;
top: 0;
left: 0;
background: var(--dark--primary-background);
z-index: 98;
box-sizing: border-box;
padding: calc(10rem / 16) calc(100rem / 16) 0;
}
.titleHeader {
margin: calc(16rem / 16) 0;
}
.sideBarCommon {
position: fixed;
right: 0;
top: 0;
min-width: calc(400rem / 16);
height: 100vh;
background: var(--secondary-background);
padding: calc(100rem / 16);
margin: 0;
z-index: 100;
padding: 0;
padding-right: calc(20rem / 16);
transition: transform 0.8s;
overflow: auto;
}
.sideBarShown {
composes: sideBarCommon;
/* -1% to hide slight line tip showing in some browsers */
transform: translateX(-1%);
}
.sideBarHidden {
composes: sideBarCommon;
transform: translateX(100%);
}
.backgroundTintCommon {
background-color: var(--label);
animation: fadeIn 1s;
position: fixed;
z-index: 99;
left: 0;
top: 0;
width: 100vw;
height: 100vh;
transition: opacity 0.8s, visibility 0.8s;
}
.backgroundTintShow {
composes: backgroundTintCommon;
visibility: visible;
opacity: 0.2;
}
.backgroundTintHidden {
composes: backgroundTintCommon;
visibility: hidden;
opacity: 0;
}
.menuHeader {
margin-bottom: 0;
padding-left: calc(30rem / 16);
padding-bottom: 0;
color: var(--dark--secondary-heading);
}
.sectionsWrapper {
padding-left: calc(30rem / 16);
}
.menuIcon {
background: none;
border: none;
}
.menuIcon:hover {
opacity: 0.8;
cursor: pointer;
}
@media screen and (max-width: 768px) {
.sideBarCommon {
min-width: calc(300rem / 16);
max-width: calc(500rem / 16);
}
.menuHeader {
padding-left: calc(20rem / 16);
}
.sectionsWrapper {
padding-left: calc(20rem / 16);
}
.headerWrapper {
padding: calc(10rem / 16) calc(20rem / 16) 0;
}
}
.closeMenuButton {
background: var(--primary-heading);
padding: 0 calc(20rem / 16);
border-radius: calc(50rem / 16);
display: flex;
flex-direction: row;
margin-left: calc(20rem / 16);
/* transparent border fixes weird coloring on the border in some browsers */
border: calc(1rem / 16) solid transparent;
}
.closeMenuButton:hover {
background-color: var(--secondary-accent-light);
cursor: pointer;
}
.lineWrapper {
width: 100%;
display: flex;
}
.lineWrapper:before {
content: "";
flex: 1 1;
border-bottom: 3px solid white;
margin: auto;
}

69
components/Header.tsx Normal file
View File

@ -0,0 +1,69 @@
import { sectionsData } from "data/routes";
import Link from "next/link";
import React, { useState } from "react";
import { Sections } from "./Sections";
import styles from "./Header.module.css";
export function Header() {
const [isShowingMenu, setIsShowingMenu] = useState(false);
return (
<>
<div
className={
isShowingMenu
? styles.backgroundTintShow
: styles.backgroundTintHidden
}
onClick={(_) => {
setIsShowingMenu(false);
}}
/>
<div className={styles.headerWrapper}>
<h1 className={styles.titleHeader}>
<Link href="/">CS 2022</Link>
</h1>
<button
onClick={(_) => {
setIsShowingMenu(true);
}}
className={styles.menuIcon}
>
<img
src="/images/menuIcon.svg"
width="50"
height="50"
draggable="false"
/>
</button>
</div>
<div
className={isShowingMenu ? styles.sideBarShown : styles.sideBarHidden}
>
<h1 className={styles.menuHeader}>Sections</h1>
<div className={styles.lineWrapper}>
<button
className={styles.closeMenuButton}
onClick={(_) => {
setIsShowingMenu(false);
}}
>
<img
src="/images/rightArrow.svg"
className={styles.arrowIcon}
width="50"
height="50"
draggable="false"
/>
</button>
</div>
<div className={styles.sectionsWrapper}>
<Sections data={sectionsData} showHeader={false} />
</div>
</div>
</>
);
}

View File

@ -83,6 +83,8 @@ interface LineGraphProps {
const DEFAULT_LABEL_SIZE = 16;
const DEFAULT_LEGEND_GAP = 16;
// TODO: Address unused props in this file
/* eslint-disable unused-imports/no-unused-vars*/
export function LineGraph(props: LineGraphProps) {
const {
width,

View File

@ -1,46 +1,46 @@
export const sectionsData = [
{
name: "Demographics",
url: "/",
url: "/demographics",
},
{
name: "Academics",
url: "/",
url: "/academics",
},
{
name: "Co-op",
url: "/",
url: "/coop",
},
{
name: "Lifestyle and Interests",
url: "/",
url: "/lifestyle-and-interests",
},
{
name: "Intimacy and Drugs",
url: "/",
url: "/intimacy-and-drugs",
},
{
name: "Post-grad",
url: "/",
url: "/postgrad",
},
{
name: "Friends",
url: "/",
url: "/friends",
},
{
name: "Miscellaneous",
url: "/",
url: "/miscellaneous",
},
{
name: "Mental Health",
url: "/",
url: "/mental-health",
},
{
name: "Personal",
url: "/",
url: "/personal",
},
{
name: "Contributors",
url: "/",
url: "/contributors",
},
];

View File

@ -2,6 +2,11 @@
const nextConfig = {
reactStrictMode: true,
trailingSlash: true,
// This image loader supports `next export`, for optimizing next <Image /> tags
images: {
loader: 'akamai',
path: '',
},
}
module.exports = nextConfig

8241
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -45,6 +45,7 @@
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.30.0",
"eslint-plugin-react-hooks": "^4.5.0",
"eslint-plugin-unused-imports": "^2.0.0",
"postcss": "^8.4.14",
"postcss-calc": "^8.2.4",
"postcss-flexbugs-fixes": "^5.0.2",

View File

@ -145,4 +145,4 @@ a:hover {
--card-background: var(--dark--card-background);
--label: var(--dark--label);
}
}
}

View File

@ -1,13 +1,13 @@
import { BarGraphHorizontal, BarGraphVertical } from "components/BarGraph";
import { mockCategoricalData, moreMockCategoricalData } from "data/mocks";
import React from "react";
import { useWindowDimensions } from "utils/getWindowDimensions";
import { useIsMobile } from "utils/isMobile";
import { BarGraphVertical, BarGraphHorizontal } from "@/components/BarGraph";
import { BottomNav } from "@/components/BottomNav";
import { ComponentWrapper } from "@/components/ComponentWrapper";
import { WordCloud } from "../components/WordCloud";
import { Header } from "@/components/Header";
import { WordCloud } from "@/components/WordCloud";
import styles from "./samplePage.module.css";
@ -17,6 +17,7 @@ export default function SamplePage() {
return (
<div className={styles.page}>
<Header />
<ComponentWrapper
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."

View File

@ -0,0 +1,5 @@
<svg width="144" height="100" viewBox="0 0 144 100" fill="none" xmlns="http://www.w3.org/2000/svg">
<line x1="139" y1="5" x2="5.00003" y2="4.99999" stroke="#E18E89" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="139" y1="50" x2="5.00003" y2="50" stroke="#E18E89" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"/>
<line x1="139" y1="95" x2="5.00003" y2="95" stroke="#E18E89" stroke-width="10" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 495 B

View File

@ -0,0 +1,3 @@
<svg width="118" height="63" viewBox="0 0 118 63" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M116.615 34.4078C118.278 32.7447 118.278 30.0483 116.615 28.3852L89.513 1.28349C87.8499 -0.379606 85.1535 -0.379606 83.4904 1.28349C81.8273 2.94658 81.8273 5.64299 83.4904 7.30609L107.581 31.3965L83.4904 55.4869C81.8273 57.15 81.8273 59.8464 83.4904 61.5095C85.1535 63.1726 87.8499 63.1726 89.513 61.5095L116.615 34.4078ZM0.75 35.6551H113.603V27.1379H0.75V35.6551Z" fill="#603E2F"/>
</svg>

After

Width:  |  Height:  |  Size: 496 B