Skip to content

Commit

Permalink
Add look and feel
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilwoodruff committed Aug 3, 2023
1 parent 1419f7a commit d6acf05
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 21 deletions.
7 changes: 4 additions & 3 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo512.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>PolicyEngine</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Serif&family=Roboto:wght@300&display=swap" rel="stylesheet">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Roboto+Serif:opsz@8..144&family=Roboto:wght@300;500&display=swap" rel="stylesheet">

<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
Expand Down
13 changes: 7 additions & 6 deletions src/images/logos/policyengine/profile/blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 6 additions & 7 deletions src/images/logos/policyengine/profile/white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import ReactDOM from "react-dom/client";
import "bootstrap/dist/css/bootstrap.min.css";
import "antd/dist/antd.min.css";
import PolicyEngine from "./PolicyEngine";
import PolicyEngine from "./redesign/PolicyEngine";
import * as serviceWorkerRegistration from "./serviceWorkerRegistration";

const root = ReactDOM.createRoot(document.getElementById("root"));
Expand Down
37 changes: 33 additions & 4 deletions src/layout/Responsive.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,32 @@ import { useEffect, useMemo, useState } from "react";

const DisplaySize = {
Mobile: 0,
Desktop: 1200,
Tablet: 768,
Desktop: 1080,
};

const determineDisplayCategory = (width) => {
if (width < DisplaySize.Desktop) {
if (width < DisplaySize.Tablet) {
return "mobile";
} else {
return "desktop";
} else if (width < DisplaySize.Desktop) {
return "tablet";
}
return "desktop";
};

const useDisplayCategory = () => {
const [currentDisplayCategory, setcurrentDisplayCategory] = useState(
determineDisplayCategory(window.innerWidth)
);

useEffect(() => {
const handler = () =>
setcurrentDisplayCategory(determineDisplayCategory(window.innerWidth));
window.addEventListener("resize", handler);
return () => window.removeEventListener("resize", handler);
}, []);

return useMemo(() => currentDisplayCategory, [currentDisplayCategory]);
};

const useMobile = () => {
Expand All @@ -30,4 +47,16 @@ const useMobile = () => {
return useMemo(() => currentDisplayCategory, [currentDisplayCategory]);
};

function ResponsiveComponent(props) {
const displayCategory = useDisplayCategory();
if (displayCategory === "mobile") {
return props.mobile;
} else if (displayCategory === "tablet") {
return props.tablet;
}
return props.desktop;
}

export default useMobile;

export { useDisplayCategory, ResponsiveComponent };
231 changes: 231 additions & 0 deletions src/redesign/PolicyEngine.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
import { useDisplayCategory } from "layout/Responsive"
import style from "style";
import PolicyEngineMainLogo from "../images/logos/policyengine/white.svg";
import PolicyEngineSmallLogo from "../images/logos/policyengine/profile/white.svg";
import { motion } from "framer-motion";
import { useState } from "react";


export default function PolicyEngine() {
return (
<div>
<HeaderBar />
</div>
)
}

function HeaderBar() {
const displayCategory = useDisplayCategory();
return (
<>
<div style={{
backgroundColor: style.colors.BLUE,
width: "100%",
height: 90,
display: "flex",
alignItems: "center",
position: "fixed",
}}>
{{
mobile: <MobileHeaderBar />,
tablet: <TabletHeaderBar />,
desktop: <DesktopHeaderBar />,
}[displayCategory]}
</div>
<div style={{
height: 90,
}}/>
</>
)
}

function MobileHeaderBar() {
return <>
<MobileHeaderLogo />
<MobileCalculatorButton />
<Hamburger />
</>
}

function TabletHeaderBar() {
return <>
<MainHeaderLogo />
<DesktopCalculatorButton />
<Hamburger />
</>
}

function DesktopHeaderBar() {
return <>
<MainHeaderLogo />
<PageLinks />
<DesktopCalculatorButton />
</>
}

function MobileHeaderLogo() {
return <div style={{
display: "flex",
alignItems: "center",
maxWidth: "20vw",
}}>
<img
src={PolicyEngineSmallLogo}
alt="PolicyEngine logo"
style={{
height: 50,
margin: 20,
}}
/>
</div>
}

function MobileCalculatorButton() {
return <div style={{
backgroundColor: "#39C6C0",
height: 50,
width: 50,
margin: 20,
marginLeft: "auto",
}}>

</div>
}

function Hamburger() {
return <div style={{
height: 50,
width: 50,
margin: 20,
alignItems: "center",
display: "flex",
justifyContent: "center",
padding: 15,
color: "white",
border: "1px solid white",
}}>
=
</div>
}

function DesktopCalculatorButton() {
return <div style={{
backgroundColor: "#39C6C0",
height: 50,
margin: 20,
marginLeft: "auto",
alignItems: "center",
display: "flex",
justifyContent: "center",
color: "white",
padding: 15,
paddingLeft: 30,
paddingRight: 30,
fontSize: 20,
fontFamily: "Roboto",
fontWeight: 500,
letterSpacing: 2.4,
}}>
CALCULATE
</div>
}

function MainHeaderLogo() {
return <div style={{
display: "flex",
alignItems: "center",
width: "min(300px, 25vw)",
margin: 20,
}}>
<img
src={PolicyEngineMainLogo}
alt="PolicyEngine logo"
style={{
// make whatever height fits the container
width: "min(300px, 25vw)",
objectFit: "contain",
}}
/>
</div>
}

function PageLinks() {
return <div style={{
display: "flex",
alignItems: "center",
justifyContent: "space-between",
width: "min(600px, 50vw)",
paddingLeft: 30,
}}>
{["Research", "About", "Contact", "Donate"].map((link) => {
return <div style={{
color: "white",
margin: 15,
fontSize: 20,
fontFamily: "Roboto",
fontWeight: 500,
letterSpacing: 2.4,
textTransform: "uppercase",
}}
key="link"
>
<HoverBackground
defaultBackground="transparent"
hoverBackground="white"
height={90}
width={150}
>
<motion.div style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
height: 90,
cursor: "pointer",
}}
whileHover={{
color: style.colors.BLUE,
}}
>
{link}
</motion.div>
</HoverBackground>
</div>
})}
</div>

}

function HoverBackground(props) {
// A div that changes color on hover by having a different covered background slide upwards.
const { children, defaultBackground, hoverBackground, height, width } = props;
const [hovering, setHovering] = useState(false);
// use motion.div
return (
<motion.div
style={{
backgroundColor: defaultBackground,
overflow: "hidden",
height: height,
width: width,
margin: 0,
}}
onMouseEnter={() => setHovering(true)}
onMouseLeave={() => setHovering(false)}
>
{children}
<motion.div
style={{
backgroundColor: hoverBackground,
position: "relative",
height: height * 2,
top: -height * 2,
zIndex: -1,
}}
animate={hovering ? { y: height / 2 } : { y: -height }}
transition={{
duration: 0.2,
}}
/>
</motion.div>
);
}
2 changes: 2 additions & 0 deletions src/style/App.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto+Serif:opsz@8..144&family=Roboto:wght@300;500&display=swap');

h1,
h2,
h3,
Expand Down

0 comments on commit d6acf05

Please sign in to comment.