diff --git a/components/ui/avatar.tsx b/components/ui/avatar.tsx new file mode 100644 index 0000000..0466fe6 --- /dev/null +++ b/components/ui/avatar.tsx @@ -0,0 +1,16 @@ +export function initials(name: string): string { + return name + .split(' ') + .map(w => w[0] ?? '') + .join('') + .toUpperCase() + .slice(0, 2) +} + +export function Avatar({ name }: { name: string }) { + return ( + + {initials(name)} + + ) +} diff --git a/components/ui/button.tsx b/components/ui/button.tsx index 0947a2b..ecaecf7 100644 --- a/components/ui/button.tsx +++ b/components/ui/button.tsx @@ -1,25 +1,36 @@ import type { ButtonHTMLAttributes } from 'react' import { cx } from './cx' -type Variant = 'primary' | 'secondary' | 'ghost' | 'icon' +type Variant = 'primary' | 'secondary' | 'icon' const BASE = - 'inline-flex items-center gap-1.5 text-left font-extrabold text-sm leading-tight ' + - 'border border-transparent cursor-pointer transition-colors ' + + 'inline-flex items-center justify-center gap-1.5 whitespace-nowrap transition-colors cursor-pointer ' + 'disabled:opacity-45 disabled:cursor-not-allowed' const VARIANTS: Record = { - primary: 'justify-start bg-accent text-ground px-3.5 py-2 hover:bg-accent-600 active:bg-accent-700', - secondary: 'justify-start border-divider text-ink px-3.5 py-2 hover:bg-ink/7 active:bg-ink/15', - ghost: 'justify-start text-accent-700 px-1 py-2 hover:bg-accent/10 active:bg-accent/20', - icon: 'justify-center w-9 h-9 p-0 text-ink hover:bg-ink/7 active:bg-ink/15', + primary: 'h-8 px-3 rounded-md bg-ink-2 text-white text-[13px] font-semibold shadow-primary hover:bg-ink active:bg-black', + secondary: 'h-8 px-3 rounded-md bg-surface text-ink text-[13px] font-medium shadow-secondary hover:bg-surface-2 active:bg-rule', + icon: 'w-7 h-7 rounded-md text-ink-3 hover:bg-rule', } type Props = ButtonHTMLAttributes & { variant?: Variant block?: boolean + mobile?: boolean } -export function Button({ variant = 'primary', block = false, className, type = 'button', ...rest }: Props) { - return + ) +} diff --git a/components/ui/drawer.tsx b/components/ui/drawer.tsx new file mode 100644 index 0000000..3f516e2 --- /dev/null +++ b/components/ui/drawer.tsx @@ -0,0 +1,51 @@ +'use client' + +import { useEffect } from 'react' +import { X } from 'lucide-react' +import { Button } from './button' + +export function Drawer({ + open, + onClose, + title, + actions, + children, +}: { + open: boolean + onClose: () => void + title: string + actions?: React.ReactNode + children: React.ReactNode +}) { + useEffect(() => { + if (!open) return + const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() } + document.addEventListener('keydown', onKey) + return () => document.removeEventListener('keydown', onKey) + }, [open, onClose]) + + if (!open) return null + + return ( +
+
+ +
+ ) +} diff --git a/components/ui/field.tsx b/components/ui/field.tsx index 7c85ffa..2815fd1 100644 --- a/components/ui/field.tsx +++ b/components/ui/field.tsx @@ -2,14 +2,13 @@ import type { InputHTMLAttributes, ReactNode, SelectHTMLAttributes, TextareaHTML import { cx } from './cx' export const INPUT_CLASS = - 'w-full min-h-9 px-2.5 py-1.5 text-sm text-ink caret-accent bg-surface border border-divider ' + - 'hover:border-ink/45 focus-visible:border-accent focus-visible:outline-offset-0 ' + - 'disabled:opacity-45 disabled:cursor-not-allowed' + 'w-full h-9 px-3 rounded-md bg-surface text-[13px] text-ink caret-accent shadow-input ' + + 'placeholder:text-faint disabled:opacity-45 disabled:cursor-not-allowed' export function Field({ label, htmlFor, children }: { label: string; htmlFor: string; children: ReactNode }) { return (
-