Compare commits

..

7 Commits

Author SHA1 Message Date
Amiram_se dc221f50bf chore(apps): run bull on 7000 and bear on 7001; ignore server-proxy.js
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:33:12 +04:00
Amiram_se 0d2528d66f docs(decisions): propose 0014, registration step 5 on the session
Step 5 runs under (onboarding) behind AuthGuard; a creator's profile
autosaves as a server draft and completes only through
POST /traders/me/profile/complete.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:33:00 +04:00
Amiram_se a6e6eddc94 feat(apps): registration step 5 pages in bull and bear
Add /onboarding/creator-profile and /onboarding/investor-profile to both
apps, with the group's loading skeleton. Each page renders its frame on the
server and its step only in the browser behind AuthGuard for its role, with
noindex. bull uses the mobile top bar and column; bear the desktop header,
with the creator's form card beside its live preview (AuthTemplate
`framed={false}`) and the investor in the 560 card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:33:00 +04:00
Amiram_se 436695ae0b feat(market): registration step 5, profile completion
Creator (required, resumable) and investor (optional) profile steps, on the
session after registration step 4.

- Profile repository: `saveDraft` (PATCH /traders/me/profile, markets may be
  empty) and `complete` (POST /traders/me/profile/complete).
- Account repository: avatar upload and removal, `interests`; the account
  payload carries `avatarUrl` and `interests`.
- Actions: completeCreatorProfile (saves the form, then completes; emits
  `profile.complete`) and saveInvestorProfile (photo with progress, then
  markets; emits `auth.profile-saved`).
- Creator models: the page (form from the saved draft, links field array,
  submit), autosave (1 s after typing and on blur, one save at a time, never
  after completion), the photo part (uploads on pick, failed state with retry)
  and the live preview.
- Investor model: photo and markets saved on «ذخیره و ورود», «بعداً» skips;
  both land on ?redirect= or home with the welcome toast.
- The auth-flow store remembers the role registered in this tab, so step 5
  shows the resume banner only after a login or a reload.
- Validations: photo, bio, link rows per platform, markets, consent.
  Utils: social link handle and URL mapping, market toggle. PROFILE_LIMITS
  moves to shared/validations.
- Screens: CreatorProfileStep (mobile column with a preview sheet, desktop
  card beside a sticky preview, end-of-registration view) with its skeleton,
  and InvestorProfileStep.
- Copy for step 5 in the auth namespace; market and status labels in common.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:33:00 +04:00
Amiram_se 9216bc8177 feat(island,tools): form pieces for the profile step
- Atoms: Chip (toggle with aria-pressed), Checkbox, FieldError (alert line
  under a group), LinkButton (a button that looks like a link; SupportLink now
  uses it), RowButton (56px choice row for sheets), and a 96px Avatar size.
- Molecules: ChipGroup (named fieldset of chips with its error), FormSection
  (titled form part with an optional marker and hint), AvatarField (photo
  pick, change, remove, upload progress, failed state with retry).
- Dialog, Sheet and Modal take `onExited`, called once the dialog has left
  the top layer. The page is inert until then, so focus moves there.
- tools/format: `time()` for a time of day in Tehran (`14:05`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:32:43 +04:00
Amiram_se f5e0ffb668 chore(lint): check ARIA roles on DOM elements only
AuthGuard and RegisterProgress take the account type as a `role` prop
(`role="creator"`), which jsx-a11y/aria-role read as an invalid ARIA role.
`ignoreNonDOM` keeps the rule for real elements.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:32:43 +04:00
Amiram_se 02e543d95d refactor(market,apps): share the registration frame with onboarding
Registration step 5 lives under (onboarding), so the pieces both route groups
use move to the nearest level they share. No behavior change.

- SupportEntry and RegisterProgress move from screens/(auth) to
  screens/organisms.
- bull's AuthTopBar and both apps' AuthTemplate move from the (auth) group to
  the app root's organisms/ and templates/.
- MARKETS and Market move from the profile feature to shared/constants, so
  features other than profile (the investor's interests) can use them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:32:05 +04:00
164 changed files with 3399 additions and 158 deletions

1
.gitignore vendored
View File

@ -29,6 +29,7 @@ next-env.d.ts
# Fonts and icon sprite, written by island's font-copy and icon-sprite plugins on next dev and next build (0012)
apps/*/public/icons/
apps/*/public/fonts/
server-proxy.js
# Testing
coverage

View File

@ -12,7 +12,9 @@
"categories": {
"correctness": "error"
},
"rules": {},
"rules": {
"jsx-a11y/aria-role": ["error", { "ignoreNonDOM": true }]
},
"env": {
"builtin": true,
"browser": true,

View File

@ -20,12 +20,12 @@
},
"dev": {
"options": {
"command": "next dev --port 3002"
"command": "next dev --port 7001"
}
},
"start": {
"options": {
"command": "next start --port 3002"
"command": "next start --port 7001"
}
}
}

View File

@ -4,7 +4,7 @@ import { LoginStep } from '@lumina/market/app/screens/(auth)/auth/login/organism
import type { Metadata } from 'next';
import { i18n } from '../../../../i18n';
import { AuthTemplate } from '../../templates/auth-template';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return { title: i18n.t('auth:login.meta-title'), robots: { index: false } };

View File

@ -4,7 +4,7 @@ import { LoginVerifyStep } from '@lumina/market/app/screens/(auth)/auth/login/ve
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -4,7 +4,7 @@ import { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/regi
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -4,7 +4,7 @@ import { RegisterTypeStep } from '@lumina/market/app/screens/(auth)/auth/registe
import type { Metadata } from 'next';
import { i18n } from '../../../../i18n';
import { AuthTemplate } from '../../templates/auth-template';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -4,7 +4,7 @@ import { RegisterPhoneStep } from '@lumina/market/app/screens/(auth)/auth/regist
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -4,7 +4,7 @@ import { RegisterVerifyStep } from '@lumina/market/app/screens/(auth)/auth/regis
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -1,7 +1,7 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { i18n } from '../../i18n';
import { AuthTemplate } from './templates/auth-template';
import { AuthTemplate } from '../templates/auth-template';
/** Login and registration, before their frame arrives: the header, the card and a form step's shape. */
export default function AuthLoading() {

View File

@ -0,0 +1,13 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { i18n } from '../../i18n';
import { AuthTemplate } from '../templates/auth-template';
/** Registration's last steps, before their frame arrives: the header, the card and a form step's shape. */
export default function OnboardingLoading() {
return (
<AuthTemplate width="wide">
<SkeletonPreset preset="form" delayed label={i18n.t('auth:loading')} />
</AuthTemplate>
);
}

View File

@ -0,0 +1,43 @@
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import {
CreatorProfileStep,
CreatorProfileStepSkeleton,
} from '@lumina/market/app/screens/(onboarding)/onboarding/creator-profile/organisms/creator-profile-step';
import type { Metadata } from 'next';
import { Suspense } from 'react';
import { i18n } from '../../../../i18n';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {
title: i18n.t('auth:register.profile.meta-title'),
robots: { index: false },
};
}
/**
* Registration step 5 for a creator, on the session: the form card beside its live preview. The
* frame renders on the server; the step only in the browser, behind the same-size skeleton.
*/
export default function CreatorProfilePage() {
const skeleton = (
<CreatorProfileStepSkeleton
layout="desktop"
label={i18n.t('auth:loading')}
/>
);
return (
<AuthTemplate framed={false}>
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<CreatorProfileStep
size="md"
layout="desktop"
supportPlacement="popover"
/>
</Suspense>
</AuthGuard>
</AuthTemplate>
);
}

View File

@ -0,0 +1,37 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import { InvestorProfileStep } from '@lumina/market/app/screens/(onboarding)/onboarding/investor-profile/organisms/investor-profile-step';
import type { Metadata } from 'next';
import { i18n } from '../../../../i18n';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {
title: i18n.t('auth:register.profile.meta-title'),
robots: { index: false },
};
}
/**
* Registration step 5 for an investor, optional, on the session, in the 560 card. The frame
* renders on the server; the step only in the browser, for the signed-in investor.
*/
export default function InvestorProfilePage() {
return (
<AuthTemplate width="wide">
<AuthGuard
role="investor"
fallback={
<SkeletonPreset
preset="form"
count={2}
label={i18n.t('auth:loading')}
/>
}
>
<InvestorProfileStep size="md" supportPlacement="popover" />
</AuthGuard>
</AuthTemplate>
);
}

View File

@ -3,19 +3,21 @@ import { Typography } from '@lumina/island/atoms/typography';
import { Card } from '@lumina/island/molecules/card';
import { cn } from '@lumina/island/tools/cn';
import { ROUTES } from '@lumina/market/app/navigation';
import { SupportEntry } from '@lumina/market/app/screens/(auth)/organisms/support-entry';
import { SupportEntry } from '@lumina/market/app/screens/organisms/support-entry';
import NextLink from 'next/link';
import { i18n } from '../../../../i18n';
import { i18n } from '../../../i18n';
import type { AuthTemplateProps } from './types';
/**
* Login and registration on desktop: the logged-out header (the brand and support) and each
* step in one centred card, its buttons inside the card under the fields. Browser back is the
* step in one centred card, its buttons inside the card under the fields. Registration step 5
* keeps the header, signed in: there is no nav until registration is complete. Browser back is the
* way back; there is no back button.
*/
export function AuthTemplate({
width = 'narrow',
framed = true,
children,
}: AuthTemplateProps) {
return (
@ -43,15 +45,19 @@ export function AuthTemplate({
justifyContent="justify-center"
className="px-4 pt-28 pb-16"
>
<Card
padding="none"
className={cn(
'w-full p-10',
width === 'wide' ? 'max-w-form' : 'max-w-checkout',
)}
>
{children}
</Card>
{framed ? (
<Card
padding="none"
className={cn(
'w-full p-10',
width === 'wide' ? 'max-w-form' : 'max-w-checkout',
)}
>
{children}
</Card>
) : (
children
)}
</FlexBox>
</FlexBox>
);

View File

@ -3,5 +3,10 @@ import type { ReactNode } from 'react';
export type AuthTemplateProps = {
/** narrow (480): the number and the code. wide (560): the account type and step 4. */
width?: 'narrow' | 'wide';
/**
* false: no card; the step draws its own, such as registration step 5's form card beside its
* live preview.
*/
framed?: boolean;
children: ReactNode;
};

View File

@ -20,12 +20,12 @@
},
"dev": {
"options": {
"command": "next dev --port 3001"
"command": "next dev --port 7000"
}
},
"start": {
"options": {
"command": "next start --port 3001"
"command": "next start --port 7000"
}
}
}

View File

@ -4,8 +4,8 @@ import { LoginStep } from '@lumina/market/app/screens/(auth)/auth/login/organism
import type { Metadata } from 'next';
import { i18n } from '../../../../i18n';
import { AuthTopBar } from '../../organisms/auth-top-bar';
import { AuthTemplate } from '../../templates/auth-template';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return { title: i18n.t('auth:login.meta-title'), robots: { index: false } };

View File

@ -5,8 +5,8 @@ import { LoginVerifyStep } from '@lumina/market/app/screens/(auth)/auth/login/ve
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTopBar } from '../../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -4,8 +4,8 @@ import { RegisterDetailsStep } from '@lumina/market/app/screens/(auth)/auth/regi
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTopBar } from '../../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -4,8 +4,8 @@ import { RegisterTypeStep } from '@lumina/market/app/screens/(auth)/auth/registe
import type { Metadata } from 'next';
import { i18n } from '../../../../i18n';
import { AuthTopBar } from '../../organisms/auth-top-bar';
import { AuthTemplate } from '../../templates/auth-template';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -5,8 +5,8 @@ import { RegisterPhoneStep } from '@lumina/market/app/screens/(auth)/auth/regist
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTopBar } from '../../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -5,8 +5,8 @@ import { RegisterVerifyStep } from '@lumina/market/app/screens/(auth)/auth/regis
import type { Metadata } from 'next';
import { i18n } from '../../../../../i18n';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
import { AuthTopBar } from '../../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {

View File

@ -1,8 +1,8 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { i18n } from '../../i18n';
import { AuthTopBar } from './organisms/auth-top-bar';
import { AuthTemplate } from './templates/auth-template';
import { AuthTopBar } from '../organisms/auth-top-bar';
import { AuthTemplate } from '../templates/auth-template';
/** Login and registration, before their frame arrives: the top bar and a form step's shape. */
export default function AuthLoading() {

View File

@ -0,0 +1,16 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { i18n } from '../../i18n';
import { AuthTopBar } from '../organisms/auth-top-bar';
import { AuthTemplate } from '../templates/auth-template';
/** Registration's last steps, before their frame arrives: the top bar and a form step's shape. */
export default function OnboardingLoading() {
return (
<AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />}
>
<SkeletonPreset preset="form" delayed label={i18n.t('auth:loading')} />
</AuthTemplate>
);
}

View File

@ -0,0 +1,46 @@
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import {
CreatorProfileStep,
CreatorProfileStepSkeleton,
} from '@lumina/market/app/screens/(onboarding)/onboarding/creator-profile/organisms/creator-profile-step';
import type { Metadata } from 'next';
import { Suspense } from 'react';
import { i18n } from '../../../../i18n';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {
title: i18n.t('auth:register.profile.meta-title'),
robots: { index: false },
};
}
/**
* Registration step 5 for a creator, on the session. The frame renders on the server; the step
* only in the browser, for the signed-in creator, behind the same-size skeleton.
*/
export default function CreatorProfilePage() {
const skeleton = (
<CreatorProfileStepSkeleton
layout="mobile"
label={i18n.t('auth:loading')}
/>
);
return (
<AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />}
>
<AuthGuard role="creator" fallback={skeleton}>
<Suspense fallback={skeleton}>
<CreatorProfileStep
size="lg"
layout="mobile"
supportPlacement="bottom"
/>
</Suspense>
</AuthGuard>
</AuthTemplate>
);
}

View File

@ -0,0 +1,40 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { AuthGuard } from '@lumina/market/app/guards/auth-guard';
import { InvestorProfileStep } from '@lumina/market/app/screens/(onboarding)/onboarding/investor-profile/organisms/investor-profile-step';
import type { Metadata } from 'next';
import { i18n } from '../../../../i18n';
import { AuthTopBar } from '../../../organisms/auth-top-bar';
import { AuthTemplate } from '../../../templates/auth-template';
export function generateMetadata(): Metadata {
return {
title: i18n.t('auth:register.profile.meta-title'),
robots: { index: false },
};
}
/**
* Registration step 5 for an investor, optional, on the session. The frame renders on the
* server; the step only in the browser, for the signed-in investor.
*/
export default function InvestorProfilePage() {
return (
<AuthTemplate
header={<AuthTopBar title={i18n.t('auth:register.header')} />}
>
<AuthGuard
role="investor"
fallback={
<SkeletonPreset
preset="form"
count={2}
label={i18n.t('auth:loading')}
/>
}
>
<InvestorProfileStep size="lg" supportPlacement="bottom" />
</AuthGuard>
</AuthTemplate>
);
}

View File

@ -2,10 +2,10 @@ import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Typography } from '@lumina/island/atoms/typography';
import { ROUTES } from '@lumina/market/app/navigation';
import { SupportEntry } from '@lumina/market/app/screens/(auth)/organisms/support-entry';
import { SupportEntry } from '@lumina/market/app/screens/organisms/support-entry';
import NextLink from 'next/link';
import { i18n } from '../../../../i18n';
import { i18n } from '../../../i18n';
import type { AuthTopBarProps } from './types';
/**

View File

@ -0,0 +1,19 @@
# 0014 Registration step 5 on the session, with a server draft
Status: Proposed · Area: architecture · Date: 2026-10-05 · Decided by: agent
## Context
Step 5 (profile completion) runs after the account exists, so it can't sit behind `GuestGuard` like the other `(auth)` steps (0013). The design autosaves a creator's profile and lets them resume after a login, but the API had no draft: any save completed the profile. The user chose to fix the back end first.
## Decision
- Serve step 5 at `/onboarding/creator-profile` and `/onboarding/investor-profile` under `(onboarding)`, rendered only in the browser behind `AuthGuard` with the role, behind a same-size skeleton, with `noindex`.
- A creator's step 5 autosaves through `PATCH /traders/me/profile` (a draft, markets may be empty) and ends only with `POST /traders/me/profile/complete`; `profileComplete` needs that call.
- An investor's step 5 saves nothing until «ذخیره و ورود» (`PUT /users/profile/avatar`, then `PATCH /users/profile` with `interests`).
## Alternatives
- Autosave with `PUT`: rejected; it completes the profile at the first market, so resume after login breaks.
- Keep the draft in local storage: rejected; it would hold profile data in the browser and not follow the creator to another device.
## Consequences
- Login lands an unfinished creator on step 5 until they complete it (`profileComplete` is false).
- Posting and tiers stay locked by the back end until completion.

View File

@ -16,3 +16,4 @@
- 0003 design: Only semantic tokens, named as in the Lumina Design System, produce Tailwind utilities (`@theme inline`); primitives stay plain `:root` variables and Tailwind's defaults are removed.
- 0005 design: Island holds Lumina's product components and status-to-tone map; they take every text as props (`children` or `labels`) and never import i18next or platform code.
- 0006 architecture: Make every non-app project a pnpm workspace package `@lumina/<name>` with subpath `exports`; third-party dependencies stay in the root package.json.
- 0014 architecture: Serve registration step 5 under `(onboarding)` behind `AuthGuard`; a creator's profile autosaves as a server draft (`PATCH`) and completes only through `POST …/profile/complete`.

View File

@ -7,6 +7,7 @@ export const AVATAR_PX: Record<AvatarSize, number> = {
md: 40,
lg: 56,
xl: 80,
'2xl': 96,
};
export const AVATAR_INITIAL_VARIANT: Record<AvatarSize, TypographyVariant> = {
@ -14,6 +15,7 @@ export const AVATAR_INITIAL_VARIANT: Record<AvatarSize, TypographyVariant> = {
md: 'body-md',
lg: 'heading-sm',
xl: 'heading-lg',
'2xl': 'display',
};
export const AVATAR_MARK_PX: Record<AvatarSize, number> = {
@ -21,4 +23,5 @@ export const AVATAR_MARK_PX: Record<AvatarSize, number> = {
md: 14,
lg: 18,
xl: 22,
'2xl': 24,
};

View File

@ -14,6 +14,8 @@ export const avatarVariants = cva(
lg: 'size-14',
/** The channel profile header. */
xl: 'size-20',
/** The profile photo field. */
'2xl': 'size-24',
},
},
defaultVariants: { size: 'md' },

View File

@ -0,0 +1,53 @@
import { Element } from '../../primitives/element';
import { cn } from '../../tools/cn';
import { FlexBox } from '../flex-box';
import { GridBox } from '../grid-box';
import { Icon } from '../icon';
import { Typography } from '../typography';
import type { CheckboxProps } from './types';
import { checkboxVariants } from './variants';
/**
* A labelled checkbox for a consent or an option. The whole row is the hit area (at least 44px
* high). Works with react-hook-form's `register` or as a controlled input; the ref reaches the
* input.
*/
export function Checkbox({
invalid = false,
className,
children,
...props
}: CheckboxProps) {
return (
<FlexBox
tag="label"
alignItems="items-start"
gap="gap-3"
className={cn('min-h-touch-target cursor-pointer', className)}
>
<GridBox
tag="span"
justifyItems="justify-items-center"
alignItems="items-center"
className="mt-px flex-none"
>
<Element
tag="input"
type="checkbox"
aria-invalid={invalid || undefined}
className={checkboxVariants({ invalid })}
{...props}
/>
<Icon
name="check"
size={14}
strokeWidth={3}
className="pointer-events-none invisible text-text-on-action [grid-area:1/1] peer-checked:visible"
/>
</GridBox>
<Typography tag="span" variant="body-sm" className="leading-6">
{children}
</Typography>
</FlexBox>
);
}

View File

@ -0,0 +1,3 @@
export { Checkbox } from './Checkbox';
export type { CheckboxProps } from './types';
export { checkboxVariants } from './variants';

View File

@ -0,0 +1,11 @@
import type { ComponentPropsWithRef, ReactNode } from 'react';
export type CheckboxProps = Omit<
ComponentPropsWithRef<'input'>,
'type' | 'children'
> & {
/** Required and unchecked on submit: a red box; the message goes under it. */
invalid?: boolean;
/** The label, a full sentence the person agrees to. */
children: ReactNode;
};

View File

@ -0,0 +1,15 @@
import { cva } from 'class-variance-authority';
/** The 22px box; the real input draws it, so focus and checked state need no script. */
export const checkboxVariants = cva(
'peer m-0 size-5.5 appearance-none rounded-sm border-[1.5px] bg-surface transition-colors duration-120 ease-standard [grid-area:1/1] checked:border-action-primary checked:bg-action-primary focus-visible:focus-ring actionable:cursor-pointer disabled:frozen',
{
variants: {
invalid: {
true: 'border-danger',
false: 'border-border-default',
},
},
defaultVariants: { invalid: false },
},
);

View File

@ -0,0 +1,35 @@
import { cn } from '../../tools/cn';
import { FlexBox } from '../flex-box';
import { Icon } from '../icon';
import { Typography } from '../typography';
import type { ChipProps } from './types';
import { chipVariants } from './variants';
/**
* A toggle pill for a multiple choice, such as markets. A real button with `aria-pressed`, so
* Tab, Space and screen readers work. Wrap a set in `role="group"` with an accessible name.
*/
export function Chip({
selected,
size = 'md',
className,
children,
...props
}: ChipProps) {
return (
<FlexBox
tag="button"
type="button"
aria-pressed={selected}
display="inline-flex"
alignItems="items-center"
className={cn(chipVariants({ selected, size }), 'gap-1.5', className)}
{...props}
>
{selected && <Icon name="check" size={16} strokeWidth={2.5} />}
<Typography tag="span" variant="label" color="inherit">
{children}
</Typography>
</FlexBox>
);
}

View File

@ -0,0 +1,3 @@
export { Chip } from './Chip';
export type { ChipProps, ChipSize } from './types';
export { chipVariants } from './variants';

View File

@ -0,0 +1,17 @@
import type { VariantProps } from 'class-variance-authority';
import type { ComponentPropsWithRef, ReactNode } from 'react';
import type { chipVariants } from './variants';
export type ChipSize = NonNullable<VariantProps<typeof chipVariants>['size']>;
export type ChipProps = Omit<
ComponentPropsWithRef<'button'>,
'children' | 'type' | 'aria-pressed'
> & {
/** On: filled with a check. Read out as a pressed toggle. */
selected: boolean;
/** `md` (44px) in forms, `sm` (36px) in compact filter rows. */
size?: ChipSize;
children: ReactNode;
};

View File

@ -0,0 +1,20 @@
import { cva } from 'class-variance-authority';
/** A pill you press to pick one of many, such as a market; a set sits in a wrapping row. */
export const chipVariants = cva(
'rounded-full border px-4 whitespace-nowrap transition-colors duration-120 ease-standard focus-visible:focus-ring actionable:cursor-pointer disabled:frozen',
{
variants: {
selected: {
true: 'border-action-primary bg-action-primary text-text-on-action actionable:hover:bg-action-primary-hover',
false:
'border-transparent bg-action-primary-muted text-action-primary-text actionable:hover:border-action-primary',
},
size: {
sm: 'min-h-control-sm px-3.5',
md: 'min-h-control-md',
},
},
defaultVariants: { selected: false, size: 'md' },
},
);

View File

@ -61,6 +61,7 @@ function exitsFinished(dialog: HTMLDialogElement): Promise<unknown> {
export function Dialog({
open,
onClose,
onExited,
dismissible = true,
alert = false,
labelledBy,
@ -81,6 +82,7 @@ export function Dialog({
);
const left = useEffectEvent((dialog: HTMLDialogElement) => {
if (raiseToasts) announce(DIALOG_CLOSE_EVENT, dialog);
onExited?.();
});
useEffect(() => {

View File

@ -4,6 +4,12 @@ export type DialogProps = {
open: boolean;
/** Escape and a tap on the scrim call it, unless `dismissible` is false. */
onClose?: () => void;
/**
* The dialog has left the top layer after its exit transitions and focus went back to the
* trigger. The page is inert until then, so move focus elsewhere here, such as to a field the
* dialog added.
*/
onExited?: () => void;
/** false: Escape and the scrim do nothing, for a halt the user must wait out. */
dismissible?: boolean;
/** An urgent message that interrupts, such as «در حال تأیید پرداخت...»: `role="alertdialog"`. */

View File

@ -0,0 +1,26 @@
import { cn } from '../../tools/cn';
import { FlexBox } from '../flex-box';
import { Icon } from '../icon';
import { Typography } from '../typography';
import type { FieldErrorProps } from './types';
/**
* The error line under a group that has no field of its own, such as a set of chips, a consent
* box or a photo: an alert icon and the message, announced when it appears.
*/
export function FieldError({ id, className, children }: FieldErrorProps) {
return (
<FlexBox
id={id}
role="alert"
alignItems="items-start"
gap="gap-1"
className={cn('text-danger-text', className)}
>
<Icon name="alert" size={16} className="mt-[3px] flex-none" />
<Typography tag="span" variant="caption" color="inherit">
{children}
</Typography>
</FlexBox>
);
}

View File

@ -0,0 +1,2 @@
export { FieldError } from './FieldError';
export type { FieldErrorProps } from './types';

View File

@ -0,0 +1,8 @@
import type { ReactNode } from 'react';
export type FieldErrorProps = {
/** Lets the control point at it with `aria-describedby`. */
id?: string;
className?: string;
children: ReactNode;
};

View File

@ -0,0 +1,41 @@
import { cn } from '../../tools/cn';
import { FlexBox } from '../flex-box';
import { Icon } from '../icon';
import { linkVariants } from '../link';
import { Typography } from '../typography';
import type { LinkButtonProps } from './types';
/**
* Looks like a Link but is a button, because it acts on the page (opens a sheet, removes a photo,
* retries an upload) rather than navigating.
*/
export function LinkButton({
standalone,
icon,
iconStart,
className,
children,
...props
}: LinkButtonProps) {
return (
<FlexBox
tag="button"
type="button"
display="inline-flex"
alignItems="items-center"
gap="gap-1"
className={cn(
linkVariants({ standalone }),
'border-0 bg-transparent p-0 text-start disabled:frozen',
className,
)}
{...props}
>
{iconStart && <Icon name={iconStart} size={18} />}
<Typography tag="span" variant="inherit" color="inherit">
{children}
</Typography>
{icon && <Icon name={icon} size={18} />}
</FlexBox>
);
}

View File

@ -0,0 +1,2 @@
export { LinkButton } from './LinkButton';
export type { LinkButtonProps } from './types';

View File

@ -0,0 +1,16 @@
import type { ComponentPropsWithRef, ReactNode } from 'react';
import type { IconName } from '../icon';
export type LinkButtonProps = Omit<
ComponentPropsWithRef<'button'>,
'children' | 'type'
> & {
/** A 44px hit area for a button on its own line. */
standalone?: boolean;
/** Trailing icon. */
icon?: IconName;
/** Leading icon, for an action named by its verb, such as `refresh` before «تلاش مجدد». */
iconStart?: IconName;
children: ReactNode;
};

View File

@ -0,0 +1,58 @@
import { cn } from '../../tools/cn';
import { FlexBox } from '../flex-box';
import { GridBox } from '../grid-box';
import { Icon } from '../icon';
import { Typography } from '../typography';
import type { RowButtonProps } from './types';
/** A 56px choice row in a sheet or a menu: an icon disc, the name, and an optional note at the end. */
export function RowButton({
icon,
meta,
metaDir,
className,
children,
...props
}: RowButtonProps) {
return (
<FlexBox
tag="button"
type="button"
alignItems="items-center"
gap="gap-3"
className={cn(
'min-h-14 w-full rounded-lg border border-border-subtle bg-surface px-3 py-2 text-start text-text-primary transition-colors duration-120 ease-standard focus-visible:focus-ring actionable:cursor-pointer actionable:hover:border-border-strong actionable:hover:bg-surface-hover disabled:frozen',
className,
)}
{...props}
>
<GridBox
tag="span"
justifyItems="justify-items-center"
alignItems="items-center"
className="size-10 flex-none rounded-full bg-action-primary-subtle text-action-primary"
>
<Icon name={icon} size={20} />
</GridBox>
<Typography
tag="span"
variant="body-md"
color="inherit"
className="min-w-0 flex-1 font-semibold"
>
{children}
</Typography>
{meta != null && (
<Typography
tag="bdi"
variant="caption"
color="secondary"
dir={metaDir}
className="flex-none"
>
{meta}
</Typography>
)}
</FlexBox>
);
}

View File

@ -0,0 +1,2 @@
export { RowButton } from './RowButton';
export type { RowButtonProps } from './types';

View File

@ -0,0 +1,16 @@
import type { ComponentPropsWithRef, ReactNode } from 'react';
import type { IconName } from '../icon';
export type RowButtonProps = Omit<
ComponentPropsWithRef<'button'>,
'children' | 'type'
> & {
icon: IconName;
/** The row's name, such as «تلگرام». */
children: ReactNode;
/** A short note at the end, such as the address prefix `t.me/`. */
meta?: ReactNode;
/** `ltr` for an address or a code in `meta`. */
metaDir?: 'ltr' | 'rtl';
};

View File

@ -1,39 +1,10 @@
import { cn } from '../../tools/cn';
import { FlexBox } from '../flex-box';
import { Icon } from '../icon';
import { linkVariants } from '../link';
import { Typography } from '../typography';
import { LinkButton } from '../link-button';
import type { SupportLinkProps } from './types';
/**
* «تماس با پشتیبانی»: looks like a Link but is a button, because it opens SupportSheet rather
* than navigating. Inside a dimmed card, put it in the card's `action` so it stays live.
*/
export function SupportLink({
icon = true,
standalone,
className,
children,
...props
}: SupportLinkProps) {
return (
<FlexBox
tag="button"
type="button"
display="inline-flex"
alignItems="items-center"
gap="gap-1"
className={cn(
linkVariants({ standalone }),
'border-0 bg-transparent p-0 text-start',
className,
)}
{...props}
>
{icon && <Icon name="headset" size={18} />}
<Typography tag="span" variant="inherit" color="inherit">
{children}
</Typography>
</FlexBox>
);
export function SupportLink({ icon = true, ...props }: SupportLinkProps) {
return <LinkButton iconStart={icon ? 'headset' : undefined} {...props} />;
}

View File

@ -9,6 +9,10 @@ export type {
ButtonAsLinkProps,
ButtonProps,
} from './atoms/button';
export { Checkbox, checkboxVariants } from './atoms/checkbox';
export type { CheckboxProps } from './atoms/checkbox';
export { Chip, chipVariants } from './atoms/chip';
export type { ChipProps, ChipSize } from './atoms/chip';
export { Countdown, countdownTone } from './atoms/countdown';
export type {
CountdownKind,
@ -23,6 +27,8 @@ export {
DIALOG_PANEL_SELECTOR,
} from './atoms/dialog';
export type { DialogProps } from './atoms/dialog';
export { FieldError } from './atoms/field-error';
export type { FieldErrorProps } from './atoms/field-error';
export { FlexBox } from './atoms/flex-box';
export type {
AlignContent,
@ -50,6 +56,10 @@ export { ICON_NAMES, Icon } from './atoms/icon';
export type { IconName, IconProps } from './atoms/icon';
export { Link, linkVariants } from './atoms/link';
export type { LinkProps } from './atoms/link';
export { LinkButton } from './atoms/link-button';
export type { LinkButtonProps } from './atoms/link-button';
export { RowButton } from './atoms/row-button';
export type { RowButtonProps } from './atoms/row-button';
export {
Skeleton,
SkeletonRegion,
@ -87,16 +97,26 @@ export type {
TypographyProps,
TypographyVariant,
} from './atoms/typography';
export { AvatarField } from './molecules/avatar-field';
export type {
AvatarFieldLabels,
AvatarFieldProps,
AvatarFieldStatus,
} from './molecules/avatar-field';
export { Banner, bannerVariants } from './molecules/banner';
export type { BannerProps, BannerTone } from './molecules/banner';
export { Card, cardVariants } from './molecules/card';
export type { CardOwnProps, CardProps } from './molecules/card';
export { ChipGroup } from './molecules/chip-group';
export type { ChipGroupOption, ChipGroupProps } from './molecules/chip-group';
export { ChoiceCard, choiceCardVariants } from './molecules/choice-card';
export type { ChoiceCardProps } from './molecules/choice-card';
export { EmptyState } from './molecules/empty-state';
export type { EmptyStateProps, EmptyStateTone } from './molecules/empty-state';
export { ERROR_KIND_STYLES, ErrorState } from './molecules/error-state';
export type { ErrorKind, ErrorStateProps } from './molecules/error-state';
export { FormSection } from './molecules/form-section';
export type { FormSectionProps } from './molecules/form-section';
export { LockedTeaser } from './molecules/locked-teaser';
export type { LockedTeaserProps } from './molecules/locked-teaser';
export { MediaCarousel } from './molecules/media-carousel';

View File

@ -0,0 +1,117 @@
'use client';
import { useId, useRef } from 'react';
import type { ChangeEvent } from 'react';
import { Avatar } from '../../atoms/avatar';
import { Button } from '../../atoms/button';
import { FieldError } from '../../atoms/field-error';
import { FlexBox } from '../../atoms/flex-box';
import { LinkButton } from '../../atoms/link-button';
import { Typography } from '../../atoms/typography';
import { Element } from '../../primitives/element';
import { cn } from '../../tools/cn';
import type { AvatarFieldProps } from './types';
/**
* A profile photo: the round picture (or the username's initial), a button that opens the picker,
* and remove. A failed upload keeps the picked photo dimmed in a red ring with the message and
* «تلاش مجدد»; the rest of the form is unaffected.
*/
export function AvatarField({
name,
src,
status = 'idle',
progress,
error,
accept,
onPick,
onRemove,
onRetry,
disabled = false,
labels,
className,
}: AvatarFieldProps) {
const inputRef = useRef<HTMLInputElement>(null);
const messageId = useId();
const isUploading = status === 'uploading';
const isFailed = status === 'failed';
const hasError = error != null && error !== false;
const pick = (event: ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];
// The same file can be picked again after it was rejected.
event.target.value = '';
if (file) onPick(file);
};
return (
<FlexBox direction="flex-col" gap="gap-3" className={className}>
<FlexBox alignItems="items-center" gap="gap-4">
<Avatar
name={name}
src={src}
size="2xl"
label={src ? labels.preview : undefined}
className={cn(
'rounded-full transition-opacity duration-120 ease-standard',
isUploading && 'opacity-70',
isFailed && 'opacity-50 ring-2 ring-danger',
)}
/>
<FlexBox direction="flex-col" alignItems="items-start" gap="gap-1">
<Button
variant="secondary"
icon="image"
isLoading={isUploading}
disabled={disabled}
aria-describedby={hasError ? messageId : undefined}
onClick={() => inputRef.current?.click()}
>
{src ? labels.change : labels.pick}
</Button>
{isUploading && progress !== undefined && labels.uploading && (
<Typography
tag="span"
variant="caption"
color="secondary"
aria-live="polite"
>
{labels.uploading(progress)}
</Typography>
)}
{src && onRemove && status === 'idle' && (
<LinkButton standalone disabled={disabled} onClick={onRemove}>
{labels.remove}
</LinkButton>
)}
</FlexBox>
</FlexBox>
{hasError && (
<FlexBox alignItems="items-center" wrap="flex-wrap" gap="gap-2">
<FieldError id={messageId}>{error}</FieldError>
{isFailed && onRetry && (
<LinkButton
standalone
iconStart="refresh"
disabled={disabled}
onClick={onRetry}
>
{labels.retry}
</LinkButton>
)}
</FlexBox>
)}
<Element
tag="input"
ref={inputRef}
type="file"
accept={accept}
tabIndex={-1}
aria-hidden
className="sr-only"
onChange={pick}
/>
</FlexBox>
);
}

View File

@ -0,0 +1,6 @@
export { AvatarField } from './AvatarField';
export type {
AvatarFieldLabels,
AvatarFieldProps,
AvatarFieldStatus,
} from './types';

View File

@ -0,0 +1,43 @@
import type { ReactNode } from 'react';
/** idle: nothing in flight. uploading: the picked photo is on its way. failed: it didn't arrive. */
export type AvatarFieldStatus = 'idle' | 'uploading' | 'failed';
/** Every text the field shows, from the translations. */
export type AvatarFieldLabels = {
/** «انتخاب تصویر», with no photo yet. */
pick: string;
/** «تغییر تصویر», with a photo. */
change: string;
/** «حذف تصویر». */
remove: string;
/** «تلاش مجدد», after a failed upload. */
retry: string;
/** The photo's accessible name: «پیش‌نمایش برش دایره‌ای تصویر پروفایل». */
preview: string;
/** While uploading, given the percent: «در حال بارگذاری… ۶۴٪». */
uploading?: (percent: number) => ReactNode;
};
export type AvatarFieldProps = {
/** The username: its first letter stands in while there is no photo. */
name: string;
/** The photo to show: the uploaded one, or the picked file's preview while it uploads. */
src: string | null;
status?: AvatarFieldStatus;
/** 0–100 while uploading. */
progress?: number;
/** A rejected pick or a failed upload. A rejected pick keeps the current photo. */
error?: ReactNode;
/** MIME types for the picker, such as `image/jpeg,image/png`. */
accept?: string;
/** A picked file. Check its type and size here, when it is picked. */
onPick: (file: File) => void;
/** Omit it when the photo can't be removed. */
onRemove?: () => void;
/** Sends the same file again after a failed upload. */
onRetry?: () => void;
disabled?: boolean;
labels: AvatarFieldLabels;
className?: string;
};

View File

@ -0,0 +1,53 @@
import { useId } from 'react';
import { Chip } from '../../atoms/chip';
import { FieldError } from '../../atoms/field-error';
import { FlexBox } from '../../atoms/flex-box';
import type { ChipGroupProps } from './types';
/**
* A multiple choice as a wrapping row of toggle chips, such as markets, with its error under it.
* The fieldset is named and can take focus, so a form error can send the person to it.
*/
export function ChipGroup<T extends string>({
options,
value,
onToggle,
label,
error,
size = 'md',
disabled = false,
ref,
className,
}: ChipGroupProps<T>) {
const errorId = useId();
const hasError = error != null && error !== false;
return (
<FlexBox direction="flex-col" gap="gap-2" className={className}>
<FlexBox
ref={ref}
tag="fieldset"
tabIndex={-1}
aria-label={label}
aria-describedby={hasError ? errorId : undefined}
wrap="flex-wrap"
gap="gap-2"
className="rounded-md outline-none"
>
{options.map((option) => (
<Chip
key={option.value}
size={size}
selected={value.includes(option.value)}
disabled={disabled}
onClick={() => onToggle(option.value)}
>
{option.label}
</Chip>
))}
</FlexBox>
{hasError && <FieldError id={errorId}>{error}</FieldError>}
</FlexBox>
);
}

View File

@ -0,0 +1,2 @@
export { ChipGroup } from './ChipGroup';
export type { ChipGroupOption, ChipGroupProps } from './types';

View File

@ -0,0 +1,22 @@
import type { ReactNode, Ref } from 'react';
import type { ChipSize } from '../../atoms/chip';
export type ChipGroupOption<T extends string> = { value: T; label: ReactNode };
export type ChipGroupProps<T extends string> = {
options: readonly ChipGroupOption<T>[];
/** The picked values. */
value: readonly T[];
/** A chip was pressed: add or remove its value. */
onToggle: (value: T) => void;
/** The group's accessible name, usually its section title. */
label: string;
/** Under the chips, such as «انتخاب حداقل یک تخصص الزامی است.». */
error?: ReactNode;
size?: ChipSize;
disabled?: boolean;
/** Reaches the fieldset, which takes focus (and scrolls into view) for a form error. */
ref?: Ref<HTMLFieldSetElement>;
className?: string;
};

View File

@ -0,0 +1,51 @@
import { useId } from 'react';
import { FlexBox } from '../../atoms/flex-box';
import { Typography } from '../../atoms/typography';
import type { FormSectionProps } from './types';
/**
* One titled part of a long form, such as a photo, a set of chips or a list of links: the heading
* with its optional marker, a hint, then the controls. The section is named by its heading.
*/
export function FormSection({
title,
note,
hint,
className,
children,
}: FormSectionProps) {
const titleId = useId();
return (
<FlexBox
tag="section"
aria-labelledby={titleId}
direction="flex-col"
gap="gap-3"
className={className}
>
<FlexBox direction="flex-col" className="gap-0.5">
<Typography tag="h2" variant="heading-sm" id={titleId}>
{title}
{note != null && (
<Typography
tag="span"
variant="caption"
color="secondary"
className="ms-1"
>
{note}
</Typography>
)}
</Typography>
{hint != null && (
<Typography tag="p" variant="caption" color="secondary">
{hint}
</Typography>
)}
</FlexBox>
{children}
</FlexBox>
);
}

View File

@ -0,0 +1,2 @@
export { FormSection } from './FormSection';
export type { FormSectionProps } from './types';

View File

@ -0,0 +1,12 @@
import type { ReactNode } from 'react';
export type FormSectionProps = {
/** The section's name, a level-2 heading. */
title: ReactNode;
/** A quiet marker after the title, such as «(اختیاری)». */
note?: ReactNode;
/** One sentence under the title: what to put here. */
hint?: ReactNode;
className?: string;
children: ReactNode;
};

View File

@ -20,6 +20,7 @@ export function Modal({
actions,
icon,
onClose,
onExited,
closeLabel,
dismissible = true,
alert,
@ -31,6 +32,7 @@ export function Modal({
<Dialog
open={open}
onClose={onClose}
onExited={onExited}
dismissible={dismissible}
alert={alert}
labelledBy={titleId}

View File

@ -11,6 +11,8 @@ export type ModalProps = {
icon?: ReactNode;
/** Escape and the scrim call it, unless `dismissible` is false. */
onClose?: () => void;
/** The modal has closed and focus is back on the page. */
onExited?: () => void;
/** The ✕'s accessible name, such as «بستن». Shows the ✕; omit it when there is a cancel button. */
closeLabel?: string;
/** false: no ✕, and Escape and the scrim do nothing, such as «در حال تأیید پرداخت...». */

View File

@ -24,6 +24,7 @@ export function Sheet({
children,
footer,
onClose,
onExited,
closeLabel,
dismissible = true,
alert,
@ -51,6 +52,7 @@ export function Sheet({
<Dialog
open={open}
onClose={onClose}
onExited={onExited}
dismissible={dismissible}
alert={alert}
labelledBy={titleId}

View File

@ -15,6 +15,8 @@ export type SheetProps = {
footer?: ReactNode;
/** Escape, the scrim and (popover) a tap outside call it. */
onClose?: () => void;
/** Bottom and side only: the sheet has closed and focus is back on the page. */
onExited?: () => void;
/** The ✕'s accessible name, such as «بستن». Shows the ✕; omit it when there is a cancel button. */
closeLabel?: string;
/** false: Escape and the scrim do nothing, for a blocking halt. */
@ -37,5 +39,5 @@ export type SheetHeadProps = {
export type SheetPopoverProps = Omit<
SheetProps,
'placement' | 'dismissible' | 'alert'
'placement' | 'dismissible' | 'alert' | 'onExited'
>;

View File

@ -157,6 +157,11 @@ export function date(
return time ? `${day}${DATE_TIME_JOINER}${timeFormatter.format(at)}` : day;
}
/** Time of day in Tehran: `14:05`, such as when a draft was last saved. */
export function time(value: DateInput): string {
return timeFormatter.format(toDate(value));
}
/** `همین الان`, `5 دقیقه پیش`, `2 ساعت پیش`, `دیروز`; older than that → `date()`. */
export function relative(
value: DateInput,

View File

@ -13,6 +13,7 @@ export {
sheba,
signed,
signedPercent,
time,
} from './format';
export { LOCALE, TIME_ZONE } from './constants';
export type { DateFormatOptions, DateInput, ShebaFormatOptions } from './types';

View File

@ -13,7 +13,7 @@ import { useTranslation } from 'react-i18next';
import { useLoginPage } from '../../../../../../../features/auth';
import { translateMessage } from '../../../../../../../shared/utils';
import { useAuthRoutes } from '../../../../../../navigation';
import { SupportEntry } from '../../../../organisms/support-entry';
import { SupportEntry } from '../../../../../organisms/support-entry';
import type { LoginStepProps } from './types';
/**

View File

@ -1,4 +1,4 @@
import type { SupportEntryProps } from '../../../../organisms/support-entry';
import type { SupportEntryProps } from '../../../../../organisms/support-entry';
export type LoginStepProps = {
/** `lg` on mobile, `md` on desktop. */

View File

@ -6,7 +6,7 @@ import { Typography } from '@lumina/island/atoms/typography';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import { SupportEntry } from '../../../../../../../organisms/support-entry';
import type { SuspendedNoticeProps } from '../types';
/**

View File

@ -1,4 +1,4 @@
import type { SupportEntryProps } from '../../../../../organisms/support-entry';
import type { SupportEntryProps } from '../../../../../../organisms/support-entry';
export type LoginVerifyStepProps = {
/** `lg` on mobile, `md` on desktop. */

View File

@ -12,7 +12,7 @@ import { Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { formatMobile, translateMessage } from '../../../../../../shared/utils';
import { SupportEntry } from '../../../organisms/support-entry';
import { SupportEntry } from '../../../../organisms/support-entry';
import type { CodeStepProps } from './types';
/**

View File

@ -1,7 +1,7 @@
import type { ReactNode } from 'react';
import type { CodeStepModel } from '../../../../../../features/auth';
import type { SupportEntryProps } from '../../../organisms/support-entry';
import type { SupportEntryProps } from '../../../../organisms/support-entry';
export type CodeStepProps = {
/** The page model's code step (`useCodeStep`). */

View File

@ -6,8 +6,8 @@ import { Banner } from '@lumina/island/molecules/banner';
import type { FormEvent } from 'react';
import { useTranslation } from 'react-i18next';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import { RegisterProgress } from '../../../../organisms/register-progress';
import { SupportEntry } from '../../../../../../../organisms/support-entry';
import { RegisterProgress } from '../../../../../../../organisms/register-progress';
import type { DetailsFrameProps } from '../types';
import { ExpiryHalt } from './ExpiryHalt';
import { ExpiryWarning } from './ExpiryWarning';

View File

@ -5,7 +5,7 @@ import type {
RegisterDetailsPageModel,
UseDetailsPartOptions,
} from '../../../../../../../../features/auth';
import type { SupportEntryProps } from '../../../../../organisms/support-entry';
import type { SupportEntryProps } from '../../../../../../organisms/support-entry';
export type RegisterDetailsStepProps = {
/** `lg` on mobile, `md` on desktop. */

View File

@ -14,8 +14,8 @@ import { useRegisterTypePage } from '../../../../../../../features/auth';
import type { UserRole } from '../../../../../../../features/auth';
import { translateMessage } from '../../../../../../../shared/utils';
import { useAuthRoutes } from '../../../../../../navigation';
import { SupportEntry } from '../../../../organisms/support-entry';
import { RegisterProgress } from '../register-progress';
import { SupportEntry } from '../../../../../organisms/support-entry';
import { RegisterProgress } from '../../../../../organisms/register-progress';
import type { RegisterTypeStepProps } from './types';
const ACCOUNT_TYPES = [

View File

@ -1,4 +1,4 @@
import type { SupportEntryProps } from '../../../../organisms/support-entry';
import type { SupportEntryProps } from '../../../../../organisms/support-entry';
export type RegisterTypeStepProps = {
/** `lg` on mobile, `md` on desktop. */

View File

@ -15,8 +15,8 @@ import { useTranslation } from 'react-i18next';
import { useRegisterPhonePage } from '../../../../../../../../features/auth';
import { translateMessage } from '../../../../../../../../shared/utils';
import { useAuthRoutes } from '../../../../../../../navigation';
import { SupportEntry } from '../../../../../organisms/support-entry';
import { RegisterProgress } from '../../../organisms/register-progress';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import { RegisterProgress } from '../../../../../../organisms/register-progress';
import type { RegisterPhoneStepProps } from './types';
/**

View File

@ -1,4 +1,4 @@
import type { SupportEntryProps } from '../../../../../organisms/support-entry';
import type { SupportEntryProps } from '../../../../../../organisms/support-entry';
export type RegisterPhoneStepProps = {
/** `lg` on mobile, `md` on desktop. */

View File

@ -6,7 +6,7 @@ import { useTranslation } from 'react-i18next';
import { useRegisterVerifyPage } from '../../../../../../../../features/auth';
import { useAuthRoutes } from '../../../../../../../navigation';
import { CodeStep } from '../../../../organisms/code-step';
import { RegisterProgress } from '../../../organisms/register-progress';
import { RegisterProgress } from '../../../../../../organisms/register-progress';
import type { RegisterVerifyStepProps } from './types';
/**

View File

@ -1,4 +1,4 @@
import type { SupportEntryProps } from '../../../../../organisms/support-entry';
import type { SupportEntryProps } from '../../../../../../organisms/support-entry';
export type RegisterVerifyStepProps = {
/** `lg` on mobile, `md` on desktop. */

View File

@ -0,0 +1,33 @@
'use client';
import {
useCreatorPhotoPart,
useCreatorProfilePage,
} from '../../../../../../../features/profile';
import { CompletedView } from './components/CompletedView';
import { ProfileForm } from './components/ProfileForm';
import { StepLayout } from './components/StepLayout';
import type { CreatorProfileStepProps } from './types';
/**
* Registration step 5 for a creator, on the normal session: the public profile, required but
* saved as it is typed, so it can be finished later. The page wraps it in Suspense while the
* saved draft loads; then the form, and after «تکمیل ثبت‌نام» the end of registration.
*/
export function CreatorProfileStep(props: CreatorProfileStepProps) {
const page = useCreatorProfilePage();
const photo = useCreatorPhotoPart(page.profile);
if (page.view === 'completed') {
return (
<StepLayout layout={props.layout}>
<CompletedView
username={page.profile.username}
size={props.size}
supportPlacement={props.supportPlacement}
/>
</StepLayout>
);
}
return <ProfileForm {...props} page={page} photo={photo} />;
}

View File

@ -0,0 +1,24 @@
import { SkeletonPreset } from '@lumina/island/organisms/skeleton-preset';
import { StepLayout } from './components/StepLayout';
import type { CreatorProfileStepSkeletonProps } from './types';
/**
* Step 5's shape before the viewer and the draft are known: the form and, on desktop, the
* preview card beside it, at the same size as the step. Server-safe, for the page's guard.
*/
export function CreatorProfileStepSkeleton({
layout,
label,
}: CreatorProfileStepSkeletonProps) {
return (
<StepLayout
layout={layout}
aside={
layout === 'desktop' && <SkeletonPreset preset="header" label={label} />
}
>
<SkeletonPreset preset="form" count={4} label={label} />
</StepLayout>
);
}

View File

@ -0,0 +1,104 @@
'use client';
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import type { IconName } from '@lumina/island/atoms/icon';
import { StateArt } from '@lumina/island/atoms/state-art';
import { StatusBadge } from '@lumina/island/atoms/status-badge';
import { Typography } from '@lumina/island/atoms/typography';
import { Card } from '@lumina/island/molecules/card';
import { useEffect, useRef } from 'react';
import { useTranslation } from 'react-i18next';
import { ROUTES } from '../../../../../../../navigation';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import type { CompletedViewProps } from '../types';
const NEXT_STEPS = [
{ icon: 'check-circle', text: 'account', tone: 'text-success-text' },
{ icon: 'clock', text: 'review', tone: 'text-text-secondary' },
{ icon: 'tag', text: 'pricing', tone: 'text-text-secondary' },
{ icon: 'lock', text: 'posting', tone: 'text-text-secondary' },
] as const satisfies readonly { icon: IconName; text: string; tone: string }[];
/**
* The end of registration for a creator: identity under review (the dashboard's badge), news by
* SMS and notification, prices can be set now, posting opens after approval. Focus moves to the
* heading so screen readers hear it.
*/
export function CompletedView({
username,
size,
supportPlacement,
}: CompletedViewProps) {
const { t } = useTranslation('auth');
const { t: tCommon } = useTranslation('common');
const headingRef = useRef<HTMLHeadingElement>(null);
useEffect(() => headingRef.current?.focus(), []);
return (
<FlexBox direction="flex-col" gap="gap-6" className="flex-1">
<FlexBox
direction="flex-col"
alignItems="items-center"
gap="gap-3"
className="text-center"
>
<StateArt icon="check" tone="success" size="compact" />
<Typography
ref={headingRef}
tabIndex={-1}
tag="h1"
variant="heading-md"
className="outline-none"
>
{t('register.profile.done.title')}
</Typography>
<StatusBadge status="verification.pending">
{tCommon('status.verification.pending')}
</StatusBadge>
</FlexBox>
<Card
tag="ul"
aria-label={t('register.profile.done.steps-label')}
className="flex flex-col gap-3"
>
{NEXT_STEPS.map(({ icon, text, tone }) => (
<FlexBox key={text} tag="li" alignItems="items-start" gap="gap-3">
<Icon
name={icon}
size={20}
className={`mt-0.5 flex-none ${tone}`}
/>
<Typography tag="span" variant="body-sm">
{t(`register.profile.done.${text}`)}
</Typography>
</FlexBox>
))}
</Card>
<FlexBox direction="flex-col" gap="gap-3">
<Button
href={ROUTES.channel(username)}
variant="primary"
size={size}
block
>
{t('register.profile.done.channel')}
</Button>
<Button
href={ROUTES.dashboard.pricing}
variant="secondary"
size={size}
block
>
{t('register.profile.done.set-pricing')}
</Button>
</FlexBox>
<FlexBox justifyContent="justify-center" className="mt-auto">
<SupportEntry trigger="link" placement={supportPlacement} />
</FlexBox>
</FlexBox>
);
}

View File

@ -0,0 +1,132 @@
'use client';
import { Button } from '@lumina/island/atoms/button';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Typography } from '@lumina/island/atoms/typography';
import { FormSection } from '@lumina/island/molecules/form-section';
import { TextInput } from '@lumina/island/molecules/text-input';
import { number } from '@lumina/tools/format';
import { useRef, useState } from 'react';
import { Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { translateMessage } from '../../../../../../../../shared/utils';
import { SOCIAL_HANDLE_ADDRESSES } from '../../../../../../../../shared/validations';
import type { SocialPlatform } from '../../../../../../../../shared/validations';
import type { LinksSectionProps } from '../types';
import { PlatformPicker } from './PlatformPicker';
/**
* Up to eight links, one row each: the platform as the label, its address as a fixed LTR prefix,
* only the handle to type (a pasted address is cut down to it), and remove. «افزودن لینک» picks
* the platform; at eight it is frozen and says why.
*/
export function LinksSection({ control, links, layout }: LinksSectionProps) {
const { t } = useTranslation('auth');
const [isPicking, setIsPicking] = useState(false);
// The picked platform waits for the picker to close: the page is inert until then, so the new
// row could not take focus.
const picked = useRef<SocialPlatform | null>(null);
return (
<FormSection
title={t('register.profile.links.title')}
note={t('register.profile.optional')}
hint={t('register.profile.links.hint')}
>
{links.rows.map((row, index) => {
const platformName = t(`register.profile.platforms.${row.platform}`);
const isWebsite = row.platform === 'website';
return (
<FlexBox key={row.key} alignItems="items-start" gap="gap-2">
<Controller
name={`links.${index}.handle`}
control={control}
render={({ field, fieldState }) => (
<TextInput
{...field}
className="flex-1"
dir="ltr"
inputMode="url"
autoComplete="off"
autoCapitalize="none"
spellCheck={false}
label={platformName}
prefix={
row.platform === 'website'
? undefined
: SOCIAL_HANDLE_ADDRESSES[row.platform].prefix
}
placeholder={
isWebsite
? t('register.profile.links.website-placeholder')
: t('register.profile.links.placeholder')
}
onPaste={(event) => {
const text = event.clipboardData.getData('text');
const handle = links.toHandle(row.platform, text);
if (handle === text.trim()) return;
event.preventDefault();
field.onChange(handle);
}}
onBlur={() => {
const handle = links.toHandle(row.platform, field.value);
if (handle !== field.value) field.onChange(handle);
field.onBlur();
}}
error={translateMessage(t, fieldState.error?.message)}
/>
)}
/>
{/* The label's height, so the button lines up with the field. */}
<Button
variant="ghost"
icon="trash"
label={t('register.profile.links.remove', {
platform: platformName,
})}
className="mt-7.5"
onClick={() => links.remove(index)}
/>
</FlexBox>
);
})}
<FlexBox
alignItems="items-center"
justifyContent="justify-between"
gap="gap-3"
>
<Button
variant="secondary"
icon="plus"
frozen={!links.canAdd}
frozenReason={t('register.profile.links.max', {
max: number(links.max),
})}
onClick={() => setIsPicking(true)}
>
{t('register.profile.links.add')}
</Button>
<Typography tag="span" variant="caption" color="secondary">
{t('register.profile.links.count', {
current: number(links.rows.length),
max: number(links.max),
})}
</Typography>
</FlexBox>
<PlatformPicker
open={isPicking}
layout={layout}
onClose={() => setIsPicking(false)}
onPick={(platform) => {
picked.current = platform;
setIsPicking(false);
}}
onExited={() => {
if (picked.current) links.add(picked.current);
picked.current = null;
}}
/>
</FormSection>
);
}

View File

@ -0,0 +1,70 @@
'use client';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { RowButton } from '@lumina/island/atoms/row-button';
import { Modal } from '@lumina/island/molecules/modal';
import { Sheet } from '@lumina/island/molecules/sheet';
import { useTranslation } from 'react-i18next';
import {
SOCIAL_HANDLE_ADDRESSES,
SOCIAL_PLATFORMS,
} from '../../../../../../../../shared/validations';
import type { PlatformPickerProps } from '../types';
/**
* «افزودن لینک»: the platforms, each with its fixed address. A tap adds a row for it; a picker
* has no cancel button, only the ✕. A bottom sheet on mobile, a modal on desktop.
*/
export function PlatformPicker({
open,
layout,
onPick,
onClose,
onExited,
}: PlatformPickerProps) {
const { t } = useTranslation('auth');
const title = t('register.profile.links.sheet-title');
const closeLabel = t('register.profile.links.close');
const rows = (
<FlexBox direction="flex-col" gap="gap-2">
{SOCIAL_PLATFORMS.map((platform) => (
<RowButton
key={platform}
icon={platform === 'telegram' ? 'telegram' : 'link'}
meta={
platform === 'website'
? t('register.profile.links.website-meta')
: SOCIAL_HANDLE_ADDRESSES[platform].prefix
}
metaDir={platform === 'website' ? undefined : 'ltr'}
onClick={() => onPick(platform)}
>
{t(`register.profile.platforms.${platform}`)}
</RowButton>
))}
</FlexBox>
);
return layout === 'mobile' ? (
<Sheet
open={open}
title={title}
closeLabel={closeLabel}
onClose={onClose}
onExited={onExited}
>
{rows}
</Sheet>
) : (
<Modal
open={open}
title={title}
closeLabel={closeLabel}
onClose={onClose}
onExited={onExited}
>
{rows}
</Modal>
);
}

View File

@ -0,0 +1,269 @@
'use client';
import { Button } from '@lumina/island/atoms/button';
import { Checkbox } from '@lumina/island/atoms/checkbox';
import { FieldError } from '@lumina/island/atoms/field-error';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import { LinkButton } from '@lumina/island/atoms/link-button';
import { Typography } from '@lumina/island/atoms/typography';
import { AvatarField } from '@lumina/island/molecules/avatar-field';
import { Banner } from '@lumina/island/molecules/banner';
import { ChipGroup } from '@lumina/island/molecules/chip-group';
import { FormSection } from '@lumina/island/molecules/form-section';
import { Sheet } from '@lumina/island/molecules/sheet';
import { TextInput } from '@lumina/island/molecules/text-input';
import { useId, useState } from 'react';
import type { FormEvent } from 'react';
import { Controller } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { MARKETS } from '../../../../../../../../shared/constants';
import {
toggleMarket,
translateMessage,
} from '../../../../../../../../shared/utils';
import {
AVATAR_IMAGE,
PROFILE_LIMITS,
} from '../../../../../../../../shared/validations';
import { SupportEntry } from '../../../../../../organisms/support-entry';
import { RegisterProgress } from '../../../../../../organisms/register-progress';
import type { ProfileFormProps } from '../types';
import { LinksSection } from './LinksSection';
import { ProfilePreview } from './ProfilePreview';
import { SaveStatus } from './SaveStatus';
import { StepLayout } from './StepLayout';
/**
* Step 5's form for a creator, top to bottom: photo, bio, markets, links and, once there is a
* link, the consent; «تکمیل ثبت‌نام» under it with the autosave line. Leaving a field saves at
* once. The preview opens in a sheet on mobile and stays beside the form on desktop.
*/
export function ProfileForm({
page,
photo,
size,
layout,
supportPlacement,
}: ProfileFormProps) {
const { t } = useTranslation('auth');
const { t: tCommon } = useTranslation('common');
const [isPreviewOpen, setIsPreviewOpen] = useState(false);
const consentErrorId = useId();
const { form, links, profile } = page;
const marketOptions = MARKETS.map((market) => ({
value: market,
label: tCommon(`markets.${market}`),
}));
const preview = (
<ProfilePreview
control={form.control}
username={profile.username}
avatarSrc={photo.src}
/>
);
return (
<StepLayout
layout={layout}
aside={
layout === 'desktop' && (
<FlexBox direction="flex-col" gap="gap-4">
<FlexBox alignItems="items-center" className="gap-1.5">
<Icon name="eye" size={16} className="text-text-secondary" />
<Typography
tag="h2"
variant="caption"
color="secondary"
className="font-semibold"
>
{t('register.profile.preview.live')}
</Typography>
</FlexBox>
{preview}
</FlexBox>
)
}
>
<FlexBox direction="flex-col" gap="gap-6" className="flex-1">
{page.isResuming && (
<Banner
tone="info"
title={t('register.profile.creator.resume-title')}
>
{t('register.profile.creator.resume-description')}
</Banner>
)}
{page.formError && (
<Banner
tone="danger"
title={t('register.profile.creator.network-title')}
>
{page.formError}
</Banner>
)}
<RegisterProgress current={4} role="creator" />
<FlexBox
direction="flex-col"
alignItems="items-start"
className="gap-1.5"
>
<Typography tag="h1" variant="heading-md">
{t('register.profile.creator.title')}
</Typography>
<Typography color="secondary">
{t('register.profile.creator.description')}
</Typography>
{layout === 'mobile' && (
<LinkButton
standalone
iconStart="eye"
aria-haspopup="dialog"
onClick={() => setIsPreviewOpen(true)}
>
{t('register.profile.preview.open')}
</LinkButton>
)}
</FlexBox>
<FlexBox
tag="form"
noValidate
direction="flex-col"
gap="gap-6"
onBlur={page.saveNow}
onSubmit={(event: FormEvent) => {
event.preventDefault();
void page.submit();
}}
>
<FormSection
title={t('register.profile.photo.title')}
note={t('register.profile.optional')}
hint={t('register.profile.photo.hint')}
>
<AvatarField
name={profile.username}
src={photo.src}
status={photo.status}
progress={photo.progress}
error={translateMessage(t, photo.error)}
accept={AVATAR_IMAGE.types.join(',')}
onPick={photo.pick}
onRetry={photo.retry}
onRemove={photo.isRemoving ? undefined : photo.remove}
labels={{
pick: t('register.profile.photo.pick'),
change: t('register.profile.photo.change'),
remove: t('register.profile.photo.remove'),
retry: t('register.profile.photo.retry'),
preview: t('register.profile.photo.preview'),
uploading: (percent) =>
t('register.profile.photo.uploading', { percent }),
}}
/>
</FormSection>
<Controller
name="bio"
control={form.control}
render={({ field, fieldState }) => (
<TextInput
{...field}
multiline
rows={5}
showCount
maxLength={PROFILE_LIMITS.bioMaxLength}
limitMessage={t('register.profile.bio.limit')}
label={t('register.profile.bio.label')}
placeholder={t('register.profile.bio.placeholder')}
hint={t('register.profile.bio.hint')}
error={translateMessage(t, fieldState.error?.message)}
/>
)}
/>
<FormSection
title={t('register.profile.creator.markets-title')}
hint={t('register.profile.creator.markets-hint')}
>
<Controller
name="markets"
control={form.control}
render={({ field, fieldState }) => (
<ChipGroup
ref={field.ref}
label={t('register.profile.creator.markets-title')}
options={marketOptions}
value={field.value}
onToggle={(market) => {
field.onChange(toggleMarket(field.value, market));
field.onBlur();
}}
error={translateMessage(t, fieldState.error?.message)}
/>
)}
/>
</FormSection>
<LinksSection control={form.control} links={links} layout={layout} />
{links.rows.length > 0 && (
<Controller
name="consent"
control={form.control}
render={({ field, fieldState }) => (
<FlexBox direction="flex-col" gap="gap-1">
<Checkbox
ref={field.ref}
name={field.name}
checked={field.value}
onChange={(event) => field.onChange(event.target.checked)}
onBlur={field.onBlur}
invalid={fieldState.error != null}
aria-describedby={
fieldState.error ? consentErrorId : undefined
}
>
{t('register.profile.links.consent')}
</Checkbox>
{fieldState.error && (
<FieldError id={consentErrorId}>
{translateMessage(t, fieldState.error.message)}
</FieldError>
)}
</FlexBox>
)}
/>
)}
<FlexBox direction="flex-col" gap="gap-3">
<Button
type="submit"
variant="primary"
size={size}
block
isLoading={page.isSubmitting}
>
{t('register.profile.creator.submit')}
</Button>
<SaveStatus status={page.autosave} />
</FlexBox>
</FlexBox>
<FlexBox justifyContent="justify-center" className="mt-auto">
<SupportEntry trigger="link" placement={supportPlacement} />
</FlexBox>
{layout === 'mobile' && (
<Sheet
open={isPreviewOpen}
title={t('register.profile.preview.title')}
closeLabel={t('register.profile.preview.close')}
onClose={() => setIsPreviewOpen(false)}
>
<FlexBox direction="flex-col" gap="gap-4">
{preview}
<Typography variant="caption" color="secondary">
{t('register.profile.preview.note')}
</Typography>
</FlexBox>
</Sheet>
)}
</FlexBox>
</StepLayout>
);
}

View File

@ -0,0 +1,85 @@
'use client';
import { Avatar } from '@lumina/island/atoms/avatar';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import { Tag } from '@lumina/island/atoms/tag';
import { Typography } from '@lumina/island/atoms/typography';
import { Element } from '@lumina/island/primitives/element';
import { useTranslation } from 'react-i18next';
import { useCreatorProfilePreview } from '../../../../../../../../features/profile';
import type { ProfilePreviewProps } from '../types';
/**
* The channel header as investors will see it, with what is filled in so far: photo, username,
* bio, markets and links. Only this part re-renders while the creator types.
*/
export function ProfilePreview({
control,
username,
avatarSrc,
}: ProfilePreviewProps) {
const { t } = useTranslation('auth');
const { t: tCommon } = useTranslation('common');
const preview = useCreatorProfilePreview(control);
return (
<FlexBox direction="flex-col" className="gap-3.5">
<FlexBox alignItems="items-center" className="gap-3.5">
<Avatar name={username} src={avatarSrc} size="lg" />
<FlexBox direction="flex-col" className="min-w-0">
<Typography
tag="bdi"
dir="ltr"
variant="heading-sm"
className="truncate text-start"
>
@{username}
</Typography>
<Typography tag="span" variant="caption" color="secondary">
{t('register.profile.preview.channel')}
</Typography>
</FlexBox>
</FlexBox>
{preview.bio && (
<Typography
variant="body-sm"
className="break-words whitespace-pre-line"
>
{preview.bio}
</Typography>
)}
{preview.markets.length > 0 && (
<FlexBox tag="ul" wrap="flex-wrap" className="gap-1.5">
{preview.markets.map((market) => (
<Element key={market} tag="li">
<Tag>{tCommon(`markets.${market}`)}</Tag>
</Element>
))}
</FlexBox>
)}
{preview.links.length > 0 && (
<FlexBox tag="ul" direction="flex-col" gap="gap-1">
{preview.links.map((link) => (
<FlexBox key={link} tag="li" alignItems="items-center" gap="gap-2">
<Icon
name="link"
size={16}
className="flex-none text-text-secondary"
/>
<Typography
tag="bdi"
dir="ltr"
variant="body-sm"
className="truncate"
>
{link}
</Typography>
</FlexBox>
))}
</FlexBox>
)}
</FlexBox>
);
}

View File

@ -0,0 +1,43 @@
'use client';
import { FlexBox } from '@lumina/island/atoms/flex-box';
import { Icon } from '@lumina/island/atoms/icon';
import { Typography } from '@lumina/island/atoms/typography';
import { time } from '@lumina/tools/format';
import { useTranslation } from 'react-i18next';
import type { SaveStatusProps } from '../types';
/** The line under «تکمیل ثبت‌نام»: that the step saves itself, when it last did, or that it didn't. */
export function SaveStatus({ status }: SaveStatusProps) {
const { t } = useTranslation('auth');
const isFailed = status.phase === 'failed';
const text =
status.phase === 'saved'
? t('register.profile.autosave.saved', { time: time(status.at) })
: isFailed
? t('register.profile.autosave.failed')
: t('register.profile.autosave.idle');
return (
<FlexBox
tag="output"
alignItems="items-center"
justifyContent="justify-center"
className="gap-1.5"
>
<Icon
name={isFailed ? 'alert' : 'check-circle'}
size={16}
className={isFailed ? 'text-danger-text' : 'text-text-secondary'}
/>
<Typography
tag="span"
variant="caption"
color={isFailed ? 'danger' : 'secondary'}
>
{text}
</Typography>
</FlexBox>
);
}

View File

@ -0,0 +1,32 @@
import { GridBox } from '@lumina/island/atoms/grid-box';
import { Card } from '@lumina/island/molecules/card';
import type { StepLayoutProps } from '../types';
/**
* Where step 5 sits. Mobile: the page's column. Desktop: a 560 card, with the live preview
* beside it when there is one; the preview stays in view while the form scrolls.
*/
export function StepLayout({ layout, aside, children }: StepLayoutProps) {
if (layout === 'mobile') return children;
const main = (
<Card padding="none" className="w-full max-w-form px-10 pt-10 pb-8">
{children}
</Card>
);
if (!aside) return main;
return (
<GridBox
alignItems="items-start"
gap="gap-8"
className="w-full max-w-max grid-cols-[minmax(0,var(--container-form))_22.5rem]"
>
{main}
<Card tag="aside" padding="lg" className="sticky top-6">
{aside}
</Card>
</GridBox>
);
}

Some files were not shown because too many files have changed in this diff Show More