This commit is contained in:
Rebecca-Chou 2022-11-08 09:26:15 -04:00
commit f5c9f2e447
20 changed files with 4954 additions and 3893 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

@ -63,7 +63,7 @@
transform: rotate(180deg);
}
@media screen and (max-width: 768px) {
@media screen and (max-width: 1000px) {
.subBox {
flex-direction: column;
align-items: flex-start;
@ -93,6 +93,14 @@
}
.arrow {
width: calc(200rem / 16);
width: 100%;
}
}
.containerOnlyRightArrow {
justify-content: flex-end;
}
.containerOnlyLeftArrow {
justify-content: flex-start;
}

View File

@ -4,35 +4,49 @@ import React from "react";
import styles from "./BottomNav.module.css";
interface PagesInfo {
leftPageLink: string;
leftPageName: string;
rightPageLink: string;
rightPageName: string;
leftPage?: {
url: string;
name: string;
};
rightPage?: {
url: string;
name: string;
};
}
export function BottomNav(props: PagesInfo) {
const onlyRightArrow = props.rightPage && !props.leftPage;
const onlyLeftArrow = !props.rightPage && props.leftPage;
return (
<div className={styles.container}>
<div className={styles.subBox + " " + styles.subBoxLeft}>
<Link href={props.leftPageLink}>
<a>
<Arrow />
</a>
</Link>
<Link href={props.leftPageLink}>
<a className={styles.item}>{props.leftPageName}</a>
</Link>
</div>
<div className={styles.subBox}>
<Link href={props.rightPageLink}>
<a className={styles.item}>{props.rightPageName}</a>
</Link>
<Link href={props.rightPageLink}>
<a>
<Arrow isPointingRight />
</a>
</Link>
</div>
<div
className={`${styles.container}
${onlyRightArrow ? styles.containerOnlyRightArrow : ""}
${onlyLeftArrow ? styles.containerOnlyLeftArrow : ""}`}
>
{props.leftPage ? (
<div className={styles.subBox + " " + styles.subBoxLeft}>
<Link href={props.leftPage.url}>
<a>
<Arrow />
</a>
</Link>
<Link href={props.leftPage.url}>
<a className={styles.item}>{props.leftPage.name}</a>
</Link>
</div>
) : null}
{props.rightPage ? (
<div className={styles.subBox}>
<Link href={props.rightPage.url}>
<a className={styles.item}>{props.rightPage.name}</a>
</Link>
<Link href={props.rightPage.url}>
<a>
<Arrow isPointingRight />
</a>
</Link>
</div>
) : null}
</div>
);
}

View File

@ -3,7 +3,7 @@
display: flex;
padding: calc(40rem / 16) calc(50rem / 16);
margin: calc(65rem / 16) 0;
width: 90%;
width: 88%;
}
.wrapperRight {
@ -43,7 +43,12 @@
padding: 0 15%;
}
@media screen and (max-width: 768px) {
.wrapperNoBodyText {
flex-direction: column;
align-items: center;
}
@media screen and (max-width: 900px) {
.sideWrapperCommon {
margin: auto;
flex-direction: column;
@ -52,6 +57,10 @@
border-radius: 0;
width: 100%;
}
.wrapperCenter {
padding: 0;
}
}
.internalWrapper {

View File

@ -7,7 +7,7 @@ type AlignOption = "left" | "center" | "right";
type ComponentWrapperProps = {
children: React.ReactNode;
heading: string;
bodyText: string;
bodyText?: string;
align?: AlignOption;
noBackground?: boolean;
};
@ -30,11 +30,12 @@ export function ComponentWrapper({
className={`
${alignClasses[align]}
${noBackground ? styles.noBackground : ""}
${bodyText ? "" : styles.wrapperNoBodyText}
`}
>
<div className={styles.internalWrapper}>
<h3>{heading}</h3>
<p>{bodyText}</p>
{bodyText ? <p>{bodyText}</p> : null}
</div>
<div className={styles.internalWrapper}>{children}</div>
</div>

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 { pageRoutes } 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={pageRoutes} 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

@ -0,0 +1,19 @@
.header {
display: flex;
flex-direction: column;
justify-content: center;
padding: calc(40rem / 16) 0;
text-align: center;
}
.title {
color: var(--primary-accent-light);
font-size: calc(70rem / 16);
margin: calc(40rem / 16) auto;
}
.subTitle {
color: var(--primary-accent-lighter);
font-size: calc(26rem / 16);
margin: auto;
}

View File

@ -0,0 +1,17 @@
import React from "react";
import styles from "./SectionHeader.module.css";
interface SectionHeaderProps {
title: string;
subtitle?: string;
}
export function SectionHeader({ title, subtitle }: SectionHeaderProps) {
return (
<div className={styles.header}>
<h1 className={styles.title}>{title}</h1>
{subtitle && <h5 className={styles.subTitle}>{subtitle}</h5>}
</div>
);
}

View File

@ -1,16 +1,12 @@
import { PageRoutes } from "data/routes";
import React from "react";
import styles from "./Sections.module.css";
interface SectionsData {
name: string;
url: string;
}
interface SectionsProps {
/* Whether to display the "Sections" title and separator that appears on the left. */
showHeader?: boolean;
data: SectionsData[];
data: PageRoutes;
}
export function Sections({ data, showHeader = true }: SectionsProps) {
@ -26,7 +22,7 @@ export function Sections({ data, showHeader = true }: SectionsProps) {
)}
<nav className={styles.nav}>
<ul>
{data.map((datum, index) => {
{Object.values(data).map((datum, index) => {
return (
<li key={`${datum.name}-${index}`}>
<a href={datum.url}>

View File

@ -1,46 +1,65 @@
export const sectionsData = [
{
export interface PageRoute {
name: string;
url: string;
}
type PageID =
| "demographics"
| "academics"
| "coop"
| "lifestyleAndInterests"
| "intimacyAndDrugs"
| "postGrad"
| "friends"
| "miscellaneous"
| "mentalHealth"
| "personal"
| "contributors";
export type PageRoutes = { [key in PageID]: PageRoute };
export const pageRoutes: PageRoutes = {
demographics: {
name: "Demographics",
url: "/",
url: "/demographics",
},
{
academics: {
name: "Academics",
url: "/",
url: "/academics",
},
{
coop: {
name: "Co-op",
url: "/",
url: "/coop",
},
{
lifestyleAndInterests: {
name: "Lifestyle and Interests",
url: "/",
url: "/lifestyle-and-interests",
},
{
intimacyAndDrugs: {
name: "Intimacy and Drugs",
url: "/",
url: "/intimacy-and-drugs",
},
{
postGrad: {
name: "Post-grad",
url: "/",
url: "/post-grad",
},
{
friends: {
name: "Friends",
url: "/",
url: "/friends",
},
{
miscellaneous: {
name: "Miscellaneous",
url: "/",
url: "/miscellaneous",
},
{
mentalHealth: {
name: "Mental Health",
url: "/",
url: "/mental-health",
},
{
personal: {
name: "Personal",
url: "/",
url: "/personal",
},
{
contributors: {
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

@ -13,7 +13,7 @@ import {
mockTimelineData,
mockGroupedBarGraphData,
} from "data/mocks";
import { sectionsData } from "data/routes";
import { pageRoutes } from "data/routes";
import React from "react";
import { Color } from "utils/Color";
@ -208,7 +208,7 @@ export default function Home() {
<h2>
<code>{"<Sections />"}</code>
</h2>
<Sections data={sectionsData} />
<Sections data={pageRoutes} />
<h2>
<code>{"<About />"}</code>
@ -245,10 +245,8 @@ export default function Home() {
<code>{"<BottomNav />"}</code>
</h2>
<BottomNav
leftPageLink="/"
leftPageName="Demographics"
rightPageLink="/"
rightPageName="Co-ops"
leftPage={pageRoutes.demographics}
rightPage={pageRoutes.coop}
></BottomNav>
<h2>

View File

@ -1,13 +1,15 @@
import { BarGraphHorizontal, BarGraphVertical } from "components/BarGraph";
import { mockCategoricalData, moreMockCategoricalData } from "data/mocks";
import { pageRoutes } from "data/routes";
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 { SectionHeader } from "@/components/SectionHeader";
import { WordCloud } from "@/components/WordCloud";
import styles from "./samplePage.module.css";
@ -15,23 +17,29 @@ export default function SamplePage() {
const { width } = useWindowDimensions();
const isMobile = useIsMobile();
// For components that are in the side wrappers, it looks better if they fill a certain amount of width, so we can make the width dynamic like this
const defaultGraphWidth = isMobile ? width / 1.25 : width / 2;
const defaultGraphHeight = 500;
// Make vars for common configs such as common margins
const defaultBarGraphMargin = { top: 20, bottom: 40, left: 150, right: 20 };
return (
<div className={styles.page}>
<Header />
<SectionHeader
title="Demographics"
subtitle="An insight into the demographics of UWs CS programs"
/>
<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."
>
<BarGraphVertical
data={mockCategoricalData}
// For components that are in the side wrappers, it looks better if they fill a certain amount of width, so we can make the width dynamic like this
width={isMobile ? width / 1.25 : width / 2}
height={500}
margin={{
top: 20,
bottom: 80,
left: 60,
right: 20,
}}
width={defaultGraphWidth}
height={defaultGraphHeight}
margin={defaultBarGraphMargin}
/>
</ComponentWrapper>
@ -46,8 +54,8 @@ export default function SamplePage() {
value: word.value,
}))}
// For components that we don't want to match the width necessarily we can provide direct values
width={isMobile ? width / 1.5 : 800}
height={500}
width={defaultGraphWidth}
height={defaultGraphHeight}
/>
</ComponentWrapper>
@ -59,14 +67,9 @@ export default function SamplePage() {
<BarGraphHorizontal
className={styles.barGraphDemo}
data={mockCategoricalData}
width={isMobile ? width / 1.45 : width / 2}
height={500}
margin={{
top: 20,
bottom: 40,
left: 150,
right: 20,
}}
width={defaultGraphWidth}
height={defaultGraphHeight}
margin={defaultBarGraphMargin}
/>
</ComponentWrapper>
@ -79,32 +82,19 @@ export default function SamplePage() {
<BarGraphHorizontal
className={styles.barGrapDemo}
data={mockCategoricalData}
width={isMobile ? width / 1.45 : width / 2}
height={500}
margin={{
top: 20,
bottom: 40,
left: 150,
right: 20,
}}
width={defaultGraphWidth}
height={defaultGraphHeight}
margin={defaultBarGraphMargin}
/>
</ComponentWrapper>
<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."
>
<ComponentWrapper heading="What program are you in?" align="left">
<BarGraphHorizontal
className={styles.barGraphDemo}
data={mockCategoricalData}
width={isMobile ? width / 1.45 : width / 2}
height={500}
margin={{
top: 20,
bottom: 40,
left: 150,
right: 20,
}}
width={defaultGraphWidth}
height={defaultGraphHeight}
margin={defaultBarGraphMargin}
/>
</ComponentWrapper>
@ -119,15 +109,86 @@ export default function SamplePage() {
text: word.key,
value: word.value,
}))}
width={isMobile ? width / 1.5 : width / 2}
height={500}
width={defaultGraphWidth}
height={defaultGraphHeight}
/>
</ComponentWrapper>
<ComponentWrapper heading="What program are you in? " align="right">
<WordCloud
data={moreMockCategoricalData.map((word) => ({
text: word.key,
value: word.value,
}))}
width={defaultGraphWidth}
height={defaultGraphHeight}
/>
</ComponentWrapper>
<ComponentWrapper heading="What program are you in?" align="center">
<WordCloud
data={moreMockCategoricalData.map((word) => ({
text: word.key,
value: word.value,
}))}
width={defaultGraphWidth}
height={defaultGraphHeight}
/>
</ComponentWrapper>
<ComponentWrapper heading="What program are you in?" align="left">
<WordCloud
data={moreMockCategoricalData.map((word) => ({
text: word.key,
value: word.value,
}))}
width={defaultGraphWidth}
height={defaultGraphHeight}
/>
</ComponentWrapper>
<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."
align="right"
noBackground
>
<BarGraphHorizontal
className={styles.barGraphDemo}
data={mockCategoricalData}
width={defaultGraphWidth}
height={defaultGraphHeight}
margin={defaultBarGraphMargin}
/>
</ComponentWrapper>
<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."
align="left"
>
<BarGraphHorizontal
className={styles.barGraphDemo}
data={mockCategoricalData}
width={defaultGraphWidth}
height={defaultGraphHeight}
margin={defaultBarGraphMargin}
/>
</ComponentWrapper>
<ComponentWrapper heading="What program are you in?" align="center">
<WordCloud
data={moreMockCategoricalData.map((word) => ({
text: word.key,
value: word.value,
}))}
width={defaultGraphWidth}
height={defaultGraphHeight}
/>
</ComponentWrapper>
<BottomNav
leftPageLink="/"
leftPageName="Demographics"
rightPageLink="/"
rightPageName="Co-ops"
leftPage={pageRoutes.demographics}
rightPage={pageRoutes.contributors}
></BottomNav>
</div>
);

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