-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More themes and sites, added routing
- Loading branch information
Showing
8 changed files
with
219 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useNavigate, NavLink, Outlet } from 'react-router-dom'; | ||
import styles from './Home.module.css'; | ||
import NavBar from './NavBar'; | ||
import themes from './themes.json'; | ||
|
||
function Home() { | ||
const navigate = useNavigate(); | ||
window.document.body.style.backgroundColor = 'transparent'; | ||
window.document.body.style.color = 'black'; | ||
return ( | ||
<> | ||
<NavBar onNavigate={navigate}/> | ||
<div className={styles.home}> | ||
<Outlet /> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
function HomePage() { | ||
return ( | ||
<> | ||
<p>Chess No. 25 is a simple and open source chess game for two players.</p> | ||
<p>Chess No. 25 has multiple themes available. <NavLink to="/themes">Try them now!</NavLink></p> | ||
<p>If you found a bug or have an idea, please <a href="https://github.com/romw314/chess-no-25/issues/new/choose">report it on GitHub</a>.</p> | ||
</> | ||
); | ||
} | ||
|
||
function ThemesPage() { | ||
let themelist = []; | ||
for (const theme in themes.themes) | ||
themelist.push(<li><NavLink to={`/play/?theme=${theme}`}>{themes.themes[theme].fullName || theme}</NavLink></li>); | ||
return ( | ||
<> | ||
<p>Please choose a theme:</p> | ||
<ul>{themelist}</ul> | ||
</> | ||
); | ||
} | ||
|
||
export { HomePage, ThemesPage }; | ||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.home { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import AppBar from '@mui/material/AppBar'; | ||
import Box from '@mui/material/Box'; | ||
import Toolbar from '@mui/material/Toolbar'; | ||
import Typography from '@mui/material/Typography'; | ||
import Button from '@mui/material/Button'; | ||
import { createContext, useContext } from 'react'; | ||
|
||
const OnNavigateContext = createContext(); | ||
|
||
|
||
function NavButton({ to, href, children }) { | ||
const navigate = useContext(OnNavigateContext); | ||
return <Button color="inherit" onClick={to ? (() => navigate(to)) : (() => window.location.href = href)}>{children}</Button>; | ||
} | ||
|
||
function NavBar({ onNavigate, children }) { | ||
return ( | ||
<Box sx={{ flexGrow: 1 }}> | ||
<AppBar position="sticky"> | ||
<Toolbar> | ||
<Typography variant="h6" component="div" sx={{ flexGrow: 1 }}> | ||
Chess No. 25 | ||
</Typography> | ||
<OnNavigateContext.Provider value={onNavigate}> | ||
{children} | ||
</OnNavigateContext.Provider> | ||
</Toolbar> | ||
</AppBar> | ||
</Box> | ||
); | ||
} | ||
|
||
function ChessNavBar({ onNavigate }) { | ||
return ( | ||
<NavBar onNavigate={onNavigate}> | ||
<NavButton to="/">Home</NavButton> | ||
<NavButton to="/themes">Themes</NavButton> | ||
<NavButton to="/play">Play</NavButton> | ||
<NavButton href="https://github.com/romw314/chess-no-25">GitHub</NavButton> | ||
</NavBar> | ||
); | ||
}; | ||
|
||
export default ChessNavBar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters