shadcn base

This commit is contained in:
wip
2026-11-04 22:31:12 +01:00
commit d16a94324b
94 changed files with 15927 additions and 0 deletions
+119
View File
@@ -0,0 +1,119 @@
import type { ReactNode } from 'react';
import { Check, ListChecks, Target, Users } 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) {
return (
<div
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>
);
}
export interface PasswordRule {
label: string;
met: boolean;
}
/** Checks a password against the design's three rules. */
export function passwordRules(pw: string): PasswordRule[] {
return [
{ label: 'Mindestens 8 Zeichen', met: pw.length >= 8 },
{ label: 'Groß- und Kleinbuchstaben', met: /[a-zäöü]/.test(pw) && /[A-ZÄÖÜ]/.test(pw) },
{ label: 'Mindestens eine Zahl', met: /\d/.test(pw) },
];
}
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) {
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}
className={cn(
'flex list-none items-center gap-2 text-xs',
r.met ? 'text-fg-muted' : showErrors ? 'text-danger-fg' : 'text-fg-subtle',
)}
>
{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>
);
}