Compare commits

..

190 Commits

Author SHA1 Message Date
16e1c8ee40 chore: sync package-lock.json with upstream deps 2026-10-30 11:59:51 +05:30
71c0671a25 chore: sync package-lock.json with upstream deps 2026-10-30 11:58:48 +05:30
26ec688fec Merge remote-tracking branch 'upstream/main'
# Conflicts:
#	app/lib/pocketbase.ts
#	app/routes/admin/login.tsx
#	yarn.lock
2026-10-30 11:47:42 +05:30
7d211e0d5b docs: add guide for reusing printed QR codes 2026-10-27 16:29:00 +05:30
60fdbf5eff docs: add project overview 2026-10-27 16:29:00 +05:30
0f017e6e2f docs: add frontend rules 2026-10-27 16:29:00 +05:30
08029b4529 docs: add CLAUDE.md 2026-10-27 16:29:00 +05:30
d18542853a refactor: remove unused skeleton 2026-10-27 16:29:00 +05:30
d54c75435d refactor: remove old AR illustration 2026-10-27 16:29:00 +05:30
09ad313983 refactor: remove old auth brand panel 2026-10-27 16:29:00 +05:30
438d3d5a98 refactor: remove FileOrUrlField 2026-10-27 16:29:00 +05:30
df401959b6 refactor: remove old AR viewer route 2026-10-27 16:28:59 +05:30
f5a4df1036 refactor: remove old asset preview route 2026-10-27 16:28:59 +05:30
7768d18426 refactor: remove old login route 2026-10-27 16:28:59 +05:30
bd7c563cb2 refactor: remove old dashboard 2026-10-27 16:28:59 +05:30
7f7c8e8acb feat: add admin layout routes for projects, assets and settings 2026-10-27 16:28:59 +05:30
54834f2beb refactor: rebuild not found page on the status screen 2026-10-27 16:28:59 +05:30
28f781e48c feat: add redesigned login page 2026-10-27 16:28:59 +05:30
ccba71b80c feat: add customer AR page route 2026-10-27 16:28:59 +05:30
cad384b52c feat: add settings page 2026-10-27 16:28:59 +05:30
6ce98e6dae feat: add projects page 2026-10-27 16:28:59 +05:30
e8bc35d443 feat: add project detail page 2026-10-27 16:28:59 +05:30
f7a741b54e feat: redirect old preview links to the asset page 2026-10-27 16:28:59 +05:30
4f8168e462 feat: add admin layout with sidebar and shared data 2026-10-27 16:28:59 +05:30
7b6aecd385 feat: add settings service 2026-10-27 16:28:59 +05:30
ed4dd44a69 feat: add projects service 2026-10-27 16:28:59 +05:30
67eb269347 feat: redirect the admin home to projects 2026-10-27 16:28:58 +05:30
897da8eac6 feat: add assets page 2026-10-27 16:28:58 +05:30
cc64f92fbb feat: add asset detail page 2026-10-27 16:28:58 +05:30
09d14a137b feat: add assets service 2026-10-27 16:28:58 +05:30
c6266d3fb7 refactor: rebuild root with toaster, model-viewer script and error screen 2026-10-27 16:28:58 +05:30
812c97157f feat: add error helpers 2026-10-27 16:28:58 +05:30
f837e9d224 feat: add status screen 2026-10-27 16:28:58 +05:30
14ddb9e860 feat: add setting toggle 2026-10-27 16:28:58 +05:30
6e4c4f2c9d feat: add unassigned assets banner 2026-10-27 16:28:58 +05:30
c8911e7e06 feat: add projects header 2026-10-27 16:28:58 +05:30
dcdbfcd086 feat: add page header 2026-10-27 16:28:58 +05:30
aaebb28a23 feat: add project card 2026-10-27 16:28:58 +05:30
db2b168521 refactor: restyle badge with tones 2026-10-27 16:28:58 +05:30
5946d625ca feat: add project header 2026-10-27 16:28:57 +05:30
9a1f261850 feat: add primary new item button 2026-10-27 16:28:57 +05:30
89e7018920 feat: add project meta 2026-10-27 16:28:57 +05:30
380f7f2045 feat: add colour tag 2026-10-27 16:28:57 +05:30
93195c34ba feat: add login showcase 2026-10-27 16:28:57 +05:30
d0130a6e56 feat: add decorative glow 2026-10-27 16:28:57 +05:30
16fe80634f feat: add login story steps 2026-10-27 16:28:57 +05:30
34af16d550 feat: add login story step 2026-10-27 16:28:57 +05:30
61c62afe6d feat: add login story phone 2026-10-27 16:28:57 +05:30
f0d54d5eb1 feat: add scan step screen for the login showcase 2026-10-27 16:28:57 +05:30
fb54bbcf9f feat: add place step screen for the login showcase 2026-10-27 16:28:57 +05:30
53b6d267df feat: add open step screen for the login showcase 2026-10-27 16:28:57 +05:30
894099345e feat: add login story and demo content 2026-10-27 16:28:57 +05:30
d75e0ba1c8 refactor: move armchair illustration into the login showcase 2026-10-27 16:28:57 +05:30
3bfbf344a6 feat: add login panel 2026-10-27 16:28:56 +05:30
23af938b4e feat: add login form 2026-10-27 16:28:56 +05:30
b59b8ed67d feat: add login failure type 2026-10-27 16:28:56 +05:30
8fde14446d feat: add login schema 2026-10-27 16:28:56 +05:30
08bb5a1dc2 feat: add checkbox component 2026-10-27 16:28:56 +05:30
bc4e2220b1 feat: add alert component 2026-10-27 16:28:56 +05:30
02259df5d3 feat: add sign in button with progress states 2026-10-27 16:28:56 +05:30
7e3f875f35 feat: add password input with show and hide 2026-10-27 16:28:56 +05:30
c560a86f97 feat: add login access note 2026-10-27 16:28:56 +05:30
f76a442367 feat: add asset list 2026-10-27 16:28:56 +05:30
ade61e299a feat: add empty state 2026-10-27 16:28:56 +05:30
4d0e3dee9f feat: add icon message 2026-10-27 16:28:56 +05:30
d857bc7990 feat: add asset pagination 2026-10-27 16:28:56 +05:30
a7194c48fe feat: add pagination helpers 2026-10-27 16:28:56 +05:30
1a7385f6f3 feat: add pagination link 2026-10-27 16:28:55 +05:30
f3f09d9c05 feat: add asset filter chips 2026-10-27 16:28:55 +05:30
57c337e0a9 feat: add filter chip 2026-10-27 16:28:55 +05:30
7dea0dace0 feat: add asset card 2026-10-27 16:28:55 +05:30
dce9e4fd2d feat: add asset project chip 2026-10-27 16:28:55 +05:30
96439b5367 feat: add scan QR dialog 2026-10-27 16:28:55 +05:30
907170a152 feat: add customer view preview 2026-10-27 16:28:55 +05:30
ce025bf6cd feat: add asset QR panel 2026-10-27 16:28:55 +05:30
6cca8610d9 feat: add QR code SVG and PNG downloads 2026-10-27 16:28:55 +05:30
b0ada303c4 feat: add copy field 2026-10-27 16:28:55 +05:30
2f02dd1ae5 feat: add clipboard, download and image browser helpers 2026-10-27 16:28:55 +05:30
f61c26af33 refactor: restyle card with surface and size variants 2026-10-27 16:28:55 +05:30
9e64ec4f8c feat: add unassigned asset note 2026-10-27 16:28:55 +05:30
238431d801 feat: add asset preview header 2026-10-27 16:28:55 +05:30
30126d9280 feat: add page breadcrumb 2026-10-27 16:28:54 +05:30
3913c73e6c feat: add breadcrumb component 2026-10-27 16:28:54 +05:30
46248e2816 feat: add asset detail list 2026-10-27 16:28:54 +05:30
3442ed452e feat: add asset QR code 2026-10-27 16:28:54 +05:30
3abbb34352 feat: add AR scene 2026-10-27 16:28:54 +05:30
1de8233667 feat: add hook that waits for model-viewer 2026-10-27 16:28:54 +05:30
20edecf598 feat: add AR launch hook 2026-10-27 16:28:54 +05:30
99a1ae969b feat: add model viewer wrapper with shared defaults 2026-10-27 16:28:54 +05:30
027e830314 feat: add full-screen loading screen 2026-10-27 16:28:54 +05:30
30a991cc66 feat: add admin sidebar with mobile menu 2026-10-27 16:28:54 +05:30
86513d8c5b feat: add sheet component 2026-10-27 16:28:54 +05:30
468d2c6940 feat: add sidebar content 2026-10-27 16:28:54 +05:30
94ac0a1d02 feat: add active nav hook 2026-10-27 16:28:54 +05:30
b4d6f976dd feat: add sidebar footer with sign out 2026-10-27 16:28:54 +05:30
c4e9f2aeaa feat: add auth service with keep me signed in 2026-10-27 16:28:53 +05:30
14bc5047fb feat: add sidebar link 2026-10-27 16:28:53 +05:30
269b3a8bb0 feat: add sidebar brand 2026-10-27 16:28:53 +05:30
03a1a1cd7a feat: add brand lockup 2026-10-27 16:28:53 +05:30
849b294cf2 feat: add brand constants and loader illustration 2026-10-27 16:28:53 +05:30
200b8cc2ea feat: add admin dialogs provider 2026-10-27 16:28:53 +05:30
1538ea6426 feat: add admin dialogs context 2026-10-27 16:28:53 +05:30
0301549b75 feat: add project form dialog 2026-10-27 16:28:53 +05:30
3982ba38fa feat: add project form data encoding 2026-10-27 16:28:53 +05:30
f9ff79c88d feat: add hook for the project form's unsaved brand 2026-10-27 16:28:53 +05:30
a72f76f814 feat: clamp custom button sizes for the live preview 2026-10-27 16:28:53 +05:30
8034b851d0 feat: add object URL hook for local file previews 2026-10-27 16:28:53 +05:30
bf3ba351d4 feat: add live AR page preview to the project form 2026-10-27 16:28:53 +05:30
4629d86289 feat: add AR page preview in a phone frame 2026-10-27 16:28:53 +05:30
6551e5fcce feat: add phone frame 2026-10-27 16:28:52 +05:30
118312d83f feat: add customer AR page layout 2026-10-27 16:28:52 +05:30
4934fc3f67 feat: add AR page header 2026-10-27 16:28:52 +05:30
9f96a34930 refactor: move logo mark into ui with sizes 2026-10-27 16:28:52 +05:30
9799ffdf14 feat: add AR launch button 2026-10-27 16:28:52 +05:30
69f9b9bc1e feat: add project form fields 2026-10-27 16:28:52 +05:30
b093803c2f feat: add textarea component 2026-10-27 16:28:52 +05:30
3a44c02099 feat: add project logo field 2026-10-27 16:28:52 +05:30
1ba3d33a61 feat: add logo file preparation with SVG to PNG conversion 2026-10-27 16:28:52 +05:30
a8c10d34d6 feat: add logo tile 2026-10-27 16:28:52 +05:30
bed79e616d feat: add logo background field 2026-10-27 16:28:52 +05:30
c647e18af7 feat: add button style fields to the project form 2026-10-27 16:28:52 +05:30
189957f5b0 feat: add AR viewer button label and loading hints 2026-10-27 16:28:52 +05:30
46ba48402e feat: add project colour field 2026-10-27 16:28:52 +05:30
e3eb3384ed feat: add custom button size fields 2026-10-27 16:28:51 +05:30
69d91f164d feat: add colour picker 2026-10-27 16:28:51 +05:30
32da0341c1 feat: add hex colour helpers 2026-10-27 16:28:51 +05:30
f852782c6c feat: add AR page layout switches to the project form 2026-10-27 16:28:51 +05:30
8f06ed3043 feat: add project form schema 2026-10-27 16:28:51 +05:30
e6483968a1 feat: add asset form dialog 2026-10-27 16:28:51 +05:30
d795140b1b feat: add asset form data encoding 2026-10-27 16:28:51 +05:30
39896998bc feat: add project select to the asset form 2026-10-27 16:28:51 +05:30
fc875ec6ca feat: add asset media and brand helpers 2026-10-27 16:28:51 +05:30
04751ff97e refactor: move PocketBase client to services and use the reachable URL 2026-10-27 16:28:51 +05:30
82b0db671c feat: add AR page options schema 2026-10-27 16:28:51 +05:30
559a487efb feat: add hex colour schema 2026-10-27 16:28:50 +05:30
d225d6209e feat: add select component 2026-10-27 16:28:50 +05:30
cf4185d890 feat: add client logo component 2026-10-27 16:28:50 +05:30
ed853200e0 feat: add upload or URL model source field 2026-10-27 16:28:50 +05:30
0317387105 feat: add input with a leading icon 2026-10-27 16:28:50 +05:30
cba840a66f refactor: restyle input with sm, md and lg sizes 2026-10-27 16:28:50 +05:30
fd36cf889a feat: add form field wrapper with label and error 2026-10-27 16:28:50 +05:30
9ccbd9dcce feat: add inline message component 2026-10-27 16:28:50 +05:30
49ed4e2b2c feat: add model file picker 2026-10-27 16:28:50 +05:30
ab27087a79 feat: add date, file size and file name formatters 2026-10-27 16:28:50 +05:30
71305f3202 feat: add file drop zone 2026-10-27 16:28:50 +05:30
2f61f1545d feat: add selected file row 2026-10-27 16:28:49 +05:30
852c25484b feat: add text pair component 2026-10-27 16:28:49 +05:30
6c9b80cd65 feat: add branded QR toggle to the asset form 2026-10-27 16:28:49 +05:30
2babc57982 feat: add asset form schema 2026-10-27 16:28:49 +05:30
adfa93cc82 feat: add QR code helpers with the logo inside the code 2026-10-27 16:28:49 +05:30
ea26eeb4c2 feat: make local dev URLs reachable from phones on the network 2026-10-27 16:28:49 +05:30
d8d472bc60 feat: add project constants for brand colours, button sizes and AR page defaults 2026-10-27 16:28:49 +05:30
023d29517c feat: add segmented control 2026-10-27 16:28:49 +05:30
d433c10804 feat: add hook for admin layout data 2026-10-27 16:28:49 +05:30
a0031e6655 feat: add settings types 2026-10-27 16:28:49 +05:30
6d29b9570b feat: add settings constants 2026-10-27 16:28:49 +05:30
017933ddd2 feat: add labelled switch row 2026-10-27 16:28:49 +05:30
c0477c3f5a feat: add switch component 2026-10-27 16:28:49 +05:30
73c67dbe9f refactor: build label on the text component 2026-10-27 16:28:49 +05:30
0da1bf0e7e feat: add text component with typography variants 2026-10-27 16:28:49 +05:30
3a6b6af96a feat: add delete asset dialog 2026-10-27 16:28:48 +05:30
1d2720f273 feat: add asset types 2026-10-27 16:28:48 +05:30
8fa53668ee feat: add project types 2026-10-27 16:28:48 +05:30
b16bfa74b9 feat: add hook to toast action results 2026-10-27 16:28:48 +05:30
d8e557dff9 feat: add action result type 2026-10-27 16:28:48 +05:30
ca68e6856d feat: add route path helpers 2026-10-27 16:28:48 +05:30
d96b06803a feat: add asset constants 2026-10-27 16:28:48 +05:30
b3f7504459 refactor: simplify confirm dialog with dialog actions and icon tile 2026-10-27 16:28:48 +05:30
cbd23f2902 feat: add icon tile component 2026-10-27 16:28:48 +05:30
8592c51e1a feat: add shared tone surface styles 2026-10-27 16:28:48 +05:30
31806455b4 feat: add dialog actions footer 2026-10-27 16:28:48 +05:30
9e3f0c518b refactor: restyle dialog with header, body and footer parts 2026-10-27 16:28:47 +05:30
7ecead13d8 refactor: restyle button with theme variants and sizes 2026-10-27 16:28:47 +05:30
a7091c126a feat: register custom text sizes and radii with tailwind-merge 2026-10-27 16:28:47 +05:30
a74a2c6200 feat: add theme tokens, breakpoints and animations 2026-10-27 16:28:47 +05:30
68a99eeef2 refactor: tidy model-viewer element types 2026-10-27 16:28:47 +05:30
af04a1b209 feat: add sofa image for the login showcase 2026-10-27 16:28:47 +05:30
c745c966f7 feat: add demo QR code for the login showcase 2026-10-27 16:28:47 +05:30
f15af3cc12 feat: add demo client mark for the login showcase 2026-10-27 16:28:47 +05:30
87f53a59c5 feat: add demo client logo for the login showcase 2026-10-27 16:28:47 +05:30
d6f3fba16c feat: add AR loader illustration 2026-10-27 16:28:47 +05:30
5b53d602bf feat: add per-project AR page options migration 2026-10-27 16:28:47 +05:30
87e1d279ee feat: keep admin sessions for 30 days 2026-10-27 16:28:47 +05:30
21e41ed492 feat: add project logo backing and button style migration 2026-10-27 16:28:46 +05:30
e5ff11a79d feat: add projects, settings and asset project link migration 2026-10-27 16:28:46 +05:30
b4ea056659 fix: load all routes up front to stop full reloads after creating a project 2026-10-27 16:28:46 +05:30
de5ac76637 fix: pre-scan app files so Vite does not reload the page mid-action 2026-10-27 16:28:46 +05:30
4e3cdbac11 chore: add shadcn components config 2026-10-27 16:28:46 +05:30
b679939308 chore: update yarn.lock 2026-10-27 16:28:46 +05:30
b64f8c5feb chore: add radix-ui, tw-animate-css and a pb script for local PocketBase 2026-10-27 16:28:46 +05:30
192 changed files with 10671 additions and 6110 deletions

Binary file not shown.

7
CLAUDE.md Normal file
View File

@ -0,0 +1,7 @@
# AR-Test
Before changing anything under `app/`, read and follow [docs/FRONTEND_RULES.md](docs/FRONTEND_RULES.md).
Project overview: [docs/PROJECT_OVERVIEW.md](docs/PROJECT_OVERVIEW.md).
- Local dev: `yarn pb` (PocketBase on port 8099) and `yarn dev` (app on :5173). Both accept connections from the local network, so a phone can open `http://<laptop IP>:5173`.
- `yarn typecheck` must pass before any commit.

85
QR_CODE_REUSE_GUIDE.md Normal file
View File

@ -0,0 +1,85 @@
# Guide: How to Reuse Existing Printed QR Codes for New 3D Assets
---
## 1. Why is the old QR code showing a missing/old asset?
Every QR code generated by the system embeds a direct AR URL containing a specific **Asset Record ID**:
```text
https://your-domain.com/ar/0gsk2w8h236474u
^^^^^^^^^^^^^^^
PocketBase Asset Record ID
```
When you delete an asset in PocketBase and create a new one:
* PocketBase automatically generates a **new random 15-character ID** (e.g., `x9y8z7w6v5u4t3s`).
* Your previously printed or saved QR code is still pointing to the **old ID** (`0gsk2w8h236474u`), which no longer exists in the database.
---
## 2. Step-by-Step Fix: Reusing Old QR Codes
To make an existing physical or saved QR code load a new 3D model, you must ensure the new PocketBase asset record uses the **exact same Record ID** encoded in the old QR code.
### Step 1: Find the Old Record ID from the QR Code
1. Open your phone camera or any QR scanner app.
2. Scan the old QR code.
3. Look at the URL it opens, for example: `http://localhost:5173/ar/0gsk2w8h236474u`
4. Copy the 15-character ID at the end of the link: **`0gsk2w8h236474u`**
---
### Step 2: Create a New Asset with the Same Record ID
#### Option A: Via PocketBase Admin UI (Easiest)
1. Open your PocketBase Admin Dashboard: `http://localhost:8090/_/` (or your PocketBase server URL).
2. Go to the **`ar_assets`** collection.
3. Click **"New Record"**.
4. In the **`id`** field at the top, manually paste your old ID (e.g., `0gsk2w8h236474u`).
> ⚠️ **Note**: PocketBase IDs must be exactly **15 characters** consisting of lowercase letters (`a-z`) and digits (`0-9`).
5. Upload your new `.glb`, `.usdz`, or `.png` files and set the asset `name`.
6. Click **Save**.
Now, scanning the old QR code will immediately load your newly created asset!
---
#### Option B: Via API / Postman / Code
When sending a `POST` request to PocketBase (`/api/collections/ar_assets/records`), include the `id` field in the payload:
```json
{
"id": "0gsk2w8h236474u",
"name": "New Shirt Model 3D"
}
```
---
#### Option C: Enabling Custom ID in your Thob Admin Dashboard
If you want to be able to enter an **"Existing / Custom QR ID"** directly inside your application dashboard:
1. Add a **"Custom ID / Reused QR ID"** input field in the asset creation form.
2. Pass the `id` field in the `formData` sent to PocketBase during asset creation:
```typescript
const formData = new FormData();
if (customId) {
formData.append('id', customId); // PocketBase will use this exact ID!
}
formData.append('name', name);
formData.append('glb_file', glbFile);
await pb.collection('ar_assets').create(formData);
```
---
## Summary Checklist
- [x] Scan the old printed QR code to get the 15-character ID at the end of the `/ar/` URL.
- [x] Create a new record in the `ar_assets` PocketBase collection.
- [x] Pass/Set the `id` field to match the old 15-character ID.
- [x] Test by scanning the old QR code — it will now display the new 3D asset!

View File

@ -1,70 +1,217 @@
@import 'tailwindcss';
@import 'tw-animate-css';
@theme {
--font-sans:
'Inter', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji',
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
--font-sans: 'Geist', ui-sans-serif, system-ui, sans-serif;
--font-mono: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
/* Type scale (design: 26 / 17 / 15 / 14 / 13 / 12 / 11 / 10) */
--text-3xs: 0.625rem;
--text-3xs--line-height: 0.875rem;
--text-2xs: 0.6875rem;
--text-2xs--line-height: 1rem;
--text-xs: 0.75rem;
--text-xs--line-height: 1.125rem;
--text-sm: 0.8125rem;
--text-sm--line-height: 1.25rem;
--text-base: 0.875rem;
--text-base--line-height: 1.375rem;
--text-md: 0.9375rem;
--text-md--line-height: 1.375rem;
--text-lg: 1.0625rem;
--text-lg--line-height: 1.5rem;
--text-xl: 1.25rem;
--text-xl--line-height: 1.75rem;
--text-display: 1.625rem;
--text-display--line-height: 2.125rem;
/* Login page headings */
--text-2xl: 1.75rem;
--text-2xl--line-height: 2.125rem;
--text-3xl: 2rem;
--text-3xl--line-height: 2.375rem;
--text-4xl: 2.25rem;
--text-4xl--line-height: 2.5rem;
--text-5xl: 2.75rem;
--text-5xl--line-height: 3rem;
/* Login layout: side by side from 960px, wide showcase from 1200px */
--breakpoint-split: 60rem;
--breakpoint-wide: 75rem;
/* Radii */
--radius-chip: 5px;
--radius-option: 7px;
--radius-item: 8px;
--radius-control: 9px;
--radius-group: 10px;
--radius-field: 11px;
--radius-card-sm: 12px;
--radius-card: 14px;
--radius-panel: 16px;
--radius-phone-screen: 37px;
--radius-phone: 46px;
/* Surfaces */
--color-background: #0b0b0c;
--color-sidebar: #0d0d0e;
--color-surface-sunken: #0d0d0f;
--color-surface-well: #0f0f10;
--color-surface: #121213;
--color-surface-dialog: #121214;
--color-surface-raised: #141416;
--color-surface-control: #161618;
--color-surface-hover-subtle: #18181b;
--color-surface-hover: #1c1c1f;
--color-surface-pressed: #26262a;
--color-overlay: rgb(0 0 0 / 0.62);
--color-shadow: #000000;
/* Borders */
--color-border-divider: #1f1f22;
--color-border-subtle: #232326;
--color-border-dialog: #26262a;
--color-border-control: #2a2a2e;
--color-border-dashed: #36363b;
--color-border-strong: #3a3a3f;
/* Text */
--color-text-primary: #f4f4f5;
--color-text-emphasis: #d4d4d8;
--color-text-secondary: #a1a1aa;
--color-text-subtle: #8b8b90;
--color-text-muted: #71717a;
--color-text-faint: #6b6b72;
--color-text-placeholder: #5c5c62;
--color-ink: #141414;
/* Brand */
--color-primary: #f97316;
--color-primary-hover: #fb8a3c;
--color-primary-foreground: #ffffff;
--color-accent-100: #ffedd5;
--color-accent-200: #fed7aa;
--color-accent-300: #fdba74;
--color-accent-400: #fb923c;
--color-accent-600: #ea580c;
--color-accent-700: #c2410c;
--color-accent-800: #9a3412;
--color-accent-900: #7c2d12;
/* Status */
--color-danger: #f87171;
--color-warning: #fbbf24;
--color-success: #22c55e;
--color-success-strong: #16a34a;
--color-note-surface: #18140f;
--color-note-border: #3a2a17;
--color-note-text: #e7c9a4;
/* Client logos */
--color-logo-tile-light: #f6f5f3;
--color-logo-tile-dark: #161618;
--color-logo-chip-light: #ffffff;
--color-logo-chip-dark: #151517;
--color-logo-badge: #ebeae7;
/* Illustration, AR page & phone frame */
--color-wood-light: #92582f;
--color-wood-dark: #3f2412;
--color-phone-frame: #1a1a1c;
--color-phone-frame-edge: #2c2c30;
--color-camera: #1a1917;
--color-room-wall: #3a3430;
--color-room-floor: #4a423b;
--color-room-floor-near: #544a42;
--color-viewer: #f4f3f0;
--color-viewer-stripe: #ebe9e5;
--color-viewer-stripe-alt: #f1efec;
--color-viewer-caption: #8a8780;
--color-qr-surface: #ffffff;
/* shadcn/ui compatibility — vendored primitives read these names */
--color-foreground: var(--color-text-primary);
--color-muted-foreground: var(--color-text-muted);
--color-accent: var(--color-surface-hover);
--color-accent-foreground: var(--color-text-primary);
--color-popover: var(--color-surface-raised);
--color-popover-foreground: var(--color-text-primary);
--color-secondary: var(--color-surface-control);
--color-destructive: var(--color-danger);
--color-border: var(--color-border-subtle);
--color-input: var(--color-border-control);
--color-ring: var(--color-primary);
/* Motion */
--animate-fade-up: fade-up 0.5s ease-out;
/* Opacity only, so absolutely placed children keep their containing block while it runs */
--animate-screen-in: screen-in 0.45s ease-out;
/* Duration comes from the component, which also advances the story when it ends */
--animate-story-progress: story-progress linear forwards;
/* Moves a full-height box, so the line inside travels from 8% to 92% of the scan frame */
--animate-scan: scan 2.8s ease-in-out infinite alternate;
--animate-float: float 3.2s ease-in-out infinite;
/* A third-width bar sliding across its track */
--animate-loading-bar: loading-bar 1.4s ease-in-out infinite;
@keyframes screen-in {
from { opacity: 0; }
}
@keyframes story-progress {
from { transform: scaleX(0); }
to { transform: scaleX(1); }
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-8px); }
}
@keyframes loading-bar {
from { transform: translateX(-100%); }
to { transform: translateX(300%); }
}
@keyframes scan {
from { transform: translateY(8%); }
to { transform: translateY(92%); }
}
@keyframes fade-up {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0); }
}
}
@utility eyebrow {
font-size: var(--text-2xs);
line-height: var(--text-2xs--line-height);
font-weight: 500;
letter-spacing: 0.06em;
text-transform: uppercase;
color: var(--color-text-faint);
}
html,
body {
@apply bg-white dark:bg-gray-950;
@media (prefers-color-scheme: dark) {
color-scheme: dark;
}
}
* {
box-sizing: border-box;
}
body {
font-family:
'Inter',
-apple-system,
BlinkMacSystemFont,
'Segoe UI',
'Roboto',
sans-serif;
background: #050509;
background-color: var(--color-background);
color: var(--color-text-primary);
color-scheme: dark;
margin: 0;
padding: 0;
height: 100vh;
min-height: 100vh;
-webkit-font-smoothing: antialiased;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 1rem;
}
model-viewer {
width: 100%;
height: 500px;
background: linear-gradient(to bottom, #e0e7ff, #f3f4f6);
border-radius: 16px;
box-shadow:
0 20px 25px -5px rgba(0, 0, 0, 0.1),
0 10px 10px -5px rgba(0, 0, 0, 0.04);
position: relative;
}
@media (max-width: 768px) {
model-viewer {
height: 400px;
}
}
::placeholder {
color: rgb(156 163 175); /* gray-400 */
color: var(--color-text-placeholder);
opacity: 1;
}
@keyframes float {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-12px); }
::selection {
background-color: color-mix(in srgb, var(--color-primary) 25%, transparent);
}
@keyframes fade-up {
from { opacity: 0; transform: translateY(12px); }
to { opacity: 1; transform: translateY(0); }
/* Pages that render their own AR launch button hide model-viewer's built-in one */
model-viewer[data-custom-ar-button]::part(default-ar-button) {
display: none;
}

View File

@ -1,148 +0,0 @@
import { Upload, Link, X } from 'lucide-react';
import { Input } from '~/components/ui/input';
import { Label } from '~/components/ui/label';
export type InputMode = 'url' | 'file';
export interface FileOrUrlFieldProps {
label: string;
required?: boolean;
mode: InputMode;
onModeChange: (m: InputMode) => void;
accept: string;
file: File | null;
onFileChange: (f: File | null) => void;
inputRef: React.RefObject<HTMLInputElement | null>;
url: string;
onUrlChange: (u: string) => void;
urlPlaceholder: string;
existingFileName?: string;
onClearExistingFile?: () => void;
}
export function FileOrUrlField({
label, required, mode, onModeChange,
accept, file, onFileChange, inputRef,
url, onUrlChange, urlPlaceholder,
existingFileName, onClearExistingFile,
}: FileOrUrlFieldProps) {
return (
<div className='space-y-1.5'>
{/* Label + toggle */}
<div className='flex items-center justify-between ml-1'>
<Label>
{label}{required && <span className='text-orange-500 ml-0.5'>*</span>}
</Label>
<div className='flex items-center gap-1 rounded-xl bg-[#181818] border border-neutral-850 p-1 text-xs'>
<button
type='button'
onClick={() => onModeChange('file')}
className={`flex items-center gap-1 rounded-lg px-3 py-1.5 transition-all font-bold cursor-pointer ${
mode === 'file'
? 'bg-orange-500 text-black shadow-md'
: 'text-neutral-500 hover:text-neutral-300'
}`}
>
<Upload size={11} />
Upload
</button>
<button
type='button'
onClick={() => onModeChange('url')}
className={`flex items-center gap-1 rounded-lg px-3 py-1.5 transition-all font-bold cursor-pointer ${
mode === 'url'
? 'bg-orange-500 text-black shadow-md'
: 'text-neutral-500 hover:text-neutral-300'
}`}
>
<Link size={11} />
URL
</button>
</div>
</div>
{mode === 'file' ? (
<div
onClick={() => inputRef.current?.click()}
className={`flex cursor-pointer items-center gap-3 rounded-xl border-2 border-dashed px-4 py-4 transition-all duration-200 ${
file || existingFileName
? 'border-orange-500/50 bg-[#161616]'
: 'border-neutral-800 hover:border-neutral-700 bg-[#161616]/40 hover:bg-[#161616]/70'
}`}
>
<input
ref={inputRef}
type='file'
accept={accept}
className='hidden'
onChange={(e) => onFileChange(e.target.files?.[0] ?? null)}
/>
{file ? (
<>
<div className='flex flex-1 items-center gap-3.5 min-w-0'>
<div className='w-8 h-8 rounded-lg bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0'>
<Upload size={14} className='text-orange-500' />
</div>
<div className="flex flex-col min-w-0">
<span className='text-sm text-white font-semibold truncate'>{file.name}</span>
<span className='text-[10px] text-neutral-500 font-medium mt-0.5'>
{(file.size / 1024 / 1024).toFixed(2)} MB
</span>
</div>
</div>
<button
type='button'
onClick={(e) => {
e.stopPropagation();
onFileChange(null);
if (inputRef.current) inputRef.current.value = '';
}}
className='shrink-0 text-neutral-500 hover:text-white p-1 hover:bg-neutral-800 rounded-lg transition-colors cursor-pointer'
>
<X size={15} />
</button>
</>
) : existingFileName ? (
<>
<div className='flex flex-1 items-center gap-3.5 min-w-0'>
<div className='w-8 h-8 rounded-lg bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0'>
<Upload size={14} className='text-orange-500' />
</div>
<div className="flex flex-col min-w-0">
<span className='text-sm text-white font-semibold truncate'>{existingFileName}</span>
<span className='text-[10px] text-neutral-500 font-medium mt-0.5'>
Existing File (Keep)
</span>
</div>
</div>
<button
type='button'
onClick={(e) => {
e.stopPropagation();
if (onClearExistingFile) onClearExistingFile();
}}
className='shrink-0 text-neutral-500 hover:text-white p-1 hover:bg-neutral-800 rounded-lg transition-colors cursor-pointer'
>
<X size={15} />
</button>
</>
) : (
<div className='flex flex-1 items-center gap-3 text-neutral-500 py-1'>
<Upload size={16} className="text-neutral-600" />
<span className='text-sm font-medium'>
Choose a file <span className='text-neutral-600 font-normal'>({accept})</span>
</span>
</div>
)}
</div>
) : (
<Input
type='url'
placeholder={urlPlaceholder}
value={url}
onChange={(e) => onUrlChange(e.target.value)}
/>
)}
</div>
);
}

View File

@ -0,0 +1,47 @@
import { useMemo, useState, type ReactNode } from 'react';
import { useNavigate } from 'react-router';
import { AssetFormDialog } from '~/components/assets/form/asset-form-dialog';
import { DeleteAssetDialog } from '~/components/assets/delete-asset-dialog';
import { ProjectFormDialog } from '~/components/projects/form/project-form-dialog';
import { ROUTES } from '~/data/routes';
import { AdminDialogsContext, type AdminDialogs } from '~/hooks/admin/use-admin-dialogs';
import type { ArAsset } from '~/types/asset';
import type { Project } from '~/types/project';
// Renders the project / asset dialogs once for the whole admin; pages open them through useAdminDialogs()
export function AdminDialogsProvider({ children }: { children: ReactNode }) {
const navigate = useNavigate();
const [project, setProject] = useState<{ open: boolean; project: Project | null; key: number }>({ open: false, project: null, key: 0 });
const [asset, setAsset] = useState<{ open: boolean; asset: ArAsset | null; projectId?: string; key: number }>({ open: false, asset: null, key: 0 });
const [deleting, setDeleting] = useState<{ asset: ArAsset; onDeleted?: () => void } | null>(null);
const dialogs = useMemo<AdminDialogs>(
() => ({
openProject: (target) => setProject((state) => ({ open: true, project: target ?? null, key: state.key + 1 })),
openAsset: (options) => setAsset((state) => ({ open: true, asset: options?.asset ?? null, projectId: options?.projectId, key: state.key + 1 })),
confirmDeleteAsset: (target, onDeleted) => setDeleting({ asset: target, onDeleted }),
}),
[],
);
return (
<AdminDialogsContext.Provider value={dialogs}>
{children}
<ProjectFormDialog
key={`project-${project.key}`}
open={project.open}
project={project.project}
onOpenChange={(open) => setProject((state) => ({ ...state, open }))}
onCreated={(id) => navigate(ROUTES.project(id))}
/>
<AssetFormDialog
key={`asset-${asset.key}`}
open={asset.open}
asset={asset.asset}
projectId={asset.projectId}
onOpenChange={(open) => setAsset((state) => ({ ...state, open }))}
/>
<DeleteAssetDialog asset={deleting?.asset ?? null} onClose={() => setDeleting(null)} onDeleted={deleting?.onDeleted} />
</AdminDialogsContext.Provider>
);
}

View File

@ -0,0 +1,33 @@
import { useState } from 'react';
import { Menu } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { Sheet, SheetContent, SheetTitle, SheetTrigger } from '~/components/ui/sheet';
import { SidebarBrand } from '~/components/admin/sidebar/sidebar-brand';
import { SidebarContent } from '~/components/admin/sidebar/sidebar-content';
// Fixed sidebar on desktop; a top bar with a slide-out menu on smaller screens
export function AdminSidebar() {
const [open, setOpen] = useState(false);
return (
<>
<aside className='sticky top-0 hidden h-screen w-60 shrink-0 border-r border-border-divider bg-sidebar lg:block'>
<SidebarContent />
</aside>
<div className='sticky top-0 z-30 flex h-14 items-center justify-between border-b border-border-divider bg-sidebar/90 px-3 backdrop-blur-md lg:hidden'>
<SidebarBrand />
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button variant='ghost' size='icon' aria-label='Open menu'>
<Menu size={18} />
</Button>
</SheetTrigger>
<SheetContent side='left' className='w-60 gap-0 border-border-divider p-0'>
<SheetTitle className='sr-only'>Menu</SheetTitle>
<SidebarContent onNavigate={() => setOpen(false)} />
</SheetContent>
</Sheet>
</div>
</>
);
}

View File

@ -0,0 +1,11 @@
import { Link } from 'react-router';
import { BrandLockup } from '~/components/ui/brand-lockup';
import { ROUTES } from '~/data/routes';
export function SidebarBrand({ onNavigate }: { onNavigate?: () => void }) {
return (
<Link to={ROUTES.home} onClick={onNavigate} className='flex px-1.5 py-0.5'>
<BrandLockup />
</Link>
);
}

View File

@ -0,0 +1,61 @@
import { Plus } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { ClientLogo } from '~/components/ui/client-logo';
import { Text } from '~/components/ui/text';
import { SidebarBrand } from '~/components/admin/sidebar/sidebar-brand';
import { SidebarFooter } from '~/components/admin/sidebar/sidebar-footer';
import { SidebarLink } from '~/components/admin/sidebar/sidebar-link';
import { ASSET_FILTER } from '~/data/assets/constants';
import { ROUTES } from '~/data/routes';
import { useActiveNav, type NavSection } from '~/hooks/admin/use-active-nav';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { useAdminDialogs } from '~/hooks/admin/use-admin-dialogs';
import { toBrand } from '~/services/asset-media';
export function SidebarContent({ onNavigate }: { onNavigate?: () => void }) {
const { projects, counts } = useAdminData();
const { openProject } = useAdminDialogs();
const active = useActiveNav();
const clients = projects.filter((project) => project.status === 'active');
const nav: { section: NavSection; label: string; to: string; count: number }[] = [
{ section: 'projects', label: 'Projects', to: ROUTES.projects, count: clients.length },
{ section: 'assets', label: 'All assets', to: ROUTES.assets, count: counts.total },
{ section: 'unassigned', label: 'Unassigned', to: ROUTES.assetsFiltered(ASSET_FILTER.unassigned), count: counts.unassigned },
];
return (
<div className='flex h-full flex-col gap-[22px] px-3 py-4'>
<SidebarBrand onNavigate={onNavigate} />
<nav aria-label='Main' className='flex flex-col gap-0.5'>
{nav.map((item) => (
<SidebarLink key={item.section} size='nav' active={active.section === item.section} onNavigate={onNavigate} {...item} />
))}
</nav>
<div className='flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto'>
<div className='flex items-center justify-between px-2.5 pb-1.5'>
<Text as='span' variant='eyebrow'>Clients</Text>
<Button variant='ghost' size='icon-sm' className='h-5 w-5 rounded-option' aria-label='New project' onClick={() => openProject()}>
<Plus size={12} strokeWidth={2.4} />
</Button>
</div>
{clients.map((project) => (
<SidebarLink
key={project.id}
size='client'
to={ROUTES.project(project.id)}
label={project.name}
count={project.assetCount}
active={active.projectId === project.id}
leading={<ClientLogo brand={toBrand(project)} variant='mark' size='sm' />}
onNavigate={onNavigate}
/>
))}
</div>
<SidebarFooter settingsActive={active.section === 'settings'} onNavigate={onNavigate} />
</div>
);
}

View File

@ -0,0 +1,40 @@
import { useNavigate } from 'react-router';
import { LogOut, Settings } from 'lucide-react';
import { toast } from 'sonner';
import { Button } from '~/components/ui/button';
import { Text } from '~/components/ui/text';
import { SidebarLink } from '~/components/admin/sidebar/sidebar-link';
import { ROUTES } from '~/data/routes';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { signOut } from '~/services/auth';
export function SidebarFooter({ settingsActive, onNavigate }: { settingsActive: boolean; onNavigate?: () => void }) {
const { email } = useAdminData();
const navigate = useNavigate();
return (
<div className='flex flex-col gap-2'>
<SidebarLink size='nav' to={ROUTES.settings} label='Settings' active={settingsActive} leading={<Settings size={14} />} onNavigate={onNavigate} />
<div className='flex flex-col items-start gap-2 border-t border-border-divider px-1.5 pt-3'>
{email && (
<Text variant='caption' tone='secondary' truncate className='max-w-full'>
{email}
</Text>
)}
<Button
variant='link'
size='sm'
className='h-auto gap-2 text-text-subtle hover:text-text-primary'
onClick={() => {
signOut();
toast.success('Signed out');
navigate(ROUTES.login, { replace: true });
}}
>
<LogOut size={13} />
Sign out
</Button>
</div>
</div>
);
}

View File

@ -0,0 +1,43 @@
import type { ReactNode } from 'react';
import { Link } from 'react-router';
import { cva } from 'class-variance-authority';
import { Text } from '~/components/ui/text';
const linkVariants = cva('flex items-center rounded-item text-sm transition-colors duration-150', {
variants: {
size: {
nav: 'h-[34px] gap-2.5 px-2.5 font-medium',
client: 'h-9 gap-2.5 px-2',
},
active: {
true: 'bg-surface-hover text-text-primary',
false: 'text-text-secondary hover:bg-surface-hover-subtle hover:text-text-primary',
},
},
});
interface SidebarLinkProps {
to: string;
label: string;
active: boolean;
size: 'nav' | 'client';
leading?: ReactNode;
count?: number;
onNavigate?: () => void;
}
export function SidebarLink({ to, label, active, size, leading, count, onNavigate }: SidebarLinkProps) {
return (
<Link to={to} onClick={onNavigate} aria-current={active ? 'page' : undefined} className={linkVariants({ size, active })}>
{leading}
<Text as='span' variant='inherit' truncate className='flex-1'>
{label}
</Text>
{count !== undefined && (
<Text as='span' variant='meta' tone='faint' numeric>
{count}
</Text>
)}
</Link>
);
}

View File

@ -0,0 +1,45 @@
import { useRef } from 'react';
import { ArPage } from '~/components/ui/ar-page';
import { LoadingScreen } from '~/components/ui/loading-screen';
import { ModelViewer } from '~/components/ui/model-viewer';
import { useArLaunch } from '~/hooks/ar-viewer/use-ar-launch';
import { useModelViewerReady } from '~/hooks/use-model-viewer-ready';
import { getArPageLayout, getButtonStyle, getGlbUrl, getUsdzUrl, toBrand } from '~/services/asset-media';
import type { ArAsset } from '~/types/asset';
import type { AppSettings } from '~/types/settings';
export function ArScene({ asset, settings }: { asset: ArAsset; settings: AppSettings }) {
const viewerRef = useRef<HTMLElement>(null);
const ready = useModelViewerReady();
const { launch, launching, hint } = useArLaunch(viewerRef);
const project = asset.expand?.project;
if (!ready) return <LoadingScreen label='Loading AR experience…' />;
return (
<ArPage
brand={project ? toBrand(project) : undefined}
modelName={asset.name}
button={getButtonStyle(project, settings)}
layout={getArPageLayout(project)}
launching={launching}
hint={hint}
onLaunch={launch}
className='fixed inset-0'
>
<ModelViewer
ref={viewerRef}
data-custom-ar-button
src={getGlbUrl(asset)}
ios-src={getUsdzUrl(asset)}
ar-scale='auto'
ar-placement='floor'
touch-action='none'
interaction-prompt='none'
exposure='1'
alt={asset.name}
className='absolute inset-0'
/>
</ArPage>
);
}

View File

@ -0,0 +1,32 @@
import { useMemo } from 'react';
import { cva } from 'class-variance-authority';
import { getArUrl, qrLogoFill, qrSvgMarkup } from '~/lib/assets/qr';
import { cn } from '~/lib/utils';
import { isBrandedQr, toBrand } from '~/services/asset-media';
import type { ArAsset } from '~/types/asset';
const frameVariants = cva('relative aspect-square w-full overflow-hidden bg-qr-surface [&>svg]:block', {
variants: {
size: {
card: 'rounded-item',
panel: 'max-w-[300px] rounded-card-sm',
},
},
});
// The asset's QR code; a branded code has the client logo inside it, in a cleared square at the centre
export function AssetQr({ asset, size, className }: { asset: ArAsset; size: 'card' | 'panel'; className?: string }) {
const project = asset.expand?.project;
const brand = isBrandedQr(asset) && project ? toBrand(project) : undefined;
const markup = useMemo(
() =>
qrSvgMarkup(getArUrl(asset.id), {
logo: brand?.logoUrl ? { href: brand.logoUrl, fill: qrLogoFill(brand) } : undefined,
label: `QR code for ${asset.name}`,
}),
[asset.id, asset.name, brand?.logoUrl, brand?.logoBg, brand?.logoBgColor],
);
// Markup built by qrSvgMarkup from our own data, with attribute values escaped
return <div className={cn(frameVariants({ size }), className)} dangerouslySetInnerHTML={{ __html: markup }} />;
}

View File

@ -0,0 +1,34 @@
import { useFetcher } from 'react-router';
import { ConfirmDialog } from '~/components/ui/confirm-dialog';
import { ASSET_INTENT, type AssetIntent } from '~/data/assets/constants';
import { ROUTES } from '~/data/routes';
import { useActionToast } from '~/hooks/use-action-toast';
import type { ActionResult } from '~/types/action';
import type { ArAsset } from '~/types/asset';
interface DeleteAssetDialogProps {
asset: ArAsset | null;
onClose: () => void;
onDeleted?: () => void;
}
export function DeleteAssetDialog({ asset, onClose, onDeleted }: DeleteAssetDialogProps) {
const fetcher = useFetcher<ActionResult<AssetIntent>>();
useActionToast(fetcher.data, () => {
onClose();
onDeleted?.();
});
return (
<ConfirmDialog
open={!!asset}
onOpenChange={(open) => !open && onClose()}
title='Delete asset?'
description={`"${asset?.name ?? ''}" will be permanently deleted and its QR code will stop working.`}
confirmLabel='Delete'
pending={fetcher.state !== 'idle'}
onConfirm={() => asset && fetcher.submit({ intent: ASSET_INTENT.delete, id: asset.id }, { method: 'post', action: ROUTES.assets })}
/>
);
}

View File

@ -0,0 +1,24 @@
import { Text } from '~/components/ui/text';
import { getModelFileName, isBrandedQr } from '~/services/asset-media';
import type { ArAsset } from '~/types/asset';
export function AssetDetailList({ asset }: { asset: ArAsset }) {
const rows = [
{ label: 'Project', value: asset.expand?.project?.name ?? 'Unassigned', mono: false },
{ label: 'QR style', value: isBrandedQr(asset) ? 'Branded · client logo' : 'Standard', mono: false },
{ label: 'Model file', value: getModelFileName(asset), mono: true },
];
return (
<dl className='flex flex-col'>
{rows.map((row) => (
<div key={row.label} className='flex justify-between gap-3 border-t border-border-divider py-[11px]'>
<Text as='dt' tone='muted'>{row.label}</Text>
<Text as='dd' variant={row.mono ? 'mono' : 'body'} tone='emphasis' truncate className='min-w-0 text-right'>
{row.value}
</Text>
</div>
))}
</dl>
);
}

View File

@ -0,0 +1,46 @@
import { Link } from 'react-router';
import { Button } from '~/components/ui/button';
import { ClientLogo } from '~/components/ui/client-logo';
import { PageBreadcrumb } from '~/components/ui/page-breadcrumb';
import { Text } from '~/components/ui/text';
import { ASSET_FILTER } from '~/data/assets/constants';
import { ROUTES } from '~/data/routes';
import { formatDate } from '~/lib/format';
import { toBrand } from '~/services/asset-media';
import type { ArAsset } from '~/types/asset';
interface AssetPreviewHeaderProps {
asset: ArAsset;
onEdit: () => void;
onDelete: () => void;
}
export function AssetPreviewHeader({ asset, onEdit, onDelete }: AssetPreviewHeaderProps) {
const project = asset.expand?.project;
const parent = project
? { label: project.name, to: ROUTES.project(project.id) }
: { label: 'Unassigned', to: ROUTES.assetsFiltered(ASSET_FILTER.unassigned) };
return (
<>
<PageBreadcrumb trail={[{ label: 'Projects', to: ROUTES.projects }, parent]} current={asset.name} />
<div className='flex flex-wrap items-end justify-between gap-4'>
<div className='flex min-w-0 flex-col gap-2.5'>
<Text as='h1' variant='display'>{asset.name}</Text>
<div className='flex flex-wrap items-center gap-2.5'>
{project && <ClientLogo brand={toBrand(project)} variant='chip' size='sm' />}
<Link to={parent.to} className='text-text-emphasis transition-colors hover:text-primary'>
<Text as='span' tone='inherit'>{parent.label}</Text>
</Link>
<Text as='span' tone='faint'>·</Text>
<Text as='span' tone='muted'>Created {formatDate(asset.created)}</Text>
</div>
</div>
<div className='flex gap-2.5'>
<Button variant='secondary' onClick={onEdit}>Edit asset</Button>
<Button variant='destructive' onClick={onDelete}>Delete</Button>
</div>
</div>
</>
);
}

View File

@ -0,0 +1,40 @@
import { Download } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { Card } from '~/components/ui/card';
import { CopyField } from '~/components/ui/copy-field';
import { AssetQr } from '~/components/assets/asset-qr';
import { AssetDetailList } from '~/components/assets/detail/asset-detail-list';
import { UnassignedNote } from '~/components/assets/detail/unassigned-note';
import { getArUrl } from '~/lib/assets/qr';
import { downloadQr } from '~/lib/assets/qr-export';
import { toFileName } from '~/lib/format';
import { isBrandedQr, toBrand } from '~/services/asset-media';
import type { ArAsset } from '~/types/asset';
export function AssetQrPanel({ asset }: { asset: ArAsset }) {
const arUrl = getArUrl(asset.id);
const project = asset.expand?.project;
const brand = project && isBrandedQr(asset) ? toBrand(project) : undefined;
const fileName = `${toFileName(asset.name)}_qr`;
const formats = [
{ format: 'png', label: 'QR · PNG', variant: 'default' },
{ format: 'svg', label: 'QR · SVG', variant: 'secondary' },
] as const;
return (
<Card size='lg' className='flex flex-col gap-[18px] p-5'>
<AssetQr asset={asset} size='panel' className='self-center' />
<CopyField value={arUrl} label='AR link' />
<div className='grid grid-cols-2 gap-2.5'>
{formats.map(({ format, label, variant }) => (
<Button key={format} variant={variant} onClick={() => downloadQr(format, arUrl, fileName, brand)}>
<Download size={13} />
{label}
</Button>
))}
</div>
<AssetDetailList asset={asset} />
{!project && <UnassignedNote />}
</Card>
);
}

View File

@ -0,0 +1,36 @@
import { ArPagePreview } from '~/components/ui/ar-page-preview';
import { Card } from '~/components/ui/card';
import { ModelViewer } from '~/components/ui/model-viewer';
import { Text } from '~/components/ui/text';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { useModelViewerReady } from '~/hooks/use-model-viewer-ready';
import { getArPageLayout, getButtonStyle, getGlbUrl, getUsdzUrl, toBrand } from '~/services/asset-media';
import type { ArAsset } from '~/types/asset';
// What a customer sees after scanning the QR, with the real 3D model
export function CustomerView({ asset }: { asset: ArAsset }) {
const { settings } = useAdminData();
const ready = useModelViewerReady();
const project = asset.expand?.project;
const glbUrl = getGlbUrl(asset);
return (
<Card surface='well' size='lg' className='flex flex-col items-center gap-3.5 px-5 pt-6 pb-7'>
<div className='flex items-baseline justify-between gap-3 self-stretch'>
<Text as='h2' variant='body-strong'>Customer view</Text>
<Text variant='caption'>After scanning the QR</Text>
</div>
<ArPagePreview
brand={project ? toBrand(project) : undefined}
modelName={asset.name}
button={getButtonStyle(project, settings)}
layout={getArPageLayout(project)}
className='h-[620px] w-[300px] max-w-full'
>
{ready && glbUrl ? (
<ModelViewer src={glbUrl} ios-src={getUsdzUrl(asset)} auto-rotate exposure='1' alt={asset.name} className='absolute inset-0' />
) : undefined}
</ArPagePreview>
</Card>
);
}

View File

@ -0,0 +1,29 @@
import { AssetQr } from '~/components/assets/asset-qr';
import { CopyField } from '~/components/ui/copy-field';
import { Dialog, DialogBody, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '~/components/ui/dialog';
import { getArUrl } from '~/lib/assets/qr';
import type { ArAsset } from '~/types/asset';
interface ScanQrDialogProps {
asset: ArAsset;
open: boolean;
onOpenChange: (open: boolean) => void;
}
// AR needs a phone camera, so "View in your space" in the admin preview offers the QR code to scan instead
export function ScanQrDialog({ asset, open, onOpenChange }: ScanQrDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className='max-w-sm'>
<DialogHeader>
<DialogTitle>View in AR</DialogTitle>
<DialogDescription>Scan this QR code with your phone’s camera to open {asset.name} and place it in your room.</DialogDescription>
</DialogHeader>
<DialogBody>
<AssetQr asset={asset} size='panel' className='self-center' />
<CopyField value={getArUrl(asset.id)} label='AR link' />
</DialogBody>
</DialogContent>
</Dialog>
);
}

View File

@ -0,0 +1,9 @@
import { Text } from '~/components/ui/text';
export function UnassignedNote() {
return (
<Text variant='caption' tone='note' className='rounded-group bg-note-surface px-3.5 py-3 ring-1 ring-inset ring-note-border'>
Not in a project yet — its AR page shows only the thob logo. Moving it into a project adds the client logo; the printed QR keeps working.
</Text>
);
}

View File

@ -0,0 +1,79 @@
import { FormProvider, useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { useFetcher } from 'react-router';
import { Dialog, DialogBody, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '~/components/ui/dialog';
import { DialogActions } from '~/components/ui/dialog-actions';
import { Field } from '~/components/ui/field';
import { Input } from '~/components/ui/input';
import { BrandedQrField } from '~/components/assets/form/branded-qr-field';
import { ModelSourceField } from '~/components/assets/form/model-source-field';
import { ProjectSelectField } from '~/components/assets/form/project-select-field';
import { ASSET_INTENT, type AssetIntent } from '~/data/assets/constants';
import { ROUTES } from '~/data/routes';
import { useActionToast } from '~/hooks/use-action-toast';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { toAssetFormData } from '~/lib/assets/form-data';
import { assetFormSchema, toAssetFormValues, type AssetFormValues } from '~/schemas/assets/asset-form';
import type { ActionResult } from '~/types/action';
import type { ArAsset } from '~/types/asset';
interface AssetFormDialogProps {
open: boolean;
asset: ArAsset | null;
projectId?: string;
onOpenChange: (open: boolean) => void;
}
export function AssetFormDialog({ open, asset, projectId, onOpenChange }: AssetFormDialogProps) {
const { settings } = useAdminData();
const fetcher = useFetcher<ActionResult<AssetIntent>>();
const form = useForm<AssetFormValues>({
resolver: zodResolver(assetFormSchema),
defaultValues: toAssetFormValues(asset, { projectId, brandedQr: settings.branded_qr_default }),
});
const { errors } = form.formState;
const intent = asset ? ASSET_INTENT.update : ASSET_INTENT.create;
useActionToast(fetcher.data, () => onOpenChange(false));
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className='max-w-xl'>
<DialogHeader>
<DialogTitle>{asset ? 'Edit asset' : 'New asset'}</DialogTitle>
<DialogDescription>{asset ? asset.name : 'Add a 3D model and get a QR code for it.'}</DialogDescription>
</DialogHeader>
<FormProvider {...form}>
<form
noValidate
className='flex flex-col'
onSubmit={form.handleSubmit((values) =>
fetcher.submit(toAssetFormData(intent, values), { method: 'post', action: ROUTES.assets, encType: 'multipart/form-data' }),
)}
>
<DialogBody>
<Field label='Name' htmlFor='asset-name' required error={errors.name?.message}>
<Input id='asset-name' placeholder='e.g. Lounge chair' aria-invalid={!!errors.name} {...form.register('name')} />
</Field>
<ProjectSelectField />
<ModelSourceField name='glb' required />
<ModelSourceField name='usdz' />
<BrandedQrField />
{!asset && (
<Field
label='Reuse QR code ID'
htmlFor='asset-id'
hint='Optional — paste the 15-character ID from an existing QR link.'
error={errors.id?.message}
>
<Input id='asset-id' maxLength={15} placeholder='e.g. 0gsk2w8h236474u' aria-invalid={!!errors.id} {...form.register('id')} />
</Field>
)}
</DialogBody>
<DialogActions confirmLabel={asset ? 'Save changes' : 'Create asset'} pendingLabel='Saving…' pending={fetcher.state !== 'idle'} />
</form>
</FormProvider>
</DialogContent>
</Dialog>
);
}

View File

@ -0,0 +1,25 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { SwitchRow } from '~/components/ui/switch-row';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import type { AssetFormValues } from '~/schemas/assets/asset-form';
// Only offered when the chosen project has a logo to put on the QR code
export function BrandedQrField() {
const { projects } = useAdminData();
const { control, setValue } = useFormContext<AssetFormValues>();
const [projectId, brandedQr] = useWatch({ control, name: ['project', 'brandedQr'] });
const project = projects.find((item) => item.id === projectId);
if (!project?.logo) return null;
return (
<SwitchRow
framed
id='asset-branded-qr'
label='Client logo on QR code'
hint={`Puts the ${project.name} logo in the centre of this asset’s QR code.`}
checked={brandedQr}
onCheckedChange={(checked) => setValue('brandedQr', checked, { shouldDirty: true })}
/>
);
}

View File

@ -0,0 +1,35 @@
import { UploadCloud } from 'lucide-react';
import { DropZone } from '~/components/ui/drop-zone';
import { Text } from '~/components/ui/text';
import { SelectedFile } from '~/components/assets/form/selected-file';
import { formatFileSize } from '~/lib/format';
interface FilePickerProps {
id?: string;
accept: string;
file: File | null;
existing: string;
invalid?: boolean;
onFileChange: (file: File | null) => void;
onClearExisting: () => void;
}
export function FilePicker({ id, accept, file, existing, invalid, onFileChange, onClearExisting }: FilePickerProps) {
return (
<DropZone id={id} accept={accept} layout='row' filled={!!file || !!existing} invalid={invalid} onFile={onFileChange}>
{file ? (
<SelectedFile name={file.name} meta={formatFileSize(file.size)} onRemove={() => onFileChange(null)} />
) : existing ? (
<SelectedFile name={existing} meta='Current file' onRemove={onClearExisting} />
) : (
<div className='flex items-center gap-3 py-0.5'>
<UploadCloud size={17} className='text-text-secondary' />
<Text>
<Text as='span' variant='label' tone='primary'>Click to upload</Text> or drag a file here{' '}
<Text as='span' variant='meta'>({accept})</Text>
</Text>
</div>
)}
</DropZone>
);
}

View File

@ -0,0 +1,64 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { Link2 } from 'lucide-react';
import { Field } from '~/components/ui/field';
import { IconInput } from '~/components/ui/icon-input';
import { SegmentedControl } from '~/components/ui/segmented-control';
import { FilePicker } from '~/components/assets/form/file-picker';
import { MODEL_FIELDS, MODEL_SOURCE_OPTIONS, type ModelFieldName } from '~/data/assets/constants';
import type { AssetFormValues } from '~/schemas/assets/asset-form';
export function ModelSourceField({ name, required }: { name: ModelFieldName; required?: boolean }) {
const { control, register, setValue, trigger, formState } = useFormContext<AssetFormValues>();
const source = useWatch({ control, name });
const config = MODEL_FIELDS[name];
const fieldErrors = formState.errors[name];
const error = fieldErrors?.file?.message ?? fieldErrors?.url?.message;
const inputId = `${name}-source`;
// Re-validates the whole source once the form has been submitted, so errors for the other mode clear
const update = (patch: Partial<AssetFormValues['glb']>) => {
setValue(name, { ...source, ...patch });
if (formState.isSubmitted) trigger(name);
};
return (
<Field
label={config.label}
htmlFor={inputId}
required={required}
hint={config.hint}
error={error}
action={
<SegmentedControl
size='sm'
surface='sunken'
label={`${config.label} source`}
value={source.mode}
options={MODEL_SOURCE_OPTIONS}
onChange={(mode) => update({ mode })}
/>
}
>
{source.mode === 'file' ? (
<FilePicker
id={inputId}
accept={config.accept}
file={source.file}
existing={source.existing}
invalid={!!error}
onFileChange={(file) => update({ file })}
onClearExisting={() => update({ existing: '' })}
/>
) : (
<IconInput
id={inputId}
type='url'
icon={Link2}
placeholder={config.urlPlaceholder}
aria-invalid={!!error}
{...register(`${name}.url`)}
/>
)}
</Field>
);
}

View File

@ -0,0 +1,35 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { ClientLogo } from '~/components/ui/client-logo';
import { Field } from '~/components/ui/field';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '~/components/ui/select';
import { NO_PROJECT } from '~/data/assets/constants';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import type { AssetFormValues } from '~/schemas/assets/asset-form';
import { toBrand } from '~/services/asset-media';
export function ProjectSelectField() {
const { projects } = useAdminData();
const { control, setValue } = useFormContext<AssetFormValues>();
const value = useWatch({ control, name: 'project' });
// Archived projects are only listed when the asset already belongs to one
const options = projects.filter((project) => project.status === 'active' || project.id === value);
return (
<Field label='Project' htmlFor='asset-project' hint={value ? undefined : 'Unassigned assets show only the thob logo on their AR page.'}>
<Select value={value || NO_PROJECT} onValueChange={(next) => setValue('project', next === NO_PROJECT ? '' : next, { shouldDirty: true })}>
<SelectTrigger id='asset-project' className='w-full'>
<SelectValue />
</SelectTrigger>
<SelectContent position='popper'>
<SelectItem value={NO_PROJECT}>Unassigned</SelectItem>
{options.map((project) => (
<SelectItem key={project.id} value={project.id}>
<ClientLogo brand={toBrand(project)} variant='mark' size='sm' />
{project.name}
</SelectItem>
))}
</SelectContent>
</Select>
</Field>
);
}

View File

@ -0,0 +1,31 @@
import { FileBox, X } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { IconTile } from '~/components/ui/icon-tile';
import { TextPair } from '~/components/ui/text-pair';
interface SelectedFileProps {
name: string;
meta: string;
onRemove: () => void;
}
export function SelectedFile({ name, meta, onRemove }: SelectedFileProps) {
return (
<div className='flex items-center gap-3'>
<IconTile icon={FileBox} size='sm' />
<TextPair title={name} meta={meta} className='flex-1' />
<Button
type='button'
variant='ghost'
size='icon-sm'
aria-label={`Remove ${name}`}
onClick={(e) => {
e.stopPropagation();
onRemove();
}}
>
<X size={15} />
</Button>
</div>
);
}

View File

@ -0,0 +1,41 @@
import { memo } from 'react';
import { Link } from 'react-router';
import { Pencil, Trash2 } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { Card } from '~/components/ui/card';
import { TextPair } from '~/components/ui/text-pair';
import { AssetQr } from '~/components/assets/asset-qr';
import { AssetProjectChip } from '~/components/assets/list/asset-project-chip';
import { ROUTES } from '~/data/routes';
import { formatDate } from '~/lib/format';
import type { ArAsset } from '~/types/asset';
interface AssetCardProps {
asset: ArAsset;
showProject: boolean;
onEdit: (asset: ArAsset) => void;
onDelete: (asset: ArAsset) => void;
}
export const AssetCard = memo(function AssetCard({ asset, showProject, onEdit, onDelete }: AssetCardProps) {
const name = asset.name || 'Untitled';
return (
<Card size='sm' interactive className='relative flex flex-col gap-3 p-[13px]'>
<AssetQr asset={asset} size='card' />
<div className='flex items-start justify-between gap-2'>
<Link to={ROUTES.asset(asset.id)} aria-label={`Open ${name}`} className='min-w-0 after:absolute after:inset-0'>
<TextPair as='h3' title={name} meta={formatDate(asset.created)} />
</Link>
<div className='relative z-10 flex shrink-0 gap-0.5'>
<Button variant='ghost' size='icon-sm' aria-label={`Edit ${name}`} onClick={() => onEdit(asset)}>
<Pencil size={13} />
</Button>
<Button variant='ghost' size='icon-sm' aria-label={`Delete ${name}`} className='hover:text-danger' onClick={() => onDelete(asset)}>
<Trash2 size={13} />
</Button>
</div>
</div>
{showProject && <AssetProjectChip project={asset.expand?.project} />}
</Card>
);
});

View File

@ -0,0 +1,22 @@
import { FilterChip } from '~/components/ui/filter-chip';
import { ASSET_FILTER } from '~/data/assets/constants';
import { ROUTES } from '~/data/routes';
import type { ProjectSummary } from '~/types/project';
export function AssetFilterChips({ filter, projects }: { filter: string; projects: ProjectSummary[] }) {
const chips = [
{ value: ASSET_FILTER.all, label: 'All', to: ROUTES.assets },
...projects.map((project) => ({ value: project.id, label: project.name, to: ROUTES.assetsFiltered(project.id) })),
{ value: ASSET_FILTER.unassigned, label: 'Unassigned', to: ROUTES.assetsFiltered(ASSET_FILTER.unassigned) },
];
return (
<nav aria-label='Filter assets' className='flex flex-wrap gap-2'>
{chips.map((chip) => (
<FilterChip key={chip.value} to={chip.to} selected={filter === chip.value}>
{chip.label}
</FilterChip>
))}
</nav>
);
}

View File

@ -0,0 +1,37 @@
import { useCallback } from 'react';
import { EmptyState } from '~/components/ui/empty-state';
import { AssetCard } from '~/components/assets/list/asset-card';
import { AssetPagination } from '~/components/assets/list/asset-pagination';
import { useAdminDialogs } from '~/hooks/admin/use-admin-dialogs';
import type { ArAsset, AssetPage } from '~/types/asset';
interface AssetListProps {
assets: AssetPage;
showProject: boolean;
emptyTitle: string;
emptyMessage?: string;
}
export function AssetList({ assets, showProject, emptyTitle, emptyMessage }: AssetListProps) {
const { openAsset, confirmDeleteAsset } = useAdminDialogs();
const editAsset = useCallback((asset: ArAsset) => openAsset({ asset }), [openAsset]);
if (assets.items.length === 0) return <EmptyState title={emptyTitle} message={emptyMessage} />;
return (
<div className='flex flex-col gap-6'>
<div className='grid grid-cols-[repeat(auto-fill,minmax(200px,1fr))] gap-3.5'>
{assets.items.map((asset) => (
<AssetCard
key={asset.id}
asset={asset}
showProject={showProject}
onEdit={editAsset}
onDelete={confirmDeleteAsset}
/>
))}
</div>
<AssetPagination page={assets.page} totalPages={assets.totalPages} totalItems={assets.totalItems} />
</div>
);
}

View File

@ -0,0 +1,44 @@
import { ChevronLeft, ChevronRight } from 'lucide-react';
import { Text } from '~/components/ui/text';
import { PaginationLink } from '~/components/assets/list/pagination-link';
import { ASSETS_PAGE_SIZE } from '~/data/assets/constants';
import { getPaginationRange } from '~/lib/pagination';
interface AssetPaginationProps {
page: number;
totalPages: number;
totalItems: number;
}
export function AssetPagination({ page, totalPages, totalItems }: AssetPaginationProps) {
if (totalItems === 0) return null;
const first = (page - 1) * ASSETS_PAGE_SIZE + 1;
const last = Math.min(page * ASSETS_PAGE_SIZE, totalItems);
return (
<nav aria-label='Pagination' className='flex flex-col items-center justify-between gap-3 border-t border-border-divider pt-5 sm:flex-row'>
<Text variant='caption'>
Showing {first}–{last} of {totalItems}
</Text>
{totalPages > 1 && (
<div className='flex items-center gap-1.5'>
<PaginationLink page={page - 1} disabled={page === 1} label='Previous page'>
<ChevronLeft size={13} strokeWidth={2.4} />
</PaginationLink>
{getPaginationRange(page, totalPages).map((item, index) =>
item === 'ellipsis' ? (
<Text key={`ellipsis-${index}`} as='span' variant='caption' className='px-1.5'>…</Text>
) : (
<PaginationLink key={item} page={item} active={item === page}>
{item}
</PaginationLink>
),
)}
<PaginationLink page={page + 1} disabled={page === totalPages} label='Next page'>
<ChevronRight size={13} strokeWidth={2.4} />
</PaginationLink>
</div>
)}
</nav>
);
}

View File

@ -0,0 +1,15 @@
import { ClientLogo } from '~/components/ui/client-logo';
import { Text } from '~/components/ui/text';
import { toBrand } from '~/services/asset-media';
import type { Project } from '~/types/project';
export function AssetProjectChip({ project }: { project?: Project }) {
return (
<div className='flex min-w-0 items-center gap-2 border-t border-border-divider pt-2.5'>
{project && <ClientLogo brand={toBrand(project)} variant='mark' size='xs' />}
<Text as='span' variant='meta' tone={project ? 'secondary' : 'muted'} truncate>
{project?.name ?? 'Unassigned'}
</Text>
</div>
);
}

View File

@ -0,0 +1,33 @@
import type { ReactNode } from 'react';
import { Link, useLocation } from 'react-router';
import { Button } from '~/components/ui/button';
import { cn } from '~/lib/utils';
interface PaginationLinkProps {
page: number;
active?: boolean;
disabled?: boolean;
label?: string;
children: ReactNode;
}
// Links to another page of the current list, keeping its other search params (e.g. the filter)
export function PaginationLink({ page, active, disabled, label, children }: PaginationLinkProps) {
const { search } = useLocation();
const params = new URLSearchParams(search);
params.set('page', String(page));
return (
<Button
asChild
size='icon'
variant={active ? 'default' : 'secondary'}
aria-label={label}
aria-current={active ? 'page' : undefined}
aria-disabled={disabled}
className={cn('shadow-none', disabled && 'pointer-events-none opacity-40')}
>
<Link to={`?${params}`}>{children}</Link>
</Button>
);
}

View File

@ -1,129 +0,0 @@
import { Armchair } from '~/components/auth/armchair';
export function ArIllustration() {
return (
<svg
viewBox="0 0 400 460"
className="h-auto w-full max-w-[380px] animate-[float_7s_ease-in-out_infinite] drop-shadow-[0_30px_60px_rgba(0,0,0,0.6)]"
role="img"
aria-label="An armchair placed in a room through a phone camera in augmented reality"
>
<defs>
<linearGradient id="chair-back" x1="0" y1="0" x2="1" y2="1">
<stop offset="0%" stopColor="#fb923c" />
<stop offset="55%" stopColor="#c2410c" />
<stop offset="100%" stopColor="#7c2d12" />
</linearGradient>
<linearGradient id="chair-back-inner" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#f97316" />
<stop offset="100%" stopColor="#9a3412" />
</linearGradient>
<linearGradient id="chair-cushion" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#fdba74" />
<stop offset="100%" stopColor="#ea580c" />
</linearGradient>
<linearGradient id="chair-base" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#c2410c" />
<stop offset="100%" stopColor="#7c2d12" />
</linearGradient>
<linearGradient id="chair-arm-left" x1="0" y1="0" x2="1" y2="0">
<stop offset="0%" stopColor="#9a3412" />
<stop offset="100%" stopColor="#ea580c" />
</linearGradient>
<linearGradient id="chair-arm-right" x1="0" y1="0" x2="1" y2="0">
<stop offset="0%" stopColor="#f97316" />
<stop offset="100%" stopColor="#9a3412" />
</linearGradient>
<linearGradient id="chair-wood" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#92582f" />
<stop offset="100%" stopColor="#3f2412" />
</linearGradient>
<linearGradient id="ar-screen" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="#161616" />
<stop offset="60%" stopColor="#1a1511" />
<stop offset="100%" stopColor="#221810" />
</linearGradient>
<linearGradient id="ar-grid-fade" x1="0" y1="0" x2="0" y2="1">
<stop offset="0%" stopColor="white" stopOpacity="0" />
<stop offset="100%" stopColor="white" stopOpacity="1" />
</linearGradient>
<mask id="ar-grid-mask">
<rect x="0" y="200" width="400" height="200" fill="url(#ar-grid-fade)" />
</mask>
<clipPath id="ar-screen-clip">
<rect x="118" y="38" width="164" height="364" rx="24" />
</clipPath>
<radialGradient id="ar-glow" cx="50%" cy="50%" r="50%">
<stop offset="0%" stopColor="#f97316" stopOpacity="0.3" />
<stop offset="100%" stopColor="#f97316" stopOpacity="0" />
</radialGradient>
<filter id="ar-blur" x="-50%" y="-50%" width="200%" height="200%">
<feGaussianBlur stdDeviation="5" />
</filter>
</defs>
{/* Phone body */}
<rect x="108" y="28" width="184" height="384" rx="32" fill="#0b0b0b" stroke="#2a2a2a" strokeWidth="2" />
<rect x="118" y="38" width="164" height="364" rx="24" fill="url(#ar-screen)" />
<g clipPath="url(#ar-screen-clip)">
{/* Wall / floor horizon */}
<rect x="118" y="38" width="164" height="176" fill="white" opacity="0.015" />
{/* Perspective floor seen through the camera */}
<g stroke="#f97316" strokeOpacity="0.3" strokeWidth="1" mask="url(#ar-grid-mask)">
{[240, 262, 290, 326, 372].map((y) => (
<line key={y} x1="100" y1={y} x2="300" y2={y} />
))}
{[-260, -170, -90, -30, 30, 90, 170, 260].map((dx) => (
<line key={dx} x1="200" y1="214" x2={200 + dx} y2="420" />
))}
</g>
<ellipse cx="200" cy="320" rx="96" ry="40" fill="url(#ar-glow)" />
{/* Placement reticle */}
<ellipse cx="200" cy="320" rx="76" ry="19" fill="none" stroke="#f97316" strokeWidth="1.5" strokeDasharray="5 5">
<animate attributeName="stroke-dashoffset" from="0" to="-20" dur="2s" repeatCount="indefinite" />
</ellipse>
<ellipse cx="200" cy="320" rx="60" ry="15" fill="#f97316" fillOpacity="0.12">
<animate attributeName="fill-opacity" values="0.18;0.05;0.18" dur="2.4s" repeatCount="indefinite" />
</ellipse>
<Armchair />
{/* Camera scan brackets */}
<g fill="none" stroke="white" strokeOpacity="0.55" strokeWidth="2" strokeLinecap="round">
<path d="M136 152 V138 H150" />
<path d="M264 152 V138 H250" />
<path d="M136 342 V356 H150" />
<path d="M264 342 V356 H250" />
</g>
{/* AR badge */}
<rect x="180" y="62" width="40" height="18" rx="9" fill="#f97316" fillOpacity="0.15" stroke="#f97316" strokeOpacity="0.6" />
<text x="200" y="74.5" textAnchor="middle" fontSize="9" fontWeight="700" letterSpacing="1" fill="#fb923c" fontFamily="Inter, sans-serif">AR</text>
{/* Shutter */}
<circle cx="200" cy="380" r="12" fill="none" stroke="white" strokeOpacity="0.4" strokeWidth="2" />
<circle cx="200" cy="380" r="8" fill="#f97316" />
</g>
{/* Notch */}
<rect x="172" y="46" width="56" height="8" rx="4" fill="#0b0b0b" />
{/* Floating particles */}
{[
{ cx: 70, cy: 120, r: 3, d: '3s' },
{ cx: 330, cy: 90, r: 2, d: '4s' },
{ cx: 345, cy: 260, r: 3, d: '3.6s' },
{ cx: 55, cy: 300, r: 2, d: '4.4s' },
{ cx: 95, cy: 210, r: 1.5, d: '2.8s' },
].map((p) => (
<circle key={`${p.cx}-${p.cy}`} cx={p.cx} cy={p.cy} r={p.r} fill="#f97316">
<animate attributeName="opacity" values="0.15;0.8;0.15" dur={p.d} repeatCount="indefinite" />
</circle>
))}
</svg>
);
}

View File

@ -1,43 +0,0 @@
// SVG armchair drawn in the coordinate space of <ArIllustration>; relies on its gradient/filter defs.
export function Armchair() {
return (
<g>
{/* Contact shadow */}
<ellipse cx="200" cy="324" rx="68" ry="11" fill="black" opacity="0.55" filter="url(#ar-blur)" />
{/* Back legs */}
<path d="M168 286 L173 286 L171 308 L168 308 Z" fill="url(#chair-wood)" />
<path d="M227 286 L232 286 L232 308 L229 308 Z" fill="url(#chair-wood)" />
{/* Backrest */}
<path d="M156 264 C150 222 158 192 176 182 C190 175 210 175 224 182 C242 192 250 222 244 264 Z" fill="url(#chair-back)" />
<path d="M166 256 C162 222 168 199 182 191 C194 186 206 186 218 191 C232 199 238 222 234 256 Z" fill="url(#chair-back-inner)" />
<path d="M176 186 C190 179 210 179 224 186" fill="none" stroke="#fed7aa" strokeOpacity="0.45" strokeWidth="1.5" strokeLinecap="round" />
{/* Tufting */}
<g fill="#7c2d12">
{[[184, 210], [200, 206], [216, 210], [192, 230], [208, 230]].map(([cx, cy]) => (
<circle key={`${cx}-${cy}`} cx={cx} cy={cy} r="1.8" />
))}
</g>
<g fill="none" stroke="#7c2d12" strokeOpacity="0.35" strokeWidth="0.8">
<path d="M184 210 L192 230 L200 206 L208 230 L216 210" />
</g>
{/* Seat base */}
<path d="M152 280 C175 290 225 290 248 280 L248 298 C225 308 175 308 152 298 Z" fill="url(#chair-base)" />
{/* Seat cushion */}
<path d="M154 276 C160 262 240 262 246 276 C246 286 224 292 200 292 C176 292 154 286 154 276 Z" fill="url(#chair-cushion)" />
<ellipse cx="200" cy="270" rx="30" ry="3.5" fill="white" opacity="0.2" />
{/* Armrests */}
<path d="M140 300 C136 270 138 248 150 238 C158 232 168 236 168 246 L168 296 Z" fill="url(#chair-arm-left)" />
<path d="M260 300 C264 270 262 248 250 238 C242 232 232 236 232 246 L232 296 Z" fill="url(#chair-arm-right)" />
<path d="M150 238 C158 232 168 236 168 246" fill="none" stroke="#fed7aa" strokeOpacity="0.5" strokeWidth="1.5" strokeLinecap="round" />
<path d="M250 238 C242 232 232 236 232 246" fill="none" stroke="#fed7aa" strokeOpacity="0.35" strokeWidth="1.5" strokeLinecap="round" />
{/* Front legs */}
<path d="M159 299 L166 299 L163 326 L160 326 Z" fill="url(#chair-wood)" />
<path d="M234 299 L241 299 L241 326 L238 326 Z" fill="url(#chair-wood)" />
</g>
);
}

View File

@ -1,36 +0,0 @@
import { LogoMark } from '~/components/logo-mark';
import { ArIllustration } from '~/components/auth/ar-illustration';
export function AuthBrandPanel() {
return (
<aside className="relative hidden overflow-hidden border-r border-neutral-900 bg-[#0A0A0A] p-12 lg:flex lg:flex-col lg:justify-between">
<div className="pointer-events-none absolute top-1/3 left-1/2 h-[520px] w-[520px] -translate-x-1/2 -translate-y-1/2 rounded-full bg-orange-500/10 blur-[140px]" />
{/* Real-world floor grid */}
<div className="pointer-events-none absolute inset-x-0 bottom-0 h-1/2 [perspective:600px]">
<div
className="absolute inset-0 origin-bottom [transform:rotateX(60deg)] opacity-30"
style={{
backgroundImage:
'linear-gradient(to right, rgba(249,115,22,0.25) 1px, transparent 1px), linear-gradient(to bottom, rgba(249,115,22,0.25) 1px, transparent 1px)',
backgroundSize: '48px 48px',
maskImage: 'linear-gradient(to top, black 10%, transparent 90%)',
WebkitMaskImage: 'linear-gradient(to top, black 10%, transparent 90%)',
}}
/>
</div>
<div className="relative z-10">
<LogoMark className="h-10 w-10 text-2xl" />
</div>
<div className="relative z-10 flex flex-1 items-center justify-center py-8">
<ArIllustration />
</div>
<p className="relative z-10 text-2xl font-semibold tracking-tight text-white">
Step into <span className="text-orange-500">augmented reality.</span>
</p>
</aside>
);
}

View File

@ -0,0 +1,12 @@
import { Text } from '~/components/ui/text';
export function AccessNote({ className }: { className?: string }) {
return (
<Text tone='muted' className={className}>
Need access?{' '}
<Text as='span' variant='inherit' tone='emphasis'>
Ask your workspace admin
</Text>
</Text>
);
}

View File

@ -0,0 +1,106 @@
import { useState } from 'react';
import { Controller, useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { useNavigation, useSubmit } from 'react-router';
import { Mail, Shield } from 'lucide-react';
import { toast } from 'sonner';
import { AccessNote } from '~/components/auth/form/access-note';
import { PasswordInput } from '~/components/auth/form/password-input';
import { SignInButton } from '~/components/auth/form/sign-in-button';
import { Alert } from '~/components/ui/alert';
import { Button } from '~/components/ui/button';
import { Checkbox } from '~/components/ui/checkbox';
import { Field } from '~/components/ui/field';
import { IconInput } from '~/components/ui/icon-input';
import { Text } from '~/components/ui/text';
import { ROUTES } from '~/data/routes';
import { loginSchema, type LoginValues } from '~/schemas/auth/login';
import type { LoginFailure } from '~/types/auth';
type TextField = 'email' | 'password';
export function LoginForm({ failure }: { failure?: LoginFailure }) {
const submit = useSubmit();
const navigation = useNavigation();
const busy = navigation.state !== 'idle';
// Loading a page other than /login means the sign-in worked and the admin is on its way
const signedIn = navigation.state === 'loading' && navigation.location.pathname !== ROUTES.login;
// The failure the user has typed since; its banner and red borders are hidden
const [dismissed, setDismissed] = useState<LoginFailure>();
const shown = failure === dismissed ? undefined : failure;
const {
register,
control,
clearErrors,
handleSubmit,
formState: { errors },
} = useForm<LoginValues>({ resolver: zodResolver(loginSchema), reValidateMode: 'onSubmit', defaultValues: { email: '', password: '', remember: true } });
// Typing clears that field's error and the banner
const textField = (name: TextField) => ({
...register(name, {
onChange: () => {
clearErrors(name);
setDismissed(failure);
},
}),
'aria-invalid': !!errors[name] || !!shown?.invalidCredentials,
});
return (
<form
onSubmit={handleSubmit((values) => submit(values, { method: 'post', encType: 'application/json' }))}
noValidate
className='flex w-full max-w-[372px] flex-col gap-7.5'
>
<div className='flex flex-col gap-2.5'>
<Text as='span' variant='kicker'>Admin portal</Text>
<Text as='h1' variant='headline'>Welcome back</Text>
<Text variant='body-lg' tone='subtle'>Sign in to manage client projects, 3D assets and QR codes.</Text>
</div>
{shown && <Alert>{shown.error}</Alert>}
<fieldset disabled={busy} className='flex min-w-0 flex-col gap-4.5'>
<Field label='Email' htmlFor='email' error={errors.email?.message}>
<IconInput id='email' type='email' icon={Mail} size='lg' autoComplete='email' autoFocus placeholder='you@company.com' {...textField('email')} />
</Field>
<Field
label='Password'
htmlFor='password'
error={errors.password?.message}
action={
<Button type='button' variant='link-muted' size='inline' onClick={() => toast.info('Ask your workspace admin to reset your password.')}>
Forgot password?
</Button>
}
>
<PasswordInput id='password' size='lg' autoComplete='current-password' placeholder='Your password' {...textField('password')} />
</Field>
<Controller
control={control}
name='remember'
render={({ field: { value, onChange } }) => (
<div className='flex items-center gap-2.5 self-start'>
<Checkbox id='remember' checked={value} onCheckedChange={(checked) => onChange(checked === true)} />
<Text as='label' htmlFor='remember' className='cursor-pointer'>
Keep me signed in for 30 days
</Text>
</div>
)}
/>
</fieldset>
<div className='flex flex-col gap-4'>
<SignInButton state={signedIn ? 'done' : busy ? 'busy' : 'idle'} />
<Text variant='caption' className='flex items-center justify-center gap-2'>
<Shield size={13} />
Access is restricted to authorised team members.
</Text>
<AccessNote className='text-center sm:hidden' />
</div>
</form>
);
}

View File

@ -0,0 +1,26 @@
import { AccessNote } from '~/components/auth/form/access-note';
import { LoginForm } from '~/components/auth/form/login-form';
import { BrandLockup } from '~/components/ui/brand-lockup';
import { Text } from '~/components/ui/text';
import { BRAND } from '~/data/brand';
import type { LoginFailure } from '~/types/auth';
// Full height on phones; natural height above the showcase on tablets; a fixed column beside it from 960px
export function LoginPanel({ failure }: { failure?: LoginFailure }) {
return (
<main className='flex min-h-screen flex-col bg-background px-6 pt-5 pb-7 sm:min-h-0 split:min-h-screen split:w-[420px] split:shrink-0 split:border-l split:border-border-divider split:px-10 split:pt-9 split:pb-8 wide:w-[480px] wide:px-14 wide:pt-10 wide:pb-9'>
<div className='flex min-h-8 items-center justify-between gap-3'>
<BrandLockup size='md' className='split:hidden' />
<AccessNote className='ml-auto hidden sm:block' />
</div>
<div className='flex flex-1 items-center justify-center py-8 sm:py-14 split:py-12'>
<LoginForm failure={failure} />
</div>
<Text variant='caption' tone='placeholder'>
© {new Date().getFullYear()} {BRAND.name}
</Text>
</main>
);
}

View File

@ -0,0 +1,39 @@
import { useState } from 'react';
import { Lock } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { IconInput } from '~/components/ui/icon-input';
import { InlineMessage } from '~/components/ui/inline-message';
import type { InputProps } from '~/components/ui/input';
export function PasswordInput(props: Omit<InputProps, 'type'>) {
const [visible, setVisible] = useState(false);
const [capsLock, setCapsLock] = useState(false);
return (
<>
<IconInput
icon={Lock}
type={visible ? 'text' : 'password'}
onKeyUp={(e) => setCapsLock(e.getModifierState('CapsLock'))}
trailing={
<Button
type='button'
variant='ghost'
size='sm'
aria-label={visible ? 'Hide password' : 'Show password'}
aria-pressed={visible}
onClick={() => setVisible((v) => !v)}
>
{visible ? 'Hide' : 'Show'}
</Button>
}
{...props}
onBlur={(e) => {
setCapsLock(false);
props.onBlur?.(e);
}}
/>
{capsLock && <InlineMessage tone='warning'>Caps Lock is on</InlineMessage>}
</>
);
}

View File

@ -0,0 +1,22 @@
import { ArrowRight, Loader2 } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { BRAND } from '~/data/brand';
export type SignInState = 'idle' | 'busy' | 'done';
const LABELS: Record<SignInState, string> = {
idle: 'Sign in',
busy: 'Signing in…',
done: `Signed in. Opening ${BRAND.product}`,
};
export function SignInButton({ state }: { state: SignInState }) {
const working = state !== 'idle';
return (
<Button type='submit' size='xl' variant={state === 'done' ? 'success' : 'default'} disabled={working} aria-busy={working} className='group w-full'>
{state === 'busy' && <Loader2 size={16} className='animate-spin' />}
{LABELS[state]}
{state === 'idle' && <ArrowRight size={15} className='transition-transform group-hover:translate-x-0.5' />}
</Button>
);
}

View File

@ -0,0 +1,68 @@
import { useId } from 'react';
// Gradient direction (x2, y2) and colour stops, spread evenly
const GRADIENTS = {
back: { x2: 1, y2: 1, stops: ['accent-400', 'accent-700', 'accent-900'] },
backInner: { x2: 0, y2: 1, stops: ['primary', 'accent-800'] },
cushion: { x2: 0, y2: 1, stops: ['accent-300', 'accent-600'] },
base: { x2: 0, y2: 1, stops: ['accent-700', 'accent-900'] },
armLeft: { x2: 1, y2: 0, stops: ['accent-800', 'accent-600'] },
armRight: { x2: 1, y2: 0, stops: ['primary', 'accent-800'] },
wood: { x2: 0, y2: 1, stops: ['wood-light', 'wood-dark'] },
} as const;
const TUFTS = [[184, 210], [200, 206], [216, 210], [192, 230], [208, 230]] as const;
// An orange armchair, the stand-in 3D model in the login story. Its contact shadow sits at 86% of the height;
// the view box leaves room around it so the blur isn't clipped.
export function Armchair({ className }: { className?: string }) {
const id = useId();
const fill = (name: keyof typeof GRADIENTS) => `url(#${id}${name})`;
return (
<svg viewBox='115 165 170 185' className={className} aria-hidden='true'>
<defs>
{Object.entries(GRADIENTS).map(([name, { x2, y2, stops }]) => (
<linearGradient key={name} id={`${id}${name}`} x1='0' y1='0' x2={x2} y2={y2}>
{stops.map((color, i) => (
<stop key={color} offset={i / (stops.length - 1)} stopColor={`var(--color-${color})`} />
))}
</linearGradient>
))}
<filter id={`${id}blur`} x='-50%' y='-50%' width='200%' height='200%'>
<feGaussianBlur stdDeviation='5' />
</filter>
</defs>
<ellipse cx='200' cy='324' rx='68' ry='11' fill='var(--color-shadow)' opacity='0.55' filter={`url(#${id}blur)`} />
{/* Back legs */}
<path d='M168 286 L173 286 L171 308 L168 308 Z' fill={fill('wood')} />
<path d='M227 286 L232 286 L232 308 L229 308 Z' fill={fill('wood')} />
{/* Backrest with tufting */}
<path d='M156 264 C150 222 158 192 176 182 C190 175 210 175 224 182 C242 192 250 222 244 264 Z' fill={fill('back')} />
<path d='M166 256 C162 222 168 199 182 191 C194 186 206 186 218 191 C232 199 238 222 234 256 Z' fill={fill('backInner')} />
<path d='M176 186 C190 179 210 179 224 186' fill='none' stroke='var(--color-accent-200)' strokeOpacity='0.45' strokeWidth='1.5' strokeLinecap='round' />
<path d='M184 210 L192 230 L200 206 L208 230 L216 210' fill='none' stroke='var(--color-accent-900)' strokeOpacity='0.35' strokeWidth='0.8' />
{TUFTS.map(([cx, cy]) => (
<circle key={`${cx}-${cy}`} cx={cx} cy={cy} r='1.8' fill='var(--color-accent-900)' />
))}
{/* Seat */}
<path d='M152 280 C175 290 225 290 248 280 L248 298 C225 308 175 308 152 298 Z' fill={fill('base')} />
<path d='M154 276 C160 262 240 262 246 276 C246 286 224 292 200 292 C176 292 154 286 154 276 Z' fill={fill('cushion')} />
<ellipse cx='200' cy='270' rx='30' ry='3.5' fill='var(--color-primary-foreground)' opacity='0.2' />
{/* Armrests */}
<path d='M140 300 C136 270 138 248 150 238 C158 232 168 236 168 246 L168 296 Z' fill={fill('armLeft')} />
<path d='M260 300 C264 270 262 248 250 238 C242 232 232 236 232 246 L232 296 Z' fill={fill('armRight')} />
<path d='M150 238 C158 232 168 236 168 246' fill='none' stroke='var(--color-accent-200)' strokeOpacity='0.5' strokeWidth='1.5' strokeLinecap='round' />
<path d='M250 238 C242 232 232 236 232 246' fill='none' stroke='var(--color-accent-200)' strokeOpacity='0.35' strokeWidth='1.5' strokeLinecap='round' />
{/* Front legs */}
<path d='M159 299 L166 299 L163 326 L160 326 Z' fill={fill('wood')} />
<path d='M234 299 L241 299 L241 326 L238 326 Z' fill={fill('wood')} />
</svg>
);
}

View File

@ -0,0 +1,54 @@
import { useId, useState } from 'react';
import { StoryPhone } from '~/components/auth/showcase/story-phone';
import { StorySteps } from '~/components/auth/showcase/story-steps';
import { BrandLockup } from '~/components/ui/brand-lockup';
import { Glow } from '~/components/ui/glow';
import { Text } from '~/components/ui/text';
import { LOGIN_STORY } from '~/data/auth/constants';
const fadeUp = 'linear-gradient(to top, black, transparent)';
const floorGrid = {
backgroundImage:
'linear-gradient(var(--color-border-divider) 1px, transparent 1px), linear-gradient(90deg, var(--color-border-divider) 1px, transparent 1px)',
backgroundSize: '64px 64px',
maskImage: fadeUp,
WebkitMaskImage: fadeUp,
};
// Hidden on phones; under the form on tablets; the left side from 960px, with the text beside the phone from 1200px
export function LoginShowcase() {
const headingId = useId();
const [story, setStory] = useState({ step: 0, cycle: 0 });
// A new cycle restarts the progress bar, even when the current step is picked again
const select = (step: number) => setStory((s) => ({ step, cycle: s.cycle + 1 }));
const steps = { active: story.step, cycle: story.cycle, onSelect: select, onComplete: () => select((story.step + 1) % LOGIN_STORY.length) };
return (
<aside
aria-labelledby={headingId}
className='relative hidden flex-col overflow-hidden border-t border-border-divider bg-sidebar px-6 pt-12 pb-16 sm:flex split:order-first split:min-h-screen split:flex-1 split:border-t-0 split:px-10 split:py-9 wide:px-14 wide:py-10'
>
<Glow intensity='strong' className='top-[48%] left-1/2 h-[45%] w-1/2 -translate-1/2 wide:left-[72%]' />
<div aria-hidden='true' className='pointer-events-none absolute -inset-x-[30%] -bottom-[8%] h-[42%] origin-bottom [transform:perspective(600px)_rotateX(64deg)]' style={floorGrid} />
<BrandLockup size='md' className='relative hidden split:flex' />
<div className='relative flex flex-1 flex-col items-center justify-center gap-8 split:pt-10 split:pb-2 wide:flex-row wide:gap-12'>
<div className='flex w-full max-w-[520px] flex-col items-center gap-5.5 text-center wide:max-w-[400px] wide:flex-[1_1_300px] wide:items-stretch wide:gap-8 wide:text-left'>
<div className='flex flex-col gap-3.5'>
<Text as='h2' id={headingId} variant='hero'>
Step into{' '}
<Text as='span' variant='inherit' tone='primary'>
augmented reality.
</Text>
</Text>
<Text variant='lead'>From a printed tag to a sofa in the living room in three taps. No app to install.</Text>
</div>
<StorySteps layout='card' {...steps} className='hidden wide:flex' />
<StorySteps layout='pill' {...steps} className='wide:hidden' />
</div>
<StoryPhone step={story.step} />
</div>
</aside>
);
}

View File

@ -0,0 +1,13 @@
import { ArPage } from '~/components/ui/ar-page';
import { DEMO_CLIENT, DEMO_MODEL_IMAGE, DEMO_MODEL_NAME } from '~/data/auth/constants';
// Step 2: the customer AR page, with the client logo next to thob's
export function OpenScreen() {
return (
<ArPage brand={DEMO_CLIENT} modelName={DEMO_MODEL_NAME} className='min-h-0 flex-1'>
<div className='absolute inset-0 flex items-center justify-center'>
<img src={DEMO_MODEL_IMAGE} alt='' className='w-[84%]' />
</div>
</ArPage>
);
}

View File

@ -0,0 +1,32 @@
import { ClientLogo } from '~/components/ui/client-logo';
import { LogoMark } from '~/components/ui/logo-mark';
import { Text } from '~/components/ui/text';
import { DEMO_CLIENT, DEMO_MODEL_IMAGE } from '~/data/auth/constants';
const room = 'linear-gradient(180deg, var(--color-room-wall) 50%, var(--color-room-floor) 50%, var(--color-room-floor-near))';
// Step 3: the model placed on the floor of the customer's room
export function PlaceScreen() {
return (
<>
<div className='absolute inset-0' style={{ backgroundImage: room }} />
<div className='relative flex items-start justify-between px-4 pt-4'>
<ClientLogo brand={DEMO_CLIENT} variant='chip' size='sm' />
<LogoMark size='sm' surface='viewer' />
</div>
<Text as='span' variant='stamp' tone='secondary' className='absolute top-24 left-4'>
Live camera · your room
</Text>
{/* Standing on the floor, just below the horizon */}
<img src={DEMO_MODEL_IMAGE} alt='' className='absolute top-[60%] left-1/2 w-[200px] max-w-none -translate-x-1/2 -translate-y-[90%]' />
<Text as='span' variant='meta' tone='emphasis' className='absolute top-[72%] left-1/2 -translate-x-1/2 whitespace-nowrap rounded-full bg-shadow/60 px-2.5 py-1.5'>
Placed · 1:1 scale
</Text>
<span className='absolute bottom-7 left-1/2 flex size-14.5 -translate-x-1/2 items-center justify-center rounded-full border-3 border-text-primary'>
<span className='size-11 rounded-full bg-text-primary' />
</span>
</>
);
}

View File

@ -0,0 +1,47 @@
import { ClientLogo } from '~/components/ui/client-logo';
import { Text } from '~/components/ui/text';
import { DEMO_CLIENT_MARK, DEMO_QR_CODE } from '~/data/auth/constants';
import { getFrontendHost } from '~/lib/assets/qr';
import { cn } from '~/lib/utils';
const CORNERS = [
'top-0 left-0 rounded-tl-card-sm border-t-3 border-l-3',
'top-0 right-0 rounded-tr-card-sm border-t-3 border-r-3',
'bottom-0 left-0 rounded-bl-card-sm border-b-3 border-l-3',
'bottom-0 right-0 rounded-br-card-sm border-b-3 border-r-3',
];
// Step 1: the camera finds the printed QR code (the phone's dark screen is the camera view)
export function ScanScreen() {
return (
<div className='relative flex flex-1 flex-col items-center'>
<Text as='span' variant='caption-strong' className='mt-5.5 rounded-full bg-shadow/55 px-3.5 py-1.75'>
Camera
</Text>
<div className='flex flex-1 items-center justify-center'>
<div className='relative flex size-49 items-center justify-center'>
{CORNERS.map((corner) => (
<span key={corner} className={cn('absolute size-7.5 border-primary', corner)} />
))}
{/* The code is 33 squares across: 132px keeps every square exactly 4px, so it renders sharp */}
<div className='relative rounded-group bg-qr-surface p-1.5'>
<img src={DEMO_QR_CODE} alt='' className='block size-33' />
<ClientLogo brand={DEMO_CLIENT_MARK} variant='mark' size='sm' className='absolute top-1/2 left-1/2 -translate-1/2' />
</div>
{/* Thin, softly lit scan line; moved with transform only, and hidden with reduced motion */}
<span className='absolute inset-x-3 top-0 h-full animate-scan motion-reduce:hidden'>
<span className='block h-0.5 rounded-full bg-linear-to-r from-transparent via-primary to-transparent shadow-[0_0_6px] shadow-primary/40' />
</span>
</div>
</div>
<div className='mb-5.5 flex items-center gap-2 rounded-card bg-qr-surface px-4 py-2.5 shadow-[0_10px_24px] shadow-shadow/35'>
<span className='size-2 rounded-full bg-primary' />
<Text as='span' variant='caption-strong' tone='ink'>
Open “{getFrontendHost()}” in Safari
</Text>
</div>
</div>
);
}

View File

@ -0,0 +1,26 @@
import { OpenScreen } from '~/components/auth/showcase/open-screen';
import { PlaceScreen } from '~/components/auth/showcase/place-screen';
import { ScanScreen } from '~/components/auth/showcase/scan-screen';
import { PhoneFrame } from '~/components/ui/phone-frame';
// One screen per LOGIN_STORY step, in the same order
const SCREENS = [
{ Screen: ScanScreen, tone: 'dark' },
{ Screen: OpenScreen, tone: 'light' },
{ Screen: PlaceScreen, tone: 'dark' },
] as const;
// Decorative: hidden from assistive tech and never focusable. Tilted only in the wide layout.
export function StoryPhone({ step }: { step: number }) {
const { Screen, tone } = SCREENS[step] ?? SCREENS[0];
return (
<div aria-hidden='true' inert className='relative shrink-0 perspective-[1600px]'>
<span className='absolute inset-x-[8%] -bottom-6.5 h-10 rounded-full bg-radial from-shadow/70 to-transparent to-70% blur-sm' />
<PhoneFrame tone={tone} className='h-[540px] w-[260px] wide:h-[600px] wide:w-[290px] wide:rotate-x-3 wide:-rotate-y-12'>
<div key={step} className='flex min-h-0 flex-1 animate-screen-in flex-col'>
<Screen />
</div>
</PhoneFrame>
</div>
);
}

View File

@ -0,0 +1,61 @@
import { cva } from 'class-variance-authority';
import { Text } from '~/components/ui/text';
import { LOGIN_STORY_STEP_MS, type LoginStoryStep } from '~/data/auth/constants';
import { cn } from '~/lib/utils';
const shell = cva('relative flex cursor-pointer overflow-hidden text-left ring-1 ring-inset transition-colors duration-200', {
variants: {
layout: {
card: 'w-full gap-4 rounded-card-sm px-4 pt-3.5 pb-4 hover:bg-surface-dialog',
pill: 'h-[38px] items-center gap-2 whitespace-nowrap rounded-full px-3.5',
},
active: { true: 'bg-surface', false: '' },
},
compoundVariants: [
{ layout: 'card', active: true, className: 'ring-border-dialog' },
{ layout: 'card', active: false, className: 'ring-transparent' },
{ layout: 'pill', active: true, className: 'ring-border-control' },
{ layout: 'pill', active: false, className: 'ring-border-divider' },
],
});
interface StoryStepProps {
step: LoginStoryStep;
// card: number, title and description (wide layout); pill: number and title
layout: 'card' | 'pill';
active: boolean;
// Restarts the progress bar
cycle: number;
onSelect: () => void;
onComplete: () => void;
}
export function StoryStep({ step, layout, active, cycle, onSelect, onComplete }: StoryStepProps) {
const card = layout === 'card';
return (
<button type='button' aria-current={active ? 'step' : undefined} onClick={onSelect} className={shell({ layout, active })}>
<Text as='span' variant='mono' tone={active ? 'primary' : 'placeholder'} className={cn(card && 'pt-0.5')}>
{step.number}
</Text>
{card ? (
<span className='flex min-w-0 flex-col gap-1'>
<Text as='span' variant='subheading' tone={active ? 'default' : 'subtle'}>{step.title}</Text>
<Text as='span' variant='body' tone={active ? 'secondary' : 'placeholder'}>{step.description}</Text>
</span>
) : (
<Text as='span' variant='label' tone={active ? 'default' : 'subtle'}>{step.title}</Text>
)}
{/* Fills over one step; its end moves the story on. With reduced motion it shows full and the story waits for clicks. */}
{active && (
<span aria-hidden='true' className={cn('absolute bottom-0 h-0.5 overflow-hidden rounded-full bg-border-divider', card ? 'inset-x-4' : 'inset-x-3.5')}>
<span
key={cycle}
onAnimationEnd={onComplete}
className='block h-full origin-left animate-story-progress bg-primary motion-reduce:animate-none'
style={{ animationDuration: `${LOGIN_STORY_STEP_MS}ms` }}
/>
</span>
)}
</button>
);
}

View File

@ -0,0 +1,24 @@
import { StoryStep } from '~/components/auth/showcase/story-step';
import { LOGIN_STORY } from '~/data/auth/constants';
import { cn } from '~/lib/utils';
interface StoryStepsProps {
layout: 'card' | 'pill';
active: number;
cycle: number;
onSelect: (step: number) => void;
onComplete: () => void;
className?: string;
}
export function StorySteps({ layout, active, cycle, onSelect, onComplete, className }: StoryStepsProps) {
return (
<ol className={cn('flex', layout === 'card' ? 'flex-col gap-1' : 'flex-wrap justify-center gap-2', className)}>
{LOGIN_STORY.map((step, i) => (
<li key={step.number}>
<StoryStep step={step} layout={layout} active={i === active} cycle={cycle} onSelect={() => onSelect(i)} onComplete={onComplete} />
</li>
))}
</ol>
);
}

View File

@ -1,9 +0,0 @@
import { cn } from '~/lib/utils';
export function LogoMark({ className }: { className?: string }) {
return (
<div className={cn('flex items-center justify-center rounded-xl border border-neutral-800 bg-black', className)}>
<span className="select-none font-extrabold leading-none text-orange-500">t.</span>
</div>
);
}

View File

@ -0,0 +1,40 @@
import { Pencil } from 'lucide-react';
import { AddButton } from '~/components/ui/add-button';
import { Button } from '~/components/ui/button';
import { LogoTile } from '~/components/ui/logo-tile';
import { PageBreadcrumb } from '~/components/ui/page-breadcrumb';
import { Text } from '~/components/ui/text';
import { ProjectMeta } from '~/components/projects/detail/project-meta';
import { ROUTES } from '~/data/routes';
import { toBrand } from '~/services/asset-media';
import type { Project } from '~/types/project';
interface ProjectHeaderProps {
project: Project;
assetCount: number;
onEdit: () => void;
onNewAsset: () => void;
}
export function ProjectHeader({ project, assetCount, onEdit, onNewAsset }: ProjectHeaderProps) {
return (
<>
<PageBreadcrumb trail={[{ label: 'Projects', to: ROUTES.projects }]} current={project.name} />
<div className='flex flex-wrap items-center gap-[22px]'>
<LogoTile brand={toBrand(project)} size='header' />
<div className='flex min-w-60 flex-1 flex-col gap-2'>
<Text as='h1' variant='display'>{project.name}</Text>
{project.description && <Text className='text-pretty'>{project.description}</Text>}
<ProjectMeta project={project} assetCount={assetCount} />
</div>
<div className='flex items-center gap-2.5'>
<Button variant='secondary' onClick={onEdit}>
<Pencil size={13} />
Edit project
</Button>
<AddButton label='New asset' onClick={onNewAsset} />
</div>
</div>
</>
);
}

View File

@ -0,0 +1,40 @@
import { ColorTag } from '~/components/ui/color-tag';
import { Text } from '~/components/ui/text';
import { AR_BUTTON_LABEL } from '~/data/ar-viewer/constants';
import { DEFAULT_BRAND_COLOR, LOGO_BACKGROUND_PRESETS } from '~/data/projects/constants';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { formatDate } from '~/lib/format';
import { cn } from '~/lib/utils';
import { getButtonStyle } from '~/services/asset-media';
import type { Project } from '~/types/project';
export function ProjectMeta({ project, assetCount }: { project: Project; assetCount: number }) {
const { settings } = useAdminData();
const archived = project.status === 'archived';
const button = getButtonStyle(project, settings);
const preset = LOGO_BACKGROUND_PRESETS[project.logo_bg];
return (
<div className='flex flex-wrap items-center gap-x-3.5 gap-y-1.5'>
<Text as='span' variant='caption' className='flex items-center gap-1.5'>
<span className={cn('h-1.5 w-1.5 rounded-full', archived ? 'bg-text-muted' : 'bg-success')} />
{archived ? 'Archived' : 'Active'}
</Text>
<Text as='span' variant='caption'>
{assetCount} {assetCount === 1 ? 'asset' : 'assets'}
</Text>
<Text as='span' variant='caption'>Created {formatDate(project.created)}</Text>
<Text as='span' variant='caption' className='flex items-center gap-1.5'>
Logo backing
<ColorTag color={project.logo_bg_color || preset.value} label={project.logo_bg_color || preset.label} />
</Text>
{settings.brand_button && (
<Text as='span' variant='caption' className='flex items-center gap-1.5'>
Button
<ColorTag color={button.color ?? DEFAULT_BRAND_COLOR} label={button.color ?? 'thob default'} />
“{button.label ?? AR_BUTTON_LABEL}”
</Text>
)}
</div>
);
}

View File

@ -0,0 +1,32 @@
import { useId } from 'react';
import { useFormContext, useWatch } from 'react-hook-form';
import { SwitchRow } from '~/components/ui/switch-row';
import { Text } from '~/components/ui/text';
import { AR_PAGE_TOGGLES } from '~/data/projects/constants';
import type { ProjectFormValues } from '~/schemas/projects/project-form';
// What the client's AR page shows around the model
export function ArPageFields() {
const headingId = useId();
const { control, setValue } = useFormContext<ProjectFormValues>();
const arPage = useWatch({ control, name: 'arPage' });
return (
<div role='group' aria-labelledby={headingId} className='flex flex-col gap-2'>
<Text as='span' id={headingId} variant='label'>
AR page
</Text>
{AR_PAGE_TOGGLES.map(({ key, label, hint }) => (
<SwitchRow
key={key}
framed
id={`ar-page-${key}`}
label={label}
hint={hint}
checked={arPage[key]}
onCheckedChange={(checked) => setValue(`arPage.${key}`, checked, { shouldDirty: true })}
/>
))}
</div>
);
}

View File

@ -0,0 +1,59 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { ColorPicker } from '~/components/ui/color-picker';
import { Field } from '~/components/ui/field';
import { Input } from '~/components/ui/input';
import { BUTTON_CUSTOM_LIMITS, BUTTON_TEXT_COLORS } from '~/data/projects/constants';
import type { ProjectFormValues } from '~/schemas/projects/project-form';
type Measurement = keyof typeof BUTTON_CUSTOM_LIMITS;
const MEASUREMENTS = Object.keys(BUTTON_CUSTOM_LIMITS) as Measurement[];
// An empty box is "not set": no width means the button fits its label; anything else must be filled in.
// The form also passes stored values through here (a saved empty width is null), not only typed text.
const toNumber = (optional: boolean) => (value: unknown) => {
if (value === '' || value === null || value === undefined) return optional ? null : Number.NaN;
return Number(value);
};
// Exact button measurements for the "Custom" size
export function ButtonCustomFields() {
const { register, control, setValue, formState } = useFormContext<ProjectFormValues>();
const [borderWidth, borderColor] = useWatch({ control, name: ['arPage.buttonCustom.borderWidth', 'arPage.buttonCustom.borderColor'] });
const errors = formState.errors.arPage?.buttonCustom;
return (
<div className='flex flex-col gap-4 rounded-control p-3.5 ring-1 ring-inset ring-border-control'>
<div className='grid grid-cols-2 gap-x-3 gap-y-4'>
{MEASUREMENTS.map((key) => {
const { label, min, max } = BUTTON_CUSTOM_LIMITS[key];
const optional = key === 'width';
return (
<Field key={key} label={`${label} (px)`} htmlFor={`button-${key}`} error={errors?.[key]?.message}>
<Input
id={`button-${key}`}
type='number'
size='sm'
min={min}
max={max}
placeholder={optional ? 'Fits the label' : undefined}
aria-invalid={!!errors?.[key]}
{...register(`arPage.buttonCustom.${key}`, { setValueAs: toNumber(optional) })}
/>
</Field>
);
})}
</div>
{borderWidth > 0 && (
<Field label='Border colour' htmlFor='button-border-color' error={errors?.borderColor?.message}>
<ColorPicker
id='button-border-color'
label='Border colour'
value={borderColor}
presets={BUTTON_TEXT_COLORS}
onChange={(hex) => setValue('arPage.buttonCustom.borderColor', hex, { shouldDirty: true })}
/>
</Field>
)}
</div>
);
}

View File

@ -0,0 +1,58 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { Field } from '~/components/ui/field';
import { Input } from '~/components/ui/input';
import { SegmentedControl } from '~/components/ui/segmented-control';
import { ButtonCustomFields } from '~/components/projects/form/button-custom-fields';
import { ColorField } from '~/components/projects/form/color-field';
import { AR_BUTTON_LABEL } from '~/data/ar-viewer/constants';
import { BRAND_COLORS, BUTTON_LABEL_MAX, BUTTON_SIZE_OPTIONS, BUTTON_SIZES, BUTTON_TEXT_COLORS } from '~/data/projects/constants';
import type { ProjectFormValues } from '~/schemas/projects/project-form';
import type { ButtonSize } from '~/types/project';
// The client's "View in your space" button: colour, text colour, label and size
export function ButtonStyleFields() {
const { register, control, setValue, formState } = useFormContext<ProjectFormValues>();
const [size, custom] = useWatch({ control, name: ['arPage.buttonSize', 'arPage.buttonCustom'] });
// Custom starts from the preset that was selected, so the button doesn't jump
const changeSize = (next: ButtonSize) => {
if (next === 'custom' && size !== 'custom') {
const preset = BUTTON_SIZES[size === 'full' ? 'md' : size];
setValue('arPage.buttonCustom', { ...custom, height: preset.height, paddingX: preset.paddingX, radius: preset.height / 2, width: null }, { shouldDirty: true });
}
setValue('arPage.buttonSize', next, { shouldDirty: true });
};
return (
<>
<ColorField name='brandColor' label='Button colour' presets={BRAND_COLORS} />
<ColorField name='buttonTextColor' label='Button text colour' presets={BUTTON_TEXT_COLORS} />
<Field
label='Button label'
htmlFor='project-button-label'
requirement='optional'
hint={`Leave empty to use “${AR_BUTTON_LABEL}”.`}
error={formState.errors.buttonLabel?.message}
>
<Input
id='project-button-label'
placeholder={AR_BUTTON_LABEL}
maxLength={BUTTON_LABEL_MAX}
aria-invalid={!!formState.errors.buttonLabel}
{...register('buttonLabel')}
/>
</Field>
<Field label='Button size'>
<SegmentedControl
label='Button size'
size='sm'
surface='sunken'
value={size}
options={BUTTON_SIZE_OPTIONS}
onChange={changeSize}
/>
</Field>
{size === 'custom' && <ButtonCustomFields />}
</>
);
}

View File

@ -0,0 +1,24 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { ColorPicker } from '~/components/ui/color-picker';
import { Field } from '~/components/ui/field';
import type { ProjectFormValues } from '~/schemas/projects/project-form';
import type { ColorPreset } from '~/types/project';
interface ColorFieldProps {
name: 'brandColor' | 'buttonTextColor';
label: string;
presets: ColorPreset[];
}
// A project form colour bound straight to one form value
export function ColorField({ name, label, presets }: ColorFieldProps) {
const { control, setValue, formState } = useFormContext<ProjectFormValues>();
const value = useWatch({ control, name });
const id = `project-${name}`;
return (
<Field label={label} htmlFor={id} error={formState.errors[name]?.message}>
<ColorPicker id={id} label={label} value={value} presets={presets} onChange={(hex) => setValue(name, hex, { shouldDirty: true })} />
</Field>
);
}

View File

@ -0,0 +1,38 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { ColorPicker } from '~/components/ui/color-picker';
import { Field } from '~/components/ui/field';
import { LOGO_BACKGROUND_PRESETS } from '~/data/projects/constants';
import { isDarkColor } from '~/lib/color';
import type { ProjectFormValues } from '~/schemas/projects/project-form';
import type { LogoBackground } from '~/types/project';
const PRESET_KEYS = Object.keys(LOGO_BACKGROUND_PRESETS) as LogoBackground[];
const PRESETS = PRESET_KEYS.map((key) => LOGO_BACKGROUND_PRESETS[key]);
// Light / Dark presets or any custom colour; a custom colour also decides light vs dark for contrast
export function LogoBackgroundField() {
const { control, setValue } = useFormContext<ProjectFormValues>();
const [logoBg, logoBgColor] = useWatch({ control, name: ['logoBg', 'logoBgColor'] });
const onChange = (hex: string) => {
const preset = PRESET_KEYS.find((key) => LOGO_BACKGROUND_PRESETS[key].value === hex);
setValue('logoBg', preset ?? (isDarkColor(hex) ? 'dark' : 'light'), { shouldDirty: true });
setValue('logoBgColor', preset ? '' : hex, { shouldDirty: true });
};
return (
<Field
label='Logo background'
htmlFor='project-logo-bg'
hint='Backing behind the logo on the light AR page. Pick a dark colour for white or light logos.'
>
<ColorPicker
id='project-logo-bg'
label='Logo background'
value={logoBgColor || LOGO_BACKGROUND_PRESETS[logoBg].value}
presets={PRESETS}
onChange={onChange}
/>
</Field>
);
}

View File

@ -0,0 +1,79 @@
import { useState } from 'react';
import { useFormContext, useWatch } from 'react-hook-form';
import { Upload } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { DropZone } from '~/components/ui/drop-zone';
import { Field } from '~/components/ui/field';
import { LogoTile } from '~/components/ui/logo-tile';
import { Text } from '~/components/ui/text';
import { TextPair } from '~/components/ui/text-pair';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { fileTypeLabel, formatFileSize } from '~/lib/format';
import { logoAccept, logoFormatsLabel, prepareLogoFile } from '~/lib/projects/logo-file';
import type { ProjectFormValues } from '~/schemas/projects/project-form';
import type { BrandIdentity } from '~/types/project';
export function LogoField({ brand }: { brand: BrandIdentity }) {
const { settings } = useAdminData();
const { control, setValue, trigger, formState } = useFormContext<ProjectFormValues>();
const logo = useWatch({ control, name: 'logo' });
const [fileError, setFileError] = useState<string>();
const hasLogo = !!logo.file || !!logo.existing;
const update = (next: ProjectFormValues['logo']) => {
setValue('logo', next, { shouldDirty: true });
if (formState.isSubmitted) trigger('logo');
};
const onFile = async (file: File) => {
setFileError(undefined);
const result = await prepareLogoFile(file, settings.allow_svg_logos);
if ('error' in result) setFileError(result.error);
else update({ file: result.file, existing: logo.existing });
};
return (
<Field
label='Company logo'
requirement={settings.logo_required ? 'required' : 'optional'}
error={fileError ?? formState.errors.logo?.message}
hint={!hasLogo && !settings.logo_required ? 'No logo yet? The company name is shown as text instead.' : undefined}
>
<DropZone accept={logoAccept(settings.allow_svg_logos)} layout={hasLogo ? 'row' : 'stack'} filled={hasLogo} invalid={!!fileError} onFile={onFile}>
{hasLogo ? (
<div className='flex items-center gap-3.5'>
<LogoTile brand={brand} size='field' />
<TextPair
className='flex-1'
title={logo.file?.name ?? logo.existing}
meta={logo.file ? `${formatFileSize(logo.file.size)} · ${fileTypeLabel(logo.file)}` : 'Current logo'}
/>
<Button type='button' variant='ghost' size='sm' className='text-text-emphasis'>
Replace
</Button>
<Button
type='button'
variant='ghost'
size='sm'
className='text-danger hover:text-danger'
onClick={(e) => {
e.stopPropagation();
update({ file: null, existing: '' });
}}
>
Remove
</Button>
</div>
) : (
<>
<Upload size={18} className='text-text-secondary' />
<Text>
<Text as='span' variant='label' tone='primary'>Click to upload</Text> or drag a file here
</Text>
<Text variant='meta'>{logoFormatsLabel(settings.allow_svg_logos)} · up to 2 MB · transparent background recommended</Text>
</>
)}
</DropZone>
</Field>
);
}

View File

@ -0,0 +1,74 @@
import { FormProvider, useForm, useWatch } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { useFetcher } from 'react-router';
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '~/components/ui/dialog';
import { DialogActions } from '~/components/ui/dialog-actions';
import { ProjectFormFields } from '~/components/projects/form/project-form-fields';
import { ProjectPreview } from '~/components/projects/form/project-preview';
import { PROJECT_INTENT, type ProjectIntent } from '~/data/projects/constants';
import { ROUTES } from '~/data/routes';
import { useActionToast } from '~/hooks/use-action-toast';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import { useProjectFormBrand } from '~/hooks/projects/use-project-form-brand';
import { toProjectFormData } from '~/lib/projects/form-data';
import { toProjectFormValues, withLogoRule, type ProjectFormValues } from '~/schemas/projects/project-form';
import type { ActionResult } from '~/types/action';
import type { Project } from '~/types/project';
interface ProjectFormDialogProps {
open: boolean;
project: Project | null;
onOpenChange: (open: boolean) => void;
onCreated: (id: string) => void;
}
export function ProjectFormDialog({ open, project, onOpenChange, onCreated }: ProjectFormDialogProps) {
const { settings } = useAdminData();
const fetcher = useFetcher<ActionResult<ProjectIntent>>();
const form = useForm<ProjectFormValues>({ resolver: zodResolver(withLogoRule(settings.logo_required)), defaultValues: toProjectFormValues(project) });
const { brand, button, layout } = useProjectFormBrand(form.control, project);
const [name, logo] = useWatch({ control: form.control, name: ['name', 'logo'] });
const canSave = !!name.trim() && (!settings.logo_required || !!logo.file || !!logo.existing);
const intent = project ? PROJECT_INTENT.update : PROJECT_INTENT.create;
useActionToast(fetcher.data, (result) => {
onOpenChange(false);
if (result.intent === PROJECT_INTENT.create && result.id) onCreated(result.id);
});
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className='max-w-[920px]'>
<DialogHeader>
<DialogTitle>{project ? 'Edit project' : 'New project'}</DialogTitle>
<DialogDescription>A project is a client company. Its logo appears on every AR page in it.</DialogDescription>
</DialogHeader>
<FormProvider {...form}>
<form
noValidate
className='flex min-h-0 flex-1 flex-col'
onSubmit={form.handleSubmit((values) =>
fetcher.submit(toProjectFormData(intent, project?.id, values), {
method: 'post',
action: ROUTES.projects,
encType: 'multipart/form-data',
}),
)}
>
{/* Only the form column scrolls; the title, preview and buttons stay in place */}
<div className='grid min-h-0 flex-1 grid-rows-[minmax(0,1fr)] md:grid-cols-[minmax(300px,1fr)_auto]'>
<ProjectFormFields isEdit={!!project} brand={brand} />
<ProjectPreview brand={brand} button={button} layout={layout} />
</div>
<DialogActions
confirmLabel={project ? 'Save changes' : 'Create project'}
pendingLabel='Saving…'
pending={fetcher.state !== 'idle'}
disabled={!canSave}
/>
</form>
</FormProvider>
</DialogContent>
</Dialog>
);
}

View File

@ -0,0 +1,55 @@
import { useFormContext, useWatch } from 'react-hook-form';
import { DialogBody } from '~/components/ui/dialog';
import { Field } from '~/components/ui/field';
import { Input } from '~/components/ui/input';
import { SegmentedControl } from '~/components/ui/segmented-control';
import { Textarea } from '~/components/ui/textarea';
import { ArPageFields } from '~/components/projects/form/ar-page-fields';
import { ButtonStyleFields } from '~/components/projects/form/button-style-fields';
import { LogoBackgroundField } from '~/components/projects/form/logo-background-field';
import { LogoField } from '~/components/projects/form/logo-field';
import { PROJECT_STATUS_OPTIONS } from '~/data/projects/constants';
import { useAdminData } from '~/hooks/admin/use-admin-data';
import type { ProjectFormValues } from '~/schemas/projects/project-form';
import type { BrandIdentity } from '~/types/project';
export function ProjectFormFields({ isEdit, brand }: { isEdit: boolean; brand: BrandIdentity }) {
const { settings } = useAdminData();
const { register, control, setValue, formState } = useFormContext<ProjectFormValues>();
const status = useWatch({ control, name: 'status' });
const { errors } = formState;
// relative: the switches' hidden inputs are positioned, and must stay inside this scroll area
return (
<DialogBody className='relative min-h-0 overflow-y-auto'>
<Field label='Company name' htmlFor='project-name' error={errors.name?.message}>
<Input id='project-name' placeholder='e.g. Oakline Interiors' aria-invalid={!!errors.name} {...register('name')} />
</Field>
<LogoField brand={brand} />
<LogoBackgroundField />
<ArPageFields />
{settings.brand_button && <ButtonStyleFields />}
<Field label='Description' htmlFor='project-description' requirement='optional'>
<Textarea id='project-description' rows={2} placeholder='Internal note about this client' {...register('description')} />
</Field>
{isEdit && (
<Field
label='Status'
action={
<SegmentedControl
label='Status'
size='sm'
surface='sunken'
value={status}
options={PROJECT_STATUS_OPTIONS}
onChange={(value) => setValue('status', value, { shouldDirty: true })}
/>
}
/>
)}
</DialogBody>
);
}

View File

@ -0,0 +1,20 @@
import { ArPagePreview } from '~/components/ui/ar-page-preview';
import { Text } from '~/components/ui/text';
import { SAMPLE_MODEL_NAME } from '~/data/projects/constants';
import type { ArPageLayout, BrandIdentity, ButtonStyle } from '~/types/project';
// Live AR page preview beside the project form
export function ProjectPreview({ brand, button, layout }: { brand: BrandIdentity; button: ButtonStyle; layout: ArPageLayout }) {
return (
<div className='hidden flex-col items-center gap-3.5 border-l border-border-divider bg-surface-sunken px-6 pt-[22px] pb-[26px] md:flex'>
<div className='flex items-baseline justify-between self-stretch'>
<Text as='span' variant='caption-strong'>
Live preview
</Text>
<Text as='span' variant='meta'>AR page</Text>
</div>
{/* Shorter on short screens, so it always fits beside the scrolling form */}
<ArPagePreview brand={brand} modelName={SAMPLE_MODEL_NAME} button={button} layout={layout} className='h-[min(560px,calc(100dvh-18rem))] w-[270px]' />
</div>
);
}

View File

@ -0,0 +1,47 @@
import { memo } from 'react';
import { Link } from 'react-router';
import { Pencil } from 'lucide-react';
import { Badge } from '~/components/ui/badge';
import { Button } from '~/components/ui/button';
import { Card } from '~/components/ui/card';
import { LogoTile } from '~/components/ui/logo-tile';
import { Text } from '~/components/ui/text';
import { ROUTES } from '~/data/routes';
import { formatDate } from '~/lib/format';
import { toBrand } from '~/services/asset-media';
import type { Project, ProjectSummary } from '~/types/project';
interface ProjectCardProps {
project: ProjectSummary;
onEdit: (project: Project) => void;
}
export const ProjectCard = memo(function ProjectCard({ project, onEdit }: ProjectCardProps) {
return (
<Card interactive className='relative flex flex-col gap-3.5 p-3'>
<LogoTile brand={toBrand(project)} size='card'>
{!project.logo && (
<Badge tone='light' className='absolute top-2.5 right-2.5'>
<Text as='span' variant='stamp' tone='inherit'>No logo · text fallback</Text>
</Badge>
)}
</LogoTile>
<div className='flex items-center justify-between gap-2.5 px-0.5 pb-0.5'>
<div className='flex min-w-0 flex-col gap-1'>
<div className='flex min-w-0 items-center gap-2'>
<Link to={ROUTES.project(project.id)} className='min-w-0 after:absolute after:inset-0'>
<Text as='h3' variant='heading' truncate>{project.name}</Text>
</Link>
{project.status === 'archived' && <Badge>Archived</Badge>}
</div>
<Text variant='caption'>
{project.assetCount} {project.assetCount === 1 ? 'asset' : 'assets'} · {formatDate(project.created)}
</Text>
</div>
<Button variant='ghost' size='icon' className='relative z-10' aria-label={`Edit ${project.name}`} onClick={() => onEdit(project)}>
<Pencil size={14} />
</Button>
</div>
</Card>
);
});

View File

@ -0,0 +1,27 @@
import { AddButton } from '~/components/ui/add-button';
import { PageHeader } from '~/components/ui/page-header';
import { SegmentedControl } from '~/components/ui/segmented-control';
import { PROJECT_STATUS_OPTIONS } from '~/data/projects/constants';
import type { ProjectStatus } from '~/types/project';
interface ProjectsHeaderProps {
description: string;
status: ProjectStatus;
onStatusChange: (status: ProjectStatus) => void;
onCreate: () => void;
}
export function ProjectsHeader({ description, status, onStatusChange, onCreate }: ProjectsHeaderProps) {
return (
<PageHeader
title='Projects'
description={description}
actions={
<>
<SegmentedControl label='Project status' value={status} options={PROJECT_STATUS_OPTIONS} onChange={onStatusChange} />
<AddButton label='New project' onClick={onCreate} />
</>
}
/>
);
}

View File

@ -0,0 +1,18 @@
import { Link } from 'react-router';
import { Button } from '~/components/ui/button';
import { Text } from '~/components/ui/text';
import { ASSET_FILTER } from '~/data/assets/constants';
import { ROUTES } from '~/data/routes';
export function UnassignedBanner({ count }: { count: number }) {
return (
<div className='flex flex-wrap items-center justify-between gap-4 rounded-card-sm bg-surface-dialog px-4 py-3 ring-1 ring-inset ring-border-subtle'>
<Text>
{count} {count === 1 ? 'asset isn’t' : 'assets aren’t'} in a project yet. Their AR pages show only the thob logo.
</Text>
<Button asChild variant='link'>
<Link to={ROUTES.assetsFiltered(ASSET_FILTER.unassigned)}>Review unassigned →</Link>
</Button>
</div>
);
}

View File

@ -0,0 +1,31 @@
import { useFetcher } from 'react-router';
import { SwitchRow } from '~/components/ui/switch-row';
import { ROUTES } from '~/data/routes';
import { useActionToast } from '~/hooks/use-action-toast';
import type { ActionResult } from '~/types/action';
import type { SettingKey } from '~/types/settings';
interface SettingToggleProps {
setting: { key: SettingKey; label: string; hint: string };
value: boolean;
}
// Saves as soon as it is flipped; shows the new value while saving
export function SettingToggle({ setting, value }: SettingToggleProps) {
const fetcher = useFetcher<ActionResult>();
const pendingValue = fetcher.formData?.get('value');
const checked = pendingValue === undefined || pendingValue === null ? value : pendingValue === 'true';
useActionToast(fetcher.data);
return (
<SwitchRow
id={`setting-${setting.key}`}
label={setting.label}
hint={setting.hint}
checked={checked}
disabled={fetcher.state !== 'idle'}
onCheckedChange={(next) => fetcher.submit({ key: setting.key, value: String(next) }, { method: 'post', action: ROUTES.settings })}
/>
);
}

View File

@ -0,0 +1,12 @@
import { Plus } from 'lucide-react';
import { Button, type ButtonProps } from '~/components/ui/button';
// Primary "+ New …" action
export function AddButton({ label, ...props }: Omit<ButtonProps, 'children'> & { label: string }) {
return (
<Button {...props}>
<Plus size={14} strokeWidth={2.4} />
{label}
</Button>
);
}

View File

@ -0,0 +1,14 @@
import type { ReactNode } from 'react';
import { AlertCircle } from 'lucide-react';
import { Text } from '~/components/ui/text';
import { toneSurface } from '~/components/ui/tone';
import { cn } from '~/lib/utils';
export function Alert({ children }: { children: ReactNode }) {
return (
<Text role='alert' tone='danger' className={cn(toneSurface({ tone: 'danger' }), 'flex items-start gap-2.5 rounded-xl px-4 py-3')}>
<AlertCircle size={16} className='mt-0.5 shrink-0' />
{children}
</Text>
);
}

View File

@ -0,0 +1,61 @@
import type { CSSProperties } from 'react';
import { Box, Loader2 } from 'lucide-react';
import { Button } from '~/components/ui/button';
import { Text } from '~/components/ui/text';
import { AR_BUTTON_LABEL } from '~/data/ar-viewer/constants';
import { BUTTON_SIZES } from '~/data/projects/constants';
import { cn } from '~/lib/utils';
import type { ButtonStyle } from '~/types/project';
// Measurements for the chosen size: a pill preset, or the project's exact custom values
function boxStyle({ size = 'md', custom }: ButtonStyle): CSSProperties {
if (size === 'custom' && custom) {
return {
height: custom.height,
width: custom.width ?? undefined,
paddingInline: custom.paddingX,
borderRadius: custom.radius,
border: custom.borderWidth ? `${custom.borderWidth}px solid ${custom.borderColor}` : undefined,
};
}
const { height, paddingX } = BUTTON_SIZES[size === 'sm' || size === 'lg' ? size : 'md'];
return { height, paddingInline: paddingX };
}
interface ArLaunchButtonProps {
style?: ButtonStyle;
launching?: boolean;
hint?: string | null;
onLaunch?: () => void;
// Placement of the button row, e.g. over the model
className?: string;
}
// "View in your space" button; takes the client's colour, text colour, label and size when the project sets them
export function ArLaunchButton({ style = {}, launching, hint, onLaunch, className }: ArLaunchButtonProps) {
const preview = !onLaunch;
return (
<div className={cn('flex justify-center px-4 pt-2 pb-[max(1.625rem,env(safe-area-inset-bottom))]', className)}>
<Button
size='pill'
disabled={launching}
onClick={onLaunch}
tabIndex={preview ? -1 : undefined}
aria-hidden={preview || undefined}
style={{ backgroundColor: style.color, color: style.textColor, ...boxStyle(style) }}
className={cn(
'max-w-full',
style.color && 'hover:brightness-110',
hint && 'min-w-64',
style.size === 'full' && 'w-full',
preview ? 'pointer-events-none' : 'pointer-events-auto',
)}
>
{launching ? <Loader2 size={16} className='animate-spin' /> : <Box size={16} />}
<Text as='span' variant='inherit' tone='inherit' truncate>
{hint ?? style.label ?? AR_BUTTON_LABEL}
</Text>
</Button>
</div>
);
}

View File

@ -0,0 +1,29 @@
import { ClientLogo } from '~/components/ui/client-logo';
import { LogoMark } from '~/components/ui/logo-mark';
import { Text } from '~/components/ui/text';
import { cn } from '~/lib/utils';
import type { ArPageLayout, BrandIdentity } from '~/types/project';
interface ArPageHeaderProps {
brand?: BrandIdentity;
modelName: string;
layout: ArPageLayout;
// Placement, e.g. over the model
className?: string;
}
// Client logo top-left with the model name under it; the thob mark top-right. Each part can be turned off per project.
export function ArPageHeader({ brand, modelName, layout, className }: ArPageHeaderProps) {
return (
<header className={cn('flex items-start justify-between gap-3 px-4 pt-[calc(18px+env(safe-area-inset-top))]', className)}>
<div className='flex min-w-0 flex-col items-start gap-2.5'>
{brand && <ClientLogo brand={brand} variant={layout.logoBacking ? 'chip' : 'bare'} size='md' />}
{/* A hidden name stays for screen readers: it is the page heading */}
<Text as='h1' variant='subheading' tone='ink' truncate className={cn('max-w-full', !layout.modelName && 'sr-only')}>
{modelName}
</Text>
</div>
{layout.thobLogo && <LogoMark size='md' surface='viewer' />}
</header>
);
}

View File

@ -0,0 +1,38 @@
import type { ReactNode } from 'react';
import { ArPage } from '~/components/ui/ar-page';
import { PhoneFrame } from '~/components/ui/phone-frame';
import { Text } from '~/components/ui/text';
import { cn } from '~/lib/utils';
import type { ArPageLayout, BrandIdentity, ButtonStyle } from '~/types/project';
const stripes = 'repeating-linear-gradient(135deg, var(--color-viewer-stripe) 0 9px, var(--color-viewer-stripe-alt) 9px 18px)';
interface ArPagePreviewProps {
brand?: BrandIdentity;
modelName: string;
button?: ButtonStyle;
layout?: ArPageLayout;
className?: string;
// The 3D viewer; a striped placeholder is shown when omitted
children?: ReactNode;
}
export function ArPagePreview({ brand, modelName, button, layout, className, children }: ArPagePreviewProps) {
return (
<PhoneFrame className={className}>
<ArPage brand={brand} modelName={modelName} button={button} layout={layout} className='min-h-0 flex-1'>
{children ?? (
// Edge to edge when the model fills the page
<div
className={cn('absolute flex items-center justify-center', layout?.bars === false ? 'inset-0' : 'inset-x-4 inset-y-[18px] rounded-[20px]')}
style={{ backgroundImage: stripes }}
>
<Text as='span' variant='stamp' tone='viewer'>
3D model
</Text>
</div>
)}
</ArPage>
</PhoneFrame>
);
}

View File

@ -0,0 +1,34 @@
import type { ReactNode } from 'react';
import { ArLaunchButton } from '~/components/ui/ar-launch-button';
import { ArPageHeader } from '~/components/ui/ar-page-header';
import { AR_PAGE_DEFAULTS } from '~/data/projects/constants';
import { cn } from '~/lib/utils';
import type { ArPageLayout, BrandIdentity, ButtonStyle } from '~/types/project';
// Over the model: placed at an edge, and only the button itself takes touches so the model can still be turned
const overlay = (edge: 'top-0' | 'bottom-0') => cn('pointer-events-none absolute inset-x-0 z-10', edge);
interface ArPageProps {
brand?: BrandIdentity;
modelName: string;
button?: ButtonStyle;
layout?: ArPageLayout;
launching?: boolean;
hint?: string | null;
onLaunch?: () => void;
className?: string;
children: ReactNode;
}
// The customer-facing AR page layout, shared by the live page and the admin previews.
// With the bars off, the model fills the page and the header and button sit over it.
export function ArPage({ brand, modelName, button, layout = AR_PAGE_DEFAULTS, launching, hint, onLaunch, className, children }: ArPageProps) {
const bars = layout.bars;
return (
<div className={cn('relative flex flex-col bg-viewer', className)}>
<ArPageHeader brand={brand} modelName={modelName} layout={layout} className={bars ? undefined : overlay('top-0')} />
<div className={bars ? 'relative min-h-0 flex-1' : 'absolute inset-0'}>{children}</div>
<ArLaunchButton style={button} launching={launching} hint={hint} onLaunch={onLaunch} className={bars ? undefined : overlay('bottom-0')} />
</div>
);
}

View File

@ -1,37 +1,12 @@
import * as React from 'react';
import type { ComponentProps } from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { toneSurface } from '~/components/ui/tone';
import { cn } from '~/lib/utils';
const badgeVariants = cva(
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 select-none uppercase tracking-wider',
{
variants: {
variant: {
default:
'border-transparent bg-neutral-800 text-white hover:bg-neutral-700',
secondary:
'border-transparent bg-neutral-900 text-neutral-400 hover:bg-neutral-850',
destructive:
'border-transparent bg-red-500/10 text-red-500 border-red-500/20',
outline: 'border-neutral-800 text-neutral-400',
orange:
'border-orange-500/20 bg-orange-500/5 text-orange-500 font-bold',
},
},
defaultVariants: {
variant: 'default',
},
}
);
const badgeVariants = cva('inline-flex select-none items-center gap-1 rounded-chip px-1.5 py-0.5 text-3xs font-medium');
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
export interface BadgeProps extends ComponentProps<'span'>, VariantProps<typeof toneSurface> {}
function Badge({ className, variant, ...props }: BadgeProps) {
return (
<div className={cn(badgeVariants({ variant }), className)} {...props} />
);
export function Badge({ className, tone, ...props }: BadgeProps) {
return <span className={cn(toneSurface({ tone }), badgeVariants(), className)} {...props} />;
}
export { Badge, badgeVariants };

View File

@ -0,0 +1,21 @@
import { LogoMark } from '~/components/ui/logo-mark';
import { Text } from '~/components/ui/text';
import { BRAND } from '~/data/brand';
import { cn } from '~/lib/utils';
const SIZES = {
sm: { mark: 'xs', text: 'heading' },
md: { mark: 'sm', text: 'subheading' },
} as const;
// The "t." mark with the product name: sidebar and login page
export function BrandLockup({ size = 'sm', className }: { size?: keyof typeof SIZES; className?: string }) {
return (
<span className={cn('flex items-center gap-2.5', className)}>
<LogoMark size={SIZES[size].mark} />
<Text as='span' variant={SIZES[size].text}>
{BRAND.product}
</Text>
</span>
);
}

View File

@ -0,0 +1,108 @@
import * as React from "react"
import { cn } from "~/lib/utils"
import { ChevronRight, MoreHorizontal } from "lucide-react"
import { Slot } from "radix-ui"
function Breadcrumb({ ...props }: React.ComponentProps<"nav">) {
return <nav aria-label="breadcrumb" data-slot="breadcrumb" {...props} />
}
function BreadcrumbList({ className, ...props }: React.ComponentProps<"ol">) {
return (
<ol
data-slot="breadcrumb-list"
className={cn(
"flex flex-wrap items-center gap-2 text-sm break-words text-muted-foreground",
className
)}
{...props}
/>
)
}
function BreadcrumbItem({ className, ...props }: React.ComponentProps<"li">) {
return (
<li
data-slot="breadcrumb-item"
className={cn("inline-flex items-center gap-1.5", className)}
{...props}
/>
)
}
function BreadcrumbLink({
asChild,
className,
...props
}: React.ComponentProps<"a"> & {
asChild?: boolean
}) {
const Comp = asChild ? Slot.Root : "a"
return (
<Comp
data-slot="breadcrumb-link"
className={cn("transition-colors hover:text-foreground", className)}
{...props}
/>
)
}
function BreadcrumbPage({ className, ...props }: React.ComponentProps<"span">) {
return (
<span
data-slot="breadcrumb-page"
role="link"
aria-disabled="true"
aria-current="page"
className={cn("font-normal text-text-emphasis", className)}
{...props}
/>
)
}
function BreadcrumbSeparator({
children,
className,
...props
}: React.ComponentProps<"li">) {
return (
<li
data-slot="breadcrumb-separator"
role="presentation"
aria-hidden="true"
className={cn("[&>svg]:size-3.5", className)}
{...props}
>
{children ?? <ChevronRight />}
</li>
)
}
function BreadcrumbEllipsis({
className,
...props
}: React.ComponentProps<"span">) {
return (
<span
data-slot="breadcrumb-ellipsis"
role="presentation"
aria-hidden="true"
className={cn("flex size-9 items-center justify-center", className)}
{...props}
>
<MoreHorizontal className="size-4" />
<span className="sr-only">More</span>
</span>
)
}
export {
Breadcrumb,
BreadcrumbList,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbPage,
BreadcrumbSeparator,
BreadcrumbEllipsis,
}

View File

@ -1,52 +1,45 @@
import * as React from 'react';
import type { ComponentProps } from 'react';
import { Slot } from '@radix-ui/react-slot';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '~/lib/utils';
const buttonVariants = cva(
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-xl text-sm font-semibold transition-all duration-200 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-neutral-700 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 active:scale-[0.98] cursor-pointer',
// A busy button (aria-busy) is disabled but keeps full colour while it works
'inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap text-sm transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 disabled:pointer-events-none disabled:opacity-40 aria-busy:disabled:opacity-100 [&_svg]:pointer-events-none [&_svg]:shrink-0',
{
variants: {
variant: {
default: 'bg-orange-500 text-black shadow-[0_0_24px_rgba(249,115,22,0.15)] hover:bg-orange-400 hover:shadow-[0_0_32px_rgba(249,115,22,0.3)]',
destructive: 'bg-red-500/10 text-red-500 border border-red-500/20 hover:bg-red-500 hover:text-white',
outline: 'border border-neutral-800 bg-[#121212] text-neutral-400 hover:bg-neutral-900 hover:text-white hover:border-orange-500/40',
secondary: 'bg-neutral-800 text-neutral-300 hover:bg-neutral-750 hover:text-white',
ghost: 'hover:bg-neutral-850 hover:text-white text-neutral-400',
link: 'text-orange-500 underline-offset-4 hover:underline',
default: 'bg-primary font-semibold text-primary-foreground shadow-[0_4px_14px] shadow-primary/25 hover:bg-primary-hover aria-busy:bg-accent-600',
success: 'bg-success-strong font-semibold text-primary-foreground shadow-[0_4px_14px] shadow-success-strong/25',
secondary: 'bg-surface-control font-medium text-text-primary ring-1 ring-inset ring-border-control hover:bg-surface-hover',
destructive: 'bg-surface-control font-medium text-danger ring-1 ring-inset ring-border-control hover:bg-surface-hover',
ghost: 'font-medium text-text-subtle hover:bg-surface-hover hover:text-text-primary',
link: 'h-auto px-0 font-medium text-primary hover:text-primary-hover',
'link-muted': 'text-text-secondary hover:text-primary',
},
size: {
default: 'h-10 px-5 py-2.5',
sm: 'h-8 rounded-lg px-3 text-xs',
lg: 'h-12 rounded-xl px-8 text-base',
icon: 'h-9 w-9 rounded-lg',
default: 'h-9 rounded-control px-4',
sm: 'h-8 rounded-item px-3 text-xs',
lg: 'h-11 rounded-control px-6',
xl: 'h-12.5 rounded-field px-6 text-base shadow-[0_10px_28px] inset-shadow-[0_1px_0] inset-shadow-primary-foreground/20',
// Text-only buttons that sit inline with labels
inline: 'h-auto px-0',
icon: 'h-[30px] w-[30px] rounded-item',
'icon-sm': 'h-[26px] w-[26px] rounded-option',
pill: 'h-[46px] rounded-full px-6 text-base shadow-[0_6px_16px] shadow-shadow/15',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
}
defaultVariants: { variant: 'default', size: 'default' },
},
);
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
VariantProps<typeof buttonVariants> {
export interface ButtonProps extends ComponentProps<'button'>, VariantProps<typeof buttonVariants> {
asChild?: boolean;
}
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : 'button';
return (
<Comp
className={cn(buttonVariants({ variant, size, className }))}
ref={ref}
{...props}
/>
);
}
);
Button.displayName = 'Button';
export function Button({ className, variant, size, asChild = false, ...props }: ButtonProps) {
const Comp = asChild ? Slot : 'button';
return <Comp className={cn(buttonVariants({ variant, size }), className)} {...props} />;
}
export { Button, buttonVariants };
export { buttonVariants };

View File

@ -1,78 +1,28 @@
import * as React from 'react';
import type { ComponentProps } from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '~/lib/utils';
const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
'rounded-2xl border border-neutral-900 bg-[#121212] text-white shadow-2xl transition-all duration-300',
className
)}
{...props}
/>
));
Card.displayName = 'Card';
const cardVariants = cva('text-text-primary ring-1 ring-inset', {
variants: {
surface: {
default: 'bg-surface ring-border-subtle',
well: 'bg-surface-well ring-border-divider',
},
size: {
sm: 'rounded-card-sm',
md: 'rounded-card',
lg: 'rounded-panel',
},
interactive: {
true: 'cursor-pointer transition-shadow duration-150 hover:ring-border-strong',
false: '',
},
},
defaultVariants: { surface: 'default', size: 'md', interactive: false },
});
const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn('flex flex-col space-y-1.5 p-6', className)}
{...props}
/>
));
CardHeader.displayName = 'CardHeader';
export interface CardProps extends ComponentProps<'div'>, VariantProps<typeof cardVariants> {}
const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn(
'text-lg font-bold tracking-tight text-white uppercase',
className
)}
{...props}
/>
));
CardTitle.displayName = 'CardTitle';
const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn('text-xs text-neutral-500 uppercase tracking-wider', className)}
{...props}
/>
));
CardDescription.displayName = 'CardDescription';
const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn('p-6 pt-0', className)} {...props} />
));
CardContent.displayName = 'CardContent';
const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn('flex items-center p-6 pt-0', className)}
{...props}
/>
));
CardFooter.displayName = 'CardFooter';
export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent };
export function Card({ className, surface, size, interactive, ...props }: CardProps) {
return <div className={cn(cardVariants({ surface, size, interactive }), className)} {...props} />;
}

View File

@ -0,0 +1,29 @@
import * as React from "react"
import { cn } from "~/lib/utils"
import { CheckIcon } from "lucide-react"
import { Checkbox as CheckboxPrimitive } from "radix-ui"
function Checkbox({
className,
...props
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
return (
<CheckboxPrimitive.Root
data-slot="checkbox"
className={cn(
"peer size-4.5 shrink-0 cursor-pointer rounded-chip border border-border-strong bg-surface transition-shadow outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
data-slot="checkbox-indicator"
className="grid place-content-center text-current transition-none"
>
<CheckIcon className="size-3" strokeWidth={3.2} />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
)
}
export { Checkbox }

View File

@ -0,0 +1,82 @@
import { cva } from 'class-variance-authority';
import { cn } from '~/lib/utils';
import type { BrandIdentity } from '~/types/project';
const frame = cva('inline-flex shrink-0 items-center justify-center overflow-hidden leading-none', {
variants: {
variant: {
// Rounded backing chip: AR page, asset header
chip: 'ring-1 ring-inset',
// The logo on its own at chip size: AR page with the backing turned off
bare: '',
// Bare logo: admin tiles that already have a coloured background
plain: '',
// Square tile with the logo (or first letter): sidebar, QR centre, project chips
mark: 'ring-1 ring-inset',
},
size: { xs: '', sm: '', md: '', lg: '', fill: '' },
background: { light: '', dark: '' },
},
compoundVariants: [
// Fills the box it is placed in (admin logo tiles)
{ variant: 'plain', size: 'fill', className: 'h-full w-full' },
{ variant: ['chip', 'mark'], background: 'light', className: 'bg-logo-chip-light ring-shadow/[0.07] shadow-xs' },
{ variant: ['chip', 'mark'], background: 'dark', className: 'bg-logo-chip-dark ring-text-primary/[0.08]' },
{ variant: 'chip', size: ['xs', 'sm'], className: 'gap-1.5 rounded-option px-2 py-1.5' },
{ variant: 'chip', size: ['md', 'lg'], className: 'gap-2 rounded-item px-2.5 py-[7px]' },
{ variant: 'mark', size: 'xs', className: 'h-[17px] w-[17px] rounded-[4px] p-0.5' },
{ variant: 'mark', size: 'sm', className: 'h-5 w-5 rounded-[5px] p-0.5' },
{ variant: 'mark', size: 'md', className: 'h-[30px] w-[30px] rounded-option p-1' },
{ variant: 'mark', size: 'lg', className: 'h-12 w-12 rounded-card-sm p-1.5' },
],
});
const image = cva('object-contain', {
variants: {
variant: { chip: 'w-auto max-w-[140px]', bare: 'w-auto max-w-[160px]', plain: 'w-auto max-w-[70%]', mark: 'h-full w-full' },
size: { xs: '', sm: '', md: '', lg: '', fill: '' },
},
compoundVariants: [
{ variant: 'plain', size: 'fill', className: 'h-full w-full max-w-none' },
{ variant: 'chip', size: ['xs', 'sm'], className: 'h-3.5' },
{ variant: 'chip', size: ['md', 'lg'], className: 'h-[18px]' },
// No chip padding, so the logo itself can be larger
{ variant: 'bare', size: ['xs', 'sm'], className: 'h-5' },
{ variant: 'bare', size: ['md', 'lg'], className: 'h-7' },
{ variant: 'plain', size: 'sm', className: 'max-h-7' },
{ variant: 'plain', size: 'md', className: 'max-h-9' },
{ variant: 'plain', size: 'lg', className: 'max-h-12' },
],
});
const fallback = cva('whitespace-nowrap font-semibold tracking-[-0.01em]', {
variants: {
size: { xs: 'text-3xs', sm: 'text-2xs', md: 'text-sm', lg: 'text-xl', fill: 'text-xl' },
background: { light: 'text-ink', dark: 'text-text-primary' },
},
});
interface ClientLogoProps {
brand: BrandIdentity;
variant?: 'chip' | 'bare' | 'plain' | 'mark';
size?: 'xs' | 'sm' | 'md' | 'lg' | 'fill';
className?: string;
}
// A client's uploaded logo, or their company name when no logo has been added
export function ClientLogo({ brand, variant = 'chip', size = 'md', className }: ClientLogoProps) {
const background = brand.logoBg;
const text = variant === 'mark' ? brand.name.trim().charAt(0).toUpperCase() || '?' : brand.name;
return (
<span
className={cn(frame({ variant, size, background }), className)}
style={(variant === 'chip' || variant === 'mark') && brand.logoBgColor ? { backgroundColor: brand.logoBgColor } : undefined}
>
{brand.logoUrl ? (
<img src={brand.logoUrl} alt={brand.name} className={image({ variant, size })} />
) : (
<span className={fallback({ size: variant === 'plain' && size === 'md' ? 'lg' : size, background })}>{text}</span>
)}
</span>
);
}

View File

@ -0,0 +1,76 @@
import { useEffect, useState } from 'react';
import { Pipette } from 'lucide-react';
import { Input } from '~/components/ui/input';
import { normalizeHex } from '~/lib/color';
import { cn } from '~/lib/utils';
import type { ColorPreset } from '~/types/project';
const swatch = 'relative h-[26px] w-[26px] shrink-0 cursor-pointer rounded-full transition-shadow';
const ring = (selected: boolean) => (selected ? 'ring-2 ring-text-primary ring-offset-2 ring-offset-surface-dialog' : 'ring-1 ring-inset ring-text-primary/15');
interface ColorPickerProps {
id: string;
label: string;
value: string;
presets: ColorPreset[];
onChange: (hex: string) => void;
}
// Preset swatches, a custom swatch that opens the system colour picker, and a hex field
export function ColorPicker({ id, label, value, presets, onChange }: ColorPickerProps) {
const [draft, setDraft] = useState(value);
const isCustom = !presets.some((preset) => preset.value === value);
// Keep the hex field in step when a swatch or the system picker changes the colour
useEffect(() => setDraft(value), [value]);
return (
<div className='flex flex-wrap items-center gap-2.5'>
<div role='radiogroup' aria-label={label} className='flex flex-wrap items-center gap-2.5'>
{presets.map((preset) => (
<button
key={preset.value}
type='button'
role='radio'
aria-checked={preset.value === value}
aria-label={preset.label}
title={preset.label}
onClick={() => onChange(preset.value)}
style={{ backgroundColor: preset.value }}
className={cn(swatch, ring(preset.value === value))}
/>
))}
<label
title='Custom colour'
style={isCustom ? { backgroundColor: value } : undefined}
className={cn(swatch, 'flex items-center justify-center bg-surface-control text-text-subtle hover:text-text-primary', ring(isCustom))}
>
{!isCustom && <Pipette size={12} />}
<input
type='color'
aria-label={`${label}: custom colour`}
value={value}
onChange={(e) => onChange(e.target.value)}
className='absolute inset-0 cursor-pointer opacity-0'
/>
</label>
</div>
<Input
id={id}
size='sm'
mono
aria-label={`${label} hex code`}
value={draft}
maxLength={7}
spellCheck={false}
className='w-[92px]'
onChange={(e) => {
setDraft(e.target.value);
const hex = normalizeHex(e.target.value);
if (hex) onChange(hex);
}}
onBlur={() => setDraft(value)}
/>
</div>
);
}

View File

@ -0,0 +1,11 @@
import { Text } from '~/components/ui/text';
// A small colour swatch with its value, for read-only summaries
export function ColorTag({ color, label }: { color: string; label: string }) {
return (
<Text as='span' variant='caption' className='inline-flex items-center gap-1.5'>
<span className='h-2.5 w-2.5 rounded-[3px] ring-1 ring-inset ring-text-primary/15' style={{ backgroundColor: color }} />
<Text as='span' variant='mono' tone='muted'>{label}</Text>
</Text>
);
}

View File

@ -1,83 +1,30 @@
import * as React from 'react';
import {
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
DialogDescription,
DialogFooter,
} from '~/components/ui/dialog';
import { Button } from '~/components/ui/button';
import { AlertTriangle, RefreshCw } from 'lucide-react';
import { AlertTriangle } from 'lucide-react';
import { Dialog, DialogBody, DialogContent, DialogDescription, DialogTitle } from '~/components/ui/dialog';
import { DialogActions } from '~/components/ui/dialog-actions';
import { IconTile } from '~/components/ui/icon-tile';
interface ConfirmDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
title: string;
description: string;
confirmText?: string;
cancelText?: string;
variant?: 'destructive' | 'default';
loading?: boolean;
confirmLabel?: string;
pending?: boolean;
onConfirm: () => void;
}
export function ConfirmDialog({
open,
onOpenChange,
title,
description,
confirmText = 'Confirm',
cancelText = 'Cancel',
variant = 'destructive',
loading = false,
onConfirm,
}: ConfirmDialogProps) {
export function ConfirmDialog({ open, onOpenChange, title, description, confirmLabel = 'Confirm', pending, onConfirm }: ConfirmDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="max-w-md bg-[#121212] border-neutral-850 p-6">
<DialogHeader className="space-y-2">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-xl bg-red-500/10 border border-red-500/20 flex items-center justify-center text-red-500 shrink-0">
<AlertTriangle size={20} />
</div>
<div>
<DialogTitle className="text-base font-bold text-white uppercase tracking-wider">
{title}
</DialogTitle>
<DialogDescription className="text-xs text-neutral-400 mt-1">
{description}
</DialogDescription>
</div>
<DialogContent className='max-w-md'>
<DialogBody className='flex-row items-start gap-4 pr-16'>
<IconTile icon={AlertTriangle} tone='danger' />
<div className='space-y-1.5'>
<DialogTitle>{title}</DialogTitle>
<DialogDescription>{description}</DialogDescription>
</div>
</DialogHeader>
<DialogFooter className="mt-6 flex flex-row items-center justify-end gap-3">
<Button
type="button"
variant="outline"
size="sm"
disabled={loading}
onClick={() => onOpenChange(false)}
className="h-9"
>
{cancelText}
</Button>
<Button
type="button"
variant={variant}
size="sm"
disabled={loading}
onClick={onConfirm}
className="h-9"
>
{loading ? (
<RefreshCw size={14} className="animate-spin" />
) : (
confirmText
)}
</Button>
</DialogFooter>
</DialogBody>
<DialogActions confirmLabel={confirmLabel} variant='destructive' pending={pending} onConfirm={onConfirm} />
</DialogContent>
</Dialog>
);

View File

@ -0,0 +1,16 @@
import { Button } from '~/components/ui/button';
import { Text } from '~/components/ui/text';
import { copyToClipboard } from '~/lib/browser';
export function CopyField({ value, label }: { value: string; label: string }) {
return (
<div className='flex h-[38px] items-center gap-2 rounded-control bg-background pr-1.5 pl-3 ring-1 ring-inset ring-border-subtle'>
<Text as='span' variant='mono' truncate className='flex-1 select-all'>
{value}
</Text>
<Button variant='secondary' size='sm' className='h-7 rounded-option ring-0' onClick={() => copyToClipboard(value, label)}>
Copy
</Button>
</div>
);
}

View File

@ -0,0 +1,30 @@
import { Loader2 } from 'lucide-react';
import { Button, type ButtonProps } from '~/components/ui/button';
import { DialogClose, DialogFooter } from '~/components/ui/dialog';
interface DialogActionsProps {
confirmLabel: string;
pendingLabel?: string;
cancelLabel?: string;
pending?: boolean;
disabled?: boolean;
variant?: ButtonProps['variant'];
onConfirm?: () => void;
}
// Cancel + confirm footer; without `onConfirm` the confirm button submits the surrounding form
export function DialogActions({ confirmLabel, pendingLabel, cancelLabel = 'Cancel', pending, disabled, variant, onConfirm }: DialogActionsProps) {
return (
<DialogFooter>
<DialogClose asChild>
<Button type='button' variant='secondary' disabled={pending}>
{cancelLabel}
</Button>
</DialogClose>
<Button type={onConfirm ? 'button' : 'submit'} variant={variant} disabled={pending || disabled} onClick={onConfirm}>
{pending && <Loader2 size={15} className='animate-spin' />}
{pending ? (pendingLabel ?? confirmLabel) : confirmLabel}
</Button>
</DialogFooter>
);
}

View File

@ -1,119 +1,49 @@
import * as React from 'react';
import * as DialogPrimitive from '@radix-ui/react-dialog';
import type { ComponentProps } from 'react';
import { Root, Trigger, Portal, Close, Overlay, Content, Title, Description } from '@radix-ui/react-dialog';
import { X } from 'lucide-react';
import { cn } from '~/lib/utils';
const Dialog = DialogPrimitive.Root;
const DialogTrigger = DialogPrimitive.Trigger;
const DialogPortal = DialogPrimitive.Portal;
const DialogClose = DialogPrimitive.Close;
export const Dialog = Root;
export const DialogTrigger = Trigger;
export const DialogClose = Close;
const DialogOverlay = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Overlay>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Overlay
ref={ref}
className={cn(
'fixed inset-0 z-50 bg-black/85 backdrop-blur-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0',
className
)}
{...props}
/>
));
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
export function DialogContent({ className, children, ...props }: ComponentProps<typeof Content>) {
return (
<Portal>
<Overlay className='fixed inset-0 z-50 bg-overlay backdrop-blur-[3px] data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0' />
<Content
className={cn(
'fixed top-1/2 left-1/2 z-50 flex max-h-[calc(100vh-3rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-y-auto rounded-panel bg-surface-dialog shadow-[0_40px_80px] shadow-shadow/50 ring-1 ring-inset ring-border-dialog data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95',
className,
)}
{...props}
>
{children}
<Close className='absolute top-5 right-5 flex h-[30px] w-[30px] cursor-pointer items-center justify-center rounded-item text-text-subtle transition-colors hover:bg-surface-hover hover:text-text-primary focus:outline-none'>
<X size={14} />
<span className='sr-only'>Close</span>
</Close>
</Content>
</Portal>
);
}
const DialogContent = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
>(({ className, children, ...props }, ref) => (
<DialogPortal>
<DialogOverlay />
<DialogPrimitive.Content
ref={ref}
className={cn(
'fixed left-[50%] top-[50%] z-50 w-full translate-x-[-50%] translate-y-[-50%] border border-neutral-850 bg-[#121212] shadow-2xl duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-1/2 data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-1/2 rounded-2xl',
!className?.includes('flex') && !className?.includes('grid') && 'grid gap-4',
!className?.includes('max-w-') && 'max-w-lg',
!className?.includes('p-') && 'p-0 p-6', // default padding if not overridden
className
)}
{...props}
>
{children}
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-full p-2 bg-black/60 border border-neutral-850 text-neutral-400 hover:text-white hover:bg-neutral-800 transition-all cursor-pointer opacity-70 hover:opacity-100 focus:outline-none disabled:pointer-events-none z-20">
<X className="h-4 w-4" />
<span className="sr-only">Close</span>
</DialogPrimitive.Close>
</DialogPrimitive.Content>
</DialogPortal>
));
DialogContent.displayName = DialogPrimitive.Content.displayName;
export function DialogHeader({ className, ...props }: ComponentProps<'div'>) {
return <div className={cn('flex flex-col gap-1 border-b border-border-divider px-6 py-5 pr-16', className)} {...props} />;
}
const DialogHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col space-y-1.5 text-center sm:text-left',
className
)}
{...props}
/>
);
DialogHeader.displayName = 'DialogHeader';
export function DialogBody({ className, ...props }: ComponentProps<'div'>) {
return <div className={cn('flex flex-col gap-5 px-6 py-[22px]', className)} {...props} />;
}
const DialogFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div
className={cn(
'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2',
className
)}
{...props}
/>
);
DialogFooter.displayName = 'DialogFooter';
export function DialogFooter({ className, ...props }: ComponentProps<'div'>) {
return <div className={cn('flex flex-col-reverse gap-2.5 border-t border-border-divider px-6 py-4 sm:flex-row sm:justify-end', className)} {...props} />;
}
const DialogTitle = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Title>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Title
ref={ref}
className={cn(
'text-lg font-semibold leading-none tracking-tight text-white',
className
)}
{...props}
/>
));
DialogTitle.displayName = DialogPrimitive.Title.displayName;
export function DialogTitle({ className, ...props }: ComponentProps<typeof Title>) {
return <Title className={cn('text-lg font-semibold text-text-primary', className)} {...props} />;
}
const DialogDescription = React.forwardRef<
React.ElementRef<typeof DialogPrimitive.Description>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>
>(({ className, ...props }, ref) => (
<DialogPrimitive.Description
ref={ref}
className={cn('text-sm text-neutral-400', className)}
{...props}
/>
));
DialogDescription.displayName = DialogPrimitive.Description.displayName;
export {
Dialog,
DialogPortal,
DialogOverlay,
DialogClose,
DialogTrigger,
DialogContent,
DialogHeader,
DialogFooter,
DialogTitle,
DialogDescription,
};
export function DialogDescription({ className, ...props }: ComponentProps<typeof Description>) {
return <Description className={cn('text-sm text-text-subtle', className)} {...props} />;
}

View File

@ -0,0 +1,66 @@
import { useRef, useState, type ReactNode } from 'react';
import { cva } from 'class-variance-authority';
import { cn } from '~/lib/utils';
const zoneVariants = cva(
'cursor-pointer rounded-control border border-dashed transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40',
{
variants: {
layout: {
row: 'px-4 py-3',
stack: 'flex flex-col items-center gap-2 px-4 py-[22px] text-center',
},
state: {
empty: 'border-border-dashed bg-surface-sunken hover:border-primary',
filled: 'border-solid border-border-control bg-background',
dragging: 'border-primary bg-primary/5',
invalid: 'border-danger/60 bg-surface-sunken',
},
},
},
);
interface DropZoneProps {
id?: string;
accept: string;
layout: 'row' | 'stack';
filled?: boolean;
invalid?: boolean;
onFile: (file: File) => void;
children: ReactNode;
}
// Click-or-drag file target with a hidden file input
export function DropZone({ id, accept, layout, filled, invalid, onFile, children }: DropZoneProps) {
const inputRef = useRef<HTMLInputElement>(null);
const [dragging, setDragging] = useState(false);
const state = dragging ? 'dragging' : invalid && !filled ? 'invalid' : filled ? 'filled' : 'empty';
const pick = (file: File | undefined) => {
if (file) onFile(file);
if (inputRef.current) inputRef.current.value = '';
};
return (
<div
role='button'
tabIndex={0}
onClick={() => inputRef.current?.click()}
onKeyDown={(e) => (e.key === 'Enter' || e.key === ' ') && inputRef.current?.click()}
onDragOver={(e) => {
e.preventDefault();
setDragging(true);
}}
onDragLeave={() => setDragging(false)}
onDrop={(e) => {
e.preventDefault();
setDragging(false);
pick(e.dataTransfer.files[0]);
}}
className={cn(zoneVariants({ layout, state }))}
>
<input ref={inputRef} id={id} type='file' accept={accept} className='hidden' onChange={(e) => pick(e.target.files?.[0])} />
{children}
</div>
);
}

View File

@ -0,0 +1,9 @@
import { IconMessage, type IconMessageProps } from '~/components/ui/icon-message';
export function EmptyState(props: Omit<IconMessageProps, 'size'>) {
return (
<div className='rounded-card px-6 py-14 ring-1 ring-inset ring-border-subtle'>
<IconMessage {...props} />
</div>
);
}

View File

@ -0,0 +1,32 @@
import type { ReactNode } from 'react';
import { InlineMessage } from '~/components/ui/inline-message';
import { Label } from '~/components/ui/label';
import { Text } from '~/components/ui/text';
interface FieldProps {
label: string;
htmlFor?: string;
required?: boolean;
hint?: string;
error?: string;
// Shown on the right of the label: "Optional" / "Required"
requirement?: 'optional' | 'required';
action?: ReactNode;
children?: ReactNode;
}
export function Field({ label, htmlFor, required, hint, error, requirement, action, children }: FieldProps) {
return (
<div className='space-y-2'>
<div className='flex min-h-6 items-center justify-between gap-3'>
<Label htmlFor={htmlFor}>
{label}
{required && <Text as='span' variant='label' tone='primary' className='ml-0.5'>*</Text>}
</Label>
{action ?? (requirement && <Text as='span' variant='meta'>{requirement === 'optional' ? 'Optional' : 'Required'}</Text>)}
</div>
{children}
{error ? <InlineMessage tone='danger'>{error}</InlineMessage> : hint && <Text variant='caption'>{hint}</Text>}
</div>
);
}

View File

@ -0,0 +1,18 @@
import type { ReactNode } from 'react';
import { Link } from 'react-router';
import { cn } from '~/lib/utils';
export function FilterChip({ to, selected, children }: { to: string; selected: boolean; children: ReactNode }) {
return (
<Link
to={to}
aria-current={selected ? 'page' : undefined}
className={cn(
'flex h-[30px] items-center rounded-full px-3 text-xs font-medium ring-1 ring-inset transition-colors',
selected ? 'bg-text-primary text-background ring-text-primary' : 'text-text-secondary ring-border-control hover:text-text-primary',
)}
>
{children}
</Link>
);
}

View File

@ -0,0 +1,17 @@
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '~/lib/utils';
const glowVariants = cva('pointer-events-none absolute rounded-full', {
variants: {
intensity: {
soft: 'bg-primary/5 blur-[120px]',
strong: 'bg-primary/10 blur-[140px]',
},
},
defaultVariants: { intensity: 'soft' },
});
// Decorative brand glow; position and size come from className
export function Glow({ intensity, className }: VariantProps<typeof glowVariants> & { className?: string }) {
return <div aria-hidden='true' className={cn(glowVariants({ intensity }), className)} />;
}

View File

@ -0,0 +1,22 @@
import type { ReactNode } from 'react';
import type { LucideIcon } from 'lucide-react';
import { Input, type InputProps } from '~/components/ui/input';
import { cn } from '~/lib/utils';
interface IconInputProps extends InputProps {
icon: LucideIcon;
trailing?: ReactNode;
}
export function IconInput({ icon: Icon, trailing, className, ...props }: IconInputProps) {
return (
<div className='group relative'>
<Icon
size={17}
className='pointer-events-none absolute left-4 top-1/2 -translate-y-1/2 text-text-muted transition-colors group-focus-within:text-primary'
/>
<Input className={cn('pl-11', trailing && 'pr-16', className)} {...props} />
{trailing && <div className='absolute right-2 top-1/2 -translate-y-1/2'>{trailing}</div>}
</div>
);
}

View File

@ -0,0 +1,26 @@
import type { ReactNode } from 'react';
import type { LucideIcon } from 'lucide-react';
import { IconTile } from '~/components/ui/icon-tile';
import { Text } from '~/components/ui/text';
export interface IconMessageProps {
icon?: LucideIcon;
title: string;
message?: string;
action?: ReactNode;
size?: 'md' | 'lg';
}
export function IconMessage({ icon, title, message, action, size = 'md' }: IconMessageProps) {
const large = size === 'lg';
return (
<div className='flex flex-col items-center gap-2 text-center'>
{icon && <IconTile icon={icon} tone={large ? 'neutral' : 'primary'} size={large ? 'xl' : 'lg'} className='mb-2' />}
<Text as={large ? 'h1' : 'h3'} variant={large ? 'title' : 'heading'}>
{title}
</Text>
{message && <Text tone='subtle' className='max-w-sm'>{message}</Text>}
{action && <div className='mt-4'>{action}</div>}
</div>
);
}

View File

@ -0,0 +1,32 @@
import type { LucideIcon } from 'lucide-react';
import { cva } from 'class-variance-authority';
import { toneSurface, type Tone } from '~/components/ui/tone';
import { cn } from '~/lib/utils';
const tileSize = cva('flex shrink-0 items-center justify-center', {
variants: {
size: {
sm: 'h-9 w-9 rounded-item',
md: 'h-10 w-10 rounded-group',
lg: 'h-12 w-12 rounded-card-sm',
xl: 'h-14 w-14 rounded-card',
},
},
});
const ICON_SIZE = { sm: 16, md: 18, lg: 22, xl: 24 } as const;
interface IconTileProps {
icon: LucideIcon;
tone?: Tone;
size?: keyof typeof ICON_SIZE;
className?: string;
}
export function IconTile({ icon: Icon, tone = 'primary', size = 'md', className }: IconTileProps) {
return (
<div className={cn(toneSurface({ tone }), tileSize({ size }), tone === 'neutral' && 'text-primary', className)}>
<Icon size={ICON_SIZE[size]} />
</div>
);
}

View File

@ -0,0 +1,12 @@
import type { ReactNode } from 'react';
import { AlertCircle } from 'lucide-react';
import { Text } from '~/components/ui/text';
export function InlineMessage({ tone, children }: { tone: 'danger' | 'warning'; children: ReactNode }) {
return (
<Text role={tone === 'danger' ? 'alert' : undefined} variant='caption' tone={tone} className='flex items-center gap-1.5'>
<AlertCircle size={13} className='shrink-0' />
{children}
</Text>
);
}

View File

@ -1,21 +1,25 @@
import * as React from 'react';
import type { ComponentProps } from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '~/lib/utils';
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<'input'>>(
({ className, type, ...props }, ref) => {
return (
<input
type={type}
className={cn(
'flex h-10 w-full rounded-xl border border-neutral-800 bg-[#181818] px-4 py-3 text-sm text-white placeholder-neutral-600 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-white focus-visible:outline-none focus-visible:border-orange-500 disabled:cursor-not-allowed disabled:opacity-50 transition-colors duration-200',
className
)}
ref={ref}
{...props}
/>
);
}
const inputVariants = cva(
'flex w-full rounded-control border border-border-control bg-background text-text-primary transition-[color,border-color,box-shadow] duration-150 focus-visible:border-primary focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger/70',
{
variants: {
size: {
sm: 'h-8 px-2.5 text-xs',
md: 'h-10 px-3 text-base',
// Login: taller, with a soft focus ring
lg: 'h-12 rounded-field border-border-dialog bg-surface px-3.5 text-base focus-visible:ring-3 focus-visible:ring-primary/15',
},
mono: { true: 'font-mono', false: '' },
},
defaultVariants: { size: 'md', mono: false },
},
);
Input.displayName = 'Input';
export { Input };
export interface InputProps extends Omit<ComponentProps<'input'>, 'size'>, VariantProps<typeof inputVariants> {}
export function Input({ className, size, mono, ...props }: InputProps) {
return <input className={cn(inputVariants({ size, mono }), className)} {...props} />;
}

View File

@ -1,17 +1,6 @@
import * as React from 'react';
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '~/lib/utils';
import type { LabelHTMLAttributes } from 'react';
import { Text } from '~/components/ui/text';
const labelVariants = cva(
'text-xs font-bold text-neutral-400 uppercase tracking-wider select-none leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'
);
const Label = React.forwardRef<
HTMLLabelElement,
React.LabelHTMLAttributes<HTMLLabelElement> & VariantProps<typeof labelVariants>
>(({ className, ...props }, ref) => (
<label ref={ref} className={cn(labelVariants(), className)} {...props} />
));
Label.displayName = 'Label';
export { Label };
export function Label(props: LabelHTMLAttributes<HTMLLabelElement>) {
return <Text as='label' variant='label' {...props} />;
}

View File

@ -0,0 +1,17 @@
import { Text } from '~/components/ui/text';
import { LOADER_ILLUSTRATION } from '~/data/brand';
// Full-screen loading state: the AR illustration, an indeterminate bar and a label. Still with reduced motion.
export function LoadingScreen({ label = 'Loading…' }: { label?: string }) {
return (
<div role='status' className='fixed inset-0 flex flex-col items-center justify-center gap-7 bg-background px-6'>
<img {...LOADER_ILLUSTRATION} alt='' className='h-auto w-full max-w-[400px] animate-float motion-reduce:animate-none' />
<div className='flex w-40 flex-col items-center gap-3'>
<span aria-hidden='true' className='relative h-0.5 w-full overflow-hidden rounded-full bg-border-divider'>
<span className='absolute inset-y-0 left-0 w-1/3 animate-loading-bar rounded-full bg-primary motion-reduce:animate-none' />
</span>
<Text variant='eyebrow'>{label}</Text>
</div>
</div>
);
}

View File

@ -0,0 +1,25 @@
import { cva, type VariantProps } from 'class-variance-authority';
import { cn } from '~/lib/utils';
const logoVariants = cva('flex shrink-0 select-none items-center justify-center font-bold leading-none text-primary', {
variants: {
size: {
xs: 'h-7 w-7 rounded-item text-base',
sm: 'h-8 w-8 rounded-control text-md',
md: 'h-[34px] w-[34px] rounded-group text-md',
},
surface: {
app: 'bg-surface-control ring-1 ring-inset ring-border-control',
viewer: 'bg-ink',
},
},
defaultVariants: { size: 'md', surface: 'app' },
});
export function LogoMark({ size, surface, className }: VariantProps<typeof logoVariants> & { className?: string }) {
return (
<span aria-hidden='true' className={cn(logoVariants({ size, surface }), className)}>
t.
</span>
);
}

View File

@ -0,0 +1,34 @@
import type { ReactNode } from 'react';
import { cva } from 'class-variance-authority';
import { ClientLogo } from '~/components/ui/client-logo';
import { cn } from '~/lib/utils';
import type { BrandIdentity } from '~/types/project';
const tileVariants = cva('relative flex items-center justify-center overflow-hidden', {
variants: {
size: {
// Padding is the room around the logo, which fills the rest
card: 'h-[150px] w-full rounded-control p-6',
header: 'h-24 w-[200px] shrink-0 rounded-card px-6 py-4',
field: 'h-14 w-[120px] shrink-0 rounded-item p-2',
},
background: { light: 'bg-logo-tile-light', dark: 'bg-logo-tile-dark' },
},
});
interface LogoTileProps {
brand: BrandIdentity;
size: 'card' | 'header' | 'field';
className?: string;
children?: ReactNode;
}
// The client logo on a tile coloured by the project's logo background (admin screens)
export function LogoTile({ brand, size, className, children }: LogoTileProps) {
return (
<div className={cn(tileVariants({ size, background: brand.logoBg }), className)} style={brand.logoBgColor ? { backgroundColor: brand.logoBgColor } : undefined}>
<ClientLogo brand={brand} variant='plain' size='fill' />
{children}
</div>
);
}

View File

@ -0,0 +1,19 @@
import type { ComponentProps } from 'react';
import { cn } from '~/lib/utils';
type ModelViewerProps = ComponentProps<'model-viewer'>;
// Shared defaults for every <model-viewer> in the app; the element itself is loaded in root.tsx
export function ModelViewer({ className, ...props }: ModelViewerProps) {
return (
<model-viewer
ar
ar-modes='webxr scene-viewer quick-look'
camera-controls
shadow-intensity='1'
shadow-softness='0.8'
className={cn('block h-full w-full', className)}
{...props}
/>
);
}

View File

@ -0,0 +1,30 @@
import { Fragment } from 'react';
import { Link } from 'react-router';
import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from '~/components/ui/breadcrumb';
interface PageBreadcrumbProps {
trail: { label: string; to: string }[];
current: string;
}
export function PageBreadcrumb({ trail, current }: PageBreadcrumbProps) {
return (
<Breadcrumb>
<BreadcrumbList>
{trail.map((crumb) => (
<Fragment key={crumb.to}>
<BreadcrumbItem>
<BreadcrumbLink asChild>
<Link to={crumb.to}>{crumb.label}</Link>
</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>/</BreadcrumbSeparator>
</Fragment>
))}
<BreadcrumbItem>
<BreadcrumbPage>{current}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
);
}

View File

@ -0,0 +1,20 @@
import type { ReactNode } from 'react';
import { Text } from '~/components/ui/text';
interface PageHeaderProps {
title: string;
description?: string;
actions?: ReactNode;
}
export function PageHeader({ title, description, actions }: PageHeaderProps) {
return (
<div className='flex flex-wrap items-end justify-between gap-4'>
<div className='flex flex-col gap-1.5'>
<Text as='h1' variant='display'>{title}</Text>
{description && <Text tone='subtle'>{description}</Text>}
</div>
{actions && <div className='flex flex-wrap items-center gap-3'>{actions}</div>}
</div>
);
}

Some files were not shown because too many files have changed in this diff Show More