Skip to content

Commit

Permalink
feat(hero): add animation
Browse files Browse the repository at this point in the history
  • Loading branch information
ur-ja committed Nov 7, 2023
1 parent 89f842a commit 4d541db
Show file tree
Hide file tree
Showing 19 changed files with 320 additions and 177 deletions.
155 changes: 45 additions & 110 deletions frontend/components/Landing.tsx
Original file line number Diff line number Diff line change
@@ -1,141 +1,76 @@
import GridViewRoundedIcon from "@mui/icons-material/GridViewRounded";
import MapIcon from "@mui/icons-material/Map";
import { Accordion } from "@mui/material";
import Box from "@mui/material/Box";
import Stack from "@mui/material/Stack";
import { styled } from "@mui/material/styles";
import Typography from "@mui/material/Typography";
import Image from "next/image";
import Link from "next/link";
import React, { useEffect, useState } from "react";
import React, { useState } from "react";

import Button from "../components/Button";
import parentLogo from "../public/assets/favicon/csesocgreyblue.png";
import Gif from "../public/assets/favicon/free_rooms_logo.gif";
import Logo from "../public/assets/favicon/free_rooms_logo.png";
import ClosedLogo from "../public/assets/favicon/free_rooms_logo_closed.png";
import HeroPanel from "../public/assets/landing_page/hero_panel.png";
import Faq from "./Faq";
import Footer from "./Footer";
import UsageTips from "./UsageTips";
import Features from "./Features";
import TextAnimation from "./TextAnimation";

const Landing = () => {
const [isHovered, setIsHovered] = useState(false);
const [isClicked, setIsClicked] = useState(false);
const [gifSource, setGifSource] = useState(Logo);

const handleMouseEnter = () => {
setIsHovered(true);
const handleClick = () => {
setIsClicked(!isClicked);
setGifSource(isClicked ? Logo : ClosedLogo);
};

const handleMouseLeave = () => {
setIsHovered(false);
};

useEffect(() => {
const intervalId = setInterval(() => {
if (isHovered) {
setGifSource(Gif);
} else {
setGifSource(Logo);
}
}, 100);

return () => clearInterval(intervalId);
}, [isHovered]);
return (
<div>
<LandingScreenContainer>
<Box margin="auto" display={{ xs: "none", md: "block" }}>
<AnimationContainer>
<DoorContainer>
<Image
width={400}
height={400}
alt={"Freerooms Logo"}
width={150}
height={150}
alt="Freerooms Logo"
src={gifSource}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
onClick={handleClick}
style={{}}
/>
</Box>
</LandingScreenContainer>
</DoorContainer>
<TextAnimation />
<HeroPanelContainer>
<Image
src={HeroPanel}
alt="hero panel"
style={{ height: "100%", width: "100%" }}
/>
</HeroPanelContainer>
</AnimationContainer>
<LandingScreenContainer>
<UsageTips />
<Features />
</LandingScreenContainer>
<Faq />
<Footer />
</div>
);
};

const GradientText = styled(Typography)({
WebkitBackgroundClip: "text",
WebkitTextFillColor: "transparent",
backgroundImage: "linear-gradient(to left, #d26038, #f5915a)",
animation: "gradient 10s ease infinite",
backgroundSize: "400% 400%",
fontWeight: 700,
"@keyframes gradient": {
"0%": {
backgroundPosition: "0% 50%",
},
"50%": {
backgroundPosition: "100% 50%",
},
"100%": {
backgroundPosition: "0% 50%",
},
},
});

const LandingScreenContainer = styled(Stack)(({ theme }) => ({
height: "100%",
width: "80%",
margin: "auto",
}));

export default Landing;
const HeroPanelContainer = styled(Stack)(({ theme }) => ({
height: "100%",
width: "100%",
}));

const DoorContainer = styled(Stack)(({ theme }) => ({
cursor: "pointer",
}));

{
/* <LandingScreenContainer direction="row" justifyContent="center">
<Stack direction="column" spacing={2} sx={{ margin: "auto" }}>
<Stack style={{ width: "auto" }}></Stack>
<GradientText
variant="h1"
fontFamily="Josefin Sans, sans-serif"
fontSize={{ xs: "4rem", md: "5rem" }}
>
Freerooms
</GradientText>
<GradientText fontSize={{ xs: "1rem", md: "1.5rem" }}>
UNSW room bookings
</GradientText>
<Stack direction="column" spacing={2}>
<Button
LinkComponent={Link}
href="/browse"
sx={{ width: "13rem" }}
endIcon={<GridViewRoundedIcon />}
>
<Typography
fontWeight="bold"
sx={{ display: "flex", margin: "auto" }}
>
Browse
</Typography>
</Button>
<Button
LinkComponent={Link}
href="/map"
sx={{ width: "13rem" }}
endIcon={<MapIcon />}
>
<Typography
fontWeight="bold"
sx={{ display: "flex", margin: "auto" }}
>
Map
</Typography>
</Button>
</Stack>
</Stack>
<Box margin="auto" display={{ xs: "none", md: "block" }}>
<Image width={400} height={400} alt={"Freerooms Logo"} src={Gif} />
</Box>
</LandingScreenContainer> */
}
const AnimationContainer = styled(Stack)(({ theme }) => ({
display: "flex",
justifyContent: "center",
alignItems: "center",
height: "100%",
width: "80%",
margin: "auto",
}));

export default Landing;
31 changes: 14 additions & 17 deletions frontend/components/NavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"use client"
"use client";

import GridIcon from "@mui/icons-material/GridViewRounded";
import MapIcon from "@mui/icons-material/Map";
Expand All @@ -10,6 +10,9 @@ import { styled } from "@mui/material/styles";
import { usePathname } from "next/navigation";
import React from "react";

import background from "../public/assets/landing_page/texture.png";
import { selectCurrentBuilding } from "../redux/currentBuildingSlice";
import { useSelector } from "../redux/hooks";
import { drawerWidth } from "../views/BuildingDrawer";
import Branding from "./Branding";
import IconButton from "./IconButton";
Expand All @@ -22,18 +25,15 @@ interface NavBarProps {
// This isn't actually enforced so update this if u change the navbar
export const navHeight = 65;

const NavBar: React.FC<NavBarProps> = ({
setSearchOpen,
drawerOpen
}) => {
const NavBar: React.FC<NavBarProps> = ({ setSearchOpen }) => {
const path = usePathname();

return (
<AppBar
position="fixed"
drawerOpen={drawerOpen}
sx={{
borderBottom: "1px solid #e0e0e0",
borderBottom: "2px solid #e0e0e0",
alignItems: "center",
display: "flex",
justifyContent: "space-between",
Expand All @@ -45,26 +45,22 @@ const NavBar: React.FC<NavBarProps> = ({
aria-label="Open search"
onClick={() => setSearchOpen(true)}
>
<SearchIcon/>
<SearchIcon />
</IconButton>
<IconButton
aria-label="Browse buildings"
active={path === "/browse"}
href="/browse"
>
<GridIcon/>
<GridIcon />
</IconButton>
<IconButton
aria-label="Go to map"
active={path === "/map"}
href="/map"
>
<MapIcon/>
<IconButton aria-label="Go to map" active={path === "/map"} href="/map">
<MapIcon />
</IconButton>
</Stack>
</AppBar>
)
}
);
};

interface AppBarProps extends MuiAppBarProps {
drawerOpen?: boolean;
Expand All @@ -73,7 +69,8 @@ interface AppBarProps extends MuiAppBarProps {
const AppBar = styled(MuiAppBar, {
shouldForwardProp: (prop) => prop !== "drawerOpen",
})<AppBarProps>(({ theme, drawerOpen }) => ({
backgroundColor: theme.palette.background.default,
// backgroundColor: theme.palette.background.default,
backgroundImage: `url(${background.src})`,
color: theme.palette.getContrastText(theme.palette.background.default),
boxShadow: "none",
display: "flex",
Expand Down
37 changes: 21 additions & 16 deletions frontend/components/UsageCard.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { styled } from "@mui/system";
import Link from "next/link";
import React from "react";

interface UsageCardProps {
interface FeatureCardProps {
icon: React.ReactElement;
heading: string;
description: string;
link: string;
}

const StyledParentDiv = styled("div")(({ theme }) => ({
Expand Down Expand Up @@ -40,26 +42,29 @@ const StyledLine = styled("h2")(({ theme }) => ({
marginTop: "-1rem",
}));

const UsageCard: React.FC<UsageCardProps> = ({
const FeatureCard: React.FC<FeatureCardProps> = ({
icon,
heading,
description,
link,
}) => {
return (
<StyledParentDiv
onMouseEnter={(e) => {
e.currentTarget.style.transform = "scale(1.05)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.transform = "scale(1)";
}}
>
<StyledIconDiv>{icon}</StyledIconDiv>
<StyledHeading>{heading}</StyledHeading>
<StyledLine />
<p>{description}</p>
</StyledParentDiv>
<Link href={link}>
<StyledParentDiv
onMouseEnter={(e) => {
e.currentTarget.style.transform = "scale(1.05)";
}}
onMouseLeave={(e) => {
e.currentTarget.style.transform = "scale(1)";
}}
>
<StyledIconDiv>{icon}</StyledIconDiv>
<StyledHeading>{heading}</StyledHeading>
<StyledLine />
<p>{description}</p>
</StyledParentDiv>
</Link>
);
};

export default UsageCard;
export default FeatureCard;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 7 additions & 6 deletions frontend/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

html,
body {
padding: 0;
margin: 0;
height: 100%;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
padding: 0;
margin: 0;
/* background-image: url("../public/assets/landing_page/texture.png"); */
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
background-image: url("../public/assets/landing_page/texture.png");
}

a {
color: inherit;
text-decoration: none;
color: inherit;
text-decoration: none;
}
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
31 changes: 31 additions & 0 deletions v2/frontend/components/CursorBlinker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { styled } from "@mui/material/styles";
import { motion } from "framer-motion";

const cursorVariants = {
blinking: {
opacity: [0, 0, 1, 1],
transition: {
duration: 1,
repeat: 3,
repeatDelay: 0,
ease: "linear",
times: [0, 0.5, 0.5, 1],
},
},
};

export default function CursorBlinker() {
return <CursorStyle variants={cursorVariants} animate="blinking" />;
}

const CursorStyle = styled(motion.div)(({ theme }) => ({
display: "inline-block",
height: "4rem",
width: "4px",
transform: "translateY(0.25rem)",
backgroundColor: "#FF9361",
[theme.breakpoints.down("md")]: {
height: "2rem",
width: "2px",
},
}));
Loading

0 comments on commit 4d541db

Please sign in to comment.