init commit
This commit is contained in:
+115
-91
@@ -1,76 +1,93 @@
|
||||
import type { ReactNode } from 'react';
|
||||
import { Check, ListChecks, Target, Users } from 'lucide-react';
|
||||
import type { ComponentProps } from 'react';
|
||||
import { Check } from 'lucide-react';
|
||||
import { cn } from '../../lib/cn';
|
||||
import { Logo } from '../Logo/Logo';
|
||||
|
||||
export interface FeatureItemProps {
|
||||
icon: ReactNode;
|
||||
title: string;
|
||||
description: string;
|
||||
}
|
||||
|
||||
/** Icon tile + title + one line, used on the login brand panel. */
|
||||
export function FeatureItem({ icon, title, description }: FeatureItemProps) {
|
||||
return (
|
||||
<li className="flex list-none items-start gap-3.5">
|
||||
<span className="flex h-9 w-9 flex-none items-center justify-center rounded-[10px] border border-line-divider bg-feature text-accent-fg">
|
||||
{icon}
|
||||
</span>
|
||||
<div>
|
||||
<div className="leading-tight font-bold">{title}</div>
|
||||
<div className="mt-0.5 leading-snug text-fg-muted">{description}</div>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
const featureIcon = { size: 18, strokeWidth: 1.75, 'aria-hidden': true } as const;
|
||||
|
||||
export const defaultFeatures: FeatureItemProps[] = [
|
||||
{ icon: <Users {...featureIcon} />, title: 'Alles an einem Ort', description: 'Team, Aufgaben und Deadlines. Endlich gebündelt!' },
|
||||
{ icon: <ListChecks {...featureIcon} />, title: 'Immer im Bild', description: 'Wer macht was bis wann? Ein Blick genügt!' },
|
||||
{ icon: <Target {...featureIcon} />, title: 'Mehr Fokus', description: 'Weniger Chaos, mehr Zeit fürs Wesentliche.' },
|
||||
];
|
||||
|
||||
export interface AuthBrandPanelProps {
|
||||
headline?: string;
|
||||
features?: FeatureItemProps[];
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/** Left half of the login and register screens. */
|
||||
export function AuthBrandPanel({
|
||||
headline = 'Gruppenarbeit, die einfach funktioniert!',
|
||||
features = defaultFeatures,
|
||||
className,
|
||||
}: AuthBrandPanelProps) {
|
||||
/**
|
||||
* Left half of the login and register screens.
|
||||
*
|
||||
* <AuthBrandPanel>
|
||||
* <Logo variant="stacked" />
|
||||
* <AuthBrandContent>
|
||||
* <AuthHeadline>Gruppenarbeit, die einfach funktioniert!</AuthHeadline>
|
||||
* <FeatureList><FeatureItem><FeatureIcon><Users /></FeatureIcon><FeatureContent>…</FeatureContent></FeatureItem></FeatureList>
|
||||
* </AuthBrandContent>
|
||||
* </AuthBrandPanel>
|
||||
*/
|
||||
export function AuthBrandPanel({ className, ...props }: ComponentProps<'div'>) {
|
||||
return (
|
||||
<div
|
||||
data-slot="auth-brand-panel"
|
||||
className={cn(
|
||||
'box-border flex min-w-0 flex-[1_1_520px] flex-col items-center justify-center gap-9 border-r border-line-shell bg-brand px-[clamp(24px,5vw,72px)] py-12',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
<Logo variant="stacked" />
|
||||
<div className="flex w-full max-w-[420px] flex-col gap-7">
|
||||
<p className="m-0 text-center text-[30px] leading-tight font-black tracking-[-0.01em] text-balance">{headline}</p>
|
||||
<ul className="m-0 flex flex-col gap-[18px] p-0">
|
||||
{features.map((f) => (
|
||||
<FeatureItem key={f.title} {...f} />
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export interface PasswordRule {
|
||||
export function AuthBrandContent({ className, ...props }: ComponentProps<'div'>) {
|
||||
return (
|
||||
<div
|
||||
data-slot="auth-brand-content"
|
||||
className={cn('flex w-full max-w-[420px] flex-col gap-7', className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function AuthHeadline({ className, ...props }: ComponentProps<'p'>) {
|
||||
return (
|
||||
<p
|
||||
data-slot="auth-headline"
|
||||
className={cn('m-0 text-center text-[30px] leading-tight font-black tracking-[-0.01em] text-balance', className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function FeatureList({ className, ...props }: ComponentProps<'ul'>) {
|
||||
return <ul data-slot="feature-list" className={cn('m-0 flex flex-col gap-[18px] p-0', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function FeatureItem({ className, ...props }: ComponentProps<'li'>) {
|
||||
return <li data-slot="feature-item" className={cn('flex list-none items-start gap-3.5', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function FeatureIcon({ className, ...props }: ComponentProps<'span'>) {
|
||||
return (
|
||||
<span
|
||||
data-slot="feature-icon"
|
||||
className={cn(
|
||||
'flex h-9 w-9 flex-none items-center justify-center rounded-[10px] border border-line-divider bg-feature text-accent-fg',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export function FeatureContent(props: ComponentProps<'div'>) {
|
||||
return <div data-slot="feature-content" {...props} />;
|
||||
}
|
||||
|
||||
export function FeatureTitle({ className, ...props }: ComponentProps<'div'>) {
|
||||
return <div data-slot="feature-title" className={cn('leading-tight font-bold', className)} {...props} />;
|
||||
}
|
||||
|
||||
export function FeatureDescription({ className, ...props }: ComponentProps<'div'>) {
|
||||
return (
|
||||
<div data-slot="feature-description" className={cn('mt-0.5 leading-snug text-fg-muted', className)} {...props} />
|
||||
);
|
||||
}
|
||||
|
||||
export interface PasswordRuleCheck {
|
||||
label: string;
|
||||
met: boolean;
|
||||
}
|
||||
|
||||
/** Checks a password against the design's three rules. */
|
||||
export function passwordRules(pw: string): PasswordRule[] {
|
||||
export function passwordRules(pw: string): PasswordRuleCheck[] {
|
||||
return [
|
||||
{ label: 'Mindestens 8 Zeichen', met: pw.length >= 8 },
|
||||
{ label: 'Groß- und Kleinbuchstaben', met: /[a-zäöü]/.test(pw) && /[A-ZÄÖÜ]/.test(pw) },
|
||||
@@ -78,42 +95,49 @@ export function passwordRules(pw: string): PasswordRule[] {
|
||||
];
|
||||
}
|
||||
|
||||
export interface PasswordRulesProps {
|
||||
rules: PasswordRule[];
|
||||
id?: string;
|
||||
/** Show unmet rules in red (after a submit attempt). */
|
||||
showErrors?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
/** Live checklist under the password field. */
|
||||
export function PasswordRules({ rules, id, showErrors, className }: PasswordRulesProps) {
|
||||
/** Live checklist under a password field: `PasswordRule`s. Link it with `aria-describedby`. */
|
||||
export function PasswordRules({ className, ...props }: ComponentProps<'ul'>) {
|
||||
return (
|
||||
<ul id={id} aria-label="Passwort-Anforderungen" className={cn('m-0 mt-1 flex flex-col gap-1.5 p-0', className)}>
|
||||
{rules.map((r) => (
|
||||
<li
|
||||
key={r.label}
|
||||
<ul
|
||||
aria-label="Passwort-Anforderungen"
|
||||
data-slot="password-rules"
|
||||
className={cn('m-0 mt-1 flex flex-col gap-1.5 p-0', className)}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export interface PasswordRuleProps extends ComponentProps<'li'> {
|
||||
met: boolean;
|
||||
/** Show it in red while unmet (after a submit attempt). */
|
||||
showError?: boolean;
|
||||
}
|
||||
|
||||
export function PasswordRule({ met, showError, className, children, ...props }: PasswordRuleProps) {
|
||||
return (
|
||||
<li
|
||||
data-slot="password-rule"
|
||||
className={cn(
|
||||
'flex list-none items-center gap-2 text-xs',
|
||||
met ? 'text-fg-muted' : showError ? 'text-danger-fg' : 'text-fg-subtle',
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
{met ? (
|
||||
<span className="flex h-4 w-4 flex-none items-center justify-center rounded-full bg-success text-on-color">
|
||||
<Check size={10} strokeWidth={4} aria-hidden="true" />
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
className={cn(
|
||||
'flex list-none items-center gap-2 text-xs',
|
||||
r.met ? 'text-fg-muted' : showErrors ? 'text-danger-fg' : 'text-fg-subtle',
|
||||
'box-border h-4 w-4 flex-none rounded-full border-[1.5px]',
|
||||
showError ? 'border-danger-fg' : 'border-line-control',
|
||||
)}
|
||||
>
|
||||
{r.met ? (
|
||||
<span className="flex h-4 w-4 flex-none items-center justify-center rounded-full bg-success text-on-color">
|
||||
<Check size={10} strokeWidth={4} aria-hidden="true" />
|
||||
</span>
|
||||
) : (
|
||||
<span
|
||||
className={cn(
|
||||
'box-border h-4 w-4 flex-none rounded-full border-[1.5px]',
|
||||
showErrors ? 'border-danger-fg' : 'border-line-control',
|
||||
)}
|
||||
/>
|
||||
)}
|
||||
{r.label}
|
||||
<span className="sr-only">{r.met ? 'erfüllt' : 'nicht erfüllt'}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
/>
|
||||
)}
|
||||
{children}
|
||||
<span className="sr-only">{met ? 'erfüllt' : 'nicht erfüllt'}</span>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user