@vvedantb/ui 0.31.0 → 0.32.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.
package/README.md CHANGED
@@ -893,9 +893,11 @@ links under a separator.
893
893
  ### `Icon*` app icons
894
894
 
895
895
  Tabler-style plain app glyphs: `IconVibot`, `IconVhub`, `IconVmem`, `IconVerve`,
896
- `IconVelth` and `IconProjectV`. No background. Each sits on an equalised square viewBox, so all apps look the same size. `APP_ICONS[app]`
896
+ `IconVelth`, `IconProjectV`, `IconEva` and `IconBee`. No background. Each sits on an equalised square viewBox, so all apps look the same size. `APP_ICONS[app]`
897
897
  looks one up by `AppName`.
898
898
 
899
+ `IconEva` (a filled four-point star) and `IconBee` (an orb with eyes, stripes and antennae) are icons only. `eva` and `bee` are in `APP_NAMES`, `APP_MARKS` and `APP_ICONS`, but not in `FAMILY_APPS` or `V_PRO_APP_BENEFITS`, and `AppWordmark` and `PricingModal` do not take them.
900
+
899
901
  ```tsx
900
902
  import { IconVerve } from "@vvedantb/ui"
901
903
 
@@ -951,13 +953,14 @@ import { AppWordmark } from "@vvedantb/ui"
951
953
  ### `AppMark` (deprecated)
952
954
 
953
955
  Deprecated in favour of the `Icon*` components for plain marks. Tiles stay here.
954
- Family app icons: `app` (`projectv`, `vibot`, `vhub`, `vmem`, `verve`, `velth`),
956
+ Family app icons: `app` (`projectv`, `vibot`, `vhub`, `vmem`, `verve`, `velth`, and the icon-only `eva` and `bee`),
955
957
  `variant`, `size`, `title`.
956
958
 
957
959
  - `variant="mark"` (default) is the plain logo in `currentColor`. It sits
958
960
  on a square viewBox. The five apps (`vibot`, `vhub`, `vmem`, `verve`, `velth`) keep one
959
961
  frame size, 629 x 629 (`APP_MARK_CROP_VIEWBOX` is the historical `173 197 629 629`), so relative
960
- glyph sizes match the tiles. Each viewBox origin is centred on that glyph's `markBBox`, so no
962
+ glyph sizes match the tiles. `eva` and `bee` use the same 629 side, but the historical crop does not
963
+ include them. Each viewBox origin is centred on that glyph's `markBBox`, so no
961
964
  glyph sits off-centre in its square. `projectv` is a brand mark, so it keeps its own 687 frame,
962
965
  centred on its bbox (`PROJECTV_MARK_VIEWBOX`, `171.5 181 687 687`). `size` sets both width and
963
966
  height; a string `size` (for example `"2rem"`) is any CSS length. `APP_MARK_VIEWBOX` holds the
@@ -982,7 +985,7 @@ default) and `renderCheckout`.
982
985
 
983
986
  #### Multi-plan (0.22.0)
984
987
 
985
- Header: `apps` (an `AppName[]`, shown as plain `Icon*` logos at the top left; each links to the app's site in a new tab and shows its display name in a tooltip, from `FAMILY_APPS`),
988
+ Header: `apps` (a `FamilyAppName[]`, shown as plain `Icon*` logos at the top left; each links to the app's site in a new tab and shows its display name in a tooltip, from `FAMILY_APPS`),
986
989
  `headline` (centre), a Monthly / Annual switch and a close button (top right).
987
990
  Then one card per entry of `plans` (2 to 4 fit) and one `finePrint` line. Cards
988
991
  stack on narrow screens.
@@ -997,7 +1000,7 @@ outlined "Current plan" button and does not call `renderCheckout`.
997
1000
 
998
1001
  `appBenefits` (`{ app, items }[]`, type `PricingPlanAppBenefit`) groups benefits per app, each under a small heading with that app's icon and display name. It renders after `benefits` and scrolls inside the card when long. Set `currentApp` on the modal to put that app's group first; the other groups keep the array order. The `featured` / `highlighted` plan uses `V_PRO_APP_BENEFITS` (the approved V Pro copy, in the order vibot, vmem, vhub, velth, verve) when it omits `appBenefits`, so apps usually pass only `currentApp`. Other plans show app benefits only when set.
999
1002
 
1000
- `FAMILY_APPS` (and `familyApp(app)`), exported from the root and `@vvedantb/ui/brand`, is the single list of app display names and sites (`vibot`, `Verve`, `Velth`, `vmem`, `vhub`, `Project V`; URLs without a trailing slash). App names live only under `src/brand/`.
1003
+ `FAMILY_APPS` (and `familyApp(app)`), exported from the root and `@vvedantb/ui/brand`, is the single list of app display names and sites (`vibot`, `Verve`, `Velth`, `vmem`, `vhub`, `Project V`; URLs without a trailing slash). Its app type is `FamilyAppName`: `AppName` without the icon-only `eva` and `bee`. App names live only under `src/brand/`.
1001
1004
 
1002
1005
  The `featured` plan's button is a solid primary button (`Button` `variant="default"`). Other plans use `secondary`.
1003
1006
 
@@ -1308,7 +1311,13 @@ import { SonnerToaster, toast } from "@vvedantb/ui";
1308
1311
  />;
1309
1312
  ```
1310
1313
 
1311
- With no new props and no `UiConfig.SonnerToaster` entry the toaster looks as it did in 0.2.1. An entry sets app defaults for any prop (see "App config: AI chat" below). Caller props merge with the package defaults instead of replacing them:
1314
+ With no new props and no `UiConfig.SonnerToaster` entry the toaster looks as it did in 0.2.1, except for three changes from 0.31.1:
1315
+
1316
+ - Toasts sit at the top right (`position="top-right"`). Sonner's own default is bottom-right. Pass `position`, or set `UiConfig.SonnerToaster.position`, to move them.
1317
+ - The text column grows (`content`: `flex min-w-0 grow flex-col`). `unstyled` drops sonner's own grow, so without it the action button left a gap at the right edge. Apps no longer need to set `classes.content` for this.
1318
+ - The action and cancel buttons are 28px tall (`h-7 shrink-0 rounded-control px-2.5 text-xs`), up from 24px. The action button presses with `motion-press active:scale-[0.96]` (`motion-press` is an app utility) and hovers with `hover:bg-primary/90`. `classes.actionButton` replaces the string, and `toastOptions.classNames.actionButton` appends to it.
1319
+
1320
+ A `UiConfig.SonnerToaster` entry sets app defaults for any prop (see "App config: AI chat" below). Caller props merge with the package defaults instead of replacing them:
1312
1321
 
1313
1322
  - `toastOptions.classNames`: per key, the package classes come first and the caller classes follow, so callers can override utilities. Other `toastOptions` fields (such as `duration`) take the caller value.
1314
1323
  - `icons`: merged per key. With `toastIcons="filled24"` the caller overrides single icons and keeps the rest.
@@ -1330,7 +1339,9 @@ Opt-in props (all default to the current look):
1330
1339
 
1331
1340
  With `closeButtonStyle="hoverChip"`, hover changes the text colour, and sonner may still change the background. The border stays `border-border` (pinned with `hover:border-border!` over sonner's dark hover border), so the ring does not brighten in dark mode.
1332
1341
 
1333
- Helpers: `createToasterClassNames`, `mergeToastClassNames`, `mergeToastOptions`, `mergeToasterStyle`, `filledToastIcons`. Fixture: `tokens/examples/toaster/`.
1342
+ Helpers: `createToasterClassNames`, `mergeToastClassNames`, `mergeToastOptions`, `mergeToasterStyle`, `filledToastIcons`. Fixture: `tokens/examples/toaster/` (`update.html` shows the update toast).
1343
+
1344
+ For the "Update available" toast, call `showUpdateAvailableToast({ toast, closeConvex })` or let `startUpdateAvailableWatcher` call it. See `app/README.md`.
1334
1345
 
1335
1346
  ## App config
1336
1347
 
package/app/README.md ADDED
@@ -0,0 +1,269 @@
1
+ # App helpers (`@vvedantb/ui`)
2
+
3
+ Shared web React helpers that were duplicated across apps. Source-exported as the `./app` subpath of `@vvedantb/ui`.
4
+
5
+ ## Install
6
+
7
+ ```sh
8
+ npm install @vvedantb/ui
9
+ ```
10
+
11
+ ## Peers
12
+
13
+ Required: `react` and `react-dom` (>=19). Optional peers of `@vvedantb/ui` used by the app helpers: `@clerk/clerk-react` (`useStableAuth`, `ConvexClerkProvider`), `convex` (`ConvexClerkProvider`, `useEnsureUser`), `@tanstack/react-hotkeys` and `zod` (your `z` for `parseClientEnv`). The root imports Clerk and `convex/react` statically, so they must be installed even if you do not use these helpers; see the package README.
14
+
15
+ `sonner` is not a dependency. The update watcher takes the toast API as an option. The app source uses a local class join, which the root does not export (the root `cn` is the clsx and tailwind-merge one). Tailwind must scan `node_modules/@vvedantb/ui/app/src/**/*.{ts,tsx}` so the class names are generated, and the app needs the `@vvedantb/ui/tokens` names (`bg-surface-card`, `divide-separator`, `text-muted-foreground` and so on).
16
+
17
+ ```css
18
+ @source "../node_modules/@vvedantb/ui/app/src/**/*.{ts,tsx}";
19
+ ```
20
+
21
+ ## Confirm skip (Alt-click)
22
+
23
+ ```tsx
24
+ import { ConfirmSkipHint, skipConfirmTitle, useRequestConfirm } from "@vvedantb/ui";
25
+
26
+ const { request } = useRequestConfirm();
27
+
28
+ <DropdownMenuItem
29
+ title={skipConfirmTitle("Delete")}
30
+ onSelect={(event) => request(() => setOpen(true), () => remove(), event)}
31
+ >
32
+ Delete <ConfirmSkipHint />
33
+ </DropdownMenuItem>
34
+ ```
35
+
36
+ - `useRequestConfirm` does not subscribe to Alt. It reads `getAltHeld()` when the request happens, so the menu owner does not re-render when Alt goes down. It returns `{ request }` only.
37
+ - `ConfirmSkipHint` stays mounted and gains a `hidden` class when Alt is not held, so an open Radix menu keeps a stable child tree.
38
+ - The Alt store resets when the last subscriber leaves, clears on blur and tab hide, and cancels a bare Alt keydown only inside `[role='menu']` or `[data-radix-menu-content]`.
39
+ - Also exported: `useAltHeld`, `getAltHeld`, `createAltHeldStore`, `bindToWindow`, `shouldSkipConfirm`, `requestConfirm`.
40
+
41
+ ## Update available watcher
42
+
43
+ ```ts
44
+ import { toast } from "sonner";
45
+ import { startUpdateAvailableWatcher } from "@vvedantb/ui";
46
+
47
+ useEffect(
48
+ () =>
49
+ startUpdateAvailableWatcher({
50
+ origin: window.location.origin,
51
+ toast,
52
+ closeConvex: () => void convex.close(),
53
+ enabled: !import.meta.env.DEV,
54
+ }),
55
+ [],
56
+ );
57
+ ```
58
+
59
+ Options: `origin`, `toast`, `closeConvex?`, `pollMs?` (default 60000), `toastId?` (default `app-update-available`), `enabled?` (default true), `reload?` (default `window.location.reload`). On a changed asset fingerprint it calls `showUpdateAvailableToast` once. `fingerprintFromHtml` and `fetchDeployFingerprint` are exported too. The fingerprint looks for Vite `/assets/*.js` URLs in the index HTML.
60
+
61
+ `showUpdateAvailableToast({ toast, closeConvex?, toastId?, reload? })` (from 0.31.1) shows the toast on its own, for an app with its own update signal:
62
+
63
+ ```ts
64
+ import { showUpdateAvailableToast, toast } from "@vvedantb/ui";
65
+
66
+ showUpdateAvailableToast({ toast, closeConvex: () => void convex.close() });
67
+ ```
68
+
69
+ It shows a sticky "Update available" toast, "Refresh to load the latest version.", with a Refresh action. Refresh calls `closeConvex` (errors ignored), then reloads. The same `toastId` replaces an open toast instead of adding a second one. Mount `SonnerToaster`: from 0.31.1 its default `content` class grows the text column, so Refresh sits at the right edge without app classes.
70
+
71
+ ## Settings chrome
72
+
73
+ ```tsx
74
+ import { SettingsPage, SettingsSection, SettingsToggleRow } from "@vvedantb/ui";
75
+
76
+ <SettingsPage
77
+ title="Notifications"
78
+ layout={({ title, headerRight, toolbar, tabs, fillHeight, children }) => (
79
+ <PageContainer title={title} rightSection={headerRight} toolbar={toolbar} tabs={tabs} noScroll={fillHeight}>
80
+ {children}
81
+ </PageContainer>
82
+ )}
83
+ >
84
+ <SettingsSection title="Email" bodyVariant="list">
85
+ <SettingsToggleRow title="Weekly digest" action={<Switch />} />
86
+ </SettingsSection>
87
+ </SettingsPage>
88
+ ```
89
+
90
+ Exports: `SettingsSection`, `SettingsField`, `SettingsStack`, `SettingsToggleRow`, `SettingsEmptyState` (icon is `ComponentType<{ size?: number; className?: string }>`), `SettingsPage`. `SettingsField` `layout`: `"stacked"` (default) puts the label above the control. `"horizontal"` renders one row with the label and description on the left and the control on the right. Without `layout`, `SettingsPage` renders a plain `div` with a heading and the optional slots.
91
+
92
+ ## useStableAuth
93
+
94
+ ```ts
95
+ import { useStableAuth } from "@vvedantb/ui"; // 2000 ms debounce, wraps Clerk useAuth
96
+ import { createUseStableAuth } from "@vvedantb/ui";
97
+
98
+ const useAuth = createUseStableAuth(useClerkAuth, { debounceMs: 3000 });
99
+ ```
100
+
101
+ After a signed-in session, a drop to signed-out reports `isLoaded: false` for the debounce window so Convex does not cascade. State is module-level. `resetStableAuthSession()` clears it and is for tests only.
102
+
103
+ ## Develop
104
+
105
+ ```sh
106
+ pnpm --filter @vvedantb/ui typecheck
107
+ pnpm --filter @vvedantb/ui test
108
+ ```
109
+
110
+ Source is in `app/src` and tests in `app/tests`. Publish steps are in the root `README.md`.
111
+
112
+ ## Theme
113
+
114
+ ```tsx
115
+ import { createThemeProvider } from "@vvedantb/ui";
116
+
117
+ // One kit per app, at module level.
118
+ export const { ThemeProvider, useTheme } = createThemeProvider();
119
+
120
+ <ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
121
+ <App />
122
+ </ThemeProvider>;
123
+
124
+ const { theme, resolvedTheme, setTheme, isDark, toggleTheme, mounted } = useTheme();
125
+ ```
126
+
127
+ `createThemeProvider` is a port of next-themes 0.4.6. An app that uses next-themes can switch without a change in behaviour: the same localStorage writes, `<html>` classes and attributes, `style.colorScheme`, `prefers-color-scheme` listener, cross-tab `storage` sync and transition blocking. Parity tests run both side by side.
128
+
129
+ - Props, as in next-themes: `storageKey` (`"theme"`), `defaultTheme` (`"system"` with `enableSystem`, else `"light"`), `enableSystem` (`true`), `enableColorScheme` (`true`), `attribute` (`"data-theme"`; `"class"`, any `data-*`, or an array), `themes` (`["light", "dark"]`), `value` (theme name to written value), `forcedTheme`, `disableTransitionOnChange` (`false`) and `nonce`.
130
+ - State: `theme`, `setTheme` (a value or a function of the current theme), `resolvedTheme`, `systemTheme`, `forcedTheme` and `themes`, as in next-themes. Added: `mounted` (after the provider's first effect), `isDark` (`mounted && resolvedTheme === "dark"`) and `toggleTheme` (from `resolvedTheme`).
131
+ - `setTheme` is a new function each time `theme` changes and stable otherwise, as in next-themes, so effects that list it re-run at the same times.
132
+ - next-themes reads the DOM options (`attribute`, `themes`, `value`, `enableSystem`, `enableColorScheme`, `defaultTheme`, `disableTransitionOnChange`, `nonce`) once, on the first render, and so does this port. If `enableSystem` starts `false` and later turns `true`, a stored `"system"` is written as the class `system`. `forcedTheme` follows props.
133
+ - A nested `ThemeProvider` from the same kit renders only its children.
134
+ - `createThemeProvider({ missingProviderMessage })`: `useTheme()` outside the provider throws that message. Without it, `useTheme()` returns an empty state with no-op setters, as next-themes does.
135
+ - No inline script is rendered. next-themes renders one for server rendering; React does not run it in a client-rendered app. Keep a pre-paint script in `index.html` if the app has one.
136
+
137
+ For an app with its own theme state (for example a theme synced from the server), two helpers:
138
+
139
+ - `getSystemTheme()`: `"dark"` or `"light"` from `prefers-color-scheme`; `"light"` without `window`.
140
+ - `applyThemeClass(theme)`: removes `light` and `dark` from `<html>`, then adds `theme`. No-op without `document`.
141
+
142
+ ## Page title
143
+
144
+ ```tsx
145
+ import { createPageTitleContext } from "@vvedantb/ui";
146
+
147
+ export const { PageTitleProvider, usePageTitle, usePageTitleSync } = createPageTitleContext({
148
+ missingProviderMessage: "usePageTitle must be used within a PageTitleProvider",
149
+ });
150
+
151
+ // The shell reads it:
152
+ const { pageTitle } = usePageTitle();
153
+ // A page publishes it while mounted:
154
+ usePageTitleSync(title);
155
+ ```
156
+
157
+ - `usePageTitle()` returns `{ pageTitle, setPageTitle, mobileActionsSlot, setMobileActionsSlot }`. `mobileActionsSlot` is an element a mobile top bar registers (pass `setMobileActionsSlot` as its `ref`) so pages can portal actions into it.
158
+ - `usePageTitleSync(title)` sets the title while the caller is mounted and clears it on unmount. Titles that are not strings publish `""`.
159
+ - `missingProviderMessage`: `usePageTitle()` outside the provider throws it. Without it, `usePageTitle()` returns an empty title and no-op setters.
160
+ - `documentTitle` (off by default; without it `document.title` is never touched): `{ suffix?, separator? = " · ", fallback? }`. While a page title is set, `document.title` is `` `${pageTitle}${separator}${suffix}` `` (just the page title without a suffix). While it is empty, `fallback`, else the title at mount. The mount-time title comes back on unmount.
161
+
162
+ ## Page motion
163
+
164
+ ```tsx
165
+ import { MotionConfig } from "motion/react";
166
+ import { PageMotionProvider, useDisablePageMotion } from "@vvedantb/ui";
167
+
168
+ <PageMotionProvider disabled={flags?.disablePageMotion === true} motionConfig={MotionConfig}>
169
+ <App />
170
+ </PageMotionProvider>;
171
+ ```
172
+
173
+ - Sets `html[data-page-motion]` to `"off"` or `"on"` in a layout effect. The attribute stays after unmount. From 0.15.0 `tokens.css` (through `tokens/css/motion.css`) ships the `"off"` rules: `.ui-page-enter`, `.ui-enter`, `.ui-enter-up` and `.ui-stagger` fade only, `animate-in` / `animate-out`, `.t-modal` and `.t-tabs-pill` stop transitioning, and view transitions stop.
174
+ - Renders `motionConfig` with `reducedMotion` `"always"` when disabled, else `"never"`.
175
+ - `useDisablePageMotion()`: the `disabled` value, `false` outside the provider.
176
+ - This module does not import `motion`. Pass `MotionConfig`, or an app component that wraps it, defined at module level, for example with `LazyMotion`:
177
+
178
+ ```tsx
179
+ function LazyMotionConfig({ reducedMotion, children }: PageMotionConfigProps) {
180
+ return (
181
+ <LazyMotion features={domAnimation}>
182
+ <MotionConfig reducedMotion={reducedMotion}>{children}</MotionConfig>
183
+ </LazyMotion>
184
+ );
185
+ }
186
+ ```
187
+
188
+ ## Compact relative time
189
+
190
+ ```ts
191
+ import { formatCompactRelativeTime } from "@vvedantb/ui";
192
+
193
+ formatCompactRelativeTime(createdAt, { justNow: "now" }); // "now", "5m", "3h", "2d", "4mo", "1y"
194
+ formatCompactRelativeTime(updatedAt, { calendar: true }); // "42s", ..., calendar months and years
195
+ ```
196
+
197
+ Pure TypeScript, no dependencies. Options:
198
+
199
+ - `now`: clock in ms, default `Date.now()`.
200
+ - `justNow`: returned for anything under a minute old, future times included. Without it the result is whole seconds (`"42s"`), and a future time gives `"0s"` or a negative count.
201
+ - `calendar`: `false` (default) counts elapsed time: a day is 24 hours, a month 30 days, a year 12 such months. `true` counts as `dayjs().diff(date, unit)` does: days by the local calendar across DST changes, and calendar months and years.
202
+
203
+ Strings are parsed with `new Date(string)`. dayjs parses a date-only string such as `"2026-03-01"` as local midnight, `new Date` as UTC midnight; numbers, `Date` objects and ISO strings with a time give the same result either way. An invalid date gives `"NaNy"` (`"0mo"` with `calendar`).
204
+
205
+ ## Convex provider, VITE env and ensure-user (0.10.0)
206
+
207
+ React and VITE env helpers for Convex apps. The non-React Convex helpers (`mapLoadedQuery`, `forEachLoadedQuery`, `updateAllCachedQueries`, `patchLoadedQuery`, `OptimisticStore`, `tempId`, `createMemoryOptimisticStore`) live in `@vvedantb/server`, so backend packages, tests and React Native can use them without loading this package.
208
+
209
+ ### `ConvexClerkProvider`
210
+
211
+ ```tsx
212
+ import { ConvexClerkProvider, useStableAuth } from "@vvedantb/ui";
213
+ import { ConvexReactClient } from "convex/react";
214
+
215
+ const convex = new ConvexReactClient(env.VITE_CONVEX_URL);
216
+
217
+ <ClerkProvider publishableKey={env.VITE_CLERK_PUBLISHABLE_KEY}>
218
+ <ConvexClerkProvider client={convex} useAuth={useStableAuth}>
219
+ <App />
220
+ </ConvexClerkProvider>
221
+ </ClerkProvider>;
222
+ ```
223
+
224
+ | Props | Renders |
225
+ | --- | --- |
226
+ | `client` is `null` or `undefined` | `children` alone (no provider). |
227
+ | `clerk={false}` | `<ConvexProvider client={client}>`. |
228
+ | otherwise | `<ConvexProviderWithClerk client={client} useAuth={useAuth}>`; `useAuth` defaults to `@clerk/clerk-react`'s. |
229
+
230
+ `clerk` defaults to `true`. Render it inside `ClerkProvider` unless `clerk` is `false`. Types: `ConvexClerkProviderProps`, `ConvexClerkUseAuth`.
231
+
232
+ ### `parseClientEnv`
233
+
234
+ ```ts
235
+ import { z } from "zod";
236
+ import { parseClientEnv } from "@vvedantb/ui";
237
+
238
+ export const clientEnv = parseClientEnv(import.meta.env, { z, viteEnv: "fallback" });
239
+ // { VITE_CONVEX_URL: string; VITE_CLERK_PUBLISHABLE_KEY: string; VITE_ENV: "development" | "staging" | "production" }
240
+
241
+ export const extensionEnv = parseClientEnv(import.meta.env, {
242
+ z,
243
+ viteEnv: false,
244
+ extend: { VITE_CLERK_SYNC_HOST: z.string().url() },
245
+ });
246
+ ```
247
+
248
+ The schema is `z.object({ VITE_CONVEX_URL: z.string().min(1), VITE_CLERK_PUBLISHABLE_KEY: z.string().min(1), VITE_ENV: z.enum(["development", "staging", "production"]), ...extend })`, built with your `z` (zod 3.25+ or 4; the package never imports zod at runtime). Only the schema's keys are read from `rawEnv`. Failure throws the `ZodError` from `.parse`.
249
+
250
+ | `viteEnv` | `VITE_ENV` |
251
+ | --- | --- |
252
+ | `"strict"` (default) | Must be one of `VITE_ENV_NAMES`. |
253
+ | `"fallback"` | Any other value, or none, becomes `"development"` before parsing. |
254
+ | `false` | Not in the schema or the result. |
255
+
256
+ Types: `ClientEnv`, `ClientEnvWithoutViteEnv`, `ClientEnvOptions`, `ClientEnvSource`, `ViteEnvMode`, `ViteEnvName`.
257
+
258
+ ### `useEnsureUser`
259
+
260
+ ```tsx
261
+ function EnsureUser() {
262
+ useEnsureUser(api.users.ensureUserExists);
263
+ return null;
264
+ }
265
+ ```
266
+
267
+ Calls `mutation({})` every time `useConvexAuth().isAuthenticated` becomes `true` (once on mount if already signed in), and logs a rejection with `console.error`. Needs a Convex auth provider above it (`ConvexClerkProvider` with Clerk on). Pair it with `ensureUser` from `@vvedantb/server`. Type: `EnsureUserMutation`.
268
+
269
+ Tests: `app/tests/convex/` ports each app's copy and runs it beside the helper (env with zod 4 and zod 3.25; provider variants; ensure-user calls over auth sequences). `app/tests-node/convex-esm.test.mjs` loads the helpers in plain Node.
package/app/src/index.ts CHANGED
@@ -17,7 +17,9 @@ export {
17
17
  fingerprintFromHtml,
18
18
  } from "./update/deployFingerprint.js";
19
19
  export {
20
+ showUpdateAvailableToast,
20
21
  startUpdateAvailableWatcher,
22
+ type ShowUpdateAvailableToastOptions,
21
23
  type UpdateAvailableWatcherOptions,
22
24
  type UpdateToastOptions,
23
25
  } from "./update/updateWatcher.js";
@@ -16,6 +16,7 @@ export type UpdateAvailableWatcherOptions = {
16
16
  closeConvex?: () => void;
17
17
  /** Poll interval in ms. Default 60000. */
18
18
  pollMs?: number;
19
+ /** Default `app-update-available`. */
19
20
  toastId?: string;
20
21
  /** Pass `!import.meta.env.DEV`. When false, nothing starts. Default true. */
21
22
  enabled?: boolean;
@@ -23,13 +24,47 @@ export type UpdateAvailableWatcherOptions = {
23
24
  reload?: () => void;
24
25
  };
25
26
 
27
+ export type ShowUpdateAvailableToastOptions = Pick<
28
+ UpdateAvailableWatcherOptions,
29
+ "toast" | "closeConvex" | "toastId" | "reload"
30
+ >;
31
+
26
32
  const DEFAULT_POLL_MS = 60_000;
27
33
  const DEFAULT_TOAST_ID = "app-update-available";
28
34
 
35
+ /**
36
+ * Show the sticky "Update available" toast with a Refresh action. Refresh
37
+ * calls `closeConvex` (errors ignored), then reloads. The same `toastId`
38
+ * replaces an open toast instead of stacking a second one.
39
+ */
40
+ export function showUpdateAvailableToast({
41
+ toast,
42
+ closeConvex,
43
+ toastId = DEFAULT_TOAST_ID,
44
+ reload = () => window.location.reload(),
45
+ }: ShowUpdateAvailableToastOptions): void {
46
+ toast.message("Update available", {
47
+ id: toastId,
48
+ description: "Refresh to load the latest version.",
49
+ duration: Number.POSITIVE_INFINITY,
50
+ action: {
51
+ label: "Refresh",
52
+ onClick: () => {
53
+ try {
54
+ closeConvex?.();
55
+ } catch {
56
+ // socket may already be closed during teardown
57
+ }
58
+ reload();
59
+ },
60
+ },
61
+ });
62
+ }
63
+
29
64
  /**
30
65
  * Poll the live index HTML for a new Vite asset fingerprint (and re-check when
31
- * the tab becomes visible). Shows a sticky "Update available" toast with a
32
- * Refresh action when a newer deploy is serving. Returns a stop function.
66
+ * the tab becomes visible). Calls `showUpdateAvailableToast` once when a newer
67
+ * deploy is serving. Returns a stop function.
33
68
  */
34
69
  export function startUpdateAvailableWatcher(
35
70
  options: UpdateAvailableWatcherOptions,
@@ -39,9 +74,9 @@ export function startUpdateAvailableWatcher(
39
74
  toast,
40
75
  closeConvex,
41
76
  pollMs = DEFAULT_POLL_MS,
42
- toastId = DEFAULT_TOAST_ID,
77
+ toastId,
43
78
  enabled = true,
44
- reload = () => window.location.reload(),
79
+ reload,
45
80
  } = options;
46
81
  if (!enabled) return () => {};
47
82
 
@@ -52,22 +87,7 @@ export function startUpdateAvailableWatcher(
52
87
  const showToast = (): void => {
53
88
  if (shown) return;
54
89
  shown = true;
55
- toast.message("Update available", {
56
- id: toastId,
57
- description: "Refresh to load the latest version.",
58
- duration: Number.POSITIVE_INFINITY,
59
- action: {
60
- label: "Refresh",
61
- onClick: () => {
62
- try {
63
- closeConvex?.();
64
- } catch {
65
- // socket may already be closed during teardown
66
- }
67
- reload();
68
- },
69
- },
70
- });
90
+ showUpdateAvailableToast({ toast, closeConvex, toastId, reload });
71
91
  };
72
92
 
73
93
  const check = async (): Promise<void> => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "license": "MIT",
5
5
  "description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
6
6
  "type": "module",
@@ -35,6 +35,7 @@
35
35
  "./tokens/css/border-beam.css": "./tokens/src/css/border-beam.css",
36
36
  "./tokens/css/markdown.css": "./tokens/src/css/markdown.css",
37
37
  "./tokens/css/marquee.css": "./tokens/src/css/marquee.css",
38
+ "./tokens/css/type-scale.css": "./tokens/src/css/type-scale.css",
38
39
  "./tokens/compat/shadcn-rgb.css": "./tokens/src/css/compat-shadcn-rgb.css",
39
40
  "./tokens/css/*.css": "./tokens/src/css/*.css",
40
41
  "./tokens/tailwind-preset": {
@@ -72,6 +73,17 @@
72
73
  "./src/marketing/landing.css",
73
74
  "./fonts/instrument-sans.css"
74
75
  ],
76
+ "scripts": {
77
+ "check:tokens": "node tokens/scripts/check-component-tokens.mjs",
78
+ "build": "node tokens/scripts/check-exports.mjs && node tokens/scripts/check-component-tokens.mjs && tsc -p tsconfig.json",
79
+ "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.consumer.json && tsc -p tsconfig.consumer-speech.json && tsc -p tokens/tsconfig.json",
80
+ "test": "node tokens/scripts/check-component-tokens.mjs && vitest run && node --test tokens/test/*.test.mjs app/tests-node/*.test.mjs",
81
+ "verify": "node tokens/scripts/check-component-tokens.mjs && node tokens/verify/run.mjs",
82
+ "analyze": "node tokens/verify/analyze.mjs",
83
+ "brand:assets": "node scripts/build-brand-assets.mjs",
84
+ "brand:sheet": "node scripts/build-brand-sheet.mjs",
85
+ "prepack": "node tokens/scripts/check-exports.mjs"
86
+ },
75
87
  "dependencies": {
76
88
  "@dnd-kit/core": "^6.3.1",
77
89
  "@dnd-kit/modifiers": "^9.0.0",
@@ -161,6 +173,7 @@
161
173
  "@tanstack/react-hotkeys": "^0.13.0",
162
174
  "@types/react": "^19.1.0",
163
175
  "@types/react-dom": "^19.1.0",
176
+ "@vvedantb/server": "workspace:*",
164
177
  "ai": "^5.0.0",
165
178
  "class-variance-authority": "^0.7.1",
166
179
  "clsx": "^2.1.1",
@@ -184,8 +197,7 @@
184
197
  "vaul": "^1.1.0",
185
198
  "vitest": "^3.2.0",
186
199
  "zod": "^4.0.0",
187
- "zod3": "npm:zod@^3.25.76",
188
- "@vvedantb/server": "0.10.0"
200
+ "zod3": "npm:zod@^3.25.76"
189
201
  },
190
202
  "peerDependenciesMeta": {
191
203
  "@clerk/clerk-react": {
@@ -206,15 +218,5 @@
206
218
  "@vvedantb/server": {
207
219
  "optional": true
208
220
  }
209
- },
210
- "scripts": {
211
- "check:tokens": "node tokens/scripts/check-component-tokens.mjs",
212
- "build": "node tokens/scripts/check-exports.mjs && node tokens/scripts/check-component-tokens.mjs && tsc -p tsconfig.json",
213
- "typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.consumer.json && tsc -p tsconfig.consumer-speech.json && tsc -p tokens/tsconfig.json",
214
- "test": "node tokens/scripts/check-component-tokens.mjs && vitest run && node --test tokens/test/*.test.mjs app/tests-node/*.test.mjs",
215
- "verify": "node tokens/scripts/check-component-tokens.mjs && node tokens/verify/run.mjs",
216
- "analyze": "node tokens/verify/analyze.mjs",
217
- "brand:assets": "node scripts/build-brand-assets.mjs",
218
- "brand:sheet": "node scripts/build-brand-sheet.mjs"
219
221
  }
220
- }
222
+ }
@@ -72,3 +72,5 @@ export const IconVmem = APP_ICONS.vmem;
72
72
  export const IconVerve = APP_ICONS.verve;
73
73
  export const IconVelth = APP_ICONS.velth;
74
74
  export const IconProjectV = APP_ICONS.projectv;
75
+ export const IconEva = APP_ICONS.eva;
76
+ export const IconBee = APP_ICONS.bee;
@@ -3,8 +3,8 @@ import { cn } from "../utils/cn";
3
3
  import { APP_ICONS } from "./AppIcons";
4
4
  import type { AppName } from "./svg";
5
5
 
6
- /** The five product apps. `projectv` keeps its Michroma wordmark and never uses `AppWordmark`. */
7
- export type ProductAppName = Exclude<AppName, "projectv">;
6
+ /** The five product apps. `projectv` keeps its Michroma wordmark and never uses `AppWordmark`. `eva` and `bee` are icons only. */
7
+ export type ProductAppName = Exclude<AppName, "projectv" | "eva" | "bee">;
8
8
 
9
9
  export type AppWordmarkProps = Pick<AnchorHTMLAttributes<HTMLAnchorElement>, "target" | "rel" | "aria-label" | "title" | "id"> & {
10
10
  /** Which product app's name to show. The label is always the lowercase app id. */
@@ -1,7 +1,10 @@
1
1
  import type { AppName } from "./svg";
2
2
 
3
+ /** Apps in the Project V family. `eva` and `bee` have marks and icons but are not family apps. */
4
+ export type FamilyAppName = Exclude<AppName, "eva" | "bee">;
5
+
3
6
  export type FamilyApp = {
4
- app: AppName;
7
+ app: FamilyAppName;
5
8
  /** Display name. */
6
9
  name: string;
7
10
  /** Home page of the app. */
@@ -19,6 +22,6 @@ export const FAMILY_APPS: readonly FamilyApp[] = [
19
22
  ];
20
23
 
21
24
  /** Entry of `FAMILY_APPS` for an app. */
22
- export function familyApp(app: AppName): FamilyApp {
25
+ export function familyApp(app: FamilyAppName): FamilyApp {
23
26
  return FAMILY_APPS.find((entry) => entry.app === app)!;
24
27
  }
@@ -25,6 +25,6 @@ export {
25
25
  } from "./svg";
26
26
  export type { AppMarkVariant, AppName, MarkShape } from "./svg";
27
27
  export { FAMILY_APPS, familyApp } from "./familyApps";
28
- export type { FamilyApp } from "./familyApps";
28
+ export type { FamilyApp, FamilyAppName } from "./familyApps";
29
29
  export { V_PRO_APP_BENEFITS } from "./vProAppBenefits";
30
30
  export type { PricingPlanAppBenefit } from "./vProAppBenefits";
package/src/brand/svg.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  // Geometry and raw SVG strings for the family app marks. No imports, so the
2
2
  // asset script can load this file directly with Node.
3
3
 
4
- export const APP_NAMES = ["projectv", "vibot", "vhub", "vmem", "verve", "velth"] as const;
4
+ /** Every mark. `eva` and `bee` are marks and icons only: they are not family apps, so `FAMILY_APPS` leaves them out. */
5
+ export const APP_NAMES = ["projectv", "vibot", "vhub", "vmem", "verve", "velth", "eva", "bee"] as const;
5
6
 
6
7
  export type AppName = (typeof APP_NAMES)[number];
7
8
 
@@ -36,7 +37,9 @@ export function markLinecap(app: AppName): "butt" | "round" {
36
37
  /**
37
38
  * Glyphs sized by one rule: longest side = 512 * min(1.2, aspect^0.25), centred halfway between
38
39
  * the bounding-box centre and the centre of mass. `verve` and `velth` are the final vectors.
39
- * The others are traced from the approved 1024px renders.
40
+ * `vibot`, `vhub`, `vmem` and `projectv` are traced from the approved 1024px renders. `eva` (option A,
41
+ * a filled four-point star) and `bee` (option D, an orb with eyes, stripes and antennae) are the final
42
+ * vectors from their design sheet, as drawn there.
40
43
  */
41
44
  export const APP_MARKS: Record<AppName, MarkShape> = {
42
45
  projectv: {
@@ -77,6 +80,22 @@ export const APP_MARKS: Record<AppName, MarkShape> = {
77
80
  "M512 732.3C644.2 652.1 734.3 471.9 724.3 301.6C604.1 371.7 524 552 512 732.3Z",
78
81
  ],
79
82
  },
83
+ eva: {
84
+ kind: "fill",
85
+ paths: ["M242.9 512Q485.1 485.1 512 278.8Q538.9 485.1 781 512Q538.9 538.9 512 745.1Q485.1 538.9 242.9 512Z"],
86
+ },
87
+ bee: {
88
+ kind: "stroke",
89
+ paths: [
90
+ "M304 530.7A208.1 208.1 0 1 1 720.1 530.7A208.1 208.1 0 1 1 304 530.7",
91
+ "M447.5 414.2L447.5 445.4",
92
+ "M576.5 414.2L576.5 445.4",
93
+ "M306.3 561.9L717.7 561.9",
94
+ "M344 653.4L680 653.4",
95
+ "M468.3 341.4Q455.8 291.4 420.5 260.2",
96
+ "M555.7 341.4Q568.2 291.4 603.5 260.2",
97
+ ],
98
+ },
80
99
  };
81
100
 
82
101
  type Point = [number, number];
@@ -180,6 +199,7 @@ export function markBBox(app: AppName): Box {
180
199
  * (x 186 to 789, y 259.96 to 761.7) at side max(width, height) x 1.04 (about 4% padding), rounded outward.
181
200
  * All five use this side, so glyph scale stays equal. Only the size is shared: each app has its own origin in
182
201
  * `APP_MARK_VIEWBOX`. `projectv` is left out so its wide brand mark does not shrink the app glyphs.
202
+ * Historical: this union covers those five only. `eva` and `bee` reuse the 629 side but are not part of it.
183
203
  */
184
204
  export const APP_MARK_CROP_VIEWBOX = "173 197 629 629";
185
205
 
@@ -190,9 +210,9 @@ export const APP_MARK_CROP_VIEWBOX = "173 197 629 629";
190
210
  export const PROJECTV_MARK_VIEWBOX = "171.5 181 687 687";
191
211
 
192
212
  /**
193
- * Plain-mark viewBox per app. Always square. The five apps keep one 629 side (equal scale), and each origin is
194
- * `markBBox(app)` centre minus 314.5 on both axes, so every glyph sits centred in its own frame. `projectv` uses
195
- * its 687 frame, centre minus 343.5. Hardcoded; checked against `markBBox` in tests.
213
+ * Plain-mark viewBox per app. Always square. Every mark except `projectv` keeps one 629 side (equal scale), and each
214
+ * origin is `markBBox(app)` centre minus 314.5 on both axes, so every glyph sits centred in its own frame. `projectv`
215
+ * uses its 687 frame, centre minus 343.5. Hardcoded; checked against `markBBox` in tests.
196
216
  */
197
217
  export const APP_MARK_VIEWBOX: Record<AppName, string> = {
198
218
  projectv: PROJECTV_MARK_VIEWBOX,
@@ -201,6 +221,8 @@ export const APP_MARK_VIEWBOX: Record<AppName, string> = {
201
221
  vmem: "197.24772201231343 196.33100022273135 629 629",
202
222
  verve: "197.5 210.9 629 629",
203
223
  velth: "197.5 202.45 629 629",
224
+ eva: "197.45 197.45 629 629",
225
+ bee: "197.55 187.2807619340906 629 629",
204
226
  };
205
227
 
206
228
  /**
@@ -215,6 +237,8 @@ export const APP_MARK_VIEWBOX_START: Record<AppName, string> = {
215
237
  vmem: "255.5301217210191 196.33100022273135 629 629",
216
238
  verve: "260.4 210.9 629 629",
217
239
  velth: "273.9433593555699 202.45 629 629",
240
+ eva: "242.9 197.45 629 629",
241
+ bee: "278.94999999999993 187.2807619340906 629 629",
218
242
  };
219
243
 
220
244
  /** Width over height of a mark's viewBox. Always about 1, because the viewBoxes are square. Kept for API stability; do not use it for sizing. */
@@ -2,7 +2,7 @@ import type { AppName } from "./svg";
2
2
 
3
3
  /** Benefits for one app, shown under that app's icon and name. */
4
4
  export type PricingPlanAppBenefit = {
5
- app: Exclude<AppName, "projectv">;
5
+ app: Exclude<AppName, "projectv" | "eva" | "bee">;
6
6
  items: readonly string[];
7
7
  };
8
8
 
package/src/client.ts CHANGED
@@ -342,7 +342,9 @@ export { useRequestConfirm } from "../app/src/confirm/useRequestConfirm";
342
342
  export { ConfirmSkipHint, skipConfirmTitle } from "../app/src/confirm/ConfirmSkipHint";
343
343
  export { fetchDeployFingerprint, fingerprintFromHtml } from "../app/src/update/deployFingerprint";
344
344
  export {
345
+ showUpdateAvailableToast,
345
346
  startUpdateAvailableWatcher,
347
+ type ShowUpdateAvailableToastOptions,
346
348
  type UpdateAvailableWatcherOptions,
347
349
  type UpdateToastOptions,
348
350
  } from "../app/src/update/updateWatcher";
@@ -1,6 +1,6 @@
1
1
  import { useRef, useState, type ReactElement, type ReactNode } from "react";
2
2
  import { IconCheck, IconX } from "@tabler/icons-react";
3
- import { APP_ICONS, IconProjectV, V_PRO_APP_BENEFITS, familyApp, type AppIconProps, type AppName, type PricingPlanAppBenefit } from "../brand";
3
+ import { APP_ICONS, IconProjectV, V_PRO_APP_BENEFITS, familyApp, type AppIconProps, type AppName, type FamilyAppName, type PricingPlanAppBenefit, type ProductAppName } from "../brand";
4
4
  import { Button } from "../ui/button";
5
5
  import { Dialog, DialogContent, DialogDescription, DialogTitle } from "../ui/dialog";
6
6
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "../ui/tooltip";
@@ -101,10 +101,10 @@ export type PricingModalMultiProps = {
101
101
  description?: string;
102
102
  /** Cards, left to right. Sized for 1 to 4. */
103
103
  plans: readonly PricingPlan[];
104
- /** App marks at the top left. */
105
- apps?: readonly AppName[];
104
+ /** App marks at the top left. Family apps only: each links to its `FAMILY_APPS` site. */
105
+ apps?: readonly FamilyAppName[];
106
106
  /** App the dialog is shown in. Its `appBenefits` group comes first. */
107
- currentApp?: Exclude<AppName, "projectv">;
107
+ currentApp?: ProductAppName;
108
108
  /** Centred headline, for example "One plan. Every V app." */
109
109
  headline?: ReactNode;
110
110
  /** Small print under the cards. */
@@ -2,4 +2,4 @@
2
2
 
3
3
  exports[`SonnerToaster DOM > renders the toaster and a toast 1`] = `"<section aria-label="Notifications alt+T" tabindex="-1" aria-live="polite" aria-relevant="additions text" aria-atomic="false" data-react-aria-top-layer="true"></section>"`;
4
4
 
5
- exports[`SonnerToaster DOM > renders the toaster and a toast 2`] = `"<section aria-label="Notifications alt+T" tabindex="-1" aria-live="polite" aria-relevant="additions text" aria-atomic="false" data-react-aria-top-layer="true"><ol dir="ltr" tabindex="-1" class="toaster group !font-sans" data-sonner-toaster="true" data-sonner-theme="light" data-y-position="top" data-x-position="right" style="--front-toast-height: 0px; --width: 356px; --gap: 12px; --offset-top: 24px; --offset-right: 24px; --offset-bottom: 24px; --offset-left: 24px; --mobile-offset-top: 16px; --mobile-offset-right: 16px; --mobile-offset-bottom: 16px; --mobile-offset-left: 16px;"><li tabindex="0" class="group toast glass-panel-strong flex w-full items-center gap-3 rounded-lg px-4 py-3 text-sm text-foreground smooth-shadow-ring-md" data-sonner-toast="" data-styled="false" data-mounted="true" data-promise="false" data-swiped="false" data-removed="false" data-visible="true" data-y-position="top" data-x-position="right" data-index="0" data-front="true" data-swiping="false" data-dismissible="true" data-swipe-out="false" data-expanded="false" style="--index: 0; --toasts-before: 0; --z-index: 1; --offset: 0px; --initial-height: 0px;"><div data-content="" class=""><div data-title="" class="font-medium leading-snug">Saved</div><div data-description="" class="text-[13px] leading-snug text-muted-foreground">All changes stored</div></div></li></ol></section>"`;
5
+ exports[`SonnerToaster DOM > renders the toaster and a toast 2`] = `"<section aria-label="Notifications alt+T" tabindex="-1" aria-live="polite" aria-relevant="additions text" aria-atomic="false" data-react-aria-top-layer="true"><ol dir="ltr" tabindex="-1" class="toaster group !font-sans" data-sonner-toaster="true" data-sonner-theme="light" data-y-position="top" data-x-position="right" style="--front-toast-height: 0px; --width: 356px; --gap: 12px; --offset-top: 24px; --offset-right: 24px; --offset-bottom: 24px; --offset-left: 24px; --mobile-offset-top: 16px; --mobile-offset-right: 16px; --mobile-offset-bottom: 16px; --mobile-offset-left: 16px;"><li tabindex="0" class="group toast glass-panel-strong flex w-full items-center gap-3 rounded-lg px-4 py-3 text-sm text-foreground smooth-shadow-ring-md" data-sonner-toast="" data-styled="false" data-mounted="true" data-promise="false" data-swiped="false" data-removed="false" data-visible="true" data-y-position="top" data-x-position="right" data-index="0" data-front="true" data-swiping="false" data-dismissible="true" data-swipe-out="false" data-expanded="false" style="--index: 0; --toasts-before: 0; --z-index: 1; --offset: 0px; --initial-height: 0px;"><div data-content="" class="flex min-w-0 grow flex-col"><div data-title="" class="font-medium leading-snug">Saved</div><div data-description="" class="text-[13px] leading-snug text-muted-foreground">All changes stored</div></div></li></ol></section>"`;
package/src/ui/sonner.tsx CHANGED
@@ -14,6 +14,9 @@ import "./sonner.css";
14
14
  // neutral. Callers should pass `theme` so sonner's internal `data-theme`
15
15
  // attribute matches the active app theme.
16
16
  //
17
+ // Position: `top-right` by default (sonner's own default is `bottom-right`), as
18
+ // apps mount it. A `position` prop or `UiConfig.SonnerToaster.position` wins.
19
+ //
17
20
  // Stacking: `expand={false}` keeps toasts collapsed (offset + scale). Hovering
18
21
  // the stack expands them. `sonner.css` hides back-toast content while collapsed
19
22
  // because `unstyled` disables sonner's built-in `data-styled` stack rules.
@@ -83,13 +86,31 @@ const hoverChipCloseButtonClassName =
83
86
  const defaultCloseButtonClassName =
84
87
  "rounded-lg bg-default px-2.5 py-1 text-xs font-medium text-foreground transition-colors hover:bg-default/78";
85
88
 
89
+ // Action and cancel buttons: 28px tall (`h-7`), 10px side padding, 12px text,
90
+ // `rounded-control` (10px), the classes apps already set through `classes`.
91
+ // Measured on the toaster fixture's Refresh button: 28px tall, up from 24px with the 0.31.0
92
+ // `px-2.5 py-1 rounded-lg` (16px radius) string. `shrink-0` keeps the button
93
+ // from squeezing when the text column grows. `motion-press` is an app utility
94
+ // (not in `tokens.css`), as in `BulkActionBar`.
95
+ const defaultActionButtonClassName =
96
+ "h-7 shrink-0 rounded-control bg-primary px-2.5 text-xs font-medium text-primary-foreground motion-press active:scale-[0.96] hover:bg-primary/90";
97
+
98
+ const defaultCancelButtonClassName =
99
+ "h-7 shrink-0 rounded-control bg-surface-secondary px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-surface-tertiary";
100
+
101
+ const defaultToasterPosition = "top-right" satisfies ToasterProps["position"];
102
+
86
103
  const toastRadiusClasses = {
87
104
  lg: "rounded-lg",
88
105
  surface: "rounded-surface",
89
106
  control: "rounded-field",
90
107
  } as const;
91
108
 
92
- /** Default `classNames`, with the opt-in variants applied. No options gives the 0.2.1 defaults. */
109
+ /**
110
+ * Default `classNames`, with the opt-in variants applied. No options gives the
111
+ * 0.2.1 defaults, plus `content` and the 28px `actionButton` and `cancelButton`
112
+ * (from 0.31.1).
113
+ */
93
114
  function createToasterClassNames({
94
115
  toastRadius = "lg",
95
116
  density = "default",
@@ -111,14 +132,15 @@ function createToasterClassNames({
111
132
  const descriptionSize = compact ? "text-xs" : "text-[13px]";
112
133
  return {
113
134
  toast: `group toast glass-panel-strong flex w-full items-center ${compact ? "gap-2" : "gap-3"} ${radius} ${compact ? "px-3 py-2 text-xs" : "px-4 py-3 text-sm"} text-foreground smooth-shadow-ring-md${hideStackedContent ? ` ${hideStackedContentClassName}` : ""}`,
135
+ // `unstyled` drops sonner's `[data-content]` grow, so the text column grows
136
+ // here and the action and cancel buttons sit at the right edge.
137
+ content: "flex min-w-0 grow flex-col",
114
138
  title: titleLeading === "5" ? "font-medium leading-5" : "font-medium leading-snug",
115
139
  description: descriptionMuted
116
140
  ? `${descriptionSize} leading-snug text-muted-foreground!`
117
141
  : `${descriptionSize} leading-snug text-muted-foreground`,
118
- actionButton:
119
- "rounded-lg bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground transition-opacity hover:opacity-90",
120
- cancelButton:
121
- "rounded-lg bg-surface-secondary px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:bg-surface-tertiary",
142
+ actionButton: defaultActionButtonClassName,
143
+ cancelButton: defaultCancelButtonClassName,
122
144
  closeButton:
123
145
  closeButtonStyle === "hoverChip"
124
146
  ? hoverChipCloseButtonClassName
@@ -192,6 +214,9 @@ function withConfigDefaults<T extends object>(defaults: Partial<T> | undefined,
192
214
  function SonnerToaster(props: ToasterProps & SonnerToasterOptions) {
193
215
  const {
194
216
  classes,
217
+ // Defaulted here, not by spreading after a literal, so `position={undefined}`
218
+ // still gets top-right rather than sonner's bottom-right.
219
+ position = defaultToasterPosition,
195
220
  toastRadius,
196
221
  density,
197
222
  toastIcons = "default",
@@ -223,6 +248,7 @@ function SonnerToaster(props: ToasterProps & SonnerToasterOptions) {
223
248
  visibleToasts={4}
224
249
  gap={12}
225
250
  {...rest}
251
+ position={position}
226
252
  closeButton={closeButton ?? (closeButtonStyle === "hoverChip" ? true : undefined)}
227
253
  className={
228
254
  toasterClassName && className
@@ -0,0 +1,122 @@
1
+ # `@vvedantb/ui/tokens`
2
+
3
+ Design tokens and shared Tailwind v4 CSS for the vvedantb web apps. The CSS and Tailwind preset are subpaths of `@vvedantb/ui`; the native JS tokens are named exports of the root (`tokens`, `Tokens`). Source-exported: no build step. Paths in the `File` column are relative to `packages/ui/tokens/`.
4
+
5
+ ## Exports
6
+
7
+ | Export | File | What it is |
8
+ | --- | --- | --- |
9
+ | `@vvedantb/ui/tokens`, `@vvedantb/ui/tokens/tokens.css` | `src/tokens.css` | Colour, radius, shadow, ease and font tokens (`@theme`), light/dark variables, `dark` variant, the radius utilities `rounded-surface` (`clamp(0.75rem, var(--radius), 1rem)`), `rounded-menu-item` (`min(var(--radius), 0.5rem)`) and `rounded-control` (`min(var(--radius), 0.625rem)`) (0.7.1; `rounded-surface` was in `utilities.css` before), `*` border and `body` defaults. From 0.16.3 `--field-radius` (`rounded-field`) is `min(var(--radius), 0.625rem)`, the same cap as `rounded-control` (was `1.25rem`). 0.7.2 adds `--sidebar-accent` / `sidebar-accent` (sidebar nav row fill: light `var(--surface-tertiary)`, dark `oklch(22.64% 0 0)`). In 0.2.1 it also defines shadcn-style aliases (`primary`, `muted-foreground`, `secondary`, `destructive`, `card`, `popover`, `input`, `ring`) that point at the same tokens. From 0.15.0 it imports `clear-input.css`, `scrollbar-thin.css` and `motion.css`, sets the `--modal-*` and `--tabs-*` motion variables on `:root`, and defines `.glass-panel-strong` (`var(--overlay)`) and `.sidebar-section-label`. |
10
+ | `tokens` and `Tokens` from `@vvedantb/ui` | `src/native.ts` | JS colours, radii and spacing for React Native. `@vvedantb/native-ui` keeps its own copy in `src/tokens.ts`; a test keeps the two equal. |
11
+ | `@vvedantb/ui/tokens/css/base.css` | `src/css/base.css` | `html` touch/accent, `::selection`, control transitions, pointer cursor, range accent (`@layer base`). |
12
+ | `@vvedantb/ui/tokens/css/dialog.css` | `src/css/dialog.css` | Unlayered `max-width: none` for `@vvedantb/ui` compact (bottom-sheet) dialogs. |
13
+ | `@vvedantb/ui/tokens/css/modal.css` | `src/css/modal.css` | `.t-modal`, `.is-open`, `.is-closing` and `t-modal-presence-wait` (`@layer components`). |
14
+ | `@vvedantb/ui/tokens/css/tabs.css` | `src/css/tabs.css` | `.t-tabs` container (0.15.0), `.t-tab` with its press scale, active colour, `.t-tabs-pill`, small-screen `.t-tabs` scrolling. |
15
+ | `@vvedantb/ui/tokens/css/tabs-pills.css` | `src/css/tabs-pills.css` | `--tabs-*` colour variables, `.t-tabs--segmented`, `.t-tabs--pills` and pill hover / active fills. |
16
+ | `@vvedantb/ui/tokens/css/utilities.css` | `src/css/utilities.css` | `@utility hit-target` and `@utility reveal-on-hover`. `rounded-surface` moved to `tokens.css` in 0.7.1. |
17
+ | `@vvedantb/ui/tokens/css/scrollbar-thin.css` | `src/css/scrollbar-thin.css` | `.scrollbar-thin` (`@layer utilities`, always emitted). Imported by `tokens.css` from 0.15.0. |
18
+ | `@vvedantb/ui/tokens/css/clear-input.css` | `src/css/clear-input.css` | `ClearInput` layers (`.t-clear*`) and the `--clear-*` / `--glow-*` timings. Imported by `tokens.css`. From 0.15.1 the layers clip in `.t-clear-clip`, so `.t-clear` keeps the focus ring, and the placeholder layer only shows during `.is-clearing`. |
19
+ | `@vvedantb/ui/tokens/css/motion.css` | `src/css/motion.css` | `.ui-page-enter`, `.ui-enter`, `.ui-enter-up`, `.ui-stagger`, their keyframes and reduced-motion rules, and the `html[data-page-motion="off"]` overrides for `PageMotionProvider`. Imported by `tokens.css`. |
20
+ | `@vvedantb/ui/tokens/css/type-scale.css` | `src/css/type-scale.css` | The `text-*` scale (`3xs` 10px to `7xl` 72px, with `2xs` 11px and `2sm` 13px) as `@theme` variables. Each tier has its own line height and letter-spacing: positive below 14px (`+0.01em` at 10-11px), `0` at `sm`, negative above (`-0.03em` at `7xl`). Imported by `tokens.css`. |
21
+ | `@vvedantb/ui/tokens/css/animations.css` | `src/css/animations.css` | `animate-aurora`, `animate-fade-in-up`, `animate-indeterminate` as `@theme` (CSS-first apps). |
22
+ | `@vvedantb/ui/tokens/css/compat-shadcn-rgb.css`, `@vvedantb/ui/tokens/compat/shadcn-rgb.css` | `src/css/compat-shadcn-rgb.css` | Replaces `tokens.css` for apps with shadcn-style `R G B` channel variables. Defines only the UI-only `--color-*` names as `rgb(var(--x) / alpha)` references, `--radius-field`, `--scrollbar`, `--field-radius` (both `min(var(--radius), 0.625rem)` from 0.16.3), the same three radius utilities as `tokens.css` and `.glass-panel-strong` (solid `--popover` from 0.15.0). Import it **or** `tokens.css`, never both. |
23
+ | `@vvedantb/ui/tokens/css/index.css` | `src/css/index.css` | base + dialog + modal + tabs + tabs-pills + utilities + animations + nav-icons, for new CSS-first apps (`tokens.css` brings scrollbar-thin). |
24
+ | `@vvedantb/ui/tokens/tailwind-preset` | `src/tailwind-preset.mjs` (+ `.d.mts`) | Tailwind preset for apps that load a JS config with `@config`. |
25
+
26
+ Every file was extracted because the same rule (same at-rule context, selector and body) sits in 3 or more of the five apps. The measured duplication is in `verify/ANALYSIS.md`, and the proof that each app compiles to the same CSS after migrating is in `verify/RESULTS.md`. Blocks that only 2 apps share, or that drift in a way that would change an app's CSS, stay in the apps; `verify/ANALYSIS.md` lists them.
27
+
28
+ ## Use
29
+
30
+ CSS-first app (no `tailwind.config`):
31
+
32
+ ```css
33
+ @import "tailwindcss";
34
+ @import "@vvedantb/ui/tokens";
35
+ @import "@vvedantb/ui/tokens/css/animations.css";
36
+ @import "@vvedantb/ui/tokens/css/base.css";
37
+ /* ...app @layer base rules... */
38
+ @import "@vvedantb/ui/tokens/css/modal.css";
39
+ @import "@vvedantb/ui/tokens/css/tabs.css";
40
+ /* ...app @layer components rules... */
41
+ /* no --modal-* / --tabs-* needed: tokens.css sets them */
42
+ ```
43
+
44
+ App with a JS config (`@config "../tailwind.config.ts"`):
45
+
46
+ ```ts
47
+ import { tokensPreset } from "@vvedantb/ui/tokens/tailwind-preset";
48
+
49
+ export default {
50
+ presets: [tokensPreset()],
51
+ // or tokensPreset({ color: (name) => `color-mix(in oklch, var(--${name}) calc(<alpha-value> * 100%), transparent)` })
52
+ content: ["./src/**/*.{ts,tsx}"],
53
+ theme: { extend: { /* app-only colours, fonts, animations */ } },
54
+ plugins: [tailwindcssAnimate],
55
+ };
56
+ ```
57
+
58
+ The preset holds `darkMode: "class"`, the shared colour map (`border`, `surface.*`, `danger.*`, `field.*`, shadcn aliases `primary`/`secondary`/`destructive`/`card`/`popover`/`input` ...), `borderRadius` lg/md/sm/field, `boxShadow` soft/panel/insetSoft, `ease-smooth`, `screens` xs to 2xl in px, and the aurora / fade-in-up / indeterminate / accordion keyframes. It does not hold plugins, `content`, fonts, `accent`/`muted`/`ring`/`sidebar` (they differ per app) or accordion timings.
59
+
60
+ Do not import `css/animations.css` in an app that uses the preset: the preset already defines the same keyframes and animations.
61
+
62
+ ### Where to put the imports
63
+
64
+ Tailwind inlines an `@import` where it sits, even in the middle of a file (it must be at top level, not inside an `@layer` block). Put each import where the app's own copy of the rules was. Within one layer, later rules win at equal specificity, so moving shared rules above or below app rules can flip the result for elements matched by both. `examples/migration.md` gives the exact position for each app, and `pnpm --filter @vvedantb/ui verify` checks it.
65
+
66
+ ### Variables each file needs
67
+
68
+ | File | Needs | Provided by |
69
+ | --- | --- | --- |
70
+ | `base.css` | `--accent`, `--foreground` | tokens.css or the app theme |
71
+ | `dialog.css` | none | |
72
+ | `modal.css` | `--modal-open-dur`, `--modal-close-dur`, `--modal-scale`, `--modal-scale-close`, `--modal-ease` | tokens.css (0.15.0), or app `:root` with the compat file |
73
+ | `tabs.css` | `--tabs-dur`, `--tabs-ease` (tokens.css, or app `:root` with the compat file); `--tabs-text-muted`, `--tabs-text-active`, `--tabs-pill-bg` | colours: tabs-pills.css or the app theme |
74
+ | `tabs-pills.css` | `--muted`, `--segment`, `--segment-foreground`, `--default` | tokens.css or the app theme |
75
+ | `utilities.css` | `--breakpoint-sm` (Tailwind default or app theme) | Tailwind |
76
+ | `scrollbar-thin.css` | `--scrollbar` | tokens.css or the app theme |
77
+ | `clear-input.css`, `motion.css` | none (own `:root` defaults) | |
78
+ | `type-scale.css` | none (own `@theme` values) | |
79
+ | `animations.css` | none | |
80
+ | `tailwind-preset` | the CSS variables named in its colour map, `--radius`, `--field-radius` | tokens.css or the app theme |
81
+
82
+ ### Using an existing shadcn RGB theme
83
+
84
+ See the package `README.md`. With the compat file, `base.css`, `scrollbar-thin.css`, `clear-input.css`, `motion.css`, `utilities.css`, `dialog.css`, `modal.css` and `tabs.css` need no `tokens.css` (`modal.css` and `tabs.css` then need the `--modal-*` / `--tabs-*` values on the app `:root`). `base.css` reads `--accent` and `--foreground` and `tabs-pills.css` reads `--muted`, `--segment` and `--default`. Those are not channel-compatible, so skip `tabs-pills.css` and `index.css` (which includes `base.css`) unless the app defines those variables as full colours.
85
+
86
+ ### Parameters
87
+
88
+ Where apps share a rule but drifted in one value, the value is a custom property whose fallback is the most common value. Set it on `:root` to keep a different value.
89
+
90
+ | File | Property | Default | Set by |
91
+ | --- | --- | --- | --- |
92
+ | `base.css` | `--tokens-control-transition-property` | `background-color, border-color, color, box-shadow, transform, opacity` | app-c: `background-color, color, transform, opacity` |
93
+ | `base.css` | `--tokens-control-transition-duration` | `240ms` | app-c: `100ms` |
94
+
95
+ From 0.15.0 the files that moved out of the apps take `:root` variables too. Every rule is in a Tailwind layer, so an app rule for the same selector (unlayered, or later in the same layer) also wins.
96
+
97
+ | File | Property | Default |
98
+ | --- | --- | --- |
99
+ | `tokens.css` | `--modal-open-dur`, `--modal-close-dur` | `180ms`, `120ms` |
100
+ | `tokens.css` | `--modal-scale`, `--modal-scale-close` | `0.96`, `0.96` |
101
+ | `tokens.css` | `--modal-ease`, `--tabs-ease` | `cubic-bezier(0.22, 1, 0.36, 1)` |
102
+ | `tokens.css` | `--tabs-dur` | `200ms` |
103
+ | `tokens.css` | `--sidebar-section-label-mix`, `--sidebar-section-label-hover-mix` | `55%`, `80%` (share of `--muted`) |
104
+ | `scrollbar-thin.css` | `--scrollbar-thin-rest`, `--scrollbar-thin-hover` | `40%`, `80%` (share of `--scrollbar`) |
105
+ | `clear-input.css` | `--clear-dur`, `--clear-out-dur`, `--clear-in-dur` | `1000ms`, `400ms`, `400ms` |
106
+ | `clear-input.css` | `--clear-out-fly`, `--clear-in-fly` | `12px`, `12px` |
107
+ | `clear-input.css` | `--clear-out-ease`, `--clear-in-ease` | `cubic-bezier(0.22, 1, 0.36, 1)` |
108
+ | `clear-input.css` | `--glow-delay`, `--glow-peak-at`, `--glow-opacity`, `--glow-spread` | `50ms`, `0.15`, `0.85`, `1.5` |
109
+ | `motion.css` | `--ui-enter-ease` | `cubic-bezier(0.22, 1, 0.36, 1)` |
110
+ | `motion.css` | `--ui-page-enter-dur`, `--ui-enter-dur`, `--ui-enter-up-dur` | `160ms`, `200ms`, `220ms` |
111
+ | `motion.css` | `--ui-stagger-step` | `40ms` (children 1 to 8) |
112
+
113
+ ## Develop
114
+
115
+ ```sh
116
+ pnpm --filter @vvedantb/ui build # export targets exist + tsc (primitives, shell, app)
117
+ pnpm --filter @vvedantb/ui test # vitest (app helpers) + offline node --test: exports, CSS structure, Tailwind compile, preset
118
+ pnpm --filter @vvedantb/ui analyze # rule-level duplication across the app clones -> verify/ANALYSIS.tables.md
119
+ pnpm --filter @vvedantb/ui verify # before/after compile of every app -> verify/RESULTS.md, examples/migration.md
120
+ ```
121
+
122
+ `analyze` and `verify` need the app clones (`APPS_DIR`, default `/workspace/cvx`; name or symlink the clones `app-a` to `app-e` inside it) and network access the first time: they install Tailwind 4.3.3, the plugins, postcss and jiti into a scratch directory (`VERIFY_DIR`, default `/workspace/pk-tokens-verify`, outside the repo). The migration for each app is data in `verify/migrations/<app>.json`. Each removed block must equal the shared file's block with the same context and selector, or the run fails.
@@ -44,6 +44,7 @@ export function Fixture() {
44
44
  <Button onClick={fire}>Show toast</Button>
45
45
  </div>
46
46
  </main>
47
+ {/* No `position`: the package default, top-right. */}
47
48
  <SonnerToaster
48
49
  theme={dark ? "dark" : "light"}
49
50
  toastRadius={compact ? "control" : "surface"}
@@ -1,11 +1,12 @@
1
1
  # toaster fixture
2
2
 
3
- Renders `SonnerToaster` with every opt-in prop on (`toastRadius="surface"`, `toastIcons="filled24"`, `closeButtonStyle="hoverChip"`, `sonnerVars`, `descriptionMuted`). It fires one sample toast with a title and a description on load. The toast stays open. Use "Show toast" to fire another.
3
+ Renders `SonnerToaster` with every opt-in prop on (`toastRadius="surface"`, `toastIcons="filled24"`, `closeButtonStyle="hoverChip"`, `sonnerVars`, `descriptionMuted`). It passes no `position`, so toasts show at the top right, the package default from 0.31.1. It fires one sample toast with a title and a description on load. The toast stays open. Use "Show toast" to fire another.
4
4
 
5
5
  | Page | Stylesheet |
6
6
  | --- | --- |
7
7
  | `/tokens.html` | `tokens.css` plus `utilities.css` (`styles-tokens.css`) |
8
8
  | `/compat.html` | `compat-shadcn-rgb.css` plus `utilities.css`, with sample `R G B` variables (`styles-compat.css`) |
9
+ | `/update.html` | `tokens.css` plus `utilities.css` (`styles-tokens.css`). Fires the update toast from `showUpdateAvailableToast` on load, at the top right: title, description and a Refresh action that reloads the page. The Refresh button uses the package default (28px tall, `rounded-control`). "Show update toast" fires it again. |
9
10
 
10
11
  Each stylesheet declares `glass-panel-strong` (tokens page only) and `smooth-shadow-ring-md`. The app owns those toast classes. The compat page also defines `--success` and `--warning` and maps them to `--color-success` and `--color-warning`.
11
12
 
@@ -15,4 +16,4 @@ Run it from this folder (it is not a workspace member, and React resolves from t
15
16
  pnpm install --ignore-workspace && pnpm dev
16
17
  ```
17
18
 
18
- Open the printed URL plus `/tokens.html` or `/compat.html`. Add `?variant=compact` for the compact density with `toastRadius="control"`. Add `?theme=dark` for dark mode (combine with `&`), or use "Toggle theme". Hover the toast to see the close chip. `Fixture.tsx` is not part of the package typecheck.
19
+ Open the printed URL plus `/tokens.html`, `/compat.html` or `/update.html`. Add `?variant=compact` for the compact density with `toastRadius="control"`. Add `?theme=dark` for dark mode (combine with `&`), or use "Toggle theme". `?variant=compact` applies to the first two pages only. Hover the toast to see the close chip. `Fixture.tsx` and `UpdateToastFixture.tsx` are not part of the package typecheck.
@@ -0,0 +1,53 @@
1
+ import { useEffect, useState } from "react";
2
+ import { toast } from "sonner";
3
+ import { showUpdateAvailableToast } from "../../../app/src/update/updateWatcher";
4
+ import { Button } from "../../../src/ui/button";
5
+ import { SonnerToaster } from "../../../src/ui/sonner";
6
+
7
+ function initialDark(): boolean {
8
+ return new URLSearchParams(window.location.search).get("theme") === "dark";
9
+ }
10
+
11
+ // The toast `startUpdateAvailableWatcher` shows. Refresh reloads this page,
12
+ // which fires the toast again.
13
+ function fireUpdateToast() {
14
+ showUpdateAvailableToast({ toast });
15
+ }
16
+
17
+ /** The update toast with its Refresh action, for screenshots. */
18
+ export function UpdateToastFixture() {
19
+ const [dark, setDark] = useState(initialDark);
20
+
21
+ // Sonner portals toasts onto `document.body`, so `.dark` must live on `<html>`.
22
+ useEffect(() => {
23
+ document.documentElement.classList.toggle("dark", dark);
24
+ return () => {
25
+ document.documentElement.classList.remove("dark");
26
+ };
27
+ }, [dark]);
28
+
29
+ useEffect(() => {
30
+ const id = window.setTimeout(fireUpdateToast, 150);
31
+ return () => window.clearTimeout(id);
32
+ }, []);
33
+
34
+ return (
35
+ <>
36
+ <main className="min-h-screen bg-background p-8 text-foreground">
37
+ <div className="flex gap-3">
38
+ <Button onClick={() => setDark((d) => !d)}>Toggle theme</Button>
39
+ <Button onClick={fireUpdateToast}>Show update toast</Button>
40
+ </div>
41
+ </main>
42
+ {/* No `position`: the package default, top-right, as Eva mounts it. */}
43
+ <SonnerToaster
44
+ theme={dark ? "dark" : "light"}
45
+ toastRadius="surface"
46
+ toastIcons="filled24"
47
+ closeButtonStyle="hoverChip"
48
+ sonnerVars
49
+ descriptionMuted
50
+ />
51
+ </>
52
+ );
53
+ }
@@ -0,0 +1,5 @@
1
+ import { createRoot } from "react-dom/client";
2
+ import { UpdateToastFixture } from "./UpdateToastFixture";
3
+ import "./styles-tokens.css";
4
+
5
+ createRoot(document.getElementById("root")!).render(<UpdateToastFixture />);
@@ -0,0 +1,12 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Update toast fixture</title>
7
+ </head>
8
+ <body>
9
+ <div id="root"></div>
10
+ <script type="module" src="./main-update.tsx"></script>
11
+ </body>
12
+ </html>
@@ -7,6 +7,6 @@ export default defineConfig({
7
7
  plugins: [tailwindcss()],
8
8
  esbuild: { jsx: "automatic" },
9
9
  resolve: { dedupe: ["react", "react-dom"] },
10
- build: { rollupOptions: { input: ["tokens.html", "compat.html"] } },
10
+ build: { rollupOptions: { input: ["tokens.html", "compat.html", "update.html"] } },
11
11
  server: { fs: { allow: ["../../.."] } },
12
12
  });
@@ -0,0 +1,61 @@
1
+ /*
2
+ * @vvedantb/ui/tokens/css/type-scale.css: the `text-*` scale with size-specific
3
+ * tracking. tokens.css imports it. Apps that pick files one by one can import
4
+ * it alone, after tailwindcss.
5
+ *
6
+ * Tracking is never one value for all sizes. Small UI text gets positive
7
+ * letter-spacing to stay legible. Display text gets negative letter-spacing,
8
+ * because letters look further apart as they grow. Line heights are the
9
+ * Tailwind defaults, so only tracking changes for the standard tiers.
10
+ *
11
+ * `3xs` (10px), `2xs` (11px) and `2sm` (13px) fill the gaps below `text-base`,
12
+ * so call sites do not need arbitrary `text-[11px]` classes.
13
+ *
14
+ * An explicit `tracking-*` or `leading-*` utility still wins. To change a tier,
15
+ * set its variable in the app's own `@theme` block.
16
+ */
17
+
18
+ @theme {
19
+ --text-3xs: 0.625rem;
20
+ --text-3xs--line-height: 0.875rem;
21
+ --text-3xs--letter-spacing: 0.01em;
22
+ --text-2xs: 0.6875rem;
23
+ --text-2xs--line-height: 1rem;
24
+ --text-2xs--letter-spacing: 0.01em;
25
+ --text-xs: 0.75rem;
26
+ --text-xs--line-height: 1rem;
27
+ --text-xs--letter-spacing: 0.005em;
28
+ --text-2sm: 0.8125rem;
29
+ --text-2sm--line-height: 1.125rem;
30
+ --text-2sm--letter-spacing: 0.005em;
31
+ --text-sm: 0.875rem;
32
+ --text-sm--line-height: 1.25rem;
33
+ --text-sm--letter-spacing: 0em;
34
+ --text-base: 1rem;
35
+ --text-base--line-height: 1.5rem;
36
+ --text-base--letter-spacing: -0.006em;
37
+ --text-lg: 1.125rem;
38
+ --text-lg--line-height: 1.75rem;
39
+ --text-lg--letter-spacing: -0.01em;
40
+ --text-xl: 1.25rem;
41
+ --text-xl--line-height: 1.75rem;
42
+ --text-xl--letter-spacing: -0.012em;
43
+ --text-2xl: 1.5rem;
44
+ --text-2xl--line-height: 2rem;
45
+ --text-2xl--letter-spacing: -0.015em;
46
+ --text-3xl: 1.875rem;
47
+ --text-3xl--line-height: 2.25rem;
48
+ --text-3xl--letter-spacing: -0.018em;
49
+ --text-4xl: 2.25rem;
50
+ --text-4xl--line-height: 2.5rem;
51
+ --text-4xl--letter-spacing: -0.022em;
52
+ --text-5xl: 3rem;
53
+ --text-5xl--line-height: 1;
54
+ --text-5xl--letter-spacing: -0.025em;
55
+ --text-6xl: 3.75rem;
56
+ --text-6xl--line-height: 1;
57
+ --text-6xl--letter-spacing: -0.028em;
58
+ --text-7xl: 4.5rem;
59
+ --text-7xl--line-height: 1;
60
+ --text-7xl--letter-spacing: -0.03em;
61
+ }
@@ -23,11 +23,15 @@
23
23
  * modal / tabs motion variables. Every rule sits in a Tailwind layer and the
24
24
  * timings and strengths are `:root` variables, so app rules and app `:root`
25
25
  * values win.
26
+ *
27
+ * It also brings the `text-*` type scale with size-specific
28
+ * tracking (css/type-scale.css), including the `3xs`, `2xs` and `2sm` tiers.
26
29
  */
27
30
 
28
31
  @import "./css/clear-input.css";
29
32
  @import "./css/scrollbar-thin.css";
30
33
  @import "./css/motion.css";
34
+ @import "./css/type-scale.css";
31
35
 
32
36
  @custom-variant dark (&:where(.dark, .dark *));
33
37