1
0
Fork 0

feat(shared): Ported account/units to new inputs

This commit is contained in:
joostdecock 2023-08-25 16:54:00 +02:00
parent 17afc07302
commit cb531dcc62
5 changed files with 48 additions and 20 deletions

View file

@ -0,0 +1,5 @@
---
title: Account
---
FIXME

View file

@ -0,0 +1,11 @@
---
title: Language
---
This controls the **language** that will be used to generate your patterns,
as well send you emails and so on.
It is in other words a central language setting stored in your account.
It does not control the language of the website itself.
That setting -- just like the theme you prefer -- is stored on your device, not in our backend.

View file

@ -0,0 +1,11 @@
---
title: Units
---
FreeSewing support both **metric units** (cm) and **imperial units** (inch).
Here you can choose which type of units you prefer.
Note that you can override these default units in various places, such as on a
specific pattern or measurements set.

View file

@ -6,8 +6,10 @@ import { useAccount } from 'shared/hooks/use-account.mjs'
import { useBackend } from 'shared/hooks/use-backend.mjs' import { useBackend } from 'shared/hooks/use-backend.mjs'
import { useLoadingStatus } from 'shared/hooks/use-loading-status.mjs' import { useLoadingStatus } from 'shared/hooks/use-loading-status.mjs'
// Components // Components
import { Choice, Icons, welcomeSteps, BackToAccountButton } from './shared.mjs' import { Icons, welcomeSteps, BackToAccountButton, NumberBullet } from './shared.mjs'
import { ContinueButton } from 'shared/components/buttons/continue-button.mjs' import { ContinueButton } from 'shared/components/buttons/continue-button.mjs'
import { ListInput } from 'shared/components/inputs.mjs'
import { DynamicOrgDocs } from 'shared/components/dynamic-docs/org.mjs'
export const ns = ['account', 'status'] export const ns = ['account', 'status']
@ -16,7 +18,7 @@ export const ImperialSettings = ({ title = false, welcome = false }) => {
const { account, setAccount } = useAccount() const { account, setAccount } = useAccount()
const { setLoadingStatus, LoadingStatus } = useLoadingStatus() const { setLoadingStatus, LoadingStatus } = useLoadingStatus()
const backend = useBackend() const backend = useBackend()
const { t } = useTranslation(ns) const { t, i18n } = useTranslation(ns)
// State // State
const [selection, setSelection] = useState(account?.imperial === true ? 'imperial' : 'metric') const [selection, setSelection] = useState(account?.imperial === true ? 'imperial' : 'metric')
@ -43,23 +45,22 @@ export const ImperialSettings = ({ title = false, welcome = false }) => {
return ( return (
<div className="max-w-xl"> <div className="max-w-xl">
<LoadingStatus /> <LoadingStatus />
{title ? <h1 className="text-4xl">{t('unitsTitle')}</h1> : <h1></h1>} <ListInput
{['metric', 'imperial'].map((val) => ( label={t('unitsTitle')}
<Choice list={['metric', 'imperial'].map((val) => ({
val={val} val,
t={t} label: (
update={update} <div className="flex flex-row items-center w-full justify-between">
current={selection} <span>{t(`${val}Units`)}</span>
bool <NumberBullet nr={val === 'imperial' ? '″' : 'cm'} color="secondary" />
key={val} </div>
boolIcons={{ yes: <span>&quot;</span>, no: <span>cm</span> }} ),
> desc: t(`${val}Unitsd`),
<span className="block text-lg leading-5"> }))}
{selection === 1 && val === 2 ? t('showMore') : t(`${val}Units`)} current={selection}
</span> update={update}
<span className="block text-normal font-light normal-case pt-1">{t(`${val}Unitsd`)}</span> docs={<DynamicOrgDocs language={i18n.language} path={`site/account/units`} />}
</Choice> />
))}
{welcome ? ( {welcome ? (
<> <>
<ContinueButton btnProps={{ href: nextHref }} link /> <ContinueButton btnProps={{ href: nextHref }} link />

View file

@ -61,7 +61,7 @@ export const FormControl = ({
onClick={() => onClick={() =>
setModal( setModal(
<ModalWrapper flex="col" justify="top lg:justify-center" slideFrom="right"> <ModalWrapper flex="col" justify="top lg:justify-center" slideFrom="right">
{docs} <div className="mdx max-w-prose">{docs}</div>
</ModalWrapper> </ModalWrapper>
) )
} }