blob: 2b1dbada9e0985cb98afc15204f680ffdcf91a0b [file] [log] [blame]
pineafandf39fd42021-09-04 16:05:27 +01001import '../styles/globals.css';
2import NavBar from '../Components/NavBar';
Skyler Turner16c08d32021-11-04 20:06:50 +00003import { ThemeProvider } from 'theme-ui';
Skyler Grey59abe292022-12-05 01:27:02 +00004import React, {useEffect} from 'react';
pineafanff3d4522022-05-06 19:51:02 +01005import Styles from '../styles/globals.module.css';
PineaFan93f540e2022-12-04 22:05:57 +00006import { getSeason } from './api/season';
7import Christmas from '../Components/overlays/christmas';
pineafandf39fd42021-09-04 16:05:27 +01008
Skyler Turner16c08d32021-11-04 20:06:50 +00009const theme = {
10 config: {
11 useColorSchemeMediaQuery: true,
12 initialColorModeName: 'light',
13 },
14 colors: {
15 text: '#424242',
16 background: '#ffffff',
17 primary: '#6576CC',
18 cardText: '#ffffff',
19 cardBackground: 'rgba(255, 255, 255, 0.65)',
20 cardBorder: '#C4C4C4',
21 cardFilter: 'rgba(0, 0, 0, 0)',
22 cardOverlay: '#00000080',
pineafane0283a82022-02-13 10:05:56 +000023 hint: '#E4E4E4',
24 panelColor: "#F0F0F0",
pineafan46270162022-02-13 12:06:17 +000025 fadeGradient: "rgba(240, 240, 240, 1)",
pineafan7bd0ad62022-10-26 22:11:29 +010026 offset: "2.5px",
pineafandf39fd42021-09-04 16:05:27 +010027
pineafanb18f0192022-10-27 22:08:36 +010028 borders: "#FFFFFF",
29 borderHint: "#E4E4E4",
30
Skyler Turner16c08d32021-11-04 20:06:50 +000031 modes: {
32 dark: {
33 text: '#ffffff',
pineafan74f16742022-11-07 21:57:55 +000034 background: '#000000',
Skyler Turner16c08d32021-11-04 20:06:50 +000035 primary: '#6576CC',
36 cardText: '#424242',
37 cardBackground: 'rgba(0, 0, 0, 0.65)',
38 cardBorder: '#424242',
pineafana841c762021-11-14 21:21:04 +000039 cardFilter: 'brightness(0.5)',
Skyler Turner16c08d32021-11-04 20:06:50 +000040 cardOverlay: '#42424280',
pineafane0283a82022-02-13 10:05:56 +000041 hint: '#242424',
pineafan46270162022-02-13 12:06:17 +000042 panelColor: "rgba(255, 255, 255, 0.05)",
43 fadeGradient: "rgba(48, 48, 48, 1)",
pineafanb18f0192022-10-27 22:08:36 +010044 offset: "-20px",
45
46 borders: "#000000",
47 borderHint: "#424242",
Skyler Turner16c08d32021-11-04 20:06:50 +000048 }
49 }
50 },
51};
52
Samuel Shuert016ea022021-09-01 16:17:24 -050053
pineafana5ce9102021-09-02 17:21:31 +010054function App({ Component, pageProps }) {
pineafanb18f0192022-10-27 22:08:36 +010055 const [subBar, setSubBar] = React.useState(false);
56 const [currentElement, setElement] = React.useState(<></>);
pineafan7bd0ad62022-10-26 22:11:29 +010057
Skyler Grey59abe292022-12-05 01:27:02 +000058 const [season, setSeason] = React.useState({ season: "normal", filePath: "normal" });
59
60 useEffect(() => async () => {
61 let season = await (await fetch("/api/season")).json();
62 setSeason(season);
63 }, [season])
64
pineafanb7c79742022-11-06 18:08:36 +000065 const showSubBar = (element, timeout, positioning="left") => {
pineafanb18f0192022-10-27 22:08:36 +010066 setSubBar(true);
pineafanb7c79742022-11-06 18:08:36 +000067 if (positioning === "center") {
68 element = <div className={Styles.centeredSubBar}>{element}</div>
69 }
pineafanb18f0192022-10-27 22:08:36 +010070 setElement(element);
71 if (timeout) {
72 setTimeout(() => {
73 setSubBar(false);
74 setTimeout(() => {
75 setElement(<></>);
76 }, 0.31 * 1000)
77 }, timeout * 1000)
78 }
79 }
pineafan7bd0ad62022-10-26 22:11:29 +010080
pineafanb18f0192022-10-27 22:08:36 +010081 const hideSubBar = () => {
82 setSubBar(false);
83 }
84
pineafanb7c79742022-11-06 18:08:36 +000085 const showMessage = (text, positioning="left") => {
86 showSubBar(<p className={Styles.message}>{text}</p>, 5, positioning);
pineafanb18f0192022-10-27 22:08:36 +010087 }
88
PineaFan93f540e2022-12-04 22:05:57 +000089 let Overlay = <></>;
90 switch (season.season) {
91 case "christmas": {
92 Overlay = <Christmas />;
93 break;
94 }
95 }
96
pineafanb18f0192022-10-27 22:08:36 +010097 return <>
98 <ThemeProvider theme={theme}>
99 <NavBar
100 subBar={subBar}
101 setSubBar={setSubBar}
102 element={currentElement}
103 setElement={setElement}
104 showMessage={showMessage}
105 showSubBar={showSubBar}
Skyler Grey59abe292022-12-05 01:27:02 +0000106 season={season}
pineafanb18f0192022-10-27 22:08:36 +0100107 />
108 <Component
109 {...pageProps}
110 showSubBar={showSubBar}
111 hideSubBar={hideSubBar}
112 showMessage={showMessage}
PineaFan93f540e2022-12-04 22:05:57 +0000113 season={season}
pineafanb18f0192022-10-27 22:08:36 +0100114 />
PineaFan93f540e2022-12-04 22:05:57 +0000115 <div className={Styles.container} style={{
116 pointerEvents: "none",
117 }}>{Overlay}</div>
pineafanb18f0192022-10-27 22:08:36 +0100118 <div className={Styles.container} />
119 </ThemeProvider>
120 </>
Samuel Shuert016ea022021-09-01 16:17:24 -0500121}
122
pineafana5ce9102021-09-02 17:21:31 +0100123export default App