Skip to content

Commit

Permalink
Fix Lex Master bug and grammar, and some refactors (#194)
Browse files Browse the repository at this point in the history
* Fix lex role hack

* Add basic theme to MUI

* Refactor useIsScreenWide() into separate module

* Add javadoc to useIsScreenWide()

* Refactor header and footer into desktop-specific files

* Refactor header and footer into HeaderFooterWrapper

* Fix kisel spelling

* Fix kisel spelling

* Switch HeaderFooter for mobile

* Refactor logout function to separate file

* CHAPTER

* Switch headers at 950 px

* Dont extend MenuItem since we don't use the extra CSS

* Share Header Navlinks between desktop and mobile

* Refactor footernav into separate file

* Refactor usermenu items into separate file

* Fix desktop footer

* Fix emotion css props

* Add new light/dark versions of colors in the palette

* Set up new mobile header

* Fix discord channel name

* Fix header css

* Bump version ot 1.0.2
  • Loading branch information
JustinLex authored Jan 5, 2023
1 parent 7e96a4d commit 57d1150
Show file tree
Hide file tree
Showing 33 changed files with 442 additions and 208 deletions.
2 changes: 1 addition & 1 deletion back/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tmeit_backend"
version = "1.0.1"
version = "1.0.2"
description = "Python backend for the TMEIT website"
authors = ["TraditionsMEsterIT"]
license = "AGPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/tmeit-se/postgres/set_image_tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/jobTemplate/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/db-backup-agent:1.0.1"
"value": "ghcr.io/tmeit/db-backup-agent:1.0.2"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/tmeit-run-migrations:1.0.1"
"value": "ghcr.io/tmeit/tmeit-run-migrations:1.0.2"
}
]
2 changes: 1 addition & 1 deletion deploy/kubernetes/tmeit-se/tmeit-app/set_image_tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/tmeit-app:1.0.1"
"value": "ghcr.io/tmeit/tmeit-app:1.0.2"
}
]
2 changes: 1 addition & 1 deletion deploy/kubernetes/tmeit-se/tmeit-worker/set_image_tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/tmeit-worker:1.0.1"
"value": "ghcr.io/tmeit/tmeit-worker:1.0.2"
}
]
2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sideEffects": [
"*.css"
],
"version": "1.0.1",
"version": "1.0.2",
"description": "Front-end for the TMEIT website.",
"main": "index.js",
"scripts": {
Expand Down
9 changes: 0 additions & 9 deletions front/src/app/components/DropdownMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,3 @@ export const DropdownMenu = React.forwardRef(
);
}
);

export const DropdownMenuItem = styled(MenuItem)`
display: flex;
justify-content: space-between !important;
& > svg {
margin-left: 32px;
}
`;
51 changes: 0 additions & 51 deletions front/src/app/components/Footer.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import {NavLink} from "react-router-dom";
import {Button} from "@mui/material";
import styled from "@emotion/styled";

import tmeit_logo_nogojan_mono from "../logos/LogoTMEIT_withoutGojan_monochrome.svg";
import { kiesel_blue, kiesel_light_blue, secondary_purp, secondary_purp_dark, primary_light, accent_yellow } from "../palette.js";
import HeaderMenu from "./HeaderMenu.js";
import tmeit_logo_nogojan_mono from "../../logos/LogoTMEIT_withoutGojan_monochrome.svg";
import { kisel_blue, secondary_purp, secondary_purp_dark, primary_light, accent_yellow } from "../../palette.js";
import DesktopHeaderMenu from "./DesktopHeaderMenu.js";
import getHeaderNavItems from "./navs/HeaderNav";

export const header_height = "6rem"

const StyledHeader = styled(Header)({
const StyledDesktopHeader = styled(DesktopHeader)({
gridRowStart: 1,
nav: {
height: header_height,
Expand Down Expand Up @@ -58,7 +59,7 @@ const StyledHeader = styled(Header)({

});

function Header({className, loggedIn, setLoginModalOpen}) {
function DesktopHeader({className, loggedIn, setLoginModalOpen}) {
return (
<header className={className}>
<nav>
Expand All @@ -68,32 +69,18 @@ function Header({className, loggedIn, setLoginModalOpen}) {
<div className="header-rows">
<div id="header-gradient"></div>
<ul>
<li>
<NavLink to="/events" activeclassname="selected">
Events
</NavLink>
</li>
<li>
<NavLink to="/team" activeclassname="selected">
Team
</NavLink>
</li>
<li id="join-navlink">
<NavLink to="/join_tmeit" activeclassname="selected">
Join
</NavLink>
</li>
<li>
{loggedIn?
<HeaderMenu />
: <Button variant="contained" onClick={() => {setLoginModalOpen(true)}}>Log in</Button>
}
</li>
{getHeaderNavItems(false).map((item) => (<li>{item}</li>))}
<li>
{loggedIn?
<DesktopHeaderMenu />
: <Button variant="contained" onClick={() => {setLoginModalOpen(true)}}>Log in</Button>
}
</li>
</ul>
</div>
</nav>
</header>
);
}

export default StyledHeader;
export default StyledDesktopHeader;
31 changes: 31 additions & 0 deletions front/src/app/components/HeaderFooter/DesktopHeaderMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {useState, useEffect} from "react";
import {Link, useNavigate} from "react-router-dom";
import {Button} from "@mui/material";
import styled from "@emotion/styled";

import {DropdownMenu} from "../DropdownMenu.js";
import {getApiFetcher} from "../../api";
import getUserMenuItems from "./navs/UserMenu";


const StyledDesktopHeaderMenu = styled(DesktopHeaderMenu)({});

function DesktopHeaderMenu({className}) {
let navigate = useNavigate();

const [meData, setMeData] = useState(null); // Yarr, set me data (Logged-in user's member data)

const loadMeData = async () => {setMeData(await getApiFetcher().get("/me").json())} // Load user information when dropdown is opened
useEffect(() => { loadMeData() }, []); // Load user information when component is mounted, only once

return (
<DropdownMenu
keepOpen
open={open}
trigger={<Button>User Menu</Button>}
menu={getUserMenuItems(navigate, meData)}
/>
);
}

export default StyledDesktopHeaderMenu;
44 changes: 44 additions & 0 deletions front/src/app/components/HeaderFooter/Footer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import styled from "@emotion/styled";

import FooterNav from "./navs/FooterNav";
import { kisel_blue, secondary_purp, primary_light, accent_yellow, primary_dark, accent_maroon } from "../../palette.js";

const StyledFooter = styled(Footer)({
height: "5rem",
background: accent_maroon,
marginTop: "auto",
marginBottom: 0,
paddingTop: "0.5rem",
paddingBottom: "0.5rem",
gridRowStart: 2,
overflow: "scroll",
color: "#bbbbbb",

ul: {
padding: 0,
display: "flex",
flexDirection: "row",
justifyContent: "space-around",
textAlign: "center",
fontSize: "1rem",
},

li: {
display: "inline"
},

"a:link": { color: "#ffffff", textDecoration: "none" },
"a:visited": { color: "#ffffff", textDecoration: "none" },
"a:hover": { color: "#ffffff", textDecoration: "none" },
"a:active": { color: "#ffffff", textDecoration: "none" },
});

function Footer({className}) {
return (
<footer className={className}>
<FooterNav />
</footer>
)
}

export default StyledFooter;
90 changes: 90 additions & 0 deletions front/src/app/components/HeaderFooter/HeaderFooterWrapper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {Suspense, lazy, useState} from "react";
import styled from "@emotion/styled";

import { getApiFetcher } from "../../api.js";

import { kisel_blue } from "../../palette.js";

import DesktopHeader from "./DesktopHeader";
import MobileHeader from "./MobileHeader";
import { header_height } from "./DesktopHeader";
import { mobile_header_height } from "./MobileHeader";
import Footer from "./Footer";
const LoginModal = lazy(() => import("../LoginModal"));

import hasLoginCookie from "../../hasLoginCookie";
import useIsScreenWide from "../../useIsScreenWide";

const StyledHeaderFooterWrapper = styled(HeaderFooterWrapper)({
"& > #expander": {
minHeight: `calc(100vh - ${header_height})`,
display: "grid",
gridTemplateRows: "1fr auto",
},
});

const DesktopExpander = styled.div({
minHeight: `calc(100vh - ${header_height})`,
display: "grid",
gridTemplateRows: "1fr auto"
});
const MobileExpander = styled.div({
minHeight: "100vh",
display: "grid",
gridTemplateRows: "1fr auto"
});

const MobileHeaderSpacer = styled.div({
height: mobile_header_height
});

/**
* Common wrapper for all routes that displays the navbars around the route
*/
function HeaderFooterWrapper({className, children}) {
const [loginModalOpen, setLoginModalOpen] = useState(false);

// State storing whether user is logged in or not. Initializes based on if user has login cookie or not. (We assume cookie is valid)
const [loggedIn, setLoggedIn] = useState(hasLoginCookie());

// Switch between mobile header and desktop header/footer at 950 px
// 950 px should be wide enough for 5 links on the desktop header
// 950 px is also less than half of 1920 px but more than the 810 px of an iPad.
const screenIsWide = useIsScreenWide(950)

if(screenIsWide) {
return (
<div className={className}>
{loginModalOpen?
(<Suspense>
<LoginModal loggedIn={loggedIn} setLoggedIn={setLoggedIn} setLoginModalOpen={setLoginModalOpen} />
</Suspense>)
: null
}
<DesktopHeader loggedIn={loggedIn} setLoginModalOpen={setLoginModalOpen} />
<DesktopExpander>
<div>{children}</div>
<Footer />
</DesktopExpander>
</div>
);
} else {
return (
<div className={className}>
{loginModalOpen?
(<Suspense>
<LoginModal loggedIn={loggedIn} setLoggedIn={setLoggedIn} setLoginModalOpen={setLoginModalOpen} />
</Suspense>)
: null
}
<MobileHeader loggedIn={loggedIn} setLoginModalOpen={setLoginModalOpen} />
<MobileExpander>
<div> {children} </div>
<MobileHeaderSpacer />
</MobileExpander>
</div>
);
}
}

export default StyledHeaderFooterWrapper;
33 changes: 33 additions & 0 deletions front/src/app/components/HeaderFooter/MobileHeader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {NavLink} from "react-router-dom";
import {Button} from "@mui/material";
import styled from "@emotion/styled";

import tmeit_logo_nogojan_mono from "../../logos/LogoTMEIT_withoutGojan_monochrome.svg";
import { kisel_blue, kisel_blue_dark, secondary_purp, secondary_purp_dark, primary_light, accent_yellow } from "../../palette.js";
import MobileHeaderMenu from "./MobileHeaderMenu.js";

export const mobile_header_height = "4rem"

const StyledMobileHeader = styled(MobileHeader)({
position: "fixed",
bottom: 0,
width: "100%",
height: mobile_header_height,
display: "grid",
background: kisel_blue_dark,
grid: "1fr auto 1fr / 1fr auto 1fr",
"#logo": {
height: "3.5rem",
}
});

function MobileHeader({className, loggedIn, setLoginModalOpen}) {
return (
<header className={className}>
<img css={{gridColumn: 2, gridRow: 2}} id="logo" src={tmeit_logo_nogojan_mono} alt="TMEIT Logo" />
<MobileHeaderMenu css={{gridColumn: 3, gridRow: 2}} loggedIn={loggedIn} setLoginModalOpen={setLoginModalOpen}/>
</header>
);
}

export default StyledMobileHeader;
Loading

0 comments on commit 57d1150

Please sign in to comment.