Skip to content

Commit 3a71da9

Browse files
authored
Merge pull request #91 from cusec/feat/hackacomm-link
feat: add a bottom banner to promote HackaComm better
2 parents 208f4b1 + 3dae5b1 commit 3a71da9

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

components/core/Text.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ export const LinkPrimary = styled(Link)`
4545
}
4646
`;
4747

48+
export const LinkSecondary = styled(Link)`
49+
font-weight: bold;
50+
font-size: 16px;
51+
color: ${theme.colors.brand.teal};
52+
53+
&:hover {
54+
color: ${theme.colors.brand.blue};
55+
}
56+
`;
57+
4858
export const LinkPrimaryVariant = styled(Link)`
4959
font-weight: bold;
5060
font-size: 16px;

components/sections/Hero.tsx

+70-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import React, { useEffect, useState } from "react";
1+
import React, { useEffect, useRef, useState } from "react";
22
import Link from "next/link";
3-
import { Flex, Text } from "@chakra-ui/core";
3+
import { Box, CloseButton, Flex, Text, useToast } from "@chakra-ui/core";
44
import styled from "@emotion/styled";
55
import Socials from "@/components/Socials";
66
import Logo from "../svgs/logo.svg";
@@ -11,9 +11,11 @@ import {
1111
BodyPrimary,
1212
Headline,
1313
LinkPrimary,
14+
LinkSecondary,
1415
} from "@/components/core/Text";
1516
import { ButtonPrimary } from "@/components/core/Button";
1617
import { WidthWrapper } from "@/components/core/Layout";
18+
import { useRouter } from "next/router";
1719

1820
const minHeights = [750, 750, 800];
1921

@@ -25,13 +27,28 @@ const FlexFullView = styled(Flex)`
2527
background-position: center bottom;
2628
`;
2729

30+
const HackaCommToast = styled(Flex)`
31+
background: black;
32+
color: white;
33+
border-radius: 15px 15px 0 0;
34+
`;
35+
2836
export default function Hero(): React.ReactElement {
2937
const [heightProp, setHeightProp] = useState(
3038
minHeights.map((minHeight) => `max(100vh, ${minHeight}px)`)
3139
);
3240
const actualWidth = useScreenWidth();
3341
const [currentWidth, setCurrentWidth] = useState(0);
3442
const setNavOverlayOpen = useStore((state) => state.setNavOverlayOpen);
43+
const toast = useToast();
44+
const router = useRouter();
45+
46+
const toastRefs = useRef<(() => void)[]>([]);
47+
48+
const closeToasts = () => {
49+
toastRefs.current.forEach((cb) => cb());
50+
toastRefs.current = [];
51+
};
3552

3653
useEffect(() => {
3754
const updateHeight = () => {
@@ -49,6 +66,57 @@ export default function Hero(): React.ReactElement {
4966
}
5067
}, [actualWidth, currentWidth, setNavOverlayOpen]);
5168

69+
useEffect(() => {
70+
const handlePageSwitch = (route: string) => {
71+
if (router.pathname !== route) {
72+
router.push(route);
73+
} else {
74+
setNavOverlayOpen(false);
75+
}
76+
};
77+
78+
const hackaCommToast = setTimeout(() => {
79+
toast({
80+
position: "bottom",
81+
duration: null,
82+
isClosable: true,
83+
render: ({ onClose }) => {
84+
toastRefs.current.push(onClose);
85+
86+
return (
87+
<>
88+
<HackaCommToast p={3}>
89+
<Box>
90+
Check out HackaComm: a brand-new hackathon brought to you by
91+
CUSEC and RBC!{" "}
92+
<LinkSecondary
93+
onClick={() => {
94+
handlePageSwitch("/hackacomm");
95+
closeToasts();
96+
}}
97+
>
98+
Click to learn more.
99+
</LinkSecondary>
100+
</Box>
101+
<Box alignSelf="center">
102+
<CloseButton
103+
size="lg"
104+
_focus={{}}
105+
onClick={() => {
106+
closeToasts();
107+
}}
108+
/>
109+
</Box>
110+
</HackaCommToast>
111+
</>
112+
);
113+
},
114+
});
115+
}, 1000);
116+
117+
return () => clearTimeout(hackaCommToast);
118+
}, [router, setNavOverlayOpen, toast]);
119+
52120
return (
53121
<FlexFullView
54122
height={heightProp}

0 commit comments

Comments
 (0)