Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Nicer login screen layout for react dashboard (#14358)
Damian Legawiec5ea82873123f
diff --git a/packages/dashboard/src/assets/login_sidebar_background.png b/packages/dashboard/src/assets/login_sidebar_background.pngnew file mode 100644index 0000000000..de3e6a7d6aBinary files /dev/null and b/packages/dashboard/src/assets/login_sidebar_background.png differdiff --git a/packages/dashboard/src/components/spree/auth-shell.tsx b/packages/dashboard/src/components/spree/auth-shell.tsxindex 8f9bac81ad..d0ca74040c 100644--- a/packages/dashboard/src/components/spree/auth-shell.tsx+++ b/packages/dashboard/src/components/spree/auth-shell.tsx@@ -1,57 +1,27 @@import type { ReactNode } from 'react'-import { useTranslation } from 'react-i18next'+import loginSidebarBackground from '../../assets/login_sidebar_background.png'/**- * Centered, muted-background layout shared by the unauthenticated auth pages- * (login, forgot/reset password, invitation acceptance): app branding on top,- * a card slot, and the "powered by" footer link.+ * Two-column layout shared by the unauthenticated auth pages (login,+ * forgot/reset password, invitation acceptance): app branding, a card slot,+ * and the "powered by" footer link on the left; brand imagery on the right+ * (hidden below the `lg` breakpoint).*/export function AuthShell({ children }: { children: ReactNode }) {- const { t } = useTranslation()-return (- <div className="flex min-h-svh flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10">- <div className="flex w-full max-w-sm flex-col gap-6">- <a href="/" className="flex items-center gap-2 self-center font-medium">- <div className="flex h-6 w-6 items-center justify-center rounded-md bg-primary text-primary-foreground">- <GalleryVerticalEnd className="size-4" />- </div>- {t('admin.branding.app_name')}- </a>- {children}- <div className="text-balance text-center text-xs text-muted-foreground">- <a- href="https://spreecommerce.org"- className="underline underline-offset-4 hover:text-primary"- target="_blank"- rel="noreferrer"- >- {t('admin.branding.powered_by')}- </a>+ <div className="grid min-h-svh lg:grid-cols-2">+ <div className="flex flex-col gap-6 bg-muted p-6 md:p-10">+ <div className="flex flex-1 items-center justify-center">+ <div className="flex w-full max-w-sm flex-col gap-6">{children}</div></div></div>+ <div className="relative hidden bg-muted lg:block border-l">+ <img+ src={loginSidebarBackground}+ alt=""+ className="absolute inset-0 h-full w-full object-cover"+ />+ </div></div>)}--function GalleryVerticalEnd(props: React.SVGProps<SVGSVGElement>) {- return (- <svg- xmlns="http://www.w3.org/2000/svg"- width="24"- height="24"- viewBox="0 0 24 24"- fill="none"- stroke="currentColor"- strokeWidth="2"- strokeLinecap="round"- strokeLinejoin="round"- aria-hidden="true"- {...props}- >- <path d="M7 2h10" />- <path d="M5 6h14" />- <rect width="18" height="12" x="3" y="10" rx="2" />- </svg>- )-}diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex d98e9ff105..6c4fe8e720 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -85,10 +85,6 @@"failed_to_delete": "فشل حذف السوق"}},- "branding": {- "app_name": "Spree Admin",- "powered_by": "مدعوم من Spree Commerce"- },"errors": {"not_found_title": "الصفحة غير موجودة","not_found_description": "الصفحة التي تبحث عنها غير موجودة.",diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex 63d8169e97..0dd7b760f9 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -37,10 +37,6 @@"empty": "Keine passenden Chargen"}},- "branding": {- "app_name": "Spree Admin",- "powered_by": "Bereitgestellt von Spree Commerce"- },"errors": {"not_found_title": "Seite nicht gefunden","not_found_description": "Die gesuchte Seite existiert nicht.",diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex 68d2a4a858..6e325ffdb5 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -85,10 +85,6 @@"failed_to_delete": "Failed to delete market"}},- "branding": {- "app_name": "Spree Admin",- "powered_by": "Powered by Spree Commerce"- },"errors": {"not_found_title": "Page not found","not_found_description": "The page you’re looking for doesn’t exist.",diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex bf2434a2ba..ceda495bee 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -37,10 +37,6 @@"empty": "Aucun lot correspondant"}},- "branding": {- "app_name": "Administration Spree",- "powered_by": "Propulsé par Spree Commerce"- },"errors": {"not_found_title": "Page introuvable","not_found_description": "La page que vous recherchez n’existe pas.",diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex decc35a8fc..9e04cf5460 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -37,10 +37,6 @@"empty": "Brak pasujących partii"}},- "branding": {- "app_name": "Panel administracyjny Spree",- "powered_by": "Obsługiwane przez Spree Commerce"- },"errors": {"not_found_title": "Nie znaleziono strony","not_found_description": "Strona, której szukasz, nie istnieje.",diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex c864f6e1e1..f65adebaef 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -85,10 +85,6 @@"failed_to_delete": "删除市场失败"}},- "branding": {- "app_name": "Spree 管理后台",- "powered_by": "由 Spree Commerce 提供支持"- },"errors": {"not_found_title": "页面未找到","not_found_description": "您访问的页面不存在。",diff --git a/packages/dashboard/src/routes/accept-invitation.$invitationId.tsx b/packages/dashboard/src/routes/accept-invitation.$invitationId.tsxindex 9e23c96a4c..70d2c24e0b 100644--- a/packages/dashboard/src/routes/accept-invitation.$invitationId.tsx+++ b/packages/dashboard/src/routes/accept-invitation.$invitationId.tsx@@ -1,21 +1,13 @@import { zodResolver } from '@hookform/resolvers/zod'import type { Invitation, SpreeError } from '@spree/admin-sdk'import { adminClient, mapSpreeErrorsToForm, useAuth } from '@spree/dashboard-core'-import {- Button,- Card,- CardContent,- CardDescription,- CardHeader,- CardTitle,- Input,- Label,-} from '@spree/dashboard-ui'+import { Button, Input, Label } from '@spree/dashboard-ui'import { useQuery } from '@tanstack/react-query'import { createFileRoute, Navigate, useNavigate } from '@tanstack/react-router'import { useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { z } from 'zod/v4'+import { AuthShell } from '../components/spree/auth-shell'import {type AcceptInvitationSignInFormValues,type AcceptInvitationSignUpFormValues,@@ -42,19 +34,19 @@ function AcceptInvitationPage() {if (!token) {return (- <Shell>+ <AuthShell><ErrorCardtitle={t('admin.invitation.missing_token_title')}message={t('admin.invitation.missing_token_message')}/>- </Shell>+ </AuthShell>)}return (- <Shell>+ <AuthShell><InvitationLoader invitationId={invitationId} token={token} />- </Shell>+ </AuthShell>)}@@ -68,11 +60,7 @@ function InvitationLoader({ invitationId, token }: { invitationId: string; tokenif (lookup.isPending) {return (- <Card>- <CardContent className="py-12 text-center text-muted-foreground">- {t('admin.invitation.loading')}- </CardContent>- </Card>+ <div className="py-12 text-center text-muted-foreground">{t('admin.invitation.loading')}</div>)}@@ -157,43 +145,35 @@ function SignInForm({const actionPart = t('admin.invitation.sign_in_to_accept')return (- <Card>- <CardHeader className="text-center">- <CardTitle className="text-xl">+ <>+ <div className="flex flex-col gap-2">+ <h1 className="text-2xl font-bold">{t('admin.invitation.join_store', { store: invitation.store.name })}- </CardTitle>- <CardDescription>{`${invitedPart}${rolePart}${actionPart}`}</CardDescription>- </CardHeader>- <CardContent>- <form onSubmit={form.handleSubmit(onSubmit)} className="grid gap-6">- {errors.root && (- <p className="text-center text-sm text-destructive">{errors.root.message}</p>- )}- <div className="grid gap-2">- <Label htmlFor="invitee-email">{t('admin.fields.email.label')}</Label>- <Input id="invitee-email" value={invitation.email} disabled />- </div>- <div className="grid gap-2">- <Label htmlFor="password">- {t('admin.fields.invitation_acceptance.password.label')}- </Label>- <Input- id="password"- type="password"- autoFocus- aria-invalid={!!errors.password || undefined}- {...form.register('password')}- />- {errors.password && (- <p className="text-sm text-destructive">{errors.password.message}</p>- )}- </div>- <Button type="submit" className="w-full" disabled={isLoading}>- {isLoading ? t('admin.invitation.accepting') : t('admin.invitation.sign_in_and_accept')}- </Button>- </form>- </CardContent>- </Card>+ </h1>+ <p className="text-sm text-muted-foreground">{`${invitedPart}${rolePart}${actionPart}`}</p>+ </div>+ <form onSubmit={form.handleSubmit(onSubmit)} className="grid gap-6">+ {errors.root && <p className="text-sm text-destructive">{errors.root.message}</p>}+ <div className="grid gap-2">+ <Label htmlFor="invitee-email">{t('admin.fields.email.label')}</Label>+ <Input id="invitee-email" value={invitation.email} disabled />+ </div>+ <div className="grid gap-2">+ <Label htmlFor="password">{t('admin.fields.invitation_acceptance.password.label')}</Label>+ <Input+ id="password"+ type="password"+ autoFocus+ aria-invalid={!!errors.password || undefined}+ {...form.register('password')}+ />+ {errors.password && <p className="text-sm text-destructive">{errors.password.message}</p>}+ </div>+ <Button type="submit" className="w-full" disabled={isLoading}>+ {isLoading ? t('admin.invitation.accepting') : t('admin.invitation.sign_in_and_accept')}+ </Button>+ </form>+ </>)}@@ -237,99 +217,81 @@ function SignUpForm({const actionPart = t('admin.invitation.create_to_accept')return (- <Card>- <CardHeader className="text-center">- <CardTitle className="text-xl">+ <>+ <div className="flex flex-col gap-2">+ <h1 className="text-2xl font-bold">{t('admin.invitation.join_store', { store: invitation.store.name })}- </CardTitle>- <CardDescription>{`${invitedPart}${rolePart}${actionPart}`}</CardDescription>- </CardHeader>- <CardContent>- <form onSubmit={form.handleSubmit(onSubmit)} className="grid gap-6">- {errors.root && (- <p className="text-center text-sm text-destructive">{errors.root.message}</p>- )}+ </h1>+ <p className="text-sm text-muted-foreground">{`${invitedPart}${rolePart}${actionPart}`}</p>+ </div>+ <form onSubmit={form.handleSubmit(onSubmit)} className="grid gap-6">+ {errors.root && <p className="text-sm text-destructive">{errors.root.message}</p>}+ <div className="grid gap-2">+ <Label htmlFor="invitee-email">{t('admin.fields.email.label')}</Label>+ <Input id="invitee-email" value={invitation.email} disabled />+ </div>+ <div className="grid grid-cols-2 gap-3"><div className="grid gap-2">- <Label htmlFor="invitee-email">{t('admin.fields.email.label')}</Label>- <Input id="invitee-email" value={invitation.email} disabled />- </div>- <div className="grid grid-cols-2 gap-3">- <div className="grid gap-2">- <Label htmlFor="first_name">{t('admin.fields.first_name.label')}</Label>- <Input- id="first_name"- autoFocus- aria-invalid={!!errors.first_name || undefined}- {...form.register('first_name')}- />- {errors.first_name && (- <p className="text-sm text-destructive">{errors.first_name.message}</p>- )}- </div>- <div className="grid gap-2">- <Label htmlFor="last_name">{t('admin.fields.last_name.label')}</Label>- <Input- id="last_name"- aria-invalid={!!errors.last_name || undefined}- {...form.register('last_name')}- />- {errors.last_name && (- <p className="text-sm text-destructive">{errors.last_name.message}</p>- )}- </div>- </div>- <div className="grid gap-2">- <Label htmlFor="password">- {t('admin.fields.invitation_acceptance.password.label')}- </Label>+ <Label htmlFor="first_name">{t('admin.fields.first_name.label')}</Label><Input- id="password"- type="password"- aria-invalid={!!errors.password || undefined}- {...form.register('password')}+ id="first_name"+ autoFocus+ aria-invalid={!!errors.first_name || undefined}+ {...form.register('first_name')}/>- {errors.password && (- <p className="text-sm text-destructive">{errors.password.message}</p>+ {errors.first_name && (+ <p className="text-sm text-destructive">{errors.first_name.message}</p>)}</div><div className="grid gap-2">- <Label htmlFor="password_confirmation">- {t('admin.fields.invitation_acceptance.password_confirmation.label')}- </Label>+ <Label htmlFor="last_name">{t('admin.fields.last_name.label')}</Label><Input- id="password_confirmation"- type="password"- aria-invalid={!!errors.password_confirmation || undefined}- {...form.register('password_confirmation')}+ id="last_name"+ aria-invalid={!!errors.last_name || undefined}+ {...form.register('last_name')}/>- {errors.password_confirmation && (- <p className="text-sm text-destructive">{errors.password_confirmation.message}</p>+ {errors.last_name && (+ <p className="text-sm text-destructive">{errors.last_name.message}</p>)}</div>- <Button type="submit" className="w-full" disabled={isLoading}>- {isLoading ? t('admin.invitation.accepting') : t('admin.invitation.create_and_accept')}- </Button>- </form>- </CardContent>- </Card>+ </div>+ <div className="grid gap-2">+ <Label htmlFor="password">{t('admin.fields.invitation_acceptance.password.label')}</Label>+ <Input+ id="password"+ type="password"+ aria-invalid={!!errors.password || undefined}+ {...form.register('password')}+ />+ {errors.password && <p className="text-sm text-destructive">{errors.password.message}</p>}+ </div>+ <div className="grid gap-2">+ <Label htmlFor="password_confirmation">+ {t('admin.fields.invitation_acceptance.password_confirmation.label')}+ </Label>+ <Input+ id="password_confirmation"+ type="password"+ aria-invalid={!!errors.password_confirmation || undefined}+ {...form.register('password_confirmation')}+ />+ {errors.password_confirmation && (+ <p className="text-sm text-destructive">{errors.password_confirmation.message}</p>+ )}+ </div>+ <Button type="submit" className="w-full" disabled={isLoading}>+ {isLoading ? t('admin.invitation.accepting') : t('admin.invitation.create_and_accept')}+ </Button>+ </form>+ </>)}function ErrorCard({ title, message }: { title: string; message: string }) {return (- <Card>- <CardHeader className="text-center">- <CardTitle className="text-xl">{title}</CardTitle>- <CardDescription>{message}</CardDescription>- </CardHeader>- </Card>- )-}--function Shell({ children }: { children: React.ReactNode }) {- return (- <div className="flex min-h-svh flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10">- <div className="flex w-full max-w-sm flex-col gap-6">{children}</div>+ <div className="flex flex-col gap-2">+ <h1 className="text-2xl font-bold">{title}</h1>+ <p className="text-sm text-muted-foreground">{message}</p></div>)}diff --git a/packages/dashboard/src/routes/forgot-password.tsx b/packages/dashboard/src/routes/forgot-password.tsxindex 34f2071894..351e9e8319 100644--- a/packages/dashboard/src/routes/forgot-password.tsx+++ b/packages/dashboard/src/routes/forgot-password.tsx@@ -68,41 +68,37 @@ function ForgotPasswordPage() {return (<AuthShell>- <Card>- <CardHeader className="text-center">- <CardTitle className="text-xl">{t('admin.auth.forgot_password.title')}</CardTitle>- <CardDescription>{t('admin.auth.forgot_password.subtitle')}</CardDescription>- </CardHeader>- <CardContent>- <form onSubmit={form.handleSubmit(onSubmit)} className="grid gap-6">- {errors.root && (- <p className="text-center text-sm text-destructive">{errors.root.message}</p>- )}- <div className="grid gap-2">- <Label htmlFor="email">{t('admin.fields.email.label')}</Label>- <Input- id="email"- type="email"- placeholder={t('admin.fields.login.email.placeholder')}- autoFocus- aria-invalid={!!errors.email || undefined}- {...form.register('email')}- />- {errors.email && <p className="text-sm text-destructive">{errors.email.message}</p>}- </div>- <Button type="submit" className="w-full" disabled={isSubmitting}>- {isSubmitting- ? t('admin.auth.forgot_password.sending')- : t('admin.auth.forgot_password.submit')}- </Button>- <div className="text-center">- <Link to="/login" className="text-sm underline underline-offset-4 hover:text-primary">- {t('admin.auth.back_to_login')}- </Link>- </div>- </form>- </CardContent>- </Card>+ <div className="flex flex-col gap-2">+ <h1 className="text-2xl font-bold">{t('admin.auth.forgot_password.title')}</h1>+ <p className="text-sm text-muted-foreground">{t('admin.auth.forgot_password.subtitle')}</p>+ </div>+ <form onSubmit={form.handleSubmit(onSubmit)} className="grid gap-6">+ {errors.root && (+ <p className="text-center text-sm text-destructive">{errors.root.message}</p>+ )}+ <div className="grid gap-2">+ <Label htmlFor="email">{t('admin.fields.email.label')}</Label>+ <Input+ id="email"+ type="email"+ placeholder={t('admin.fields.login.email.placeholder')}+ autoFocus+ aria-invalid={!!errors.email || undefined}+ {...form.register('email')}+ />+ {errors.email && <p className="text-sm text-destructive">{errors.email.message}</p>}+ </div>+ <Button type="submit" className="w-full" disabled={isSubmitting}>+ {isSubmitting+ ? t('admin.auth.forgot_password.sending')+ : t('admin.auth.forgot_password.submit')}+ </Button>+ <div className="text-center">+ <Link to="/login" className="text-sm underline underline-offset-4 hover:text-primary">+ {t('admin.auth.back_to_login')}+ </Link>+ </div>+ </form></AuthShell>)}diff --git a/packages/dashboard/src/routes/login.tsx b/packages/dashboard/src/routes/login.tsxindex 19818ffe16..fa1463402f 100644--- a/packages/dashboard/src/routes/login.tsx+++ b/packages/dashboard/src/routes/login.tsx@@ -1,15 +1,6 @@import { zodResolver } from '@hookform/resolvers/zod'import { useAuth } from '@spree/dashboard-core'-import {- Button,- Card,- CardContent,- CardDescription,- CardHeader,- CardTitle,- Input,- Label,-} from '@spree/dashboard-ui'+import { Button, Input, Label } from '@spree/dashboard-ui'import { createFileRoute, Link, Navigate } from '@tanstack/react-router'import { useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'@@ -42,60 +33,47 @@ function LoginPage() {return (<AuthShell>- <Card>- <CardHeader className="text-center">- <CardTitle className="text-xl">{t('admin.auth.login.title')}</CardTitle>- <CardDescription>{t('admin.auth.login.subtitle')}</CardDescription>- </CardHeader>- <CardContent>- <form onSubmit={form.handleSubmit(onSubmit)}>- <div className="grid gap-6">- {errors.root && (- <p className="text-sm text-destructive text-center">{errors.root.message}</p>- )}- <div className="grid gap-6">- <div className="grid gap-2">- <Label htmlFor="email">{t('admin.fields.email.label')}</Label>- <Input- id="email"- type="email"- placeholder={t('admin.fields.login.email.placeholder')}- aria-invalid={!!errors.email || undefined}- autoFocus={true}- {...form.register('email')}- />- {errors.email && (- <p className="text-sm text-destructive">{errors.email.message}</p>- )}- </div>- <div className="grid gap-2">- <div className="flex items-center justify-between">- <Label htmlFor="password">{t('admin.fields.password.label')}</Label>- <Link- to="/forgot-password"- className="text-sm underline-offset-4 hover:underline"- >- {t('admin.auth.forgot_password.link')}- </Link>- </div>- <Input- id="password"- type="password"- aria-invalid={!!errors.password || undefined}- {...form.register('password')}- />- {errors.password && (- <p className="text-sm text-destructive">{errors.password.message}</p>- )}- </div>- <Button type="submit" className="w-full" disabled={isLoading}>- {isLoading ? t('admin.actions.signing_in') : t('admin.actions.sign_in')}- </Button>- </div>+ <div className="flex flex-col gap-2">+ <h1 className="text-2xl font-bold">{t('admin.auth.login.title')}</h1>+ <p className="text-sm text-muted-foreground">{t('admin.auth.login.subtitle')}</p>+ </div>+ <form onSubmit={form.handleSubmit(onSubmit)}>+ <div className="grid gap-6">+ {errors.root && <p className="text-sm text-destructive">{errors.root.message}</p>}+ <div className="grid gap-2">+ <Label htmlFor="email">{t('admin.fields.email.label')}</Label>+ <Input+ id="email"+ type="email"+ placeholder={t('admin.fields.login.email.placeholder')}+ aria-invalid={!!errors.email || undefined}+ autoFocus={true}+ {...form.register('email')}+ />+ {errors.email && <p className="text-sm text-destructive">{errors.email.message}</p>}+ </div>+ <div className="grid gap-2">+ <div className="flex items-center justify-between">+ <Label htmlFor="password">{t('admin.fields.password.label')}</Label>+ <Link to="/forgot-password" className="text-sm underline-offset-4 hover:underline">+ {t('admin.auth.forgot_password.link')}+ </Link></div>- </form>- </CardContent>- </Card>+ <Input+ id="password"+ type="password"+ aria-invalid={!!errors.password || undefined}+ {...form.register('password')}+ />+ {errors.password && (+ <p className="text-sm text-destructive">{errors.password.message}</p>+ )}+ </div>+ <Button type="submit" className="w-full" disabled={isLoading}>+ {isLoading ? t('admin.actions.signing_in') : t('admin.actions.sign_in')}+ </Button>+ </div>+ </form></AuthShell>)}