wip: Updates to lab to support v3 patterns
This commit is contained in:
parent
d59bab6a6c
commit
a023f1810c
19 changed files with 101 additions and 155 deletions
|
@ -2,12 +2,10 @@ import Page from 'site/components/wrappers/page.js'
|
|||
import useApp from 'site/hooks/useApp.js'
|
||||
import Link from 'next/link'
|
||||
import { useTranslation } from 'next-i18next'
|
||||
import { formatVersionTitle } from 'site/components/version-picker.js'
|
||||
import Layout from 'site/components/layouts/bare'
|
||||
import { PageTitle } from 'shared/components/layouts/default'
|
||||
import availableVersions from 'site/available-versions.json'
|
||||
|
||||
const DesignLinks = ({ list, prefix='', version=false }) => {
|
||||
const DesignLinks = ({ list, prefix='' }) => {
|
||||
const { t } = useTranslation(['patterns'])
|
||||
|
||||
return (
|
||||
|
@ -27,7 +25,7 @@ const DesignLinks = ({ list, prefix='', version=false }) => {
|
|||
)
|
||||
}
|
||||
|
||||
const PatternListPageTemplate = ({ section=false, version=false }) => {
|
||||
const PatternListPageTemplate = ({ section=false }) => {
|
||||
const app = useApp()
|
||||
const { t } = useTranslation(['app'])
|
||||
|
||||
|
@ -35,45 +33,22 @@ const PatternListPageTemplate = ({ section=false, version=false }) => {
|
|||
? app.navigation[section].__title
|
||||
: t('designs')
|
||||
|
||||
const sectionDesigns = (section=false, version=false) => {
|
||||
const sectionDesigns = (section=false) => {
|
||||
if (!section) {
|
||||
const all = []
|
||||
if (!version || version === 'next') {
|
||||
for (const section in app.designs) all.push(...app.designs[section])
|
||||
return all
|
||||
}
|
||||
else if (availableVersions[version]) return availableVersions[version]
|
||||
} else {
|
||||
if (!version || version === 'next') return app.designs[section]
|
||||
else if (availableVersions[version]) return availableVersions[version]
|
||||
}
|
||||
for (const section in app.designs) all.push(...app.designs[section])
|
||||
return all
|
||||
} else return app.designs[section]
|
||||
|
||||
return []
|
||||
}
|
||||
|
||||
return (
|
||||
<Page app={app} title={`FreeSewing Lab: ${formatVersionTitle(version)}`} layout={Layout}>
|
||||
<Page app={app} title={`FreeSewing Lab: ${title}`} layout={Layout}>
|
||||
<div className="max-w-7xl m-auto py-20 md:py-36 min-h-screen">
|
||||
<section className="px-8">
|
||||
<PageTitle app={app} slug={section ? app.navigation[section].__slug : '/' } title={title} />
|
||||
{version && version !== 'next'
|
||||
? (
|
||||
<ul className="flex flex-col flex-wrap gap-2">
|
||||
{availableVersions[version].map( d => (
|
||||
<li key={d} className="p-2">
|
||||
<Link href={`/v/${version}/${d}`}>
|
||||
<a className="capitalize text-xl p-4 font-bold text-secondary hover:text-secondary-focus hover:underline">
|
||||
{t(`patterns:${d}.t`)}
|
||||
<br />
|
||||
<span className="text-lg font-normal p-4 text-base-content">{t(`patterns:${d}.d`)}</span>
|
||||
</a>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
: <DesignLinks list={sectionDesigns(section)} />
|
||||
}
|
||||
<DesignLinks list={sectionDesigns(section)} />
|
||||
</section>
|
||||
</div>
|
||||
</Page>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue