1
0
Fork 0
freesewing/sites/org/pages/index.mjs

163 lines
5.8 KiB
JavaScript
Raw Normal View History

// Dependencies
2022-05-25 18:35:20 +02:00
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { nsMerge } from 'shared/utils.mjs'
// Hooks
import { useTranslation } from 'next-i18next'
2023-07-28 20:28:27 +02:00
import { useAccount } from 'shared/hooks/use-account.mjs'
import { useEffect, useState } from 'react'
// Components
import Head from 'next/head'
import { PageWrapper, ns as pageNs } from 'shared/components/wrappers/page.mjs'
import { BareLayout } from 'site/components/layouts/bare.mjs'
import { ForceAccountCheck } from 'shared/components/account/force-account-check.mjs'
2023-08-01 16:15:11 +02:00
import {
OkIcon,
NoIcon,
2023-08-01 16:15:11 +02:00
DesignIcon,
ShowcaseIcon,
DocsIcon,
HelpIcon,
ChatIcon,
} from 'shared/components/icons.mjs'
2023-07-28 20:28:27 +02:00
import { HowDoesItWorkAnimation } from 'shared/components/animations/how-does-it-work.mjs'
2023-08-28 14:28:07 +02:00
import { SignUp, ns as susiNs } from 'shared/components/susi/sign-up.mjs'
import { PleaseSubscribe, ns as subNs } from 'shared/components/patrons/please-subscribe.mjs'
2023-09-04 17:12:52 +02:00
import { Link, CardLink } from 'shared/components/link.mjs'
2023-08-28 14:28:07 +02:00
const ns = nsMerge(pageNs, subNs, susiNs, 'homepage')
const Card = ({ bg = 'bg-base-200', textColor = 'text-base-content', title, children, icon }) => (
<div className={`px-8 ${bg} py-10 rounded-lg block ${textColor} shadow-lg grow`}>
<h2 className="mb-4 text-inherit flex flex-row gap-4 justify-between items-center font-medium">
{title}
{icon}
</h2>
{children}
</div>
)
/*
* Each page MUST be wrapped in the PageWrapper component.
* You also MUST spread props.page into this wrapper component
* when path and locale come from static props (as here)
* or set them manually.
*/
const HomePage = ({ page }) => {
const { t } = useTranslation(ns)
2023-07-28 20:28:27 +02:00
const { account } = useAccount()
const [user, setUser] = useState(false)
useEffect(() => {
// Do this here to avoid hydration issues
if (account.username) setUser(account.username)
}, [account.username])
return (
<PageWrapper {...page} layout={BareLayout}>
<ForceAccountCheck />
<Head>
2023-07-28 20:28:27 +02:00
<title>FreeSewing.org</title>
</Head>
2023-07-29 21:06:08 +02:00
<div className="max-w-7xl m-auto px-0 -mt-12 mb-24 md:my-24">
2023-08-29 12:19:47 +02:00
<div className="text-center mt-20 md:mt-20">
<HowDoesItWorkAnimation t={t} />
2023-07-29 21:01:26 +02:00
</div>
2023-07-30 15:55:11 +02:00
<div className="flex flex-col gap-8 md:grid md:grid-cols-2 md:gap-4 mt-12 md:mt-20 md:px-4">
<Card
title={t('whatIsFreeSewing')}
icon={<OkIcon className="w-12 h-12 text-success" stroke={4} />}
>
<p className="font-medium text-lg">{t('homepage:what1')}</p>
<p className="font-medium text-lg">{t('homepage:what3')}</p>
</Card>
<Card
title={t('whatIsFreeSewingNot')}
icon={<NoIcon className="w-12 h-12 text-error" stroke={3} />}
>
<p className="font-medium text-lg">{t('homepage:whatNot1')}</p>
<p className="font-medium text-lg">{t('homepage:whatNot2')}</p>
</Card>
2023-07-28 20:28:27 +02:00
</div>
2023-08-29 18:20:03 +02:00
{!user && (
<div className="p-1 bg-primary bg-opacity-10 mt-12 rounded-none md:rounded-lg lg:rounded-xl md:shadow-lg md:mx-4 p-8 lg:px-12 md:py-0">
<div className="flex flex-col md:gap-8 lg:gap-12 md:flex md:flex-row m-auto">
<div className="-mx-4 md:mx-0 md:pt-8 pb-8 lg:py-12 grow m-auto max-w-prose">
<SignUp />
</div>
<div className="-mx-4 md:mx-0 md:mt-0 pt-0 md:pt-8 pb-8 lg:py-12 max-w-prose m-auto m-auto">
<h2 className="text-inherit mb-4 hidden md:block">{t('homepage:whyBother')}</h2>
<ul>
{[1, 2, 3, 4].map((i) => (
<li className="flex flex-row gap-2 my-2" key={i}>
<OkIcon stroke={4} /> {t(`homepage:why${i}`)}
</li>
))}
</ul>
</div>
2023-08-29 12:19:47 +02:00
</div>
</div>
2023-08-29 18:20:03 +02:00
)}
</div>
2023-07-30 14:21:39 +02:00
2023-08-01 16:15:11 +02:00
<div className="flex flex-col md:grid md:grid-cols-2 gap-4 max-w-7xl m-auto mb-24 px-4">
<CardLink
2023-08-01 16:17:08 +02:00
href="/designs"
2023-08-01 16:15:11 +02:00
title="Designs"
icon={<DesignIcon className="w-10 h-10 shrink-0" />}
2023-08-01 16:15:11 +02:00
text="Browse our collection of designs, and turn them into sewing patterns that are made-to-measure just for you."
/>
<CardLink
2023-08-01 16:17:08 +02:00
href="/showcase"
2023-08-01 16:15:11 +02:00
title="Showcase"
icon={<ShowcaseIcon className="w-10 h-10 shrink-0" />}
2023-08-01 16:15:11 +02:00
text="Get inspiration from the FreeSewing community, and see how others have applied their creativity to our designs."
/>
<CardLink
2023-08-01 16:17:08 +02:00
href="/docs/guide"
2023-08-01 16:15:11 +02:00
title="Getting Started"
icon={<DocsIcon className="w-10 h-10 shrink-0" />}
2023-08-01 16:15:11 +02:00
text="FreeSewing.org is unlike any sewing pattern website you know. Read this short guide to get the most our of our platform."
/>
<CardLink
2023-08-01 16:17:08 +02:00
href="/docs/faq"
2023-08-01 16:15:11 +02:00
title="Frequently Asked Questions"
icon={<HelpIcon className="w-10 h-10 shrink-0" />}
2023-08-01 16:15:11 +02:00
text="Some of the questions that come up often when people discover our platform are answered here."
/>
</div>
2023-08-29 12:19:47 +02:00
<div className="lg:px-4 max-w-7xl mx-auto">
<PleaseSubscribe />
</div>
2023-08-01 16:15:11 +02:00
<div className="max-w-7xl m-auto mb-24 px-4">
<div className="w-full lg:w-1/2 m-auto">
<CardLink
2023-08-01 16:17:08 +02:00
href="/support"
2023-08-01 16:15:11 +02:00
title="Need Help?"
icon={<ChatIcon className="w-10 h-10 shrink-0" />}
2023-08-01 16:15:11 +02:00
text="While we are all volunteers, we have a good track record of helping people. So don't be shy to reach out."
/>
</div>
</div>
</PageWrapper>
)
}
export default HomePage
2022-05-25 18:35:20 +02:00
export async function getStaticProps({ locale }) {
return {
props: {
2023-07-28 20:28:27 +02:00
...(await serverSideTranslations(locale, ns)),
2023-03-26 16:50:46 +02:00
page: {
locale,
2023-03-26 16:50:46 +02:00
path: [],
},
2022-12-03 11:25:02 -06:00
},
2022-05-25 18:35:20 +02:00
}
}