Baseline: stan przed refaktoryzacja struktury

This commit is contained in:
tisachi
2026-09-04 19:06:19 +02:00
commit 1c8594ad96
369 changed files with 71407 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
import { DAY_NAMES, TIME_SLOTS } from '../lib/availability';
import { Select } from './ui';
import type { Availability, DayAvailability } from '../api/types';
const DEFAULT_START = '18:00';
const DEFAULT_END = '20:00';
export function AvailabilityEditor({
value,
onChange,
}: {
value: Availability;
onChange: (value: Availability) => void;
}) {
const setDay = (i: number, day: DayAvailability | null) => {
const next = [...value];
next[i] = day;
onChange(next);
};
return (
<div className="space-y-2">
{DAY_NAMES.map((name, i) => {
const day = value[i];
const enabled = day != null;
const start = day?.start ?? DEFAULT_START;
const end = day?.end ?? DEFAULT_END;
return (
<div key={name} className="flex items-center gap-2">
<span className="w-12 shrink-0 text-dim text-[0.875rem]">{name}</span>
<input
type="checkbox"
aria-label={`${name}: dostępny`}
checked={enabled}
onChange={(e) => setDay(i, e.target.checked ? { start, end } : null)}
className="size-4 accent-[var(--accent)]"
/>
<Select
aria-label={`${name}: od`}
value={start}
disabled={!enabled}
onChange={(e) => setDay(i, { start: e.target.value, end })}
className="flex-1"
>
{TIME_SLOTS.map((s) => (
<option key={s} value={s}>
{s}
</option>
))}
</Select>
<span className="text-dim">–</span>
<Select
aria-label={`${name}: do`}
value={end}
disabled={!enabled}
onChange={(e) => setDay(i, { start, end: e.target.value })}
className="flex-1"
>
{TIME_SLOTS.map((s) => (
<option key={s} value={s}>
{s}
</option>
))}
</Select>
</div>
);
})}
</div>
);
}

View File

@@ -0,0 +1,46 @@
import { cn } from '../lib/utils';
const VARIANTS = [
'bg-[linear-gradient(150deg,#e0704f,#a63c22)]',
'bg-[linear-gradient(150deg,#c9a24d,#8a651f)]',
'bg-[linear-gradient(150deg,#5f93b8,#37617f)]',
'bg-[linear-gradient(150deg,#7fa06a,#4c6a3a)]',
];
function hash(s: string): number {
let h = 0;
for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) | 0;
return Math.abs(h);
}
/** Awatar z inicjałami (4 gradientowe warianty dobierane stabilnie po nazwie). */
export function Avatar({
name,
size = 32,
className = '',
}: {
name: string;
size?: number;
className?: string;
}) {
const initials = name
.trim()
.split(/\s+/)
.slice(0, 2)
.map((p) => p[0]?.toUpperCase() ?? '')
.join('');
return (
<span
aria-hidden="true"
className={cn(
'grid flex-none place-items-center rounded-full font-extrabold tracking-[0.02em] text-white',
'shadow-[inset_0_1px_0_rgb(255_255_255/0.25),0_1px_4px_rgb(0_0_0/0.25)]',
VARIANTS[hash(name || '?') % VARIANTS.length],
className,
)}
style={{ width: size, height: size, fontSize: size * 0.375 }}
>
{initials || '?'}
</span>
);
}

View File

@@ -0,0 +1,26 @@
import { cn } from '../lib/utils';
/** Geometryczny znak marki (sztanga-monogram) w koralowym gradiencie. */
export function Brandmark({ size = 30, className = '' }: { size?: number; className?: string }) {
return (
<span
aria-hidden="true"
className={cn(
'grid flex-none place-items-center rounded-[8px] bg-(image:--mark-grad) text-accent-ink shadow-(--mark-shadow)',
className,
)}
style={{ width: size, height: size }}
>
<svg
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2.4}
strokeLinecap="round"
style={{ width: size * 0.57, height: size * 0.57 }}
>
<path d="M6.5 6.5v11M17.5 6.5v11M3 9.5v5M21 9.5v5M6.5 12h11" />
</svg>
</span>
);
}

View File

@@ -0,0 +1,186 @@
import { useState } from 'react';
import { NavLink, Outlet, useNavigate } from 'react-router-dom';
import {
Building2,
Dumbbell,
LogOut,
ScrollText,
ShieldCheck,
Target,
Users,
Wrench,
X,
type LucideIcon,
} from 'lucide-react';
import { useAuth } from '../store/auth';
import { Button, ThemeToggle } from './ui';
import { Topbar } from '../topbar';
import { Brandmark } from './Brandmark';
import { Avatar } from './Avatar';
import { cn } from '../lib/utils';
interface NavItem {
to: string;
label: string;
icon: LucideIcon;
end: boolean;
}
interface NavSection {
label: string;
items: NavItem[];
}
const SECTIONS: NavSection[] = [
{
label: 'Zarządzanie',
items: [
{ to: '/gyms', label: 'Siłownie', icon: Building2, end: false },
{ to: '/verifications', label: 'Weryfikacje', icon: ShieldCheck, end: false },
{ to: '/users', label: 'Użytkownicy', icon: Users, end: false },
],
},
{
label: 'Słowniki',
items: [
{ to: '/focus-areas', label: 'Obszary treningowe', icon: Target, end: false },
{ to: '/exercises', label: 'Rodzaje ćwiczeń', icon: Dumbbell, end: false },
{ to: '/equipment', label: 'Urządzenia', icon: Wrench, end: false },
],
},
{
label: 'System',
items: [{ to: '/logs', label: 'Logi', icon: ScrollText, end: true }],
},
];
/* Wiersze nawigacji wg Ember: aktywny = tint akcentu + pionowy pasek przy krawędzi. */
function NavLinks({ items, onNavigate }: { items: NavItem[]; onNavigate?: () => void }) {
return (
<nav className="flex flex-col gap-0.5 px-3" aria-label="Nawigacja główna">
{items.map((item) => (
<NavLink
key={item.to}
to={item.to}
end={item.end}
onClick={onNavigate}
className={({ isActive }) =>
cn(
'relative flex h-[38px] items-center gap-2.5 rounded-[10px] px-3 text-[13.5px] font-semibold transition-colors duration-150',
isActive ? 'bg-accent/11 text-accent-text' : 'text-dim hover:bg-line/30 hover:text-ink',
)
}
>
{({ isActive }) => (
<>
{isActive && (
<span
aria-hidden="true"
className="absolute -left-3 bottom-[9px] top-[9px] w-[3px] rounded-full bg-(image:--nav-bar-grad)"
/>
)}
<item.icon className="h-[17px] w-[17px] shrink-0" strokeWidth={1.9} />
<span className="min-w-0 truncate">{item.label}</span>
</>
)}
</NavLink>
))}
</nav>
);
}
function NavSections({ onNavigate }: { onNavigate?: () => void }) {
return (
<div className="flex flex-col gap-4">
{SECTIONS.map((section) => (
<div key={section.label}>
<div className="mb-1 px-6 text-[10.5px] font-bold uppercase tracking-[0.13em] text-dim/80">
{section.label}
</div>
<NavLinks items={section.items} onNavigate={onNavigate} />
</div>
))}
</div>
);
}
export default function Layout() {
const { user, logout } = useAuth();
const navigate = useNavigate();
const [drawerOpen, setDrawerOpen] = useState(false);
const fullName = user?.email ?? 'Admin';
const doLogout = async () => {
await logout();
navigate('/login');
};
const footer = (
<div className="mt-auto border-t border-line px-4 pb-4 pt-3">
<div className="mb-3 flex items-center gap-2.5">
<Avatar name={fullName} size={32} />
<div className="min-w-0">
<div className="truncate text-[13px] font-bold">{user?.email}</div>
<div className="text-[11.5px] text-dim">Administrator</div>
</div>
</div>
<div className="flex items-center gap-2">
<ThemeToggle />
<Button variant="secondary" size="sm" className="flex-1" onClick={doLogout}>
<LogOut className="w-4 h-4" />
Wyloguj
</Button>
</div>
</div>
);
return (
<div className="min-h-screen md:flex">
{/* Mobile drawer (telefon): ten sam zestaw pozycji co sidebar */}
{drawerOpen && (
<div className="fixed inset-0 z-50 md:hidden">
<div
className="absolute inset-0 animate-in fade-in-0 bg-black/60 duration-150"
onClick={() => setDrawerOpen(false)}
/>
<aside className="absolute left-0 top-0 flex h-full w-72 animate-in slide-in-from-left flex-col border-r border-line bg-card duration-200">
<div className="flex items-center justify-between px-4 py-4">
<div className="flex items-center gap-2.5">
<Brandmark size={26} />
<span className="font-display text-[1.05rem] font-bold tracking-[-0.02em]">FitOS Admin</span>
</div>
<button
type="button"
onClick={() => setDrawerOpen(false)}
aria-label="Zamknij menu"
className="-m-2 cursor-pointer p-2 text-dim hover:text-ink"
>
<X className="h-5 w-5" />
</button>
</div>
<NavSections onNavigate={() => setDrawerOpen(false)} />
{footer}
</aside>
</div>
)}
{/* Desktop/tablet sidebar z sekcjami */}
<aside className="hidden h-screen flex-col border-r border-line bg-card md:sticky md:top-0 md:flex md:w-64">
<div className="flex items-center gap-2.5 px-4 py-4">
<Brandmark size={26} />
<span className="font-display text-[1.05rem] font-bold tracking-[-0.02em]">FitOS Admin</span>
</div>
<NavSections />
{footer}
</aside>
<main className="min-w-0 flex-1">
<Topbar onMenuOpen={() => setDrawerOpen(true)} />
<div className="mx-auto max-w-5xl px-4 pb-24 pt-6 md:px-8 md:pb-10 md:pt-8">
<Outlet />
</div>
</main>
</div>
);
}

452
admin/src/components/ui.tsx Normal file
View File

@@ -0,0 +1,452 @@
import type {
ButtonHTMLAttributes,
InputHTMLAttributes,
ReactNode,
SelectHTMLAttributes,
TextareaHTMLAttributes,
} from 'react';
import { Link } from 'react-router-dom';
import { ArrowLeft, Moon, Sun, X } from 'lucide-react';
import { cva } from 'class-variance-authority';
import { useTheme } from '../store/theme';
import { cn } from '../lib/utils';
import { Button as UIButton, buttonVariants } from './ui/button';
import { Card as UICard } from './ui/card';
import { Badge as UIBadge } from './ui/badge';
import { Input as UIInput } from './ui/input';
import { Textarea as UITextarea } from './ui/textarea';
import { Label as UILabel } from './ui/label';
import { Field as UIField } from './ui/field';
import { Skeleton as UISkeleton } from './ui/skeleton';
import { Progress as UIProgress } from './ui/progress';
import { ErrorText as UIErrorText, SuccessText as UISuccessText } from './ui/alert';
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
} from './ui/dialog';
/* Button */
export type ButtonVariant = 'primary' | 'secondary' | 'danger' | 'ghost';
export type ButtonSize = 'md' | 'sm';
export function Button({
variant,
size,
className,
...props
}: ButtonHTMLAttributes<HTMLButtonElement> & { variant?: ButtonVariant; size?: ButtonSize }) {
return <UIButton variant={variant} size={size} className={className} {...props} />;
}
/* Card */
export function Card({ className, children }: { className?: string; children: ReactNode }) {
return <UICard className={className}>{children}</UICard>;
}
/* Badge */
export type BadgeColor = 'green' | 'gray' | 'red' | 'yellow' | 'blue';
export function Badge({
color,
className,
children,
}: {
color?: BadgeColor;
className?: string;
children: ReactNode;
}) {
return <UIBadge color={color} className={className}>{children}</UIBadge>;
}
/* Form fields */
export type FieldSize = 'md' | 'sm';
const FIELD_BASE =
'w-full bg-input border border-line rounded-[10px] text-ink font-[inherit] shadow-(--inset-shadow) transition-shadow duration-150 focus:outline-none focus:border-accent-text focus:ring-[3px] focus:ring-accent/18 disabled:cursor-not-allowed disabled:opacity-50';
const FIELD_SIZES: Record<FieldSize, string> = {
md: 'h-10 px-3 text-[0.95rem]',
// matches the height of <Button size="sm"> (header / context menu)
sm: 'h-8 px-3 text-[0.875rem]',
};
export function Input({
size = 'md',
className,
...props
}: Omit<InputHTMLAttributes<HTMLInputElement>, 'size'> & { size?: FieldSize }) {
return <UIInput size={size} className={className} {...props} />;
}
const selectVariants = cva(FIELD_BASE, {
variants: { size: FIELD_SIZES },
defaultVariants: { size: 'md' },
});
export function Select({
size = 'md',
className,
children,
...props
}: Omit<SelectHTMLAttributes<HTMLSelectElement>, 'size'> & { size?: FieldSize }) {
return (
<select data-slot="select" className={cn(selectVariants({ size }), className)} {...props}>
{children}
</select>
);
}
export function Textarea({
size = 'md',
className,
...props
}: TextareaHTMLAttributes<HTMLTextAreaElement> & { size?: FieldSize }) {
return <UITextarea size={size} className={className} {...props} />;
}
export function Label({ children, className }: { children: ReactNode; className?: string }) {
return <UILabel className={className}>{children}</UILabel>;
}
export function Field({
label,
children,
className,
}: {
label: string;
children: ReactNode;
className?: string;
}) {
return (
<UIField label={label} className={className}>
{children}
</UIField>
);
}
/* Headings */
export function H1({ className = '', children }: { className?: string; children: ReactNode }) {
return <h1 className={`text-[1.45rem] sm:text-[1.6rem] font-bold tracking-[-0.02em] mb-4 ${className}`.trim()}>{children}</h1>;
}
export function H2({ className = '', children }: { className?: string; children: ReactNode }) {
return <h2 className={`text-[1.15rem] sm:text-[1.25rem] font-bold tracking-[-0.01em] mb-3 ${className}`.trim()}>{children}</h2>;
}
export function H3({ className = '', children }: { className?: string; children: ReactNode }) {
return <h3 className={`text-[1.05rem] font-semibold mb-2 ${className}`.trim()}>{children}</h3>;
}
/* Page header: title + optional badge, actions on the right (stacks on mobile) */
export function PageHeader({
title,
badge,
actions,
}: {
title: string;
badge?: ReactNode;
actions?: ReactNode;
}) {
return (
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 mb-5">
<div className="flex items-center gap-3 flex-wrap">
<H1 className="mb-0">{title}</H1>
{badge}
</div>
{actions}
</div>
);
}
/* Back button — ghost, small; `to` renders a Link, `onClick` a plain button */
export function BackButton({
to,
onClick,
children = 'Wstecz',
className = '',
}: {
to?: string;
onClick?: () => void;
children?: ReactNode;
className?: string;
}) {
const cls = cn(buttonVariants({ variant: 'ghost', size: 'sm' }), className);
if (to) {
return (
<Link to={to} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
</Link>
);
}
return (
<button type="button" onClick={onClick} className={cls}>
<ArrowLeft className="w-4 h-4" />
{children}
</button>
);
}
/* Section header: H2 + muted description + optional actions (right) */
export function SectionHeader({
title,
description,
actions,
className = '',
}: {
title: ReactNode;
description?: ReactNode;
actions?: ReactNode;
className?: string;
}) {
return (
<div className={`flex flex-wrap items-start justify-between gap-3 mb-3 ${className}`.trim()}>
<div className="min-w-0">
<H2 className="mb-0.5">{title}</H2>
{description && <Muted className="text-[0.875rem]">{description}</Muted>}
</div>
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
</div>
);
}
/* Meta item: small icon + muted text */
export function MetaItem({
icon: Icon,
children,
className = '',
}: {
icon: React.ComponentType<{ className?: string }>;
children: ReactNode;
className?: string;
}) {
return (
<span className={`inline-flex items-center gap-1.5 text-dim text-[0.875rem] ${className}`.trim()}>
<Icon className="w-4 h-4 shrink-0" />
<span className="min-w-0 truncate">{children}</span>
</span>
);
}
/* List row: płaski wiersz (tytuł + meta lewo, akcje prawo); w listach w karcie
rodzic używa `divide-y divide-line` (dłuższe) albo `space-y-1` (krótkie). */
export function ListRow({
title,
meta,
actions,
children,
className = '',
}: {
title: ReactNode;
meta?: ReactNode;
actions?: ReactNode;
children?: ReactNode;
className?: string;
}) {
return (
<div
data-slot="list-row"
className={`flex flex-wrap items-center justify-between gap-3 px-2 py-3 rounded-lg transition-colors hover:bg-line/20 ${className}`.trim()}
>
<div className="min-w-0 flex-1">
<div className="text-[0.95rem] font-semibold min-w-0 truncate">{title}</div>
{meta && <Muted className="text-[0.875rem]">{meta}</Muted>}
</div>
{actions && <div className="flex items-center gap-2 shrink-0">{actions}</div>}
{children}
</div>
);
}
/* Chip: small pill (+ optional remove button) */
export function Chip({
children,
onRemove,
removeLabel = 'Usuń',
className = '',
}: {
children: ReactNode;
onRemove?: () => void;
removeLabel?: string;
className?: string;
}) {
return (
<span
data-slot="chip"
className={`inline-flex items-center gap-1.5 bg-card border border-line rounded-full px-3 py-1 text-[0.8125rem] font-semibold text-dim ${className}`.trim()}
>
{children}
{onRemove && (
<button type="button" onClick={onRemove} aria-label={removeLabel} className="text-dim hover:text-danger cursor-pointer">
<X className="w-3.5 h-3.5" />
</button>
)}
</span>
);
}
/* Text helpers */
export function Muted({ className = '', children }: { className?: string; children: ReactNode }) {
return <span className={`text-dim ${className}`.trim()}>{children}</span>;
}
export function ErrorText({ children }: { children: ReactNode }) {
return <UIErrorText>{children}</UIErrorText>;
}
export function SuccessText({ children }: { children: ReactNode }) {
return <UISuccessText>{children}</UISuccessText>;
}
export function Loading({ children = 'Ładowanie…' }: { children?: ReactNode }) {
return <div className="text-dim">{children}</div>;
}
/* Skeleton */
export function Skeleton({ className = '' }: { className?: string }) {
return <UISkeleton className={className} />;
}
/* Empty state */
export function EmptyState({
icon: Icon,
title,
description,
action,
}: {
icon: React.ComponentType<{ className?: string }>;
title: string;
description?: string;
action?: ReactNode;
}) {
return (
<div className="flex flex-col items-center justify-center text-center py-10 px-4">
<div className="w-14 h-14 rounded-full bg-accent/10 border border-accent/25 text-accent-text flex items-center justify-center mb-4">
<Icon className="w-7 h-7" />
</div>
<H3 className="mb-1">{title}</H3>
{description && <p className="text-dim text-[0.9rem] max-w-sm">{description}</p>}
{action && <div className="mt-4">{action}</div>}
</div>
);
}
/* Progress bar */
export function ProgressBar({ percent, className = '' }: { percent: number; className?: string }) {
return <UIProgress percent={percent} className={className} />;
}
/* Tabs */
export function Tabs({
tabs,
active,
onChange,
}: {
tabs: { id: string; label: string }[];
active: string;
onChange: (id: string) => void;
}) {
return (
<div className="flex gap-1 p-1 bg-input rounded-[10px] border border-line overflow-x-auto">
{tabs.map((t) => (
<button
key={t.id}
type="button"
onClick={() => onChange(t.id)}
className={`px-3.5 py-2 rounded-lg text-[0.9rem] font-semibold whitespace-nowrap cursor-pointer transition-all duration-150 ${
active === t.id ? 'bg-card text-ink border border-line shadow-card' : 'border border-transparent text-dim hover:text-ink'
}`}
>
{t.label}
</button>
))}
</div>
);
}
/* Modal — Radix Dialog: focus trap, Esc, scroll-lock, aria; bottom-sheet na mobile */
export function Modal({
open,
onClose,
title,
children,
}: {
open: boolean;
onClose: () => void;
title: string;
children: ReactNode;
}) {
return (
<Dialog open={open} onOpenChange={(o) => !o && onClose()}>
<DialogContent>
<DialogHeader>
<DialogTitle asChild>
<h3 className="text-[1.05rem] font-semibold">{title}</h3>
</DialogTitle>
<DialogClose asChild>
<button aria-label="Zamknij" className="p-1.5 -m-1.5 text-dim hover:text-ink cursor-pointer">
<X className="w-5 h-5" />
</button>
</DialogClose>
</DialogHeader>
<DialogDescription asChild>
<span className="sr-only" />
</DialogDescription>
{children}
</DialogContent>
</Dialog>
);
}
/* Confirm dialog */
export function ConfirmDialog({
open,
onClose,
onConfirm,
title,
description,
confirmLabel = 'Potwierdź',
danger,
busy,
}: {
open: boolean;
onClose: () => void;
onConfirm: () => void;
title: string;
description: string;
confirmLabel?: string;
danger?: boolean;
busy?: boolean;
}) {
return (
<Modal open={open} onClose={onClose} title={title}>
<p className="text-dim text-[0.95rem]">{description}</p>
<div className="flex flex-col-reverse sm:flex-row sm:items-center sm:justify-end gap-3 mt-5">
<Button variant="secondary" onClick={onClose} className="w-full sm:w-auto">
Anuluj
</Button>
<Button variant={danger ? 'danger' : 'primary'} onClick={onConfirm} disabled={busy} className="w-full sm:w-auto">
{confirmLabel}
</Button>
</div>
</Modal>
);
}
/* Theme toggle */
export function ThemeToggle({ className = '' }: { className?: string }) {
const { theme, toggle } = useTheme();
return (
<button
onClick={toggle}
aria-label="Przełącz motyw"
title="Przełącz motyw"
className={`p-2.5 rounded-full bg-card border border-line text-dim shadow-card hover:text-ink hover:border-accent/45 cursor-pointer transition-all duration-150 ${className}`.trim()}
>
{theme === 'dark' ? <Sun className="w-5 h-5" /> : <Moon className="w-5 h-5" />}
</button>
);
}

View File

@@ -0,0 +1,12 @@
import type { ReactNode } from 'react';
import { cn } from '../../lib/utils';
function ErrorText({ children, className }: { children: ReactNode; className?: string }) {
return <div data-slot="alert" className={cn('mt-2 text-[0.9rem] text-danger', className)}>{children}</div>;
}
function SuccessText({ children, className }: { children: ReactNode; className?: string }) {
return <div data-slot="alert" className={cn('mt-2 text-[0.9rem] text-accent-text', className)}>{children}</div>;
}
export { ErrorText, SuccessText };

View File

@@ -0,0 +1,31 @@
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '../../lib/utils';
const badgeVariants = cva(
'inline-flex items-center gap-1 px-2.5 py-0.5 rounded-full text-[0.75rem] font-bold whitespace-nowrap',
{
variants: {
color: {
green: 'bg-accent/14 text-accent-text',
gray: 'bg-dim/13 text-dim',
red: 'bg-danger/12 text-danger',
yellow: 'bg-warn/13 text-warn',
blue: 'bg-info/13 text-info',
},
},
defaultVariants: {
color: 'gray',
},
},
);
export interface BadgeProps
extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'color'>,
VariantProps<typeof badgeVariants> {}
function Badge({ className, color, ...props }: BadgeProps) {
return <span data-slot="badge" className={cn(badgeVariants({ color }), className)} {...props} />;
}
export { Badge, badgeVariants };

View File

@@ -0,0 +1,47 @@
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '../../lib/utils';
const buttonVariants = cva(
'inline-flex items-center justify-center gap-2 rounded-[10px] font-bold whitespace-nowrap cursor-pointer transition-all duration-150 disabled:cursor-not-allowed disabled:opacity-50 active:scale-[.985] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/60 focus-visible:ring-offset-2 focus-visible:ring-offset-bg',
{
variants: {
variant: {
primary: 'bg-(image:--btn-grad) text-accent-ink shadow-(--btn-shadow) hover:brightness-105',
secondary:
'bg-card/60 text-ink border border-line shadow-card hover:border-accent/55 hover:text-accent-text',
danger: 'bg-transparent text-danger border border-danger/45 hover:bg-danger/10',
ghost: 'bg-transparent text-dim hover:text-ink hover:bg-line/30',
},
size: {
md: 'h-10 px-[18px] text-[0.875rem]',
sm: 'h-8 px-3 text-[0.8125rem] rounded-lg',
},
},
defaultVariants: {
variant: 'primary',
size: 'md',
},
},
);
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
Omit<VariantProps<typeof buttonVariants>, 'size'> {
size?: 'md' | 'sm';
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, type = 'button', ...props }, ref) => (
<button
type={type}
data-slot="button"
className={cn(buttonVariants({ variant, size }), className)}
ref={ref}
{...props}
/>
),
);
Button.displayName = 'Button';
export { Button, buttonVariants };

View File

@@ -0,0 +1,16 @@
import * as React from 'react';
import { cn } from '../../lib/utils';
const Card = React.forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
({ className, ...props }, ref) => (
<div
ref={ref}
data-slot="card"
className={cn('bg-(image:--card-grad) border border-line rounded-lg shadow-card p-5 sm:p-6 mb-4', className)}
{...props}
/>
),
);
Card.displayName = 'Card';
export { Card };

View File

@@ -0,0 +1,101 @@
import * as React from 'react';
import * as DialogPrimitive from '@radix-ui/react-dialog';
import { cn } from '../../lib/utils';
const Dialog = DialogPrimitive.Root;
const DialogTrigger = DialogPrimitive.Trigger;
const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;
const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
data-slot="dialog-overlay"
className={cn(
'fixed inset-0 z-50 bg-black/60 backdrop-blur-[2px] data-[state=open]:animate-in data-[state=open]:fade-in-0 duration-200',
className,
)}
ref={ref}
{...props}
/>
));
DialogOverlay.displayName = 'DialogOverlay';
/**
* Content: bottom-sheet na mobile (przylega do dołu, zaokrąglone góra),
* wyśrodkowany panel na desktopie. max-h 85vh ze scrollowaniem.
*/
const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
data-slot="dialog-content"
ref={ref}
className={cn(
'fixed inset-x-0 bottom-0 z-50 max-h-[85vh] w-full overflow-y-auto rounded-t-2xl border border-line bg-card p-5 shadow-card',
'sm:bottom-auto sm:left-1/2 sm:right-auto sm:top-1/2 sm:max-w-md sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-2xl',
'duration-200 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=open]:slide-in-from-bottom-2',
'data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95',
className,
)}
{...props}
>
{children}
</DialogPrimitive.Content>
</DialogPortal>
));
DialogContent.displayName = 'DialogContent';
const DialogHeader = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div data-slot="dialog-header" className={cn('mb-4 flex items-center justify-between gap-3', className)} {...props} />
);
DialogHeader.displayName = 'DialogHeader';
const DialogFooter = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
<div data-slot="dialog-footer" className={cn('mt-5 flex flex-col-reverse gap-3 sm:flex-row sm:items-center sm:justify-end', className)} {...props} />
);
DialogFooter.displayName = 'DialogFooter';
const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
data-slot="dialog-title"
ref={ref}
className={cn('text-[1.05rem] font-semibold', className)}
{...props}
/>
));
DialogTitle.displayName = 'DialogTitle';
const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
data-slot="dialog-description"
ref={ref}
className={cn('text-dim text-[0.95rem]', className)}
{...props}
/>
));
DialogDescription.displayName = 'DialogDescription';
export {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogOverlay,
DialogPortal,
DialogTitle,
DialogTrigger,
};

View File

@@ -0,0 +1,18 @@
import * as React from 'react';
import { Label } from './label';
import { cn } from '../../lib/utils';
interface FieldProps extends React.HTMLAttributes<HTMLDivElement> {
label: string;
}
function Field({ className, label, children, ...props }: FieldProps) {
return (
<div data-slot="field" className={cn('mb-3.5', className)} {...props}>
<Label>{label}</Label>
{children}
</div>
);
}
export { Field };

View File

@@ -0,0 +1,31 @@
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '../../lib/utils';
const inputVariants = cva(
'w-full bg-input border border-line rounded-[10px] text-ink font-[inherit] placeholder:text-dim/70 shadow-(--inset-shadow) transition-shadow duration-150 focus:outline-none focus:border-accent-text focus:ring-[3px] focus:ring-accent/18 disabled:cursor-not-allowed disabled:opacity-50',
{
variants: {
size: {
md: 'h-10 px-3 text-[0.95rem]',
sm: 'h-8 px-3 text-[0.875rem]',
},
},
defaultVariants: {
size: 'md',
},
},
);
export interface InputProps
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size'>,
VariantProps<typeof inputVariants> {}
const Input = React.forwardRef<HTMLInputElement, InputProps>(
({ className, size, type, ...props }, ref) => (
<input type={type} data-slot="input" className={cn(inputVariants({ size }), className)} ref={ref} {...props} />
),
);
Input.displayName = 'Input';
export { Input, inputVariants };

View File

@@ -0,0 +1,16 @@
import * as React from 'react';
import { cn } from '../../lib/utils';
const Label = React.forwardRef<HTMLLabelElement, React.LabelHTMLAttributes<HTMLLabelElement>>(
({ className, ...props }, ref) => (
<label
ref={ref}
data-slot="label"
className={cn('block mb-1.5 text-dim text-[11px] font-bold uppercase tracking-[0.1em]', className)}
{...props}
/>
),
);
Label.displayName = 'Label';
export { Label };

View File

@@ -0,0 +1,14 @@
import { cn } from '../../lib/utils';
function Progress({ percent, className }: { percent: number; className?: string }) {
return (
<div data-slot="progress" className={cn('h-2 overflow-hidden rounded-full bg-input', className)}>
<div
className="h-full rounded-full bg-(image:--progress-grad) transition-[width] duration-300"
style={{ width: `${Math.max(0, Math.min(100, percent))}%` }}
/>
</div>
);
}
export { Progress };

View File

@@ -0,0 +1,23 @@
import * as React from 'react';
import * as SeparatorPrimitive from '@radix-ui/react-separator';
import { cn } from '../../lib/utils';
const Separator = React.forwardRef<
React.ElementRef<typeof SeparatorPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (
<SeparatorPrimitive.Root
ref={ref}
data-slot="separator"
decorative={decorative}
orientation={orientation}
className={cn(
'shrink-0 bg-line data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px',
className,
)}
{...props}
/>
));
Separator.displayName = 'Separator';
export { Separator };

View File

@@ -0,0 +1,8 @@
import * as React from 'react';
import { cn } from '../../lib/utils';
function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) {
return <div data-slot="skeleton" className={cn('skeleton-shimmer rounded-lg', className)} {...props} />;
}
export { Skeleton };

View File

@@ -0,0 +1,31 @@
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '../../lib/utils';
const textareaVariants = cva(
'w-full bg-input border border-line rounded-[10px] text-ink font-[inherit] placeholder:text-dim/70 shadow-(--inset-shadow) transition-shadow duration-150 focus:outline-none focus:border-accent-text focus:ring-[3px] focus:ring-accent/18 disabled:cursor-not-allowed disabled:opacity-50',
{
variants: {
size: {
md: 'px-3 py-2.5 text-[0.95rem]',
sm: 'px-3 py-1.5 text-[0.875rem]',
},
},
defaultVariants: {
size: 'md',
},
},
);
export interface TextareaProps
extends React.TextareaHTMLAttributes<HTMLTextAreaElement>,
VariantProps<typeof textareaVariants> {}
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(
({ className, size, ...props }, ref) => (
<textarea data-slot="textarea" className={cn(textareaVariants({ size }), className)} ref={ref} {...props} />
),
);
Textarea.displayName = 'Textarea';
export { Textarea, textareaVariants };