@vvedantb/ui 0.26.1 → 0.28.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
@@ -4,13 +4,16 @@ Shared React 19 web UI. Source-exported: no build step.
4
4
 
5
5
  | Import | What it is |
6
6
  | --- | --- |
7
- | `@vvedantb/ui` | The only JavaScript entry. Primitives (Radix-based), AI elements, audio (`playChime`, `useReplyChime`, `playTone`), `toast` and `SonnerToaster`, the composer (`InputArea`, deprecated 0.3 `Composer`), shell (`SidebarHeader`, `SidebarUpgradeCard`, `PillTabs`, `SessionsHoverCard`, and the app shell: `AppShell`, `AppSidebar`, `SidebarRail`, `RailTile`, `SidebarPanel`, `SidebarAccountMenu`, `SignOutDialog` and related helpers), app helpers (confirm skip, update watcher, settings chrome, `useStableAuth`, and from 0.8.0 `createThemeProvider`, `createPageTitleContext`, `PageMotionProvider` and `formatCompactRelativeTime`), marketing pieces from 0.9.0 (`createLandingKit` and the `Landing*` parts, `SiteFooter`, `PricingModal`), animated nav icons from 0.11.0 (`MemoryIcon`, `BoardIcon`, ... and `NavIconBase`; `SettingsIcon` `variant` from 0.12.0), artifact viewers from 0.13.0 (`ArtifactFrame`, `ArtifactList`, `ArtifactViewer`, ...), date pickers from 0.14.0 (`Calendar`, `DatePicker`, `DateTimePicker`, `MonthPicker`), `cn`, and the native tokens `tokens` and `Tokens`. See `app/README.md` in the repository for the app helpers. |
7
+ | `@vvedantb/ui` | The main JavaScript entry. Primitives (Radix-based), AI elements, audio (`playChime`, `useReplyChime`, `playTone`), `toast` and `SonnerToaster`, the composer (`InputArea`, deprecated 0.3 `Composer`), shell (`SidebarHeader`, `SidebarUpgradeCard`, `PillTabs`, `SessionsHoverCard`, and the app shell: `AppShell`, `AppSidebar`, `SidebarRail`, `RailTile`, `SidebarPanel`, `SidebarAccountMenu`, `SignOutDialog` and related helpers), app helpers (confirm skip, update watcher, settings chrome, `useStableAuth`, and from 0.8.0 `createThemeProvider`, `createPageTitleContext`, `PageMotionProvider` and `formatCompactRelativeTime`), marketing pieces from 0.9.0 (`createLandingKit` and the `Landing*` parts, `SiteFooter`, `PricingModal`), animated nav icons from 0.11.0 (`MemoryIcon`, `BoardIcon`, ... and `NavIconBase`; `SettingsIcon` `variant` from 0.12.0), artifact viewers from 0.13.0 (`ArtifactFrame`, `ArtifactList`, `ArtifactViewer`, ...), date pickers from 0.14.0 (`Calendar`, `DatePicker`, `DateTimePicker`, `MonthPicker`), `cn`, and the native tokens `tokens` and `Tokens`. See `app/README.md` in the repository for the app helpers. |
8
+ | `@vvedantb/ui/client` | The root without `@vvedantb/server`, convex or Clerk, for Chrome extensions (0.28.0). Leaves out the artifact viewers, `ConvexClerkProvider`, `useStableAuth`, `createUseStableAuth`, `resetStableAuthSession` and `useEnsureUser`. See [Chrome extensions](#chrome-extensions-0280). |
9
+ | `@vvedantb/ui/brand` | App icons (`Icon*`, `APP_ICONS`), `AppWordmark`, deprecated `AppMark`, raw SVG strings and `FAMILY_APPS`. Also in the root and `/client`. |
8
10
  | `@vvedantb/ui/tokens` | `tokens.css`: colour, radius, shadow, ease and font tokens for Tailwind v4. CSS. |
9
11
  | `@vvedantb/ui/tokens/tokens.css` | Same file as `@vvedantb/ui/tokens`. CSS. |
10
12
  | `@vvedantb/ui/tokens/css/*.css` | `index`, `base`, `dialog`, `modal`, `tabs`, `tabs-pills`, `utilities`, `scrollbar-thin`, `clear-input`, `motion`, `animations`, `nav-icons`, `compat-shadcn-rgb`, `border-beam` (opt-in, for `BorderBeam`), `markdown` (opt-in, for `Markdown`). CSS. `tokens.css` imports `scrollbar-thin`, `clear-input` and `motion`. |
11
13
  | `@vvedantb/ui/tokens/compat/shadcn-rgb.css` | Same file as `tokens/css/compat-shadcn-rgb.css`. CSS. |
12
14
  | `@vvedantb/ui/tokens/tailwind-preset` | Tailwind preset (`.mjs`) for `@config "@vvedantb/ui/tokens/tailwind-preset"`. Kept as a build-tool entry: Tailwind needs a resolvable package path, and it is not a React API. |
13
15
  | `@vvedantb/ui/landing.css` | Landing page classes (`landing-wordmark-text` for `AppWordmark`, `landing-atmosphere`, `landing-grain`, `landing-pulse-dot`, ambient graph and preview animations, smooth `#top` scrolling). CSS. |
16
+ | `@vvedantb/ui/fonts/instrument-sans.css` | Instrument Sans `@font-face` rules over packaged woff2 files, and the Clerk Inter override, for extension pages (0.28.0). Opt-in. CSS. |
14
17
  | `@vvedantb/ui/package.json` | Package metadata. |
15
18
 
16
19
  Removed in 0.4.0-rc.1: the `/cn`, `/sonner`, `/audio`, `/shell`, `/app`, `/composer` and `/tokens/native` subpaths. Import from `@vvedantb/ui`. See [`MIGRATION.md`](MIGRATION.md).
@@ -910,7 +913,7 @@ Shared marketing wordmark for product app names across Project V sites: the `Ico
910
913
 
911
914
  Never use `AppWordmark` for `projectv` (the type rejects it).
912
915
 
913
- Setup. The package does not bundle the font. `--font-sans` comes from the package tokens. Load Instrument Sans in the app, as for the rest of the UI, if it is not already loaded.
916
+ Setup. `--font-sans` comes from the package tokens. Load Instrument Sans in the app, as for the rest of the UI, if it is not already loaded. Extension pages can import `@vvedantb/ui/fonts/instrument-sans.css` (0.28.0); web apps keep their own font loading.
914
917
 
915
918
  ```css
916
919
  @import "@vvedantb/ui/landing.css"; /* provides .landing-wordmark-text */
@@ -1184,8 +1187,80 @@ import { DatePicker, DateTimePicker, MonthPicker } from "@vvedantb/ui";
1184
1187
  - `DatePicker`: `value` "YYYY-MM-DD" or "". The trigger matches `TimePicker` and shows the date with `dateStyle: "medium"` (`locale`) or `placeholder` ("Pick a date"). `min` and `max` disable days; `clearable` adds a clear control (`onChange("")`); `name` adds a hidden input. `className` goes on the wrapper, `triggerClassName` merges onto the button (default `w-40`). A width on either sizes the field, and `w-full` on either fills the row; pill inputs can pass `triggerClassName="h-10 w-full rounded-full px-4 text-sm"`. `ariaLabel` names the trigger, followed by the shown text.
1185
1188
  - `DateTimePicker`: `value` "YYYY-MM-DDTHH:mm" or "". A date with no time uses `defaultTime` ("00:00"); a time with no date uses today. Only the date part of `min` and `max` applies. `triggerClassName` goes to both triggers, a width only to the date.
1186
1189
  - `MonthPicker`: `value` "YYYY-MM" or "", with year navigation and a month grid. `min` and `max` are "YYYY-MM".
1190
+ - `TimePicker`: `value` "HH:mm" (24h) or "". `hourCycle={12}` (0.27.0) shows "02:30 PM" and adds an AM/PM column; `value` stays 24h. Each column opens centred on the selected item.
1187
1191
  - `Calendar`: the styled `DayPicker` for custom layouts (every `DayPicker` prop). `parseDateValue` and `formatDateValue` convert between "YYYY-MM-DD" and a local `Date`.
1188
1192
 
1193
+ ## Hooks, media and list motion (0.27.0)
1194
+
1195
+ Generic pieces lifted from an app. Components that use `m` need the app's `LazyMotion`.
1196
+
1197
+ ```tsx
1198
+ import {
1199
+ ErrorBoundary, ListEnter, useFirstPaintGate, CountPop, countLabel, UnreadDot,
1200
+ MarqueeOnHover, RelativeDateTime, ImageLightbox, ImageGalleryPreview, ScreenshotPreview, VideoPreview,
1201
+ useMediaQuery, useDocumentVisible, useIdleCallback, useSingleFlight, usePersistedScrollParent,
1202
+ convexErrorMessage, userFacingErrorMessage, useHeldResult,
1203
+ } from "@vvedantb/ui";
1204
+ ```
1205
+
1206
+ - `ErrorBoundary` (`fallback` node or `(retry) => node`, `onError`): contains a failure to its subtree; `retry` clears the error.
1207
+ - `ListEnter` (`index`, `fast`, `firstPaint`, `staggerStep`, `staggerMax`, `slide`, `as` `div | tr | li`) and `useFirstPaintGate()`: first-paint fade and 8px slide, staggered with `staggerDelay`. Pass `firstPaint={gate.current}` so recycled rows do not restagger.
1208
+ - `CountPop` (`label`, `className`, `children`): pop-in and shrink-out for a live count, re-popping on each change. `countLabel(n)` gives `null`, the number or `"99+"`. `UnreadDot` (`show`): a `bg-primary` dot on `CountPop`.
1209
+ - `MarqueeOnHover`: a single-line label that scrolls its hidden tail into view on hover (or on hover of a `group` ancestor). Import `@vvedantb/ui/tokens/css/marquee.css`; `--mq-delay` sets the dwell.
1210
+ - `RelativeDateTime` (`at`, `emptyLabel` default "—", `exactFormat` default "DD/MM/YYYY HH:mm"): "15m" / "2d" with the exact time in a tooltip.
1211
+ - `ImageLightbox` (`images`, `index` or `null`, `onIndexChange`, `onClose`): fullscreen viewer with arrow keys, buttons and swipe. `ImageGalleryPreview` (`images`): up to a 2×2 grid with a "+N" tile. `ScreenshotPreview` (`url`, `alt`) and `VideoPreview` (`url`).
1212
+ - Hooks: `useMediaQuery(query)`, `useDocumentVisible()`, `useIdleCallback(ms, fn)` (trailing debounce; `createIdleCallback` is the React-free core), `useSingleFlight(fn)` (one call at a time, latest args run next), `usePersistedScrollParent(storageKey)` (restores a container's `scrollTop` from `sessionStorage`).
1213
+ - Convex: `convexErrorMessage(error, fallback)` reads `ConvexError` data first; `userFacingErrorMessage(error, fallback)` strips the client envelope and stack. `useHeldResult(result, key)` keeps the last result while a query is skipped (`key` `null`). None of these import `convex`.
1214
+
1215
+ ## Chrome extensions (0.28.0)
1216
+
1217
+ Extension pages (popup, side panel, options, welcome) run under the MV3 extension-page CSP, which blocks remote font stylesheets, and should not load `@vvedantb/server`. Three pieces cover them. Web apps change nothing unless they opt in.
1218
+
1219
+ ### Fonts
1220
+
1221
+ ```css
1222
+ @import "tailwindcss";
1223
+ @import "@vvedantb/ui/tokens";
1224
+ @import "@vvedantb/ui/fonts/instrument-sans.css";
1225
+ @source "../node_modules/@vvedantb/ui/src/**/*.{ts,tsx}";
1226
+ ```
1227
+
1228
+ `instrument-sans.css` has four `@font-face` rules: variable weight 400-700, normal and italic, latin and latin-ext. The `url()`s are relative, so Vite and WXT copy the woff2 files into the build. The licence is `fonts/OFL.txt`. The file ends with the rule both extensions carried in `globals.css`:
1229
+
1230
+ ```css
1231
+ html,
1232
+ body {
1233
+ font-family: var(--font-sans);
1234
+ }
1235
+ ```
1236
+
1237
+ Clerk injects an unlayered `body { font-family: Inter }`, which beats the `@layer base` rule in the tokens; this rule is unlayered too. `tokens.css` does not import the file. Once an extension imports it, it can drop its own copy of the fonts, the CSS and the override.
1238
+
1239
+ ### `@vvedantb/ui/client`
1240
+
1241
+ ```tsx
1242
+ import { AppWordmark, Button, Card, Tabs, TabsList, TabsTrigger, cn, createThemeProvider } from "@vvedantb/ui/client";
1243
+ ```
1244
+
1245
+ The root's exports, without:
1246
+
1247
+ - the artifact viewers (`src/artifacts`: `ArtifactFrame`, `ArtifactViewer`, ...), which import `@vvedantb/server`;
1248
+ - `ConvexClerkProvider`, `useStableAuth`, `createUseStableAuth`, `resetStableAuthSession` and `useEnsureUser`, which import `convex` or `@clerk/clerk-react`.
1249
+
1250
+ Every other name is the same binding as in the root. `src/client-exports.test.ts` keeps the two in step, and `app/tests-node/client-graph.test.mjs` checks that the entry's module graph has no `@vvedantb/server`, convex, Clerk or `node:` import. The root is unchanged.
1251
+
1252
+ ### Icons
1253
+
1254
+ `scripts/build-brand-assets.mjs` ships in the package and writes `<out>/<app>/extension/icon-{16,32,48,128}.png` (the tile at 16, 32 and 48 px, `appExtension128Svg` at 128 px). Copy them into the extension's public folder:
1255
+
1256
+ ```sh
1257
+ out=$(mktemp -d)
1258
+ node node_modules/@vvedantb/ui/scripts/build-brand-assets.mjs --out "$out" --app vmem
1259
+ mkdir -p public/icons && cp "$out"/vmem/extension/icon-*.png public/icons/
1260
+ ```
1261
+
1262
+ PNGs need `rsvg-convert` (librsvg); without it the script writes only the SVGs and says so. It needs Node 22.18 or later. Under `node_modules` it strips the types from `src/brand/svg.ts` itself, because Node will not, and Node prints an `ExperimentalWarning` for that. `defineVExtensionConfig` in `@vvedantb/config/extension` points the manifest `icons` and `action.default_icon` at `icons/icon-{16,32,48,128}.png`.
1263
+
1189
1264
  ## Slider (0.16.0, dark contrast and className props 0.16.1)
1190
1265
 
1191
1266
  shadcn's slider on `@radix-ui/react-slider` (a peer dependency), with package tokens.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * The message to show the user for a failed Convex call.
3
+ *
4
+ * Production Convex redacts plain `Error` messages to "Server Error", so
5
+ * `error.message` alone leaves the user with a request id and no reason. Only
6
+ * `ConvexError` data crosses the wire intact — read that first. Matched by
7
+ * `name` rather than `instanceof`, so this module does not import `convex`.
8
+ */
9
+ export function convexErrorMessage(error: unknown, fallback: string): string {
10
+ if (
11
+ error instanceof Error &&
12
+ error.name === "ConvexError" &&
13
+ "data" in error &&
14
+ typeof error.data === "string"
15
+ ) {
16
+ return error.data;
17
+ }
18
+ return error instanceof Error ? error.message : fallback;
19
+ }
20
+
21
+ const UNCAUGHT = "Uncaught Error:";
22
+ const PLAIN = "Error:";
23
+
24
+ /**
25
+ * The same failure, stripped of everything the Convex client wraps around it.
26
+ *
27
+ * A client-side rejection reads
28
+ * `[CONVEX M(teams:create)] [Request ID: abc] Server Error\nUncaught Error: Team
29
+ * name is required\n at handler (../convex/teams.ts:107:12)`. Shown verbatim
30
+ * in a form's error slot that is a stack trace with the sentence buried in the
31
+ * middle, so take the text the handler actually threw: after the last
32
+ * `Uncaught Error:` / `Error:`, up to the newline or the stack frame.
33
+ *
34
+ * `error` is deliberately not `unknown` — callers catch `unknown` and narrow at
35
+ * the boundary with `err instanceof Error ? err : null`.
36
+ */
37
+ export function userFacingErrorMessage(
38
+ error: Error | string | null | undefined,
39
+ fallback: string,
40
+ ): string {
41
+ const raw = typeof error === "string" ? error : (error?.message ?? "");
42
+
43
+ let start = 0;
44
+ const uncaught = raw.lastIndexOf(UNCAUGHT);
45
+ if (uncaught !== -1) {
46
+ start = uncaught + UNCAUGHT.length;
47
+ } else {
48
+ const plain = raw.lastIndexOf(PLAIN);
49
+ if (plain !== -1) start = plain + PLAIN.length;
50
+ }
51
+
52
+ let text = raw.slice(start);
53
+ const newline = text.indexOf("\n");
54
+ if (newline !== -1) text = text.slice(0, newline);
55
+ const frame = text.indexOf(" at ");
56
+ if (frame !== -1) text = text.slice(0, frame);
57
+ text = text.trim();
58
+
59
+ // Nothing survived the strip, or the whole thing was the client's envelope.
60
+ if (text.length === 0 || text.startsWith("[CONVEX")) return fallback;
61
+ return text;
62
+ }
@@ -0,0 +1,26 @@
1
+ import { useState } from "react";
2
+
3
+ /**
4
+ * Keeps the last loaded `result` while a query is skipped, instead of
5
+ * flipping to `undefined`. Pair it with any `useQuery`:
6
+ *
7
+ * const result = useQuery(api.x.get, args);
8
+ * const shown = useHeldResult(result, args === "skip" ? null : JSON.stringify(args));
9
+ *
10
+ * `key` names what the result is for, and `null` means skipped. While skipped
11
+ * the last result stays (so a hidden pane that pauses its subscription does
12
+ * not flash a spinner when shown again). A new non-null key loads as
13
+ * `undefined` rather than showing the previous key's data; pass a stable key
14
+ * on purpose to keep the last result across argument changes.
15
+ */
16
+ export function useHeldResult<T>(result: T | undefined, key: string | null): T | undefined {
17
+ // State, not a ref: reading a ref during render makes the React Compiler
18
+ // skip the file. Adjusting state during render is the supported way to
19
+ // remember a previous value.
20
+ const [held, setHeld] = useState({ key, value: result });
21
+ if (result !== undefined && (result !== held.value || key !== held.key)) {
22
+ setHeld({ key, value: result });
23
+ }
24
+ if (result !== undefined) return result;
25
+ return key === null || key === held.key ? held.value : undefined;
26
+ }
package/app/src/index.ts CHANGED
@@ -22,11 +22,17 @@ export {
22
22
  type UpdateToastOptions,
23
23
  } from "./update/updateWatcher.js";
24
24
 
25
- export { SettingsSection } from "./settings/SettingsSection.js";
25
+ export {
26
+ SettingsSection,
27
+ type SettingsSectionConfig,
28
+ } from "./settings/SettingsSection.js";
26
29
  export { SettingsField } from "./settings/SettingsField.js";
27
30
  export { SettingsStack } from "./settings/SettingsStack.js";
28
31
  export { SettingsToggleRow } from "./settings/SettingsToggleRow.js";
29
- export { SettingsEmptyState } from "./settings/SettingsEmptyState.js";
32
+ export {
33
+ SettingsEmptyState,
34
+ type SettingsEmptyStateConfig,
35
+ } from "./settings/SettingsEmptyState.js";
30
36
  export {
31
37
  DefaultSettingsLayout,
32
38
  SettingsPage,
@@ -89,3 +95,5 @@ export {
89
95
  type ViteEnvName,
90
96
  } from "./convex/env.js";
91
97
  export { useEnsureUser, type EnsureUserMutation } from "./convex/useEnsureUser.js";
98
+ export { convexErrorMessage, userFacingErrorMessage } from "./convex/errorMessage.js";
99
+ export { useHeldResult } from "./convex/useHeldResult.js";
@@ -1,4 +1,15 @@
1
1
  import type { ComponentType, ReactNode } from "react";
2
+ import { useUiConfig } from "../../../src/ui/ui-config";
3
+
4
+ const ICON_CLASS = "mb-5 text-muted-foreground opacity-50";
5
+
6
+ /** `UiConfig.SettingsEmptyState`: replaces the built-in classes of a part. */
7
+ export interface SettingsEmptyStateConfig {
8
+ classes?: {
9
+ /** The icon above the title (colour, opacity, spacing). */
10
+ icon?: string;
11
+ };
12
+ }
2
13
 
3
14
  interface SettingsEmptyStateProps {
4
15
  /** Tabler icon component, rendered muted above the copy. */
@@ -23,9 +34,11 @@ export function SettingsEmptyState({
23
34
  description,
24
35
  action,
25
36
  }: SettingsEmptyStateProps) {
37
+ const iconClass =
38
+ useUiConfig("SettingsEmptyState")?.classes?.icon ?? ICON_CLASS;
26
39
  return (
27
40
  <div className="flex flex-col items-center justify-center px-4 py-16 text-center">
28
- <Icon size={28} className="mb-5 text-muted-foreground opacity-50" />
41
+ <Icon size={28} className={iconClass} />
29
42
  <h4 className="text-sm font-medium text-foreground">{title}</h4>
30
43
  {description ? (
31
44
  <p className="mt-2 max-w-sm text-xs leading-relaxed text-muted-foreground">
@@ -1,6 +1,6 @@
1
1
  import type { ReactNode } from "react";
2
2
 
3
- import { cn } from "../cn.js";
3
+ import { useCn, useUiConfig } from "../../../src/ui/ui-config";
4
4
 
5
5
  type SettingsSectionBodyVariant = "form" | "list" | "compact";
6
6
 
@@ -10,6 +10,23 @@ const BODY_VARIANT_CLASS: Record<SettingsSectionBodyVariant, string> = {
10
10
  compact: "px-4 py-3",
11
11
  };
12
12
 
13
+ const CARD_CLASS =
14
+ "rounded-lg bg-surface-card [&_input]:bg-field-background [&_textarea]:bg-field-background [&_[data-slot=select-trigger]]:bg-field-background [&_[role=combobox]]:border-border [&_[role=combobox]]:bg-field-background";
15
+ const FOOTER_CLASS =
16
+ "flex items-center justify-end gap-2 rounded-b-lg bg-surface-secondary px-4 py-3";
17
+
18
+ /** `UiConfig.SettingsSection`: replaces the built-in classes of a part. */
19
+ export interface SettingsSectionConfig {
20
+ classes?: {
21
+ /** The card behind the body and footer (tone, radius, nested field fills). */
22
+ card?: string;
23
+ /** The bottom bar that holds `footer`. */
24
+ footer?: string;
25
+ /** Body padding per `bodyVariant`. */
26
+ body?: Partial<Record<SettingsSectionBodyVariant, string>>;
27
+ };
28
+ }
29
+
13
30
  interface SettingsSectionProps {
14
31
  /** Section heading. Kept short — the description carries the detail. */
15
32
  title: ReactNode;
@@ -49,6 +66,9 @@ export function SettingsSection({
49
66
  bodyClassName,
50
67
  className,
51
68
  }: SettingsSectionProps) {
69
+ const config = useUiConfig("SettingsSection");
70
+ const cn = useCn();
71
+ const classes = config?.classes;
52
72
  const hasBody = children != null;
53
73
  const hasCard = hasBody || footer != null;
54
74
 
@@ -71,17 +91,22 @@ export function SettingsSection({
71
91
  {hasCard ? (
72
92
  <div
73
93
  className={cn(
74
- "rounded-lg bg-surface-card [&_input]:bg-field-background [&_textarea]:bg-field-background [&_[data-slot=select-trigger]]:bg-field-background [&_[role=combobox]]:border-border [&_[role=combobox]]:bg-field-background",
94
+ classes?.card ?? CARD_CLASS,
75
95
  bodyVariant === "list" && "overflow-hidden",
76
96
  )}
77
97
  >
78
98
  {hasBody ? (
79
- <div className={cn(BODY_VARIANT_CLASS[bodyVariant], bodyClassName)}>
99
+ <div
100
+ className={cn(
101
+ classes?.body?.[bodyVariant] ?? BODY_VARIANT_CLASS[bodyVariant],
102
+ bodyClassName,
103
+ )}
104
+ >
80
105
  {children}
81
106
  </div>
82
107
  ) : null}
83
108
  {footer ? (
84
- <div className="flex items-center justify-end gap-2 rounded-b-lg bg-surface-secondary px-4 py-3">
109
+ <div className={classes?.footer ?? FOOTER_CLASS}>
85
110
  {footer}
86
111
  </div>
87
112
  ) : null}
Binary file
package/fonts/OFL.txt ADDED
@@ -0,0 +1,93 @@
1
+ Copyright 2022 The Instrument Sans Project Authors (https://github.com/Instrument/instrument-sans)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,73 @@
1
+ /*
2
+ * @vvedantb/ui/fonts/instrument-sans.css: Instrument Sans for chrome-extension
3
+ * pages (popup, welcome). Opt-in: tokens.css does not import it, so web apps
4
+ * are unchanged.
5
+ *
6
+ * @import "@vvedantb/ui/fonts/instrument-sans.css";
7
+ *
8
+ * @vvedantb/ui/tokens only names the family; MV3 extension-page CSP cannot load
9
+ * remote webfont stylesheets, so the files ship here. Variable weight 400-700,
10
+ * normal and italic, latin and latin-ext. The url()s are relative, so Vite and
11
+ * WXT copy the woff2 files into the build. Licence: OFL.txt in this folder.
12
+ *
13
+ * The last rule sets html and body to --font-sans (from @vvedantb/ui/tokens).
14
+ * It is unlayered on purpose: see the comment above it.
15
+ */
16
+ @font-face {
17
+ font-family: "Instrument Sans";
18
+ font-style: italic;
19
+ font-weight: 400 700;
20
+ font-stretch: 100%;
21
+ font-display: swap;
22
+ src: url("./InstrumentSans-Italic-latin-ext.woff2") format("woff2");
23
+ unicode-range:
24
+ U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
25
+ U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
26
+ U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
27
+ }
28
+
29
+ @font-face {
30
+ font-family: "Instrument Sans";
31
+ font-style: italic;
32
+ font-weight: 400 700;
33
+ font-stretch: 100%;
34
+ font-display: swap;
35
+ src: url("./InstrumentSans-Italic-latin.woff2") format("woff2");
36
+ unicode-range:
37
+ U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
38
+ U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
39
+ U+2215, U+FEFF, U+FFFD;
40
+ }
41
+
42
+ @font-face {
43
+ font-family: "Instrument Sans";
44
+ font-style: normal;
45
+ font-weight: 400 700;
46
+ font-stretch: 100%;
47
+ font-display: swap;
48
+ src: url("./InstrumentSans-latin-ext.woff2") format("woff2");
49
+ unicode-range:
50
+ U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
51
+ U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
52
+ U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
53
+ }
54
+
55
+ @font-face {
56
+ font-family: "Instrument Sans";
57
+ font-style: normal;
58
+ font-weight: 400 700;
59
+ font-stretch: 100%;
60
+ font-display: swap;
61
+ src: url("./InstrumentSans-latin.woff2") format("woff2");
62
+ unicode-range:
63
+ U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
64
+ U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212,
65
+ U+2215, U+FEFF, U+FFFD;
66
+ }
67
+
68
+ /* Clerk injects unlayered `body { font-family: Inter }` which beats
69
+ * `@layer base` from @vvedantb/ui/tokens. Keep extension pages on Instrument Sans. */
70
+ html,
71
+ body {
72
+ font-family: var(--font-sans);
73
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@vvedantb/ui",
3
- "version": "0.26.1",
3
+ "version": "0.28.0",
4
4
  "license": "MIT",
5
- "description": "Shared React 19 UI for web apps: one 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), design-token CSS, shared Tailwind v4 CSS and a Tailwind preset.",
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",
7
7
  "publishConfig": {
8
8
  "access": "public"
@@ -34,6 +34,7 @@
34
34
  "./tokens/css/compat-shadcn-rgb.css": "./tokens/src/css/compat-shadcn-rgb.css",
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
+ "./tokens/css/marquee.css": "./tokens/src/css/marquee.css",
37
38
  "./tokens/compat/shadcn-rgb.css": "./tokens/src/css/compat-shadcn-rgb.css",
38
39
  "./tokens/css/*.css": "./tokens/src/css/*.css",
39
40
  "./tokens/tailwind-preset": {
@@ -44,7 +45,12 @@
44
45
  "types": "./src/brand/index.ts",
45
46
  "default": "./src/brand/index.ts"
46
47
  },
48
+ "./client": {
49
+ "types": "./src/client.ts",
50
+ "default": "./src/client.ts"
51
+ },
47
52
  "./landing.css": "./src/marketing/landing.css",
53
+ "./fonts/instrument-sans.css": "./fonts/instrument-sans.css",
48
54
  "./package.json": "./package.json"
49
55
  },
50
56
  "types": "./src/index.ts",
@@ -54,6 +60,7 @@
54
60
  "app/src",
55
61
  "tokens/src",
56
62
  "tokens/examples",
63
+ "fonts",
57
64
  "scripts/build-brand-assets.mjs",
58
65
  "README.md",
59
66
  "LICENSE",
@@ -62,7 +69,8 @@
62
69
  ],
63
70
  "sideEffects": [
64
71
  "./src/ui/sonner.css",
65
- "./src/marketing/landing.css"
72
+ "./src/marketing/landing.css",
73
+ "./fonts/instrument-sans.css"
66
74
  ],
67
75
  "scripts": {
68
76
  "check:tokens": "node tokens/scripts/check-component-tokens.mjs",
@@ -5,10 +5,19 @@
5
5
  // SVGs are always written. PNGs and favicon.ico need `rsvg-convert`; without it they are skipped
6
6
  // with a message. Layout: <dir>/<app>/{mark,icon,favicon,icon-light}.svg, PNGs, extension/, android/.
7
7
  import { spawnSync } from "node:child_process";
8
- import { mkdirSync, writeFileSync } from "node:fs";
9
- import { dirname, join } from "node:path";
8
+ import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
9
+ import { dirname, join, sep } from "node:path";
10
10
  import { fileURLToPath } from "node:url";
11
- import { APP_NAMES, appAdaptiveSvg, appExtension128Svg, appMarkSvg, appTileSvg } from "../src/brand/svg.ts";
11
+
12
+ // Node does not strip types from files under node_modules, so an installed copy
13
+ // of this script strips svg.ts itself (svg.ts has no imports).
14
+ async function loadSvg() {
15
+ const url = new URL("../src/brand/svg.ts", import.meta.url);
16
+ if (!fileURLToPath(url).split(sep).includes("node_modules")) return import(url.href);
17
+ const { stripTypeScriptTypes } = await import("node:module");
18
+ return import(`data:text/javascript,${encodeURIComponent(stripTypeScriptTypes(readFileSync(url, "utf8")))}`);
19
+ }
20
+ const { APP_NAMES, appAdaptiveSvg, appExtension128Svg, appMarkSvg, appTileSvg } = await loadSvg();
12
21
 
13
22
  /** Whether `rsvg-convert` can be run. */
14
23
  export function hasRsvg() {