@arbol-ai/ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,79 @@
1
+ # Setting up an app with @arbol-ai/ui
2
+
3
+ ## 1. Install
4
+
5
+ ```bash
6
+ bun add @arbol-ai/ui react-aria-components react-aria
7
+ # Optional entries:
8
+ bun add echarts # @arbol-ai/ui/charts
9
+ bun add @tanstack/react-form # @arbol-ai/ui/form
10
+ ```
11
+
12
+ Peers: React 19, `react-aria-components` ≥1.21, `react-aria` ≥3.52, Tailwind CSS ≥4.1. Keep one copy of
13
+ React Aria in the app (`bun pm ls react-aria-components`): two copies split the locale and router contexts.
14
+
15
+ ## 2. Styles
16
+
17
+ In the app's entry stylesheet, after Tailwind:
18
+
19
+ ```css
20
+ @import 'tailwindcss';
21
+ @import '@arbol-ai/ui/theme.css';
22
+ ```
23
+
24
+ The theme adds the tokens (`bg-primary`, `text-muted-foreground`, `rounded-field`, `shadow-md`, the gray
25
+ and status ramps), the base layer and an `@source` for the library's files, so Tailwind generates the
26
+ classes the components use. Dark mode is the `dark` class on `<html>`; the grayscale appearance is
27
+ `data-theme="mono"` on `<html>`. Set them before the first paint (an inline script in `index.html`) to
28
+ avoid a flash.
29
+
30
+ Fonts are named, never shipped: load your faces with `@font-face`, or the brand's open ones (Schibsted
31
+ Grotesk, Martian Mono) from Fontsource, or override `--ui-font-sans`, `--ui-font-heading`, `--ui-font-mono`.
32
+
33
+ ## 3. The provider
34
+
35
+ Render `UIProvider` once, above every component:
36
+
37
+ ```tsx
38
+ import { UIProvider } from '@arbol-ai/ui';
39
+ import { useRouter } from '@tanstack/react-router';
40
+
41
+ export const Providers = ({ children }: { children: React.ReactNode }) => {
42
+ const router = useRouter();
43
+ return (
44
+ <UIProvider
45
+ locale={locale}
46
+ navigate={(to, options) => router.navigate({ ...options, to })}
47
+ useHref={(to) => router.buildLocation({ to }).href}
48
+ >
49
+ {children}
50
+ </UIProvider>
51
+ );
52
+ };
53
+ ```
54
+
55
+ - `locale`: the app's language as a BCP 47 tag. React Aria formats dates and numbers with it, and the
56
+ library picks its own strings by language (`es-*` → Spanish, anything else → English).
57
+ - Paraglide: `locale={getLocale() === 'es' ? 'es-CO' : 'en-US'}`.
58
+ - i18next: `locale={i18n.language}`.
59
+ - Spanish only: `locale="es-CO"`.
60
+ - `navigate` / `useHref`: every `href` in the library (links, menu items, tabs, table rows, breadcrumbs,
61
+ navigation) then navigates client-side. Type the hrefs with React Aria's `RouterConfig`:
62
+
63
+ ```ts
64
+ import type { NavigateOptions, ToOptions } from '@tanstack/react-router';
65
+
66
+ declare module 'react-aria-components' {
67
+ interface RouterConfig {
68
+ href: ToOptions['to'];
69
+ routerOptions: Omit<NavigateOptions, keyof ToOptions>;
70
+ }
71
+ }
72
+ ```
73
+
74
+ - `messages`: optional replacements for the library's own strings (see `i18n.md`).
75
+
76
+ ## 4. Toasts
77
+
78
+ Mount `<Toaster />` once inside `UIProvider` (usually in the root layout), then call
79
+ `toast.success(...)` / `toast.error(...)` from anywhere.