|
| 1 | +import { HashRouter as Router, Routes, Route, Link } from "react-router-dom"; |
| 2 | +import { HashLink } from 'react-router-hash-link'; |
| 3 | +import React from 'react'; |
| 4 | +import ReactDOM from 'react-dom/client'; |
| 5 | +import reportWebVitals from './reportWebVitals.js'; |
| 6 | +import { useState, useEffect } from 'react'; |
| 7 | +import Markdown from 'react-markdown' |
| 8 | + |
| 9 | +// Scripts |
| 10 | +import { News } from "./news.jsx" |
| 11 | +import { Games } from "./games.jsx" |
| 12 | + |
| 13 | +// Stylesheets |
| 14 | +import "./assets/fonts.css"; |
| 15 | +import "./styles/index.css"; |
| 16 | + |
| 17 | +// Assets |
| 18 | +import strings from "./strings.jsx"; |
| 19 | +import logo from "./assets/images/Logo.png"; |
| 20 | +import logo_JP from "./assets/images/Logo_JP.png" |
| 21 | +import wonder_of_u from "./assets/images/Wonder_of_U.png"; |
| 22 | +import banner from "./assets/images/Banner.png"; |
| 23 | +import banner_long from "./assets/images/Long Banner.png"; |
| 24 | +import { GetFlag } from "./assets/flags.jsx"; |
| 25 | + |
| 26 | +const UseDebounce = (callback, delay) => { |
| 27 | + let timeout; |
| 28 | + return (...args) => { |
| 29 | + clearTimeout(timeout); |
| 30 | + timeout = setTimeout(() => callback(...args), delay); |
| 31 | + }; |
| 32 | +}; |
| 33 | + |
| 34 | +function Home({lang}) { |
| 35 | + const [showFooter, setShowFooter] = useState(false); |
| 36 | + |
| 37 | + useEffect(() => { |
| 38 | + const handleScroll = UseDebounce(() => { |
| 39 | + if (window.scrollY > 700) { // Change 300 to however many pixels you want |
| 40 | + setShowFooter(true); |
| 41 | + } else { |
| 42 | + setShowFooter(false); |
| 43 | + } |
| 44 | + }, 100); |
| 45 | + |
| 46 | + window.addEventListener('scroll', handleScroll); |
| 47 | + |
| 48 | + return () => { |
| 49 | + window.removeEventListener('scroll', handleScroll); // Cleanup event listener |
| 50 | + }; |
| 51 | + }, []); |
| 52 | + |
| 53 | + const nav_pipe = <span className="nav-pipe">F</span>; |
| 54 | + |
| 55 | + function LanguageButton({code, name}) { |
| 56 | + if (code != lang) { |
| 57 | + return ( |
| 58 | + <Link to={`${strings[code].url}`}> |
| 59 | + <span className="small-flag"> |
| 60 | + <table> |
| 61 | + <td><img src={GetFlag(code)}/></td> |
| 62 | + <td>{name}</td> |
| 63 | + </table> |
| 64 | + </span> |
| 65 | + </Link> |
| 66 | + ); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + var logo_image = logo; |
| 71 | + if (lang == "jp") logo_image = logo_JP; |
| 72 | + |
| 73 | + const string = strings[lang]; |
| 74 | + |
| 75 | + return ( |
| 76 | + <> |
| 77 | + <div className="bg-container"> |
| 78 | + <div className="bg"></div> |
| 79 | + |
| 80 | + <div className="navbar"> |
| 81 | + <div className="nav-buttons"> |
| 82 | + <a href="https://wiki.jojomodding.com" target="_blank">{string.navbar.wiki}</a> |
| 83 | + {nav_pipe} |
| 84 | + <HashLink to={`${string.url}#about-us`}>{string.navbar.about}</HashLink> |
| 85 | + {nav_pipe} |
| 86 | + <div className="flag"> |
| 87 | + <div className="flag-overflow"><img src={GetFlag(lang)}/></div> |
| 88 | + <div className="language-hitbox"></div> |
| 89 | + <div className="language-dropdown"> |
| 90 | + <LanguageButton code="en" name="English"/> |
| 91 | + <LanguageButton code="es" name="español"/> |
| 92 | + <LanguageButton code="pt-br" name="português brasileiro"/> |
| 93 | + {/* <LanguageButton code="ja" name="日本語"/> */} |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + |
| 99 | + <News lang={lang}/> |
| 100 | + |
| 101 | + <div className="wonder-of-u no-mobile"> |
| 102 | + <img src={wonder_of_u}/> |
| 103 | + </div> |
| 104 | + <div className="jjbmc-logo"> |
| 105 | + <img src={logo_image} alt="Logo"/> |
| 106 | + </div> |
| 107 | + </div> |
| 108 | + |
| 109 | + <div className="border"></div> |
| 110 | + <div className="underneath"> |
| 111 | + <Games heading={string.headings.mods}/> |
| 112 | + |
| 113 | + <div id="about-us" className="about-us"> |
| 114 | + <div className="about-us-content"> |
| 115 | + <h1>{string.headings.about}</h1> |
| 116 | + <img className="banner only-mobile" src={banner}></img> |
| 117 | + <img className="banner no-mobile" src={banner_long}></img> |
| 118 | + <Markdown className="markdown">{string.about}</Markdown> |
| 119 | + </div> |
| 120 | + </div> |
| 121 | + </div> |
| 122 | + |
| 123 | + <div className={`footer ${showFooter ? 'visible' : 'hidden'}`}><HashLink to={`${strings[lang].url}#top`}>{string.navbar.top}</HashLink></div> |
| 124 | + </> |
| 125 | + ); |
| 126 | +} |
| 127 | + |
| 128 | +function App() { |
| 129 | + return ( |
| 130 | + <Router> |
| 131 | + <Routes> |
| 132 | + <Route path={strings["en"].url} element={<Home lang="en"/>} /> |
| 133 | + <Route path={strings["es"].url} element={<Home lang="es"/>} /> |
| 134 | + <Route path={strings["pt-br"].url} element={<Home lang="pt-br"/>} /> |
| 135 | + <Route path={strings["ja"].url} element={<Home lang="ja"/>} /> |
| 136 | + <Route path="*" element={<><p>Error 404: This page does not exist.</p><br/><a href="/">Go back!</a></>}/> |
| 137 | + </Routes> |
| 138 | + </Router> |
| 139 | + ); |
| 140 | +} |
| 141 | + |
| 142 | +const root = ReactDOM.createRoot(document.getElementById('root')); |
| 143 | +root.render( |
| 144 | + <React.StrictMode> |
| 145 | + <App /> |
| 146 | + </React.StrictMode> |
| 147 | +); |
| 148 | + |
| 149 | +// If you want to start measuring performance in your app, pass a function |
| 150 | +// to log results (for example: reportWebVitals(console.log)) |
| 151 | +// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals |
| 152 | +reportWebVitals(); |
0 commit comments