1
0
Fork 0

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

This commit is contained in:
joostdecock 2023-08-25 17:59:47 +02:00
parent d568f42556
commit bef5d13c2e
3 changed files with 29 additions and 25 deletions

View file

@ -0,0 +1,9 @@
---
title: Bio
---
Your account **bio** is the place where you can tell a little bit about yourself.
Other FreeSewing users can see your bio, so this is a way to find like-minded people or promote your own content.
This field supports Markdown, so you can add links and even images.

View file

@ -11,6 +11,9 @@ import { Icons, welcomeSteps, BackToAccountButton } from './shared.mjs'
import { Popout } from 'shared/components/popout/index.mjs' import { Popout } from 'shared/components/popout/index.mjs'
import { SaveSettingsButton } from 'shared/components/buttons/save-settings-button.mjs' import { SaveSettingsButton } from 'shared/components/buttons/save-settings-button.mjs'
import { ContinueButton } from 'shared/components/buttons/continue-button.mjs' import { ContinueButton } from 'shared/components/buttons/continue-button.mjs'
import { MarkdownInput } from 'shared/components/inputs.mjs'
import { DynamicOrgDocs } from 'shared/components/dynamic-docs/org.mjs'
import { TipIcon } from 'shared/components/icons.mjs'
export const ns = ['account', 'status'] export const ns = ['account', 'status']
@ -28,7 +31,7 @@ export const BioSettings = ({ title = false, welcome = false }) => {
// Hooks // Hooks
const { account, setAccount } = useAccount() const { account, setAccount } = useAccount()
const backend = useBackend() const backend = useBackend()
const { t } = useTranslation(ns) const { t, i18n } = useTranslation(ns)
const { setLoadingStatus, LoadingStatus } = useLoadingStatus() const { setLoadingStatus, LoadingStatus } = useLoadingStatus()
// State // State
@ -57,31 +60,21 @@ export const BioSettings = ({ title = false, welcome = false }) => {
return ( return (
<div className="max-w-xl xl:pl-4"> <div className="max-w-xl xl:pl-4">
<LoadingStatus /> <LoadingStatus />
{title ? <h1 className="text-4xl">{t('bioTitle')}</h1> : null} <MarkdownInput
<div className="tabs w-full"> label={t('bioTitle')}
<Tab id="edit" {...tabProps} /> update={setBio}
<Tab id="preview" {...tabProps} /> current={bio}
</div> placeholder={t('bioTitle')}
<div className="flex flex-row items-center mt-4"> docs={<DynamicOrgDocs language={i18n.language} path={`site/account/bio`} />}
{activeTab === 'edit' ? ( labelBL={
<textarea <span className="flex flex-row items-center gap-1">
rows="5" <TipIcon className="w-6 h-6 text-success" />
className="textarea textarea-bordered textarea-lg w-full" {t('mdSupport')}
placeholder={t('placeholder')} </span>
onChange={(evt) => setBio(evt.target.value)} }
value={bio} />
/>
) : (
<div className="text-left px-4 border w-full">
<Markdown>{bio}</Markdown>
</div>
)}
</div>
<SaveSettingsButton btnProps={{ onClick: save }} welcome={welcome} /> <SaveSettingsButton btnProps={{ onClick: save }} welcome={welcome} />
{!welcome && <BackToAccountButton />} {!welcome && <BackToAccountButton />}
<Popout tip compact>
{t('mdSupport')}
</Popout>
{welcome ? ( {welcome ? (
<> <>

View file

@ -417,11 +417,13 @@ export const MarkdownInput = ({
placeholder, // The placeholder content placeholder, // The placeholder content
docs = false, // Docs to load, if any docs = false, // Docs to load, if any
id = '', // An id to tie the input to the label id = '', // An id to tie the input to the label
labelBL = false, // Bottom-Left label
labelBR = false, // Bottom-Right label
}) => { }) => {
const [activeTab, setActiveTab] = useState('edit') const [activeTab, setActiveTab] = useState('edit')
return ( return (
<FormControl label={label} docs={docs} forId={id}> <FormControl {...{ label, labelBL, labelBR, docs }} forId={id}>
<div className="tabs w-full"> <div className="tabs w-full">
{['edit', 'preview'].map((tab) => ( {['edit', 'preview'].map((tab) => (
<Tab id={tab} key={tab} label={tab} {...{ activeTab, setActiveTab }} /> <Tab id={tab} key={tab} label={tab} {...{ activeTab, setActiveTab }} />