Switch to vite and preact

This commit is contained in:
Misode
2021-06-23 20:44:28 +02:00
parent e551b7ef75
commit 09c851914f
89 changed files with 6398 additions and 15531 deletions

38
src/app/pages/Home.tsx Normal file
View File

@@ -0,0 +1,38 @@
import { Link } from 'preact-router'
import config from '../../config.json'
import { Octicon } from '../components/Octicon'
import { locale } from '../Locales'
import { cleanUrl } from '../Utils'
type HomeProps = {
lang: string,
changeTitle: (title: string) => unknown,
path?: string,
category?: string,
}
export function Home({ lang, changeTitle, category }: HomeProps) {
const loc = locale.bind(null, lang)
changeTitle(category ? loc('title.generator_category', loc(category)) : loc('title.home'))
return <main>
<div class="home">
<div class="generator-picker">
<ul class="generators-list">
{config.models.filter(m => typeof m.category !== 'string').map(m => <li>
<Link class={`generators-card${m.category === true && m.id === category ? ' selected' : ''}`} href={cleanUrl(m.id)}>
{loc(m.id)}
{m.category && Octicon.chevron_right}
</Link>
</li>)}
</ul>
{(category && config.models.some(m => m.category === category)) &&
<ul class="generators-list">
{config.models.filter(m => m.category === category).map(m => <li>
<Link class="generators-card" href={cleanUrl(m.id)}>
{loc(m.id)}
</Link>
</li>)}
</ul>}
</div>
</div>
</main>
}