mirror of
https://github.com/He4eT/elseifplayer.git
synced 2026-05-05 01:17:22 +00:00
Add GameEntry component
This commit is contained in:
parent
a7603a4cf8
commit
9e4e101495
5 changed files with 96 additions and 5 deletions
22
src/components/GameEntry/GameEntry.jsx
Normal file
22
src/components/GameEntry/GameEntry.jsx
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { h } from 'preact'
|
||||||
|
import { Link } from 'wouter-preact'
|
||||||
|
|
||||||
|
import {
|
||||||
|
buildPlayLinkHref
|
||||||
|
} from '~/src/utils/utils.routing'
|
||||||
|
|
||||||
|
export default ({ name, ifdb, url, theme }) => (
|
||||||
|
<div>
|
||||||
|
<h4>{name}</h4>
|
||||||
|
<a
|
||||||
|
target='_blank'
|
||||||
|
href={ifdb}>
|
||||||
|
IFDB page
|
||||||
|
</a>
|
||||||
|
<span> | </span>
|
||||||
|
<Link
|
||||||
|
href={buildPlayLinkHref({ url, theme })}>
|
||||||
|
Play
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
10
src/index.js
10
src/index.js
|
|
@ -10,6 +10,7 @@ import {
|
||||||
} from '~/src/themes/themes'
|
} from '~/src/themes/themes'
|
||||||
|
|
||||||
import HomeView from '~/src/views/HomeView'
|
import HomeView from '~/src/views/HomeView'
|
||||||
|
import GamesView from '~/src/views/GamesView'
|
||||||
import PlayerView from '~/src/views/PlayerView'
|
import PlayerView from '~/src/views/PlayerView'
|
||||||
import NotFoundView from '~/src/views/NotFoundView'
|
import NotFoundView from '~/src/views/NotFoundView'
|
||||||
|
|
||||||
|
|
@ -33,15 +34,18 @@ function App () {
|
||||||
themeEngine
|
themeEngine
|
||||||
}} />
|
}} />
|
||||||
</Route>
|
</Route>
|
||||||
|
<Route path='/games/:theme'>
|
||||||
|
{params => <GamesView {...{
|
||||||
|
...themeEngine,
|
||||||
|
...params
|
||||||
|
}} />}
|
||||||
|
</Route>
|
||||||
<Route path='/play/:theme/:encodedUrl'>
|
<Route path='/play/:theme/:encodedUrl'>
|
||||||
{params => <PlayerView {...{
|
{params => <PlayerView {...{
|
||||||
...themeEngine,
|
...themeEngine,
|
||||||
...params
|
...params
|
||||||
}} />}
|
}} />}
|
||||||
</Route>
|
</Route>
|
||||||
<Route path='/top100'>
|
|
||||||
top100
|
|
||||||
</Route>
|
|
||||||
<Route>
|
<Route>
|
||||||
<NotFoundView />
|
<NotFoundView />
|
||||||
</Route>
|
</Route>
|
||||||
|
|
|
||||||
58
src/views/GamesView.jsx
Normal file
58
src/views/GamesView.jsx
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
import { h } from 'preact'
|
||||||
|
import { useEffect } from 'preact/hooks'
|
||||||
|
import { Link } from 'wouter-preact'
|
||||||
|
|
||||||
|
import GameEntry from
|
||||||
|
'~/src/components/GameEntry/GameEntry'
|
||||||
|
|
||||||
|
import './style/GamesView.css'
|
||||||
|
|
||||||
|
const tutorialGame = {
|
||||||
|
name: 'The Dreamhold',
|
||||||
|
ifdb: 'https://ifdb.org/viewgame?id=3myqnrs64nbtwdaz',
|
||||||
|
url: 'http://mirror.ifarchive.org/if-archive/games/zcode/dreamhold.z8'
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function ({ setTheme, theme }) {
|
||||||
|
useEffect(() => setTheme(theme), [theme])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<main className='view games'>
|
||||||
|
|
||||||
|
<h1>
|
||||||
|
<a
|
||||||
|
target='_blank'
|
||||||
|
href='https://ifdb.org/'
|
||||||
|
title='The Interactive Fiction Database'>
|
||||||
|
IFDB
|
||||||
|
</a> games
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Choose one or <Link href='/'>
|
||||||
|
go back
|
||||||
|
</Link>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>
|
||||||
|
Tutorial
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If you are not familiar with Interactive Fiction,
|
||||||
|
you should start with this tutorial game
|
||||||
|
by Andrew Plotkin.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<GameEntry {...{
|
||||||
|
...tutorialGame,
|
||||||
|
theme
|
||||||
|
}} />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</main>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -64,8 +64,8 @@ export default function ({ themeEngine }) {
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<Link href='/top100'>
|
<Link href={`/games/${themeEngine.currentTheme}`}>
|
||||||
IFDB Top 100 games
|
IFDB games
|
||||||
</Link>
|
</Link>
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
||||||
7
src/views/style/GamesView.css
Normal file
7
src/views/style/GamesView.css
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
.app > .view.games {
|
||||||
|
padding: var(--inner-padding);
|
||||||
|
}
|
||||||
|
|
||||||
|
h4 {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue