2022-05-14 14:13:35 +02:00
|
|
|
import Page from 'site/components/wrappers/page.js'
|
2022-01-22 17:55:03 +01:00
|
|
|
import useApp from 'site/hooks/useApp.js'
|
|
|
|
import Link from 'next/link'
|
2022-02-06 19:16:49 +01:00
|
|
|
import { useTranslation } from 'next-i18next'
|
2022-05-14 14:13:35 +02:00
|
|
|
import Layout from 'site/components/layouts/bare'
|
2022-07-15 16:30:40 -04:00
|
|
|
import { PageTitle } from 'shared/components/layouts/default'
|
2022-01-22 17:55:03 +01:00
|
|
|
|
2022-08-29 17:44:50 +02:00
|
|
|
const DesignLinks = ({ list, prefix='' }) => {
|
2022-05-14 15:43:52 +02:00
|
|
|
const { t } = useTranslation(['patterns'])
|
2022-06-22 13:54:53 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<ul className="flex flex-col flex-wrap gap-2">
|
|
|
|
{list.map( d => (
|
|
|
|
<li key={d} className="p-2">
|
|
|
|
<Link href={`${prefix}/${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>
|
|
|
|
)
|
2022-05-14 15:43:52 +02:00
|
|
|
}
|
|
|
|
|
2022-08-29 17:44:50 +02:00
|
|
|
const PatternListPageTemplate = ({ section=false }) => {
|
2022-01-22 17:55:03 +01:00
|
|
|
const app = useApp()
|
2022-05-14 15:43:52 +02:00
|
|
|
const { t } = useTranslation(['app'])
|
2022-05-14 14:13:35 +02:00
|
|
|
|
2022-05-14 15:43:52 +02:00
|
|
|
const title = section
|
|
|
|
? app.navigation[section].__title
|
|
|
|
: t('designs')
|
2022-01-25 09:03:06 +01:00
|
|
|
|
2022-08-29 17:44:50 +02:00
|
|
|
const sectionDesigns = (section=false) => {
|
2022-06-22 13:54:53 +02:00
|
|
|
if (!section) {
|
|
|
|
const all = []
|
2022-08-29 17:44:50 +02:00
|
|
|
for (const section in app.designs) all.push(...app.designs[section])
|
|
|
|
return all
|
2022-09-14 15:02:39 +02:00
|
|
|
}
|
2022-06-22 13:54:53 +02:00
|
|
|
|
2022-09-14 15:02:39 +02:00
|
|
|
return app.designs[section]
|
2022-06-22 13:54:53 +02:00
|
|
|
}
|
2022-05-31 15:31:29 -04:00
|
|
|
|
2022-01-22 17:55:03 +01:00
|
|
|
return (
|
2022-08-29 17:44:50 +02:00
|
|
|
<Page app={app} title={`FreeSewing Lab: ${title}`} layout={Layout}>
|
2022-05-14 14:13:35 +02:00
|
|
|
<div className="max-w-7xl m-auto py-20 md:py-36 min-h-screen">
|
|
|
|
<section className="px-8">
|
2022-05-31 15:31:29 -04:00
|
|
|
<PageTitle app={app} slug={section ? app.navigation[section].__slug : '/' } title={title} />
|
2022-08-29 17:44:50 +02:00
|
|
|
<DesignLinks list={sectionDesigns(section)} />
|
2022-05-14 14:13:35 +02:00
|
|
|
</section>
|
2022-01-22 17:55:03 +01:00
|
|
|
</div>
|
|
|
|
</Page>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-01-24 12:34:29 +01:00
|
|
|
export default PatternListPageTemplate
|
2022-05-14 15:43:52 +02:00
|
|
|
|
|
|
|
|