@vvedantb/ui 0.36.0 → 0.37.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 +27 -8
- package/package.json +14 -15
- package/src/brand/index.ts +1 -0
- package/src/brand/productApps.ts +20 -0
- package/src/client.ts +12 -2
- package/src/index.ts +12 -2
- package/src/marketing/SiteFooter.tsx +86 -22
- package/src/marketing/landing.tsx +35 -7
- package/src/ui/page-title.tsx +29 -0
- package/app/README.md +0 -269
- package/tokens/README.md +0 -122
package/README.md
CHANGED
|
@@ -890,7 +890,7 @@ Plain parts, no Motion:
|
|
|
890
890
|
| `LandingLattice` | `className` (grid columns). Cells share 1px borders. |
|
|
891
891
|
| `LandingFeatureCard` | `icon` (a component, rendered `size={18} stroke={1.5}`), `title`, `description`. |
|
|
892
892
|
| `LandingNavMenu` | `links`, `github` (`href`, `icon`). Overflow menu below `md`. |
|
|
893
|
-
| `LandingFooter` | `brand`, `tagline`, `links`, `actions` (after the links), `github` (`href`, `label`, `icon`). |
|
|
893
|
+
| `LandingFooter` | New path (0.37.0): `app`, `tagline`, `links` (a "Navigation" column) or `columns`, `actions`, plus the `SiteFooter` options. A thin wrapper over `SiteFooter` with every Project V default. Deprecated path (no `app`): `brand`, `tagline`, `links`, `actions` (after the links), `github` (`href`, `label`, `icon`), in the old compact layout. `brand` and `github` are ignored when `app` is set. |
|
|
894
894
|
|
|
895
895
|
Constants: `landingShellClass`, `landingPanelClass`, `landingItemVariants`, and
|
|
896
896
|
for the footer's `actions` slot `landingFooterLinkClass` (a text link) and
|
|
@@ -898,17 +898,36 @@ for the footer's `actions` slot `landingFooterLinkClass` (a text link) and
|
|
|
898
898
|
|
|
899
899
|
### `SiteFooter`
|
|
900
900
|
|
|
901
|
-
Brand, tagline and social icon buttons; link columns; then copyright and legal
|
|
902
|
-
links under a separator.
|
|
901
|
+
Brand, tagline and social icon buttons; link columns; then copyright, product-of line and legal
|
|
902
|
+
links under a separator. Set `app` for the Project V footer (0.37.0):
|
|
903
|
+
|
|
904
|
+
```tsx
|
|
905
|
+
<SiteFooter
|
|
906
|
+
app="vibot"
|
|
907
|
+
tagline="AI-powered assistant designed to automate tasks, and enhance productivity effortlessly."
|
|
908
|
+
columns={[{ heading: "Navigation", links: [{ href: "#features", label: "Features" }] }]}
|
|
909
|
+
/>
|
|
910
|
+
```
|
|
903
911
|
|
|
904
912
|
| Prop | |
|
|
905
913
|
| --- | --- |
|
|
906
|
-
| `
|
|
907
|
-
| `
|
|
908
|
-
| `columns` | `{ heading, links }[]`. A link is `{ href, label, external?, image?: { src, alt }, app?: AppName }`. `image` is a 20px round image before the label. `app`
|
|
909
|
-
| `
|
|
910
|
-
| `
|
|
914
|
+
| `app` | `vibot`, `vmem`, `verve`, `velth` or `vhub`. Brand is `AppWordmark` at `SITE_FOOTER_WORDMARK_SIZE` (16px; no size prop). Copyright name and product-of line use the lowercase id. |
|
|
915
|
+
| `tagline` | Node. |
|
|
916
|
+
| `columns` | Required. `{ heading, links }[]`. A link is `{ href, label, external?, image?: { src, alt }, app?: AppName }`. `image` is a 20px round image before the label. `app` is the 14px `APP_ICONS[app]` glyph before the label, in `currentColor` and `aria-hidden`; it wins over `image`. |
|
|
917
|
+
| `includeAppsColumn` | Default `true`: appends `PROJECT_V_PRODUCT_APPS` (vibot, vmem, verve, velth, vhub) unless `columns` has an "Apps" heading (case-insensitive). `projectVAppsColumn()` returns the column for composition. |
|
|
918
|
+
| `showProductOf` | Default `true`: "{app} is a product of Project V." linking to `https://projectv.uk`. |
|
|
919
|
+
| `socials` | Default `PROJECT_V_SOCIALS` (X, Instagram, GitHub). `[]` hides them. `{ href, icon, label? }[]`; links open in a new tab. |
|
|
920
|
+
| `legalLinks` | Default `PROJECT_V_LEGAL_LINKS` (Privacy Policy, Terms of Service). |
|
|
921
|
+
| `actions` | Node under the socials, for example Sign in. |
|
|
922
|
+
| `year` | Default: the current year. |
|
|
911
923
|
| `variant` | `"muted"` (default, `text-muted`), `"muted-foreground"`, or `"touch"` (`text-muted-foreground`, `max-sm:hit-target` links, safe-area bottom padding). |
|
|
924
|
+
| `brand`, `name` | Optional overrides on the `app` path. |
|
|
925
|
+
|
|
926
|
+
**Deprecated (no `app`):** `brand`, `socials`, `name` and `legalLinks` are required, and the footer renders as before: the brand sits in the Michroma wrapper, with no product-of line and no Apps column. `actions`, `includeAppsColumn` and `showProductOf` do nothing. Set `app` instead.
|
|
927
|
+
|
|
928
|
+
### `PageTitle` and `PageHeader`
|
|
929
|
+
|
|
930
|
+
`PageTitle` is an `h1` with `text-xl font-semibold leading-tight tracking-tight` (`pageTitleClass`): Instrument Sans, 20px, weight 600, never lighter. `PageHeader` is a title row: `title` in a `PageTitle`, an optional `action` slot, and no safe-area padding.
|
|
912
931
|
|
|
913
932
|
### `Icon*` app icons
|
|
914
933
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.37.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), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), 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",
|
|
@@ -81,17 +81,6 @@
|
|
|
81
81
|
"./src/marketing/landing.css",
|
|
82
82
|
"./fonts/instrument-sans.css"
|
|
83
83
|
],
|
|
84
|
-
"scripts": {
|
|
85
|
-
"check:tokens": "node tokens/scripts/check-component-tokens.mjs",
|
|
86
|
-
"build": "node tokens/scripts/check-exports.mjs && node tokens/scripts/check-component-tokens.mjs && tsc -p tsconfig.json",
|
|
87
|
-
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.consumer.json && tsc -p tsconfig.consumer-speech.json && tsc -p tokens/tsconfig.json",
|
|
88
|
-
"test": "node tokens/scripts/check-component-tokens.mjs && vitest run && node --test tokens/test/*.test.mjs app/tests-node/*.test.mjs",
|
|
89
|
-
"verify": "node tokens/scripts/check-component-tokens.mjs && node tokens/verify/run.mjs",
|
|
90
|
-
"analyze": "node tokens/verify/analyze.mjs",
|
|
91
|
-
"brand:assets": "node scripts/build-brand-assets.mjs",
|
|
92
|
-
"brand:sheet": "node scripts/build-brand-sheet.mjs",
|
|
93
|
-
"prepack": "node tokens/scripts/check-exports.mjs"
|
|
94
|
-
},
|
|
95
84
|
"dependencies": {
|
|
96
85
|
"@dnd-kit/core": "^6.3.1",
|
|
97
86
|
"@dnd-kit/modifiers": "^9.0.0",
|
|
@@ -182,7 +171,6 @@
|
|
|
182
171
|
"@tanstack/react-hotkeys": "^0.13.0",
|
|
183
172
|
"@types/react": "^19.1.0",
|
|
184
173
|
"@types/react-dom": "^19.1.0",
|
|
185
|
-
"@vvedantb/server": "workspace:*",
|
|
186
174
|
"ai": "^5.0.0",
|
|
187
175
|
"class-variance-authority": "^0.7.1",
|
|
188
176
|
"clsx": "^2.1.1",
|
|
@@ -206,7 +194,8 @@
|
|
|
206
194
|
"vaul": "^1.1.0",
|
|
207
195
|
"vitest": "^3.2.0",
|
|
208
196
|
"zod": "^4.0.0",
|
|
209
|
-
"zod3": "npm:zod@^3.25.76"
|
|
197
|
+
"zod3": "npm:zod@^3.25.76",
|
|
198
|
+
"@vvedantb/server": "0.14.0"
|
|
210
199
|
},
|
|
211
200
|
"peerDependenciesMeta": {
|
|
212
201
|
"@clerk/clerk-react": {
|
|
@@ -227,5 +216,15 @@
|
|
|
227
216
|
"@vvedantb/server": {
|
|
228
217
|
"optional": true
|
|
229
218
|
}
|
|
219
|
+
},
|
|
220
|
+
"scripts": {
|
|
221
|
+
"check:tokens": "node tokens/scripts/check-component-tokens.mjs",
|
|
222
|
+
"build": "node tokens/scripts/check-exports.mjs && node tokens/scripts/check-component-tokens.mjs && tsc -p tsconfig.json",
|
|
223
|
+
"typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.consumer.json && tsc -p tsconfig.consumer-speech.json && tsc -p tokens/tsconfig.json",
|
|
224
|
+
"test": "node tokens/scripts/check-component-tokens.mjs && vitest run && node --test tokens/test/*.test.mjs app/tests-node/*.test.mjs",
|
|
225
|
+
"verify": "node tokens/scripts/check-component-tokens.mjs && node tokens/verify/run.mjs",
|
|
226
|
+
"analyze": "node tokens/verify/analyze.mjs",
|
|
227
|
+
"brand:assets": "node scripts/build-brand-assets.mjs",
|
|
228
|
+
"brand:sheet": "node scripts/build-brand-sheet.mjs"
|
|
230
229
|
}
|
|
231
|
-
}
|
|
230
|
+
}
|
package/src/brand/index.ts
CHANGED
|
@@ -28,3 +28,4 @@ export { FAMILY_APPS, familyApp } from "./familyApps";
|
|
|
28
28
|
export type { FamilyApp, FamilyAppName } from "./familyApps";
|
|
29
29
|
export { V_PRO_APP_BENEFITS } from "./vProAppBenefits";
|
|
30
30
|
export type { PricingPlanAppBenefit } from "./vProAppBenefits";
|
|
31
|
+
export { PROJECT_V_PRODUCT_APPS, PROJECT_V_PRODUCT_APP_IDS, projectVAppsColumn } from "./productApps";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ProductAppName } from "./AppWordmark";
|
|
2
|
+
|
|
3
|
+
/** The five product apps in footer order (not `FAMILY_APPS` order). */
|
|
4
|
+
export const PROJECT_V_PRODUCT_APP_IDS: readonly ProductAppName[] = ["vibot", "vmem", "verve", "velth", "vhub"];
|
|
5
|
+
|
|
6
|
+
/** Apps column: each app links to `https://{app}.projectv.uk` in a new tab, with its glyph and lowercase id as the label. */
|
|
7
|
+
export function projectVAppsColumn() {
|
|
8
|
+
return {
|
|
9
|
+
heading: "Apps",
|
|
10
|
+
links: PROJECT_V_PRODUCT_APP_IDS.map((app) => ({
|
|
11
|
+
href: `https://${app}.projectv.uk`,
|
|
12
|
+
label: app,
|
|
13
|
+
external: true as const,
|
|
14
|
+
app,
|
|
15
|
+
})),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** `projectVAppsColumn()`, built once. */
|
|
20
|
+
export const PROJECT_V_PRODUCT_APPS = projectVAppsColumn();
|
package/src/client.ts
CHANGED
|
@@ -54,6 +54,7 @@ export * from "./ui/avatar";
|
|
|
54
54
|
export * from "./ui/badge";
|
|
55
55
|
export * from "./ui/border-beam";
|
|
56
56
|
export * from "./ui/breadcrumb";
|
|
57
|
+
export * from "./ui/page-title";
|
|
57
58
|
export * from "./ui/button";
|
|
58
59
|
export * from "./ui/button-group";
|
|
59
60
|
export * from "./ui/card";
|
|
@@ -285,6 +286,8 @@ export {
|
|
|
285
286
|
} from "./marketing/landing";
|
|
286
287
|
export type {
|
|
287
288
|
LandingFeature,
|
|
289
|
+
LandingFooterAppProps,
|
|
290
|
+
LandingFooterLegacyProps,
|
|
288
291
|
LandingFooterProps,
|
|
289
292
|
LandingLatticeProps,
|
|
290
293
|
LandingLink,
|
|
@@ -311,8 +314,15 @@ export {
|
|
|
311
314
|
landingShellClass,
|
|
312
315
|
} from "./marketing/marketing-classes";
|
|
313
316
|
export type { PricingModalTone, SiteFooterVariant } from "./marketing/marketing-classes";
|
|
314
|
-
export { SiteFooter } from "./marketing/SiteFooter";
|
|
315
|
-
export type {
|
|
317
|
+
export { PROJECT_V_LEGAL_LINKS, PROJECT_V_SOCIALS, SITE_FOOTER_WORDMARK_SIZE, SiteFooter } from "./marketing/SiteFooter";
|
|
318
|
+
export type {
|
|
319
|
+
SiteFooterAppProps,
|
|
320
|
+
SiteFooterColumn,
|
|
321
|
+
SiteFooterLegacyProps,
|
|
322
|
+
SiteFooterLink,
|
|
323
|
+
SiteFooterProps,
|
|
324
|
+
SiteFooterSocial,
|
|
325
|
+
} from "./marketing/SiteFooter";
|
|
316
326
|
export { PricingModal, V_PRO_APP_BENEFITS } from "./marketing/PricingModal";
|
|
317
327
|
export type {
|
|
318
328
|
PricingModalLegacyProps,
|
package/src/index.ts
CHANGED
|
@@ -50,6 +50,7 @@ export * from "./ui/avatar";
|
|
|
50
50
|
export * from "./ui/badge";
|
|
51
51
|
export * from "./ui/border-beam";
|
|
52
52
|
export * from "./ui/breadcrumb";
|
|
53
|
+
export * from "./ui/page-title";
|
|
53
54
|
export * from "./ui/button";
|
|
54
55
|
export * from "./ui/button-group";
|
|
55
56
|
export * from "./ui/card";
|
|
@@ -285,6 +286,8 @@ export {
|
|
|
285
286
|
} from "./marketing/landing";
|
|
286
287
|
export type {
|
|
287
288
|
LandingFeature,
|
|
289
|
+
LandingFooterAppProps,
|
|
290
|
+
LandingFooterLegacyProps,
|
|
288
291
|
LandingFooterProps,
|
|
289
292
|
LandingLatticeProps,
|
|
290
293
|
LandingLink,
|
|
@@ -311,8 +314,15 @@ export {
|
|
|
311
314
|
landingShellClass,
|
|
312
315
|
} from "./marketing/marketing-classes";
|
|
313
316
|
export type { PricingModalTone, SiteFooterVariant } from "./marketing/marketing-classes";
|
|
314
|
-
export { SiteFooter } from "./marketing/SiteFooter";
|
|
315
|
-
export type {
|
|
317
|
+
export { PROJECT_V_LEGAL_LINKS, PROJECT_V_SOCIALS, SITE_FOOTER_WORDMARK_SIZE, SiteFooter } from "./marketing/SiteFooter";
|
|
318
|
+
export type {
|
|
319
|
+
SiteFooterAppProps,
|
|
320
|
+
SiteFooterColumn,
|
|
321
|
+
SiteFooterLegacyProps,
|
|
322
|
+
SiteFooterLink,
|
|
323
|
+
SiteFooterProps,
|
|
324
|
+
SiteFooterSocial,
|
|
325
|
+
} from "./marketing/SiteFooter";
|
|
316
326
|
export { PricingModal, V_PRO_APP_BENEFITS } from "./marketing/PricingModal";
|
|
317
327
|
export type {
|
|
318
328
|
PricingModalLegacyProps,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ComponentType, ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { IconBrandGithub, IconBrandInstagram, IconBrandX } from "@tabler/icons-react";
|
|
3
|
+
import { APP_ICONS, AppWordmark, projectVAppsColumn, type AppName, type ProductAppName } from "../brand";
|
|
3
4
|
import { Button } from "../ui/button";
|
|
4
5
|
import { Separator } from "../ui/separator";
|
|
5
6
|
import { siteFooterClasses, type SiteFooterVariant } from "./marketing-classes";
|
|
@@ -23,47 +24,100 @@ export type SiteFooterSocial = {
|
|
|
23
24
|
label?: string;
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
/** Text size in px of the built-in `AppWordmark` brand. Fixed: `SiteFooter` has no size prop. */
|
|
28
|
+
export const SITE_FOOTER_WORDMARK_SIZE = 16;
|
|
29
|
+
|
|
30
|
+
/** Default `socials` on the `app` path: X, Instagram and GitHub. */
|
|
31
|
+
export const PROJECT_V_SOCIALS: readonly SiteFooterSocial[] = [
|
|
32
|
+
{ href: "https://x.com/projectvdotuk", icon: IconBrandX, label: "Project V on X" },
|
|
33
|
+
{ href: "https://www.instagram.com/projectvdotuk/", icon: IconBrandInstagram, label: "Project V on Instagram" },
|
|
34
|
+
{ href: "https://github.com/projectvdotuk", icon: IconBrandGithub, label: "Project V on GitHub" },
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
/** Default `legalLinks` on the `app` path. */
|
|
38
|
+
export const PROJECT_V_LEGAL_LINKS: readonly { href: string; label: string }[] = [
|
|
39
|
+
{ href: "https://projectv.uk/privacy", label: "Privacy Policy" },
|
|
40
|
+
{ href: "https://projectv.uk/terms", label: "Terms of Service" },
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
export type SiteFooterColumn = { heading: string; links: readonly SiteFooterLink[] };
|
|
44
|
+
|
|
45
|
+
type SiteFooterCommonProps = {
|
|
29
46
|
tagline: ReactNode;
|
|
30
|
-
/** Icon buttons under the tagline. Always open in a new tab. */
|
|
31
|
-
socials: readonly SiteFooterSocial[];
|
|
32
47
|
/** Link columns to the right of the brand block. */
|
|
33
|
-
columns: readonly
|
|
34
|
-
/** Name in "Copyright © {year} {name}". */
|
|
35
|
-
name: string;
|
|
48
|
+
columns: readonly SiteFooterColumn[];
|
|
36
49
|
/** Default: the current year. */
|
|
37
50
|
year?: number;
|
|
38
|
-
/** Bottom-right links, for example Privacy Policy and Terms of Service. Always open in a new tab. */
|
|
39
|
-
legalLinks: readonly { href: string; label: string }[];
|
|
40
51
|
/**
|
|
41
52
|
* `"muted"` (default) and `"muted-foreground"` pick the secondary text
|
|
42
53
|
* colour class. `"touch"` uses `text-muted-foreground`, `max-sm:hit-target`
|
|
43
54
|
* links and a safe-area bottom padding.
|
|
44
55
|
*/
|
|
45
56
|
variant?: SiteFooterVariant;
|
|
57
|
+
/** Under the socials, for example a Sign-in button. Not rendered on the legacy path. */
|
|
58
|
+
actions?: ReactNode;
|
|
46
59
|
};
|
|
47
60
|
|
|
61
|
+
/** Opinionated footer: set `app` and the Project V brand, socials, legal links, Apps column and product-of line follow. */
|
|
62
|
+
export type SiteFooterAppProps = SiteFooterCommonProps & {
|
|
63
|
+
/** Product app id. Sets the wordmark (size 16), the copyright name and the product-of line. */
|
|
64
|
+
app: ProductAppName;
|
|
65
|
+
/** Replaces the `AppWordmark`. */
|
|
66
|
+
brand?: ReactNode;
|
|
67
|
+
/** Default `PROJECT_V_SOCIALS`. `[]` hides them. */
|
|
68
|
+
socials?: readonly SiteFooterSocial[];
|
|
69
|
+
/** Default `PROJECT_V_LEGAL_LINKS`. */
|
|
70
|
+
legalLinks?: readonly { href: string; label: string }[];
|
|
71
|
+
/** Overrides the copyright name (default: `app`). */
|
|
72
|
+
name?: string;
|
|
73
|
+
/** Appends the standard Apps column unless `columns` has an "Apps" heading (default `true`). */
|
|
74
|
+
includeAppsColumn?: boolean;
|
|
75
|
+
/** Shows "{app} is a product of Project V." (default `true`). */
|
|
76
|
+
showProductOf?: boolean;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Legacy footer: you pass every part. Prefer `SiteFooterAppProps`. */
|
|
80
|
+
export type SiteFooterLegacyProps = SiteFooterCommonProps & {
|
|
81
|
+
app?: undefined;
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Set `app` instead: the footer renders `AppWordmark`. Without `app` the brand sits in the Michroma wrapper.
|
|
84
|
+
*/
|
|
85
|
+
brand: ReactNode;
|
|
86
|
+
/** @deprecated Set `app` for the Project V defaults (`PROJECT_V_SOCIALS`). Icon buttons under the tagline; always open in a new tab. */
|
|
87
|
+
socials: readonly SiteFooterSocial[];
|
|
88
|
+
/** @deprecated Set `app`: the copyright name is then the app id. Name in "Copyright © {year} {name}". */
|
|
89
|
+
name: string;
|
|
90
|
+
/** @deprecated Set `app` for `PROJECT_V_LEGAL_LINKS`. Bottom-right links; always open in a new tab. */
|
|
91
|
+
legalLinks: readonly { href: string; label: string }[];
|
|
92
|
+
includeAppsColumn?: undefined;
|
|
93
|
+
showProductOf?: undefined;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
export type SiteFooterProps = SiteFooterAppProps | SiteFooterLegacyProps;
|
|
97
|
+
|
|
48
98
|
/** Marketing site footer: brand, socials, link columns, then copyright and legal links under a separator. */
|
|
49
|
-
export function SiteFooter({
|
|
50
|
-
|
|
51
|
-
tagline,
|
|
52
|
-
socials,
|
|
53
|
-
columns,
|
|
54
|
-
name,
|
|
55
|
-
year = new Date().getFullYear(),
|
|
56
|
-
legalLinks,
|
|
57
|
-
variant = "muted",
|
|
58
|
-
}: SiteFooterProps) {
|
|
99
|
+
export function SiteFooter(props: SiteFooterProps) {
|
|
100
|
+
const { tagline, year = new Date().getFullYear(), variant = "muted", actions } = props;
|
|
59
101
|
const c = siteFooterClasses[variant];
|
|
102
|
+
const modern = props.app !== undefined;
|
|
103
|
+
const brandNode = modern ? (
|
|
104
|
+
<div className="mb-3 md:mb-4">{props.brand ?? <AppWordmark app={props.app} size={SITE_FOOTER_WORDMARK_SIZE} />}</div>
|
|
105
|
+
) : (
|
|
106
|
+
<div className="text-lg font-michroma font-normal tracking-wider mb-3 md:mb-4">{props.brand}</div>
|
|
107
|
+
);
|
|
108
|
+
const socials = modern ? (props.socials ?? PROJECT_V_SOCIALS) : props.socials;
|
|
109
|
+
const legalLinks = modern ? (props.legalLinks ?? PROJECT_V_LEGAL_LINKS) : props.legalLinks;
|
|
110
|
+
const name = modern ? (props.name ?? props.app) : props.name;
|
|
111
|
+
const hasApps = props.columns.some((column) => column.heading.toLowerCase() === "apps");
|
|
112
|
+
const columns: readonly SiteFooterColumn[] = modern && (props.includeAppsColumn ?? true) && !hasApps ? [...props.columns, projectVAppsColumn()] : props.columns;
|
|
113
|
+
const showProductOf = modern && (props.showProductOf ?? true);
|
|
60
114
|
return (
|
|
61
115
|
<footer className={c.footer}>
|
|
62
116
|
<div className="relative z-10">
|
|
63
117
|
<div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
|
|
64
118
|
<div className="flex flex-col lg:flex-row lg:items-start lg:justify-between gap-8 lg:gap-12">
|
|
65
119
|
<div className="flex-1 lg:flex-none">
|
|
66
|
-
|
|
120
|
+
{brandNode}
|
|
67
121
|
<p className={c.tagline}>{tagline}</p>
|
|
68
122
|
<div className="flex gap-3 md:gap-4">
|
|
69
123
|
{socials.map(({ href, icon: Icon, label }) => (
|
|
@@ -74,6 +128,7 @@ export function SiteFooter({
|
|
|
74
128
|
</a>
|
|
75
129
|
))}
|
|
76
130
|
</div>
|
|
131
|
+
{modern && actions ? <div className="mt-3 md:mt-4">{actions}</div> : null}
|
|
77
132
|
</div>
|
|
78
133
|
|
|
79
134
|
<div className="flex flex-col sm:flex-row gap-8 md:gap-12 lg:gap-16 xl:gap-20">
|
|
@@ -120,6 +175,15 @@ export function SiteFooter({
|
|
|
120
175
|
{` ${name}`}
|
|
121
176
|
</p>
|
|
122
177
|
<p className={c.rights}>All rights reserved.</p>
|
|
178
|
+
{showProductOf ? (
|
|
179
|
+
<p className={c.rights}>
|
|
180
|
+
{props.app} is a product of{" "}
|
|
181
|
+
<a href="https://projectv.uk" target="_blank" rel="noopener noreferrer" className="underline underline-offset-2">
|
|
182
|
+
Project V
|
|
183
|
+
</a>
|
|
184
|
+
.
|
|
185
|
+
</p>
|
|
186
|
+
) : null}
|
|
123
187
|
</div>
|
|
124
188
|
|
|
125
189
|
<div className="flex flex-col gap-1 text-center sm:text-right">
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
DropdownMenuTrigger,
|
|
12
12
|
} from "../ui/dropdown-menu";
|
|
13
13
|
import { cn } from "../utils/cn";
|
|
14
|
+
import { SiteFooter, type SiteFooterAppProps } from "./SiteFooter";
|
|
14
15
|
import { landingClasses, landingFooterLinkClass, landingShellClass } from "./marketing-classes";
|
|
15
16
|
|
|
16
17
|
export type LandingLink = { href: string; label: string };
|
|
@@ -140,19 +141,46 @@ export function LandingNavMenu({ links, github }: LandingNavMenuProps) {
|
|
|
140
141
|
);
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
|
|
144
|
-
/** Wordmark above the tagline. */
|
|
145
|
-
brand: ReactNode;
|
|
144
|
+
type LandingFooterCommonProps = {
|
|
146
145
|
tagline: ReactNode;
|
|
146
|
+
/** Section links. On the `app` path they become a "Navigation" column unless `columns` is set. */
|
|
147
147
|
links: readonly LandingLink[];
|
|
148
|
-
/**
|
|
148
|
+
/** App actions, for example Sign in. Style with `landingFooterLinkClass` or `landingFooterButtonClass`. */
|
|
149
149
|
actions?: ReactNode;
|
|
150
|
-
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** Project V footer: a thin wrapper over `SiteFooter` with every default (wordmark, socials, legal links, Apps column, product-of line). */
|
|
153
|
+
export type LandingFooterAppProps = LandingFooterCommonProps &
|
|
154
|
+
Pick<SiteFooterAppProps, "app" | "year" | "variant" | "socials" | "legalLinks" | "includeAppsColumn" | "showProductOf"> & {
|
|
155
|
+
/** Replaces the Navigation column built from `links`. */
|
|
156
|
+
columns?: SiteFooterAppProps["columns"];
|
|
157
|
+
/** @deprecated Ignored on the `app` path: the footer renders `AppWordmark`. */
|
|
158
|
+
brand?: ReactNode;
|
|
159
|
+
/** @deprecated Ignored on the `app` path: `PROJECT_V_SOCIALS` includes GitHub. */
|
|
160
|
+
github?: LandingFooterLegacyProps["github"];
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/** Old compact footer. Deprecated: set `app` instead. */
|
|
164
|
+
export type LandingFooterLegacyProps = LandingFooterCommonProps & {
|
|
165
|
+
app?: undefined;
|
|
166
|
+
/** @deprecated Set `app`. Wordmark above the tagline. */
|
|
167
|
+
brand: ReactNode;
|
|
168
|
+
/** @deprecated Set `app`: `PROJECT_V_SOCIALS` includes GitHub. `label` is the link's `aria-label`. */
|
|
151
169
|
github: { href: string; label: string; icon: ReactNode };
|
|
152
170
|
};
|
|
153
171
|
|
|
154
|
-
|
|
155
|
-
|
|
172
|
+
export type LandingFooterProps = LandingFooterAppProps | LandingFooterLegacyProps;
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* With `app`: `SiteFooter` with `links` as a Navigation column. Without `app` (deprecated): the old compact row of
|
|
176
|
+
* brand and tagline, section links, app actions and a GitHub icon link.
|
|
177
|
+
*/
|
|
178
|
+
export function LandingFooter(props: LandingFooterProps) {
|
|
179
|
+
if (props.app !== undefined) {
|
|
180
|
+
const { links, columns, brand: _brand, github: _github, ...rest } = props;
|
|
181
|
+
return <SiteFooter {...rest} columns={columns ?? [{ heading: "Navigation", links }]} />;
|
|
182
|
+
}
|
|
183
|
+
const { brand, tagline, links, actions, github } = props;
|
|
156
184
|
return (
|
|
157
185
|
<footer className="border-t border-separator">
|
|
158
186
|
<div
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../utils/cn";
|
|
3
|
+
|
|
4
|
+
/** The page title class contract: Instrument Sans (the sans token), 20px, weight 600, never lighter. Same string as `Breadcrumb`. */
|
|
5
|
+
export const pageTitleClass = "text-xl font-semibold leading-tight tracking-tight";
|
|
6
|
+
|
|
7
|
+
/** Page title: `h1`, `text-xl font-semibold leading-tight tracking-tight`. */
|
|
8
|
+
const PageTitle = React.forwardRef<HTMLHeadingElement, React.HTMLAttributes<HTMLHeadingElement>>(
|
|
9
|
+
({ className, ...props }, ref) => <h1 ref={ref} className={cn(pageTitleClass, className)} {...props} />,
|
|
10
|
+
);
|
|
11
|
+
PageTitle.displayName = "PageTitle";
|
|
12
|
+
|
|
13
|
+
export type PageHeaderProps = Omit<React.HTMLAttributes<HTMLElement>, "title"> & {
|
|
14
|
+
/** Title text or node, rendered in `PageTitle`. */
|
|
15
|
+
title: React.ReactNode;
|
|
16
|
+
/** Right-aligned slot, for example a button. */
|
|
17
|
+
action?: React.ReactNode;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Title row: `PageTitle` with an optional `action` slot. No safe-area padding (web). */
|
|
21
|
+
const PageHeader = React.forwardRef<HTMLElement, PageHeaderProps>(({ title, action, className, ...props }, ref) => (
|
|
22
|
+
<header ref={ref} className={cn("flex min-w-0 items-center justify-between gap-3 px-4 py-4 sm:px-6", className)} {...props}>
|
|
23
|
+
<PageTitle className="min-w-0 truncate">{title}</PageTitle>
|
|
24
|
+
{action ? <div className="flex shrink-0 items-center gap-2">{action}</div> : null}
|
|
25
|
+
</header>
|
|
26
|
+
));
|
|
27
|
+
PageHeader.displayName = "PageHeader";
|
|
28
|
+
|
|
29
|
+
export { PageHeader, PageTitle };
|
package/app/README.md
DELETED
|
@@ -1,269 +0,0 @@
|
|
|
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/tokens/README.md
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
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`, `reveal-on-hover`, `motion-press`, `motion-base`, `motion-emphasized` and `scrollbar-none`. The motion utilities read `--motion-fast`, `--motion-base`, `--motion-ease-out` and `--motion-ease-emphasized`, with defaults in the utility. `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); optional `--motion-*` | 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.
|