feat(app): identity screens and /app shell — auth store, login/signup/reset flows, dashboard, account
- state/authStore: session subscription (initialize + onAuthStateChange), profile + roles load, recovery flag, URL failure; services/localeSync: profiles.locale <-> localeStore - routes: /login, /signup, /forgot-password, /reset-password, /auth/callback; guards RequireAuth (next=) and RedirectIfSignedIn; /app (dashboard), /app/account behind the guard - shell: AppLayout (desktop sidebar, light top bar, mobile drawer), SidebarNav, UserBadge, SignOutButton - account: personal / professional / preferences / security sections, one save each, Zod validation with i18n keys - ui: Icon, FormField, Notice, ButtonLink (buttonClassName shared), PasswordField, OAuthButtons (config-driven) - Home header: Mon espace / Se connecter when Supabase is configured; local tool routes untouched - i18n: auth.*, shell.*, dashboard.*, account.*, home.space.* in fr + en
This commit is contained in:
1 parent
0f7292f9b3
commit
c517ea267b
46 files changed
+2798
-11
No files matched your search
@@ -23,6 +23,20 @@ const SIZES: Record<NonNullable<ButtonProps['size']>, string> = {
|
||||
lg: 'h-12 px-5 sm:px-6 text-base rounded-lg',
|
||||
}
|
||||
|
||||
/** The button look, reusable by links that act as buttons (ButtonLink). */
|
||||
export function buttonClassName(
|
||||
variant: NonNullable<ButtonProps['variant']> = 'primary',
|
||||
size: NonNullable<ButtonProps['size']> = 'md',
|
||||
className = '',
|
||||
): string {
|
||||
return [
|
||||
'inline-flex items-center justify-center font-medium transition disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
||||
VARIANTS[variant],
|
||||
SIZES[size],
|
||||
className,
|
||||
].join(' ')
|
||||
}
|
||||
|
||||
export default function Button({
|
||||
variant = 'primary',
|
||||
size = 'md',
|
||||
@@ -32,12 +46,7 @@ export default function Button({
|
||||
}: ButtonProps) {
|
||||
return (
|
||||
<button
|
||||
className={[
|
||||
'inline-flex items-center justify-center font-medium transition disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
||||
VARIANTS[variant],
|
||||
SIZES[size],
|
||||
className,
|
||||
].join(' ')}
|
||||
className={buttonClassName(variant, size, className)}
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
import { Link, type LinkProps } from 'react-router-dom'
|
||||
import { buttonClassName, type ButtonProps } from './Button'
|
||||
|
||||
export interface ButtonLinkProps extends LinkProps {
|
||||
variant?: ButtonProps['variant']
|
||||
size?: ButtonProps['size']
|
||||
}
|
||||
|
||||
/** A router link that looks like a Button: navigation stays a link for the browser and assistive tech. */
|
||||
export default function ButtonLink({
|
||||
variant = 'primary',
|
||||
size = 'md',
|
||||
className = '',
|
||||
...rest
|
||||
}: ButtonLinkProps) {
|
||||
return <Link className={buttonClassName(variant, size, className)} {...rest} />
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import Label from './Label'
|
||||
|
||||
export interface FormFieldProps {
|
||||
id: string
|
||||
label: string
|
||||
/** Rendered under the control, greyed; the error replaces it when present. */
|
||||
hint?: string
|
||||
error?: string
|
||||
optional?: string
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
/** Describes a field for assistive tech: ids for hint and error, wired through aria-describedby. */
|
||||
export function fieldDescribedBy(id: string, hint?: string, error?: string) {
|
||||
const ids: string[] = []
|
||||
if (error) ids.push(`${id}-error`)
|
||||
else if (hint) ids.push(`${id}-hint`)
|
||||
return ids.length ? ids.join(' ') : undefined
|
||||
}
|
||||
|
||||
export default function FormField({
|
||||
id,
|
||||
label,
|
||||
hint,
|
||||
error,
|
||||
optional,
|
||||
children,
|
||||
}: FormFieldProps) {
|
||||
return (
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor={id} className="flex items-baseline justify-between">
|
||||
<span>{label}</span>
|
||||
{optional && (
|
||||
<span className="text-xs font-normal text-[var(--color-ink-muted)]">
|
||||
{optional}
|
||||
</span>
|
||||
)}
|
||||
</Label>
|
||||
{children}
|
||||
{error ? (
|
||||
<p id={`${id}-error`} role="alert" className="text-sm text-[var(--color-danger)]">
|
||||
{error}
|
||||
</p>
|
||||
) : (
|
||||
hint && (
|
||||
<p id={`${id}-hint`} className="text-xs text-[var(--color-ink-muted)]">
|
||||
{hint}
|
||||
</p>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
import type { SVGProps } from 'react'
|
||||
|
||||
export type IconName =
|
||||
| 'menu'
|
||||
| 'close'
|
||||
| 'dashboard'
|
||||
| 'user'
|
||||
| 'tool'
|
||||
| 'logout'
|
||||
| 'eye'
|
||||
| 'eye-off'
|
||||
| 'check'
|
||||
| 'alert'
|
||||
| 'google'
|
||||
| 'apple'
|
||||
|
||||
/** Stroke paths on a 24-unit grid; decorative by default (aria-hidden). */
|
||||
const PATHS: Record<IconName, string> = {
|
||||
menu: 'M4 7h16M4 12h16M4 17h16',
|
||||
close: 'M6 6l12 12M18 6L6 18',
|
||||
dashboard: 'M4 4h7v7H4zM13 4h7v4h-7zM13 11h7v9h-7zM4 14h7v6H4z',
|
||||
user: 'M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8zM4 21a8 8 0 0 1 16 0',
|
||||
tool: 'M14 3l7 7-4 4-7-7zM10 10l-6 6 4 4 6-6M3 21l3-3',
|
||||
logout: 'M10 4H5v16h5M15 8l5 4-5 4M20 12H9',
|
||||
eye: 'M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12zM12 15a3 3 0 1 0 0-6 3 3 0 0 0 0 6z',
|
||||
'eye-off':
|
||||
'M3 3l18 18M10.6 10.6A3 3 0 0 0 13.4 13.4M9.9 5.2A10.5 10.5 0 0 1 12 5c6 0 10 7 10 7a17 17 0 0 1-3.2 3.9M6.1 6.1A17 17 0 0 0 2 12s4 7 10 7a10 10 0 0 0 4-.8',
|
||||
check: 'M5 12l5 5L20 7',
|
||||
alert: 'M12 9v4M12 17h.01M10.3 3.9L2.8 17a2 2 0 0 0 1.7 3h15a2 2 0 0 0 1.7-3L13.7 3.9a2 2 0 0 0-3.4 0z',
|
||||
google:
|
||||
'M21 12.2c0-.7-.1-1.3-.2-1.9H12v3.6h5.1a4.4 4.4 0 0 1-1.9 2.9v2.4h3.1c1.8-1.7 2.7-4.1 2.7-7zM12 21c2.4 0 4.5-.8 6-2.2l-3.1-2.4c-.8.6-1.8.9-2.9.9-2.3 0-4.2-1.5-4.9-3.6H4v2.5A9 9 0 0 0 12 21zM7.1 13.7a5.4 5.4 0 0 1 0-3.4V7.8H4a9 9 0 0 0 0 8.4zM12 6.6c1.3 0 2.5.5 3.4 1.3l2.6-2.6A9 9 0 0 0 4 7.8l3.1 2.5c.7-2.1 2.6-3.7 4.9-3.7z',
|
||||
apple:
|
||||
'M16.4 12.6c0-2.3 1.9-3.4 2-3.5a4.3 4.3 0 0 0-3.4-1.8c-1.4-.1-2.8.9-3.5.9s-1.9-.8-3.1-.8A4.6 4.6 0 0 0 4.5 9.8c-1.7 2.9-.4 7.2 1.2 9.5.8 1.1 1.7 2.4 3 2.4s1.7-.8 3.2-.8 1.9.8 3.2.8 2.2-1.2 3-2.3a10 10 0 0 0 1.3-2.8 4.1 4.1 0 0 1-3-4zM13.8 5.6A4 4 0 0 0 14.7 2.7a4.1 4.1 0 0 0-2.7 1.4 3.8 3.8 0 0 0-1 2.8 3.4 3.4 0 0 0 2.8-1.3z',
|
||||
}
|
||||
|
||||
const FILLED: ReadonlySet<IconName> = new Set(['google', 'apple'])
|
||||
|
||||
export interface IconProps extends SVGProps<SVGSVGElement> {
|
||||
name: IconName
|
||||
size?: number
|
||||
}
|
||||
|
||||
export default function Icon({ name, size = 20, className, ...rest }: IconProps) {
|
||||
const filled = FILLED.has(name)
|
||||
return (
|
||||
<svg
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 24 24"
|
||||
fill={filled ? 'currentColor' : 'none'}
|
||||
stroke={filled ? 'none' : 'currentColor'}
|
||||
strokeWidth={1.8}
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
aria-hidden="true"
|
||||
focusable="false"
|
||||
className={className}
|
||||
{...rest}
|
||||
>
|
||||
<path d={PATHS[name]} />
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import Icon from './Icon'
|
||||
|
||||
export interface NoticeProps {
|
||||
tone: 'success' | 'error' | 'info'
|
||||
children: ReactNode
|
||||
className?: string
|
||||
}
|
||||
|
||||
const TONE: Record<NoticeProps['tone'], string> = {
|
||||
success: 'border-[var(--severity-mild)]/40 bg-[color-mix(in_srgb,var(--severity-mild)_10%,white)] text-[var(--color-ink)]',
|
||||
error: 'border-[var(--color-danger)]/40 bg-[color-mix(in_srgb,var(--color-danger)_8%,white)] text-[var(--color-danger-strong)]',
|
||||
info: 'border-[var(--color-border)] bg-[var(--color-surface-strong)] text-[var(--color-ink)]',
|
||||
}
|
||||
|
||||
/** Inline status line: icon + text, never colour alone. */
|
||||
export default function Notice({ tone, children, className = '' }: NoticeProps) {
|
||||
return (
|
||||
<div
|
||||
role={tone === 'error' ? 'alert' : 'status'}
|
||||
className={`flex items-start gap-2 rounded-lg border px-3 py-2 text-sm ${TONE[tone]} ${className}`}
|
||||
>
|
||||
<Icon
|
||||
name={tone === 'success' ? 'check' : 'alert'}
|
||||
size={18}
|
||||
className="mt-0.5 shrink-0"
|
||||
/>
|
||||
<div className="min-w-0">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user