Skip to content

The only tool you need to know what is happening and how to fix it.

feat: shop ui update (#247)

narrow-adventure319b4c0f2957
diff --git a/skills/traceway/SKILL.md b/skills/traceway/SKILL.md
index 94fc0647..1dde59e7 100644
--- a/skills/traceway/SKILL.md
+++ b/skills/traceway/SKILL.md
@@ -187,7 +187,7 @@ The selected project is used implicitly by all subsequent commands.
| Reference looks like | How to resolve |
|---|---|
-| Dashboard URL | See "Resolving Dashboard URLs" above; for `/issues/...` URLs the path segment right after `/issues/` is the hash, and `?preset`/`?from`/`?to` give the time window |
+| Dashboard URL | See "Resolving Dashboard URLs" above; for `/issues/...` URLs the path segment right after `/issues/` is the hash, and `?preset`/`?from`/`?to` give the time window. **When a URL points at an issue, fix the LAST (most recent) occurrence of that issue — see step 2.** |
| Bare 16-char hex string | Already the hash |
| Anything else (title, error message, type, file name) | Search: `traceway exceptions list --since 7d --search "<text>"`; widen to `--since 30d` (and `--include-archived`) if empty |
| No issue reference, just a bug description | Skip to triage below |
@@ -207,6 +207,22 @@ traceway exceptions show <hash>
This is the high-value call: full stack trace, occurrence list with `recordedAt`, `attributes` (user IDs, app versions, request context), and optional `distributedTraceId` / `sessionId` per occurrence. `firstSeen` correlates with deploys: a group that first appeared right after a release points at that release's diff. A bogus hash exits 5 with `not_found`; fall back to search.
+**When the user gave an issue URL (or hash), fix the LAST occurrence — not "the group".** A single hash can bundle *several distinct errors*: the hash is computed from a normalized stack trace with the message stripped, so two unrelated failures that share their top frames (e.g. both captured at the same middleware/recovery frame) collapse into one group. The group's representative stack trace and `firstSeen` may belong to a different, now-dormant error than the one the user is looking at. Anchor on the most recent occurrence and fix that specific failure path:
+
+```bash
+# The occurrence the user actually wants: the latest one. Pin its exact message + attributes + trace.
+traceway exceptions show <hash> --output json \
+ | jq '.occurrences | sort_by(.recordedAt) | last
+ | {recordedAt, message: (.stackTrace | split("\n")[0]), attributes, traceId, distributedTraceId}'
+
+# Then confirm whether the group is homogeneous or mixed — distinct first lines = distinct bugs:
+traceway exceptions show <hash> --output json \
+ | jq -r '[.occurrences[].stackTrace | split("\n")[0]] | group_by(.)
+ | map("\(length)x \(.[0])") | .[]'
+```
+
+If the group is mixed, scope the fix to the last occurrence's error only; mention the other clusters in the report but do not fix them unless asked. The last occurrence's message and `attributes` (not the group's representative stack) define the failure to reproduce and fix — and its `recordedAt` is the time hint to pass to the by-id `traces show` / `sessions show` lookups below.
+
### 3. Triage and correlate (also the entry point for free-form bug descriptions)
From the description extract symptom, affected endpoint/feature, and time window, then read several signals before forming a hypothesis:
@@ -254,8 +270,8 @@ The CLI also accepts `p50|p95|p99`, but the server has no quantile aggregation f
1. Open the files and lines named in the stack trace and read the failing path.
2. If the issue started at a known time, check what shipped then: `git log --since "<firstSeen>" --until "<firstSeen + 1h>"` or the deploy history.
-3. Form a hypothesis that explains ALL observations (error message, affected endpoint, timing, volume), not just the first stack frame.
-4. Propose or implement the fix per the user's instruction.
+3. Form a hypothesis that explains the targeted occurrence's full observation set (its message, affected endpoint, timing, volume) — not just the first stack frame. When a URL/hash anchored you to the last occurrence (step 2), explain *that* error; do not stretch one hypothesis to cover sibling clusters that merely share the hash.
+4. Propose or implement the fix per the user's instruction, scoped to the targeted occurrence's failure path.
### 5. Report and clean up
diff --git a/testing/shop/.gitignore b/testing/shop/.gitignore
new file mode 100644
index 00000000..8299200e
--- /dev/null
+++ b/testing/shop/.gitignore
@@ -0,0 +1,3 @@
+.traceway/
+.tw-bin/
+.envrc
diff --git a/testing/shop/backend/.env.example b/testing/shop/backend/.env.example
new file mode 100644
index 00000000..54d9195e
--- /dev/null
+++ b/testing/shop/backend/.env.example
@@ -0,0 +1,2 @@
+# Backend Traceway Go SDK endpoint (token@url). Secret token — keep real values in backend/.env (gitignored).
+TRACEWAY_ENDPOINT=<project-token>@https://cloud.tracewayapp.com/api/report
diff --git a/testing/shop/backend/.gitignore b/testing/shop/backend/.gitignore
index 719a48b8..4341d483 100644
--- a/testing/shop/backend/.gitignore
+++ b/testing/shop/backend/.gitignore
@@ -2,3 +2,4 @@
/shop-backend
/dist/*
!/dist/.gitkeep
+.env
diff --git a/testing/shop/backend/checkout.go b/testing/shop/backend/checkout.go
index 71a6d275..314491eb 100644
--- a/testing/shop/backend/checkout.go
+++ b/testing/shop/backend/checkout.go
@@ -43,6 +43,12 @@ func checkout(c *gin.Context) {
}
rows.Close()
+ if len(lines) == 0 {
+ traceway.CaptureExceptionWithContext(ctx, traceway.NewStackTraceErrorf("checkout attempted with empty cart"))
+ c.JSON(http.StatusInternalServerError, gin.H{"error": "your cart is empty"})
+ return
+ }
+
pay := traceway.StartSpan(ctx, "payment.charge")
if !fastPath() {
slowJitter(300, 1200)
diff --git a/testing/shop/backend/coupon.go b/testing/shop/backend/coupon.go
index c4227004..105e72e9 100644
--- a/testing/shop/backend/coupon.go
+++ b/testing/shop/backend/coupon.go
@@ -12,7 +12,7 @@ import (
"github.com/gin-gonic/gin"
)
-var couponHits map[string]int
+var couponHits = map[string]int{}
func applyCoupon(c *gin.Context) {
ctx := c.Request.Context()
@@ -42,12 +42,12 @@ func applyCoupon(c *gin.Context) {
return
}
- if fastPath() {
- if couponHits != nil {
- couponHits[req.Code]++
- }
- } else {
- couponHits[req.Code]++
+ couponHits[req.Code]++
+
+ if !fastPath() {
+ traceway.CaptureExceptionWithContext(ctx, traceway.NewStackTraceErrorf("coupon service timeout while applying %s", req.Code))
+ c.JSON(http.StatusInternalServerError, gin.H{"error": "could not apply coupon, please try again"})
+ return
}
total := cartTotal(ctx, twdb)
diff --git a/testing/shop/backend/products.go b/testing/shop/backend/products.go
index 36aff9d2..1794a6c2 100644
--- a/testing/shop/backend/products.go
+++ b/testing/shop/backend/products.go
@@ -61,7 +61,7 @@ func listProducts(c *gin.Context) {
rows.Close()
for i := range products {
- slowJitter(900, 1100)
+ slowJitter(200, 300)
catRow := twdb.QueryRowContext(ctx, `SELECT name FROM categories WHERE id = ?`, products[i].CategoryId)
_ = catRow.Scan(&products[i].Category)
diff --git a/testing/shop/build-and-run.sh b/testing/shop/build-and-run.sh
index aaff5cb1..28b43309 100755
--- a/testing/shop/build-and-run.sh
+++ b/testing/shop/build-and-run.sh
@@ -20,4 +20,7 @@ cd backend
CGO_ENABLED=1 go build -o shop .
echo "==> Starting shop on http://localhost:8090"
+set -a
+[ -f .env ] && source .env
+set +a
exec ./shop
diff --git a/testing/shop/frontend/index.html b/testing/shop/frontend/index.html
index 79866a42..977e3c82 100644
--- a/testing/shop/frontend/index.html
+++ b/testing/shop/frontend/index.html
@@ -3,9 +3,9 @@
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Traceway Demo Shop</title>
+ <title>Shoply · Modern Goods</title>
</head>
- <body>
+ <body class="min-h-dvh bg-white text-neutral-900 antialiased">
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
diff --git a/testing/shop/frontend/package-lock.json b/testing/shop/frontend/package-lock.json
index 37b91b9f..291e4240 100644
--- a/testing/shop/frontend/package-lock.json
+++ b/testing/shop/frontend/package-lock.json
@@ -11,9 +11,11 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
+ "@tailwindcss/vite": "^4.1.11",
"@tracewayapp/bundler-plugin": "^1.2.0",
"@tracewayapp/sourcemap-upload": "^1.2.0",
"@vitejs/plugin-react": "^4.3.4",
+ "tailwindcss": "^4.1.11",
"vite": "^7.0.0"
}
},
@@ -1170,6 +1172,278 @@
"integrity": "sha512-t+b+4rB23/e4EpoGMdPUr6cKtDsFuOb3LxA9IHE8e3A/Xo0nMUfH0bkwqdpUNa/VGDOdiGeG3bhHjuO9zWX54g==",
"license": "MIT"
},
+ "node_modules/@tailwindcss/node": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/node/-/node-4.3.1.tgz",
+ "integrity": "sha512-6NDaqRoAMSXD1mr/RXu0HBvNE9a2n5tHPsxu9XHLws8o4Twes5rBM2205SUUiJ9goAtadrN6xTGX0UDEwp/N4A==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@jridgewell/remapping": "^2.3.5",
+ "enhanced-resolve": "5.21.6",
+ "jiti": "^2.7.0",
+ "lightningcss": "1.32.0",
+ "magic-string": "^0.30.21",
+ "source-map-js": "^1.2.1",
+ "tailwindcss": "4.3.1"
+ }
+ },
+ "node_modules/@tailwindcss/oxide": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide/-/oxide-4.3.1.tgz",
+ "integrity": "sha512-yVPyo8RNkabVr3O2EhHEE0Rewu7YKzc1DhIqfL46LKveFrmu9XbDazNOJY7/GRuvw1h6u3utWnR29H/p5JPlgA==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">= 20"
+ },
+ "optionalDependencies": {
+ "@tailwindcss/oxide-android-arm64": "4.3.1",
+ "@tailwindcss/oxide-darwin-arm64": "4.3.1",
+ "@tailwindcss/oxide-darwin-x64": "4.3.1",
+ "@tailwindcss/oxide-freebsd-x64": "4.3.1",
+ "@tailwindcss/oxide-linux-arm-gnueabihf": "4.3.1",
+ "@tailwindcss/oxide-linux-arm64-gnu": "4.3.1",
+ "@tailwindcss/oxide-linux-arm64-musl": "4.3.1",
+ "@tailwindcss/oxide-linux-x64-gnu": "4.3.1",
+ "@tailwindcss/oxide-linux-x64-musl": "4.3.1",
+ "@tailwindcss/oxide-wasm32-wasi": "4.3.1",
+ "@tailwindcss/oxide-win32-arm64-msvc": "4.3.1",
+ "@tailwindcss/oxide-win32-x64-msvc": "4.3.1"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-android-arm64": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-android-arm64/-/oxide-android-arm64-4.3.1.tgz",
+ "integrity": "sha512-SVlyf61g374l5cHyg8x9kf5xmLcOaxvOTsbsqDnSsDJaKOEFZ7GCvi84VAVGpxojYOs1+3K6M0UjXfqPU8vmOQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-darwin-arm64": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-arm64/-/oxide-darwin-arm64-4.3.1.tgz",
+ "integrity": "sha512-hVnWLwv+e/l7c4WKyVtHVrIPvYdqWHjRB3MDIqARynzFtnQg85kmQEFCbV9Ja0VVx4xXTIiDWY60Y7iz/iNoDA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-darwin-x64": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-darwin-x64/-/oxide-darwin-x64-4.3.1.tgz",
+ "integrity": "sha512-Cf7abu0WVgbhU7ANgPUnSAvm7nCvMweusHb8FnaHlLfv/Caq4GYaEZg7ZImzzmjx4lIAfuS8q+eLIS7A7IzxIg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-freebsd-x64": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-freebsd-x64/-/oxide-freebsd-x64-4.3.1.tgz",
+ "integrity": "sha512-ZZqzX2Y+GXtXXfqSfpJhDm60OoZfvLHLCgm+J7NVqgHHJjG/m9ugZI77RwTsVd4fnBJuCFP6Ae6kTJb71UdS8g==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-linux-arm-gnueabihf": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm-gnueabihf/-/oxide-linux-arm-gnueabihf-4.3.1.tgz",
+ "integrity": "sha512-/Ah/xik0LaMYfv9DZ0S/t4pBlBNYOcqtRwusjgovHkvT8ixueWCLyJjsaF5kQIckjb4IT8Q6K6p/iPmZMixYgg==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-linux-arm64-gnu": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-gnu/-/oxide-linux-arm64-gnu-4.3.1.tgz",
+ "integrity": "sha512-gqdFoVJlw444GvpnheZLHmvTzSxI/cOUUh2KSNejQjTcYkW062SVD+En0rUgD+QV91bz1XGIGtt1HJd48xUGbQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-linux-arm64-musl": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-arm64-musl/-/oxide-linux-arm64-musl-4.3.1.tgz",
+ "integrity": "sha512-Bwv9KwOvE0VKa86xPFif9b9c3Y1NxOV1P0gLti/IYaWEsQYZXDlxfGEtA8mdDZ7SG3wyNXAWYT5SIn3giL57oA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-linux-x64-gnu": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-gnu/-/oxide-linux-x64-gnu-4.3.1.tgz",
+ "integrity": "sha512-Ymi8O8T15HYQdOUWUtTI6ldN0neHP85FC+Qz32xTcZ7iJXtem/x8ITev0o1e9e5rkqj4lONZfTRLvkmin1+tKg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-linux-x64-musl": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-linux-x64-musl/-/oxide-linux-x64-musl-4.3.1.tgz",
+ "integrity": "sha512-M+P/91qJ6uILLw4k2G93GMDRAXj61SMvFQYt39AqvUqYgExXpLL5aepfns7sj4HiAQeolirQF9E0lzRvdf4zPQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-wasm32-wasi": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-wasm32-wasi/-/oxide-wasm32-wasi-4.3.1.tgz",
+ "integrity": "sha512-zsM8uOeqvVGHsAXsJxsT28ttosFahLJKCLOTUBqRAtKnVgGSRitds9T432QiT8b77Yga7JIBkulIRRlJPtYhRA==",
+ "bundleDependencies": [
+ "@napi-rs/wasm-runtime",
+ "@emnapi/core",
+ "@emnapi/runtime",
+ "@tybys/wasm-util",
+ "@emnapi/wasi-threads",
+ "tslib"
+ ],
+ "cpu": [
+ "wasm32"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "dependencies": {
+ "@emnapi/core": "^1.10.0",
+ "@emnapi/runtime": "^1.10.0",
+ "@emnapi/wasi-threads": "^1.2.1",
+ "@napi-rs/wasm-runtime": "^1.1.4",
+ "@tybys/wasm-util": "^0.10.2",
+ "tslib": "^2.8.1"
+ },
+ "engines": {
+ "node": ">=14.0.0"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-win32-arm64-msvc": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.3.1.tgz",
+ "integrity": "sha512-aiNvSq9BsVk8V513lDKlrCFAgf8qBMPZTpgEhInL+NwQqs97mYmupVMrPrgBBSL8Pv/0zXu9MrMF9rMun1ZeNg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/oxide-win32-x64-msvc": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-x64-msvc/-/oxide-win32-x64-msvc-4.3.1.tgz",
+ "integrity": "sha512-xDEyu1rg290472FEGaKHnzyDyh5QH+AlWvsU5hMoMtPpzmKlRI0jaYKCgSHDYtaQWZOYbMaduSyCwFwY4n1HmA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MIT",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 20"
+ }
+ },
+ "node_modules/@tailwindcss/vite": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/@tailwindcss/vite/-/vite-4.3.1.tgz",
+ "integrity": "sha512-hItDHuIIlEV61R+faXu66s1K36aTurO/Qw0e45Vskz57gXl9pWOT6eg3zmcEui6CZXddbN7zd41bwmvag4JGwQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@tailwindcss/node": "4.3.1",
+ "@tailwindcss/oxide": "4.3.1",
+ "tailwindcss": "4.3.1"
+ },
+ "peerDependencies": {
+ "vite": "^5.2.0 || ^6 || ^7 || ^8"
+ }
+ },
"node_modules/@tracewayapp/bundler-plugin": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@tracewayapp/bundler-plugin/-/bundler-plugin-1.2.0.tgz",
@@ -1442,6 +1716,16 @@
}
}
},
+ "node_modules/detect-libc": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz",
+ "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
+ "dev": true,
+ "license": "Apache-2.0",
+ "engines": {
+ "node": ">=8"
+ }
+ },
"node_modules/electron-to-chromium": {
"version": "1.5.376",
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.376.tgz",
@@ -1449,6 +1733,20 @@
"dev": true,
"license": "ISC"
},
+ "node_modules/enhanced-resolve": {
+ "version": "5.21.6",
+ "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.21.6.tgz",
+ "integrity": "sha512-aNnGCvbJ/RIyWo1IuhNdVjnNF+EjH9wpzpNHt+ci/m9He9LJvUN8wrCcXjp9cWsGNAuvSpVFTx/vraAFQ8qGjQ==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "graceful-fs": "^4.2.4",
+ "tapable": "^2.3.3"
+ },
+ "engines": {
+ "node": ">=10.13.0"
+ }
+ },
"node_modules/esbuild": {
"version": "0.27.7",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.7.tgz",
@@ -1586,6 +1884,13 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/graceful-fs": {
+ "version": "4.2.11",
+ "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz",
+ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==",
+ "dev": true,
+ "license": "ISC"
+ },
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
@@ -1609,6 +1914,16 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/jiti": {
+ "version": "2.7.0",
+ "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.7.0.tgz",
+ "integrity": "sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "jiti": "lib/jiti-cli.mjs"
+ }
+ },
"node_modules/js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
@@ -1641,6 +1956,267 @@
"node": ">=6"
}
},
+ "node_modules/lightningcss": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz",
+ "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==",
+ "dev": true,
+ "license": "MPL-2.0",
+ "dependencies": {
+ "detect-libc": "^2.0.3"
+ },
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ },
+ "optionalDependencies": {
+ "lightningcss-android-arm64": "1.32.0",
+ "lightningcss-darwin-arm64": "1.32.0",
+ "lightningcss-darwin-x64": "1.32.0",
+ "lightningcss-freebsd-x64": "1.32.0",
+ "lightningcss-linux-arm-gnueabihf": "1.32.0",
+ "lightningcss-linux-arm64-gnu": "1.32.0",
+ "lightningcss-linux-arm64-musl": "1.32.0",
+ "lightningcss-linux-x64-gnu": "1.32.0",
+ "lightningcss-linux-x64-musl": "1.32.0",
+ "lightningcss-win32-arm64-msvc": "1.32.0",
+ "lightningcss-win32-x64-msvc": "1.32.0"
+ }
+ },
+ "node_modules/lightningcss-android-arm64": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz",
+ "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "android"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-arm64": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz",
+ "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-darwin-x64": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz",
+ "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-freebsd-x64": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz",
+ "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "freebsd"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm-gnueabihf": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz",
+ "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-gnu": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz",
+ "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-arm64-musl": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz",
+ "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-gnu": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz",
+ "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-linux-x64-musl": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz",
+ "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-arm64-msvc": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz",
+ "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
+ "node_modules/lightningcss-win32-x64-msvc": {
+ "version": "1.32.0",
+ "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz",
+ "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "license": "MPL-2.0",
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "engines": {
+ "node": ">= 12.0.0"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/parcel"
+ }
+ },
"node_modules/loose-envify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz",
@@ -2009,6 +2585,27 @@
"node": ">=0.10.0"
}
},
+ "node_modules/tailwindcss": {
+ "version": "4.3.1",
+ "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-4.3.1.tgz",
+ "integrity": "sha512-hk+TB1m+K8CYNrP6rjQaq/Y+4Zylwpa87mLYBKCunwnnQ9p+fHb7kmSfGqyEJoxF/O6CDyABWVFEafNSYKll+Q==",
+ "dev": true,
+ "license": "MIT"
+ },
+ "node_modules/tapable": {
+ "version": "2.3.3",
+ "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz",
+ "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==",
+ "dev": true,
+ "license": "MIT",
+ "engines": {
+ "node": ">=6"
+ },
+ "funding": {
+ "type": "opencollective",
+ "url": "https://opencollective.com/webpack"
+ }
+ },
"node_modules/tinyglobby": {
"version": "0.2.17",
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz",
diff --git a/testing/shop/frontend/package.json b/testing/shop/frontend/package.json
index e2b713d0..9f9507d4 100644
--- a/testing/shop/frontend/package.json
+++ b/testing/shop/frontend/package.json
@@ -14,9 +14,11 @@
"react-dom": "^18.3.1"
},
"devDependencies": {
+ "@tailwindcss/vite": "^4.1.11",
"@tracewayapp/bundler-plugin": "^1.2.0",
"@tracewayapp/sourcemap-upload": "^1.2.0",
"@vitejs/plugin-react": "^4.3.4",
+ "tailwindcss": "^4.1.11",
"vite": "^7.0.0"
}
}
diff --git a/testing/shop/frontend/src/App.jsx b/testing/shop/frontend/src/App.jsx
index 86200b4a..fe517d8f 100644
--- a/testing/shop/frontend/src/App.jsx
+++ b/testing/shop/frontend/src/App.jsx
@@ -3,6 +3,13 @@ import { getCart } from './api.js'
import ProductsPage from './ProductsPage.jsx'
import CartPage from './CartPage.jsx'
import CheckoutPage from './CheckoutPage.jsx'
+import { cx, Logo, IconBag } from './ui.jsx'
+
+const NAV = [
+ { key: 'products', label: 'Shop' },
+ { key: 'cart', label: 'Cart' },
+ { key: 'checkout', label: 'Checkout' }
+]
export default function App() {
const [page, setPage] = useState('products')
@@ -23,27 +30,75 @@ export default function App() {
}, [page])
return (
- <div className="app">
- <header className="topbar">
- <div className="brand" onClick={() => setPage('products')}>
- <span className="logo">🛍️</span> Traceway Demo Shop
- </div>
- <nav>
- <button className={page === 'products' ? 'active' : ''} onClick={() => setPage('products')}>
- Products
- </button>
- <button className={page === 'cart' ? 'active' : ''} onClick={() => setPage('cart')}>
- Cart <span className="badge">{cartCount}</span>
- </button>
- <button className={page === 'checkout' ? 'active' : ''} onClick={() => setPage('checkout')}>
- Checkout
+ <div className="isolate flex min-h-dvh flex-col">
+ <div className="bg-neutral-900 px-4 py-2 text-center text-xs font-medium text-neutral-300 sm:text-sm">
+ Free shipping on orders over $50 · 30-day returns, no questions asked.
+ </div>
+
+ <header className="sticky top-0 z-40 border-b border-neutral-950/5 bg-white/80 backdrop-blur-md">
+ <div className="mx-auto flex h-16 max-w-6xl items-center justify-between gap-4 px-4 sm:px-6">
+ <button
+ type="button"
+ onClick={() => setPage('products')}
+ className="group flex items-center gap-2.5 rounded-lg focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-neutral-900"
+ >
+ <Logo className="size-8" />
+ <span className="text-lg font-semibold tracking-tight text-neutral-900">Shoply</span>
</button>
- </nav>
+
+ <nav className="flex items-center gap-1">
+ {NAV.map((item) => {
+ const active = page === item.key
+ if (item.key === 'cart') {
+ return (
+ <button
+ key={item.key}
+ type="button"
+ onClick={() => setPage('cart')}
+ aria-label={`Cart, ${cartCount} items`}
+ className={cx(
+ 'relative inline-flex items-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-900',
+ active ? 'text-neutral-900' : 'text-neutral-500 hover:text-neutral-900'
+ )}
+ >
+ <span className="relative inline-flex">
+ <IconBag className="size-5" />
+ {cartCount > 0 && (
+ <span className="absolute -top-2 -right-2 inline-flex h-4 min-w-4 items-center justify-center rounded-full bg-neutral-900 px-1 text-[0.625rem] font-semibold tabular-nums text-white">
+ {cartCount}
+ </span>
+ )}
+ </span>
+ <span className="max-sm:hidden">Cart</span>
+ </button>
+ )
+ }
+ return (
+ <button
+ key={item.key}
+ type="button"
+ onClick={() => setPage(item.key)}
+ className={cx(
+ 'rounded-lg px-3 py-2 text-sm font-medium transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-900',
+ active ? 'text-neutral-900' : 'text-neutral-500 hover:text-neutral-900'
+ )}
+ >
+ {item.label}
+ </button>
+ )
+ })}
+ </nav>
+ </div>
</header>
- <main className="content">
+
+ <main className="mx-auto w-full max-w-6xl flex-1 px-4 py-10 sm:px-6 sm:py-12">
{page === 'products' && <ProductsPage onCartChanged={refreshCartCount} />}
{page === 'cart' && (
- <CartPage onCartChanged={refreshCartCount} goCheckout={() => setPage('checkout')} />
+ <CartPage
+ onCartChanged={refreshCartCount}
+ goCheckout={() => setPage('checkout')}
+ goShop={() => setPage('products')}
+ />
)}
{page === 'checkout' && (
<CheckoutPage
@@ -54,6 +109,23 @@ export default function App() {
/>
)}
</main>
+
+ <footer className="border-t border-neutral-950/5">
+ <div className="mx-auto flex max-w-6xl flex-col gap-6 px-4 py-10 sm:flex-row sm:items-center sm:justify-between sm:px-6">
+ <div className="flex items-center gap-2.5">
+ <Logo className="size-7" />
+ <p className="text-sm text-neutral-500 text-pretty">
+ Shoply — modern goods for everyday life.
+ </p>
+ </div>
+ <nav className="flex flex-wrap gap-x-6 gap-y-2 text-sm text-neutral-500">
+ <a href="#" className="hover:text-neutral-900">About</a>
+ <a href="#" className="hover:text-neutral-900">Shipping</a>
+ <a href="#" className="hover:text-neutral-900">Returns</a>
+ <a href="#" className="hover:text-neutral-900">Powered by Traceway</a>
+ </nav>
+ </div>
+ </footer>
</div>
)
}
diff --git a/testing/shop/frontend/src/CartPage.jsx b/testing/shop/frontend/src/CartPage.jsx
index 33824e61..acfe4bd8 100644
--- a/testing/shop/frontend/src/CartPage.jsx
+++ b/testing/shop/frontend/src/CartPage.jsx
@@ -1,7 +1,8 @@
import React, { useEffect, useState } from 'react'
import { getCart, removeFromCart, formatPrice } from './api.js'
+import { Button, IconBag, IconArrowRight, IconLock } from './ui.jsx'
-export default function CartPage({ onCartChanged, goCheckout }) {
+export default function CartPage({ onCartChanged, goCheckout, goShop }) {
const [cart, setCart] = useState({ items: [], total_cents: 0 })
const [loading, setLoading] = useState(true)
const [error, setError] = useState('')
@@ -33,47 +34,101 @@ export default function CartPage({ onCartChanged, goCheckout }) {
}
}
- if (loading) return <div className="loading">Loading cart…</div>
+ if (loading) return <p className="py-16 text-center text-sm text-neutral-500">Loading your cart…</p>
if (error)
return (
- <div className="error-box">
- <p>{error}</p>
- <button onClick={load}>Retry</button>
+ <div className="mx-auto max-w-md rounded-2xl border border-neutral-950/10 p-8 text-center">
+ <p className="text-sm text-neutral-600 text-pretty">{error}</p>
+ <Button variant="secondary" size="sm" className="mt-4" onClick={load}>
+ Try again
+ </Button>
</div>
)
+ if (cart.items.length === 0) {
+ return (
+ <div className="mx-auto max-w-md py-16 text-center">
+ <div className="mx-auto flex size-14 items-center justify-center rounded-full bg-neutral-100">
+ <IconBag className="size-7 text-neutral-400" />
+ </div>
+ <h1 className="mt-5 text-xl font-semibold tracking-tight text-neutral-900">Your cart is empty</h1>
+ <p className="mx-auto mt-2 max-w-[40ch] text-sm text-pretty text-neutral-500">
+ Looks like you haven’t added anything yet. Browse the catalog to get started.
+ </p>
+ <Button className="mt-6" onClick={goShop}>
+ Continue shopping
+ <IconArrowRight className="size-4" />
+ </Button>
+ </div>
+ )
+ }
+
return (
<div>
- <h1>Your Cart</h1>
- {cart.items.length === 0 ? (
- <p className="muted">Your cart is empty.</p>
- ) : (
- <div className="cart">
+ <h1 className="text-2xl font-semibold tracking-tight text-neutral-900">Your cart</h1>
+ <p className="mt-1 text-sm text-neutral-500">
+ {cart.items.length} {cart.items.length === 1 ? 'item' : 'items'}
+ </p>
+
+ <div className="mt-8 grid gap-10 lg:grid-cols-[1fr_22rem]">
+ <ul role="list" className="divide-y divide-neutral-950/5 border-y border-neutral-950/5">
{cart.items.map((line) => (
- <div className="cart-row" key={line.id}>
- <img src={line.image_url} alt={line.name} />
- <div className="cart-info">
- <div className="card-name">{line.name}</div>
- <div className="muted">
+ <li key={line.id} className="flex items-center gap-4 py-5">
+ <img
+ src={line.image_url}
+ alt={line.name}
+ className="size-20 shrink-0 rounded-lg object-cover ring-1 ring-black/5"
+ />
+ <div className="min-w-0 flex-1">
+ <p className="text-sm font-medium text-neutral-900">{line.name}</p>
+ <p className="mt-1 text-sm tabular-nums text-neutral-500">
{formatPrice(line.price_cents)} × {line.qty}
- </div>
+ </p>
+ <button
+ type="button"
+ onClick={() => handleRemove(line.id)}
+ className="mt-2 text-sm font-medium text-neutral-500 underline-offset-4 transition hover:text-neutral-900 hover:underline"
+ >
+ Remove
+ </button>
</div>
- <div className="cart-line-total">{formatPrice(line.line_total_cents)}</div>
- <button className="ghost" onClick={() => handleRemove(line.id)}>
- Remove
- </button>
- </div>
+ <p className="text-sm font-medium tabular-nums text-neutral-900">
+ {formatPrice(line.line_total_cents)}
+ </p>
+ </li>
))}
- <div className="cart-footer">
- <div className="cart-total">
- Total: <strong>{formatPrice(cart.total_cents)}</strong>
- </div>
- <button className="primary" onClick={goCheckout}>
+ </ul>
+
+ <aside className="lg:sticky lg:top-28 lg:self-start">
+ <div className="rounded-2xl bg-neutral-50 p-6 ring-1 ring-neutral-950/5">
+ <h2 className="text-sm font-semibold text-neutral-900">Order summary</h2>
+ <dl className="mt-4 space-y-3 text-sm">
+ <div className="flex items-center justify-between">
+ <dt className="text-neutral-500">Subtotal</dt>
+ <dd className="font-medium tabular-nums text-neutral-900">{formatPrice(cart.total_cents)}</dd>
+ </div>
+ <div className="flex items-center justify-between">
+ <dt className="text-neutral-500">Shipping</dt>
+ <dd className="font-medium text-emerald-600">Free</dd>
+ </div>
+ <div className="flex items-center justify-between border-t border-neutral-950/10 pt-3">
+ <dt className="font-medium text-neutral-900">Total</dt>
+ <dd className="text-base font-semibold tabular-nums text-neutral-900">
+ {formatPrice(cart.total_cents)}
+ </dd>
+ </div>
+ </dl>
+ <Button className="mt-6 w-full" onClick={goCheckout}>
Proceed to checkout
- </button>
+ <IconArrowRight className="size-4" />
+ </Button>
+ <p className="mt-3 flex items-center justify-center gap-1.5 text-xs text-neutral-500">
+ <IconLock className="size-3.5" />
+ Secure checkout
+ </p>
</div>
- </div>
- )}
+ </aside>
+ </div>
</div>
)
}
diff --git a/testing/shop/frontend/src/CheckoutPage.jsx b/testing/shop/frontend/src/CheckoutPage.jsx
index 018d9298..3a1556b7 100644
--- a/testing/shop/frontend/src/CheckoutPage.jsx
+++ b/testing/shop/frontend/src/CheckoutPage.jsx
@@ -1,5 +1,6 @@
-import React, { useState } from 'react'
-import { applyCoupon, checkout, formatPrice } from './api.js'
+import React, { useEffect, useState } from 'react'
+import { applyCoupon, checkout, getCart, formatPrice } from './api.js'
+import { Button, IconCheck, IconLock } from './ui.jsx'
class ErrorBoundary extends React.Component {
constructor(props) {
@@ -16,12 +17,16 @@ class ErrorBoundary extends React.Component {
function CouponBadge({ discount }) {
return (
- <div className="coupon-badge">
+ <div className="flex items-center gap-2 rounded-lg bg-emerald-50 px-3 py-2.5 text-sm font-medium text-emerald-700 ring-1 ring-emerald-600/20">
+ <IconCheck className="size-4 shrink-0" />
Coupon applied — saved {discount.percent.toFixed(0)}% ({formatPrice(discount.cents)})
</div>
)
}
+const inputClass =
+ 'w-full rounded-lg bg-white px-3.5 py-2.5 text-sm text-neutral-900 ring-1 ring-neutral-950/10 outline-none placeholder:text-neutral-400 focus-visible:ring-2 focus-visible:ring-neutral-900 max-sm:text-base'
+
export default function CheckoutPage({ onDone }) {
const [code, setCode] = useState('')
const [discount, setDiscount] = useState(undefined)
@@ -30,6 +35,13 @@ export default function CheckoutPage({ onDone }) {
const [result, setResult] = useState(null)
const [checkoutError, setCheckoutError] = useState('')
const [busy, setBusy] = useState(false)
+ const [cart, setCart] = useState(null)
+
+ useEffect(() => {
+ getCart()
+ .then(setCart)
+ .catch(() => setCart(null))
+ }, [])
async function handleApplyCoupon() {
setCouponError('')
@@ -62,64 +74,137 @@ export default function CheckoutPage({ onDone }) {
if (result) {
return (
- <div className="confirmation">
- <h1>Order confirmed 🎉</h1>
- <p>
- Order <strong>{result.order_id}</strong> placed for{' '}
- <strong>{formatPrice(result.total_cents)}</strong>.
+ <div className="mx-auto max-w-md py-16 text-center">
+ <div className="mx-auto flex size-14 items-center justify-center rounded-full bg-emerald-50 ring-1 ring-emerald-600/20">
+ <IconCheck className="size-7 text-emerald-600" />
+ </div>
+ <h1 className="mt-5 text-2xl font-semibold tracking-tight text-neutral-900">Order confirmed</h1>
+ <p className="mx-auto mt-2 max-w-[44ch] text-sm text-pretty text-neutral-500">
+ Order <strong className="font-medium text-neutral-900">{result.order_id}</strong> placed for{' '}
+ <strong className="font-medium text-neutral-900 tabular-nums">{formatPrice(result.total_cents)}</strong>. A
+ receipt is on its way to your inbox.
</p>
- <button className="primary" onClick={onDone}>
+ <Button className="mt-6" onClick={onDone}>
Back to shop
- </button>
+ </Button>
</div>
)
}
+ const validDiscount = discount && typeof discount.cents === 'number' ? discount : null
+ const subtotal = cart?.total_cents ?? 0
+ const total = validDiscount ? Math.max(0, subtotal - validDiscount.cents) : subtotal
+
return (
- <div className="checkout">
- <h1>Checkout</h1>
+ <div>
+ <h1 className="text-2xl font-semibold tracking-tight text-neutral-900">Checkout</h1>
+
+ <div className="mt-8 grid gap-10 lg:grid-cols-[1fr_22rem]">
+ <div className="flex flex-col gap-10">
+ <section>
+ <h2 className="text-sm font-semibold text-neutral-900">Have a coupon?</h2>
+ <p className="mt-1 text-sm text-neutral-500">Try {''}<code className="rounded bg-neutral-100 px-1.5 py-0.5 text-xs font-medium text-neutral-700">SAVE10</code>.</p>
+ <div className="mt-3 flex gap-2">
+ <input
+ type="text"
+ name="coupon"
+ aria-label="Coupon code"
+ placeholder="Coupon code"
+ value={code}
+ onChange={(e) => setCode(e.target.value)}
+ className={inputClass}
+ />
+ <Button variant="secondary" onClick={handleApplyCoupon} className="shrink-0">
+ Apply
+ </Button>
+ </div>
+ {couponError && <p className="mt-2 text-sm text-red-600">{couponError}</p>}
+ {discount !== undefined && (
+ <div className="mt-3">
+ <ErrorBoundary
+ fallback={
+ <div className="rounded-lg bg-red-50 px-3 py-2.5 text-sm font-medium text-red-700 ring-1 ring-red-600/20">
+ Could not display coupon.
+ </div>
+ }
+ >
+ <CouponBadge discount={discount} />
+ </ErrorBoundary>
+ </div>
+ )}
+ </section>
- <section className="panel">
- <h2>Coupon</h2>
- <div className="coupon-row">
- <input
- placeholder="Coupon code (try SAVE10)"
- value={code}
- onChange={(e) => setCode(e.target.value)}
- />
- <button className="ghost" onClick={handleApplyCoupon}>
- Apply
- </button>
+ <section>
+ <h2 className="text-sm font-semibold text-neutral-900">Contact &amp; payment</h2>
+ <form onSubmit={handleCheckout} className="mt-3 flex flex-col gap-4">
+ <div className="flex flex-col gap-1.5">
+ <label htmlFor="co-name" className="text-sm font-medium text-neutral-700">Full name</label>
+ <input id="co-name" name="name" value={form.name} onChange={update('name')} required placeholder="Ada Lovelace" className={inputClass} />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label htmlFor="co-email" className="text-sm font-medium text-neutral-700">Email</label>
+ <input id="co-email" name="email" type="email" value={form.email} onChange={update('email')} required placeholder="[email protected]" className={inputClass} />
+ </div>
+ <div className="flex flex-col gap-1.5">
+ <label htmlFor="co-card" className="text-sm font-medium text-neutral-700">Card last 4</label>
+ <input id="co-card" name="card_last4" value={form.card_last4} onChange={update('card_last4')} maxLength={4} required placeholder="4242" inputMode="numeric" className={inputClass} />
+ </div>
+ <div className="mt-2">
+ <Button type="submit" className="w-full" disabled={busy}>
+ {busy ? 'Placing order…' : 'Place order'}
+ </Button>
+ {checkoutError && <p className="mt-2 text-sm text-red-600">{checkoutError}</p>}
+ <p className="mt-3 flex items-center justify-center gap-1.5 text-xs text-neutral-500">
+ <IconLock className="size-3.5" />
+ Payments are encrypted. This is a demo — no card is charged.
+ </p>
+ </div>
+ </form>
+ </section>
</div>
- {couponError && <div className="error-inline">{couponError}</div>}
- {discount !== undefined && (
- <ErrorBoundary fallback={<div className="error-inline">Could not display coupon.</div>}>
- <CouponBadge discount={discount} />
- </ErrorBoundary>
- )}
- </section>
- <section className="panel">
- <h2>Payment</h2>
- <form onSubmit={handleCheckout} className="checkout-form">
- <label>
- Name
- <input value={form.name} onChange={update('name')} required />
- </label>
- <label>
- Email
- <input type="email" value={form.email} onChange={update('email')} required />
- </label>
- <label>
- Card last 4
- <input value={form.card_last4} onChange={update('card_last4')} maxLength={4} required />
- </label>
- <button className="primary" type="submit" disabled={busy}>
- {busy ? 'Placing order…' : 'Place order'}
- </button>
- {checkoutError && <div className="error-inline">{checkoutError}</div>}
- </form>
- </section>
+ <aside className="lg:sticky lg:top-28 lg:self-start">
+ <div className="rounded-2xl bg-neutral-50 p-6 ring-1 ring-neutral-950/5">
+ <h2 className="text-sm font-semibold text-neutral-900">Order summary</h2>
+ {cart && cart.items?.length > 0 ? (
+ <ul role="list" className="mt-4 space-y-3">
+ {cart.items.map((line) => (
+ <li key={line.id} className="flex items-center gap-3">
+ <img src={line.image_url} alt={line.name} className="size-12 shrink-0 rounded-md object-cover ring-1 ring-black/5" />
+ <div className="min-w-0 flex-1">
+ <p className="truncate text-sm font-medium text-neutral-900">{line.name}</p>
+ <p className="text-xs tabular-nums text-neutral-500">Qty {line.qty}</p>
+ </div>
+ <p className="text-sm tabular-nums text-neutral-700">{formatPrice(line.line_total_cents)}</p>
+ </li>
+ ))}
+ </ul>
+ ) : (
+ <p className="mt-4 text-sm text-neutral-500">Your order details will appear here.</p>
+ )}
+ <dl className="mt-5 space-y-3 border-t border-neutral-950/10 pt-5 text-sm">
+ <div className="flex items-center justify-between">
+ <dt className="text-neutral-500">Subtotal</dt>
+ <dd className="font-medium tabular-nums text-neutral-900">{formatPrice(subtotal)}</dd>
+ </div>
+ {validDiscount && (
+ <div className="flex items-center justify-between">
+ <dt className="text-neutral-500">Discount</dt>
+ <dd className="font-medium tabular-nums text-emerald-600">−{formatPrice(validDiscount.cents)}</dd>
+ </div>
+ )}
+ <div className="flex items-center justify-between">
+ <dt className="text-neutral-500">Shipping</dt>
+ <dd className="font-medium text-emerald-600">Free</dd>
+ </div>
+ <div className="flex items-center justify-between border-t border-neutral-950/10 pt-3">
+ <dt className="font-medium text-neutral-900">Total</dt>
+ <dd className="text-base font-semibold tabular-nums text-neutral-900">{formatPrice(total)}</dd>
+ </div>
+ </dl>
+ </div>
+ </aside>
+ </div>
</div>
)
}
diff --git a/testing/shop/frontend/src/ProductsPage.jsx b/testing/shop/frontend/src/ProductsPage.jsx
index eb425612..a5332db2 100644
--- a/testing/shop/frontend/src/ProductsPage.jsx
+++ b/testing/shop/frontend/src/ProductsPage.jsx
@@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react'
import { getProducts, addToCart, formatPrice } from './api.js'
+import { Button, IconButton, Stars, IconClose, IconCheck, IconEye, cx } from './ui.jsx'
export default function ProductsPage({ onCartChanged }) {
const [products, setProducts] = useState([])
@@ -8,6 +9,7 @@ export default function ProductsPage({ onCartChanged }) {
const [adding, setAdding] = useState(null)
const [quickView, setQuickView] = useState(null)
const [notice, setNotice] = useState('')
+ const [category, setCategory] = useState('All')
async function load() {
setLoading(true)
@@ -26,6 +28,12 @@ export default function ProductsPage({ onCartChanged }) {
load()
}, [])
+ useEffect(() => {
+ if (!notice) return
+ const t = setTimeout(() => setNotice(''), 2200)
+ return () => clearTimeout(t)
+ }, [notice])
+
async function handleAdd(productId) {
setAdding(productId)
setNotice('')
@@ -36,56 +44,205 @@ export default function ProductsPage({ onCartChanged }) {
}
function handleQuickView(p) {
- try {
- const variant = p.variants.find((v) => v.default)
- setQuickView({ name: p.name, label: variant.label })
- } catch {
- setQuickView({ name: p.name, label: 'No variants available' })
- }
+ setQuickView(p)
}
- if (loading) return <div className="loading">Loading products…</div>
- if (error)
- return (
- <div className="error-box">
- <p>{error}</p>
- <button onClick={load}>Retry</button>
- </div>
- )
+ const categories = ['All', ...Array.from(new Set(products.map((p) => p.category).filter(Boolean)))]
+ const visible = category === 'All' ? products : products.filter((p) => p.category === category)
return (
<div>
- <h1>Products</h1>
- {notice && <div className="notice">{notice}</div>}
- {quickView && (
- <div className="quickview" onClick={() => setQuickView(null)}>
- <strong>{quickView.name}</strong> — {quickView.label} <span className="dismiss">✕</span>
+ <section className="border-b border-neutral-950/5 pb-10">
+ <p className="text-sm font-medium text-neutral-500">New season</p>
+ <h1 className="mt-2 max-w-[18ch] text-4xl font-semibold tracking-tight text-balance text-neutral-900 sm:text-5xl">
+ Modern goods for everyday life.
+ </h1>
+ <p className="mt-4 max-w-[60ch] text-base text-pretty text-neutral-500">
+ A small, considered catalog of apparel, electronics, and home essentials — shipped fast and
+ backed by a 30-day return policy.
+ </p>
+ </section>
+
+ <div className="sticky top-16 z-30 -mx-4 mt-2 bg-white/80 px-4 py-4 backdrop-blur-md sm:-mx-6 sm:px-6">
+ <div className="no-scrollbar flex gap-2 overflow-x-auto">
+ {categories.map((c) => (
+ <button
+ key={c}
+ type="button"
+ onClick={() => setCategory(c)}
+ className={cx(
+ 'shrink-0 rounded-full px-4 py-1.5 text-sm font-medium transition focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-900',
+ category === c
+ ? 'bg-neutral-900 text-white'
+ : 'bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900'
+ )}
+ >
+ {c}
+ </button>
+ ))}
+ </div>
+ </div>
+
+ {loading ? (
+ <ProductGridSkeleton />
+ ) : error ? (
+ <div className="mx-auto mt-16 max-w-md rounded-2xl border border-neutral-950/10 p-8 text-center">
+ <p className="text-sm text-neutral-600 text-pretty">{error}</p>
+ <Button variant="secondary" size="sm" className="mt-4" onClick={load}>
+ Try again
+ </Button>
+ </div>
+ ) : (
+ <div className="mt-6 grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
+ {visible.map((p) => (
+ <ProductCard
+ key={p.id}
+ product={p}
+ adding={adding === p.id}
+ onAdd={() => handleAdd(p.id)}
+ onQuickView={() => handleQuickView(p)}
+ />
+ ))}
</div>
)}
- <div className="grid">
- {products.map((p) => (
- <div className="card" key={p.id}>
- <img src={p.image_url} alt={p.name} loading="lazy" />
- <div className="card-body">
- <div className="card-cat">{p.category}</div>
- <div className="card-name">{p.name}</div>
- <div className="card-desc">{p.description}</div>
- <div className="card-meta">
- <span className="price">{formatPrice(p.price_cents)}</span>
- <span className="reviews">★ {p.review_count}</span>
- </div>
- <div className="card-actions">
- <button className="primary" disabled={adding === p.id} onClick={() => handleAdd(p.id)}>
- {adding === p.id ? 'Adding…' : 'Add to cart'}
- </button>
- <button className="ghost" onClick={() => handleQuickView(p)}>
- Quick view
- </button>
- </div>
+
+ {quickView && (
+ <QuickViewModal
+ product={quickView}
+ adding={adding === quickView.id}
+ onAdd={() => handleAdd(quickView.id)}
+ onClose={() => setQuickView(null)}
+ />
+ )}
+
+ <div
+ aria-live="polite"
+ className="pointer-events-none fixed inset-x-0 bottom-6 z-50 flex justify-center px-4"
+ >
+ {notice && (
+ <div className="pointer-events-auto inline-flex items-center gap-2 rounded-full bg-neutral-900 py-2.5 pr-4 pl-3 text-sm font-medium text-white shadow-lg ring-1 ring-black/5">
+ <span className="inline-flex size-5 items-center justify-center rounded-full bg-emerald-500/20">
+ <IconCheck className="size-3.5 text-emerald-300" />
+ </span>
+ {notice}
+ </div>
+ )}
+ </div>
+ </div>
+ )
+}
+
+function ProductCard({ product: p, adding, onAdd, onQuickView }) {
+ return (
+ <div className="group flex flex-col">
+ <div className="relative aspect-4/3 overflow-hidden rounded-xl bg-neutral-100">
+ <img
+ src={p.image_url}
+ alt={p.name}
+ loading="lazy"
+ className="size-full object-cover transition duration-500 group-hover:scale-105"
+ />
+ {p.stock <= 20 && (
+ <span className="absolute top-3 left-3 rounded-full bg-white/90 px-2.5 py-1 text-xs font-medium text-neutral-700 ring-1 ring-black/5 backdrop-blur">
+ Only {p.stock} left
+ </span>
+ )}
+ <div className="absolute inset-x-3 bottom-3 flex translate-y-2 justify-center opacity-0 transition duration-300 group-hover:translate-y-0 group-hover:opacity-100">
+ <Button
+ variant="secondary"
+ size="sm"
+ onClick={onQuickView}
+ className="w-full shadow-sm backdrop-blur"
+ >
+ <IconEye className="size-4" />
+ Quick view
+ </Button>
+ </div>
+ </div>
+
+ <div className="mt-4 flex flex-1 flex-col">
+ <div className="flex items-start justify-between gap-3">
+ <h3 className="text-sm font-medium text-neutral-900">{p.name}</h3>
+ <p className="text-sm font-medium tabular-nums text-neutral-900">{formatPrice(p.price_cents)}</p>
+ </div>
+ <div className="mt-1 flex items-center gap-2 text-sm text-neutral-500">
+ <span>{p.category}</span>
+ <span aria-hidden="true">·</span>
+ <Stars count={p.review_count} />
+ </div>
+ <p className="mt-2 line-clamp-2 text-sm text-pretty text-neutral-500">{p.description}</p>
+ <div className="mt-4 flex items-end">
+ <Button className="w-full" disabled={adding} onClick={onAdd}>
+ {adding ? 'Adding…' : 'Add to cart'}
+ </Button>
+ </div>
+ </div>
+ </div>
+ )
+}
+
+function QuickViewModal({ product: p, adding, onAdd, onClose }) {
+ useEffect(() => {
+ function onKey(e) {
+ if (e.key === 'Escape') onClose()
+ }
+ window.addEventListener('keydown', onKey)
+ return () => window.removeEventListener('keydown', onKey)
+ }, [onClose])
+
+ return (
+ <div
+ className="fixed inset-0 z-50 flex items-end justify-center bg-neutral-950/40 p-4 backdrop-blur-sm sm:items-center"
+ role="dialog"
+ aria-modal="true"
+ aria-label={`${p.name} quick view`}
+ onClick={onClose}
+ >
+ <div
+ className="relative w-full max-w-2xl overflow-hidden rounded-2xl bg-white shadow-xl ring-1 ring-black/5"
+ onClick={(e) => e.stopPropagation()}
+ >
+ <IconButton label="Close" onClick={onClose} className="absolute top-3 right-3 z-10 bg-white/70 backdrop-blur">
+ <IconClose className="size-5" />
+ </IconButton>
+ <div className="grid sm:grid-cols-2">
+ <div className="aspect-4/3 bg-neutral-100 sm:aspect-auto">
+ <img src={p.image_url} alt={p.name} className="size-full object-cover" />
+ </div>
+ <div className="flex flex-col gap-3 p-6">
+ <p className="text-sm text-neutral-500">{p.category}</p>
+ <h2 className="text-xl font-semibold tracking-tight text-balance text-neutral-900">{p.name}</h2>
+ <div className="flex items-center gap-3">
+ <p className="text-lg font-semibold tabular-nums text-neutral-900">{formatPrice(p.price_cents)}</p>
+ <Stars count={p.review_count} className="text-sm" />
+ </div>
+ <p className="text-sm text-pretty text-neutral-500">{p.description}</p>
+ <p className="text-sm text-neutral-500">
+ {p.stock > 20 ? 'In stock — ships in 1–2 days.' : `Only ${p.stock} left in stock.`}
+ </p>
+ <div className="mt-auto pt-2">
+ <Button className="w-full" disabled={adding} onClick={onAdd}>
+ {adding ? 'Adding…' : 'Add to cart'}
+ </Button>
</div>
</div>
- ))}
+ </div>
</div>
</div>
)
}
+
+function ProductGridSkeleton() {
+ return (
+ <div className="mt-6 grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4">
+ {Array.from({ length: 8 }).map((_, i) => (
+ <div key={i} className="flex flex-col">
+ <div className="aspect-4/3 animate-pulse rounded-xl bg-neutral-100" />
+ <div className="mt-4 h-4 w-2/3 animate-pulse rounded bg-neutral-100" />
+ <div className="mt-2 h-3 w-1/3 animate-pulse rounded bg-neutral-100" />
+ <div className="mt-4 h-9 w-full animate-pulse rounded-lg bg-neutral-100" />
+ </div>
+ ))}
+ </div>
+ )
+}
diff --git a/testing/shop/frontend/src/styles.css b/testing/shop/frontend/src/styles.css
index d2a5ab79..99415871 100644
--- a/testing/shop/frontend/src/styles.css
+++ b/testing/shop/frontend/src/styles.css
@@ -1,348 +1,20 @@
-:root {
- --bg: #0f1115;
- --panel: #181b22;
- --panel-2: #1f232c;
- --border: #2a2f3a;
- --text: #e8eaed;
- --muted: #9aa3b2;
- --accent: #6d9eff;
- --accent-2: #4f7cff;
- --danger: #ff6b6b;
- --good: #4ade80;
-}
-
-* {
- box-sizing: border-box;
-}
-
-body {
- margin: 0;
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
- background: var(--bg);
- color: var(--text);
-}
-
-.app {
- max-width: 1080px;
- margin: 0 auto;
- padding: 0 16px 64px;
-}
-
-.topbar {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 18px 0;
- border-bottom: 1px solid var(--border);
- position: sticky;
- top: 0;
- background: var(--bg);
- z-index: 10;
-}
-
-.brand {
- font-size: 18px;
- font-weight: 700;
- cursor: pointer;
-}
-
-.logo {
- margin-right: 4px;
-}
-
-nav {
- display: flex;
- gap: 8px;
-}
-
-nav button {
- background: transparent;
- color: var(--muted);
- border: 1px solid transparent;
- padding: 8px 14px;
- border-radius: 8px;
- cursor: pointer;
- font-size: 14px;
-}
-
-nav button.active,
-nav button:hover {
- color: var(--text);
- border-color: var(--border);
- background: var(--panel);
-}
-
-.badge {
- display: inline-block;
- min-width: 20px;
- text-align: center;
- background: var(--accent-2);
- color: white;
- border-radius: 999px;
- padding: 1px 7px;
- font-size: 12px;
- margin-left: 4px;
-}
-
-.content {
- padding-top: 24px;
-}
-
-h1 {
- font-size: 24px;
- margin: 0 0 18px;
-}
-
-h2 {
- font-size: 16px;
- margin: 0 0 12px;
- color: var(--muted);
-}
-
-.grid {
- display: grid;
- grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
- gap: 16px;
-}
-
-.card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 12px;
- overflow: hidden;
- display: flex;
- flex-direction: column;
-}
-
-.card img {
- width: 100%;
- height: 150px;
- object-fit: cover;
- background: var(--panel-2);
-}
-
-.card-body {
- padding: 12px;
- display: flex;
- flex-direction: column;
- gap: 6px;
- flex: 1;
-}
-
-.card-cat {
- font-size: 11px;
- text-transform: uppercase;
- letter-spacing: 0.05em;
- color: var(--accent);
-}
-
-.card-name {
- font-weight: 600;
-}
-
-.card-desc {
- font-size: 13px;
- color: var(--muted);
- flex: 1;
-}
-
-.card-meta {
- display: flex;
- justify-content: space-between;
- align-items: center;
-}
-
-.price {
- font-weight: 700;
-}
-
-.reviews {
- font-size: 13px;
- color: var(--muted);
-}
-
-.card-actions {
- display: flex;
- gap: 8px;
- margin-top: 4px;
-}
-
-button.primary {
- background: var(--accent-2);
- color: white;
- border: none;
- padding: 9px 14px;
- border-radius: 8px;
- cursor: pointer;
- font-size: 14px;
- flex: 1;
-}
-
-button.primary:disabled {
- opacity: 0.6;
- cursor: default;
-}
-
-button.ghost {
- background: transparent;
- color: var(--text);
- border: 1px solid var(--border);
- padding: 9px 12px;
- border-radius: 8px;
- cursor: pointer;
- font-size: 14px;
-}
-
-.loading,
-.muted {
- color: var(--muted);
-}
-
-.notice {
- background: rgba(74, 222, 128, 0.12);
- border: 1px solid rgba(74, 222, 128, 0.4);
- color: var(--good);
- padding: 8px 12px;
- border-radius: 8px;
- margin-bottom: 14px;
-}
-
-.quickview {
- background: var(--panel-2);
- border: 1px solid var(--border);
- padding: 8px 12px;
- border-radius: 8px;
- margin-bottom: 14px;
- cursor: pointer;
-}
-
-.dismiss {
- float: right;
- color: var(--muted);
-}
-
-.error-box,
-.error-inline {
- color: var(--danger);
-}
-
-.error-box {
- background: var(--panel);
- border: 1px solid var(--border);
- padding: 16px;
- border-radius: 12px;
-}
-
-.error-inline {
- margin-top: 8px;
- font-size: 14px;
-}
-
-.cart {
- display: flex;
- flex-direction: column;
- gap: 10px;
-}
-
-.cart-row {
- display: flex;
- align-items: center;
- gap: 14px;
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 10px;
- padding: 10px 14px;
-}
-
-.cart-row img {
- width: 56px;
- height: 56px;
- object-fit: cover;
- border-radius: 8px;
-}
-
-.cart-info {
- flex: 1;
-}
-
-.cart-line-total {
- font-weight: 700;
- margin-right: 8px;
-}
-
-.cart-footer {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-top: 12px;
- padding-top: 14px;
- border-top: 1px solid var(--border);
-}
-
-.cart-total {
- font-size: 16px;
-}
-
-.checkout {
- display: flex;
- flex-direction: column;
- gap: 16px;
- max-width: 520px;
-}
-
-.panel {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 12px;
- padding: 16px;
-}
-
-.coupon-row {
- display: flex;
- gap: 8px;
-}
-
-.coupon-row input,
-.checkout-form input {
- flex: 1;
- background: var(--panel-2);
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 9px 12px;
- color: var(--text);
- font-size: 14px;
- width: 100%;
-}
-
-.coupon-badge {
- margin-top: 10px;
- background: rgba(109, 158, 255, 0.12);
- border: 1px solid rgba(109, 158, 255, 0.4);
- color: var(--accent);
- padding: 8px 12px;
- border-radius: 8px;
-}
+@import 'https://rsms.me/inter/inter.css';
+@import 'tailwindcss';
-.checkout-form {
- display: flex;
- flex-direction: column;
- gap: 12px;
+@theme {
+ --font-sans: 'InterVariable', ui-sans-serif, system-ui, sans-serif;
+ --font-sans--font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}
-.checkout-form label {
- display: flex;
- flex-direction: column;
- gap: 6px;
- font-size: 13px;
- color: var(--muted);
+@layer base {
+ html {
+ scroll-behavior: smooth;
+ }
}
-.confirmation {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 12px;
- padding: 28px;
- text-align: center;
- max-width: 460px;
- margin: 0 auto;
+@utility no-scrollbar {
+ scrollbar-width: none;
+ &::-webkit-scrollbar {
+ display: none;
+ }
}
diff --git a/testing/shop/frontend/src/ui.jsx b/testing/shop/frontend/src/ui.jsx
new file mode 100644
index 00000000..8d83905f
--- /dev/null
+++ b/testing/shop/frontend/src/ui.jsx
@@ -0,0 +1,147 @@
+import React from 'react'
+
+export function cx(...parts) {
+ return parts.filter(Boolean).join(' ')
+}
+
+const VARIANTS = {
+ primary:
+ 'bg-neutral-900 text-white hover:bg-neutral-800 focus-visible:outline-neutral-900',
+ secondary:
+ 'bg-white text-neutral-900 ring-1 ring-neutral-950/10 hover:bg-neutral-50 focus-visible:outline-neutral-900',
+ ghost:
+ 'bg-transparent text-neutral-600 hover:bg-neutral-100 hover:text-neutral-900 focus-visible:outline-neutral-900'
+}
+
+const SIZES = {
+ md: 'px-4 py-2.5 text-sm',
+ sm: 'px-3 py-1.5 text-sm'
+}
+
+export function Button({ variant = 'primary', size = 'md', className, type = 'button', ...props }) {
+ return (
+ <button
+ type={type}
+ className={cx(
+ 'inline-flex items-center justify-center gap-2 rounded-lg font-medium transition focus-visible:outline-2 focus-visible:outline-offset-2 disabled:pointer-events-none disabled:opacity-50',
+ VARIANTS[variant],
+ SIZES[size],
+ className
+ )}
+ {...props}
+ />
+ )
+}
+
+export function IconButton({ className, label, type = 'button', children, ...props }) {
+ return (
+ <button
+ type={type}
+ aria-label={label}
+ className={cx(
+ 'relative inline-flex size-9 items-center justify-center rounded-lg text-neutral-600 transition hover:bg-neutral-100 hover:text-neutral-900 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-neutral-900',
+ className
+ )}
+ {...props}
+ >
+ {children}
+ <span
+ className="absolute top-1/2 left-1/2 size-[max(100%,3rem)] -translate-1/2 pointer-fine:hidden"
+ aria-hidden="true"
+ />
+ </button>
+ )
+}
+
+export function Logo({ className }) {
+ return (
+ <svg viewBox="0 0 32 32" fill="none" aria-hidden="true" className={className}>
+ <rect width="32" height="32" rx="9" className="fill-neutral-900" />
+ <path
+ d="M11 13h10l-.7 9.3a1.4 1.4 0 0 1-1.4 1.3h-5.8a1.4 1.4 0 0 1-1.4-1.3L11 13Z"
+ className="stroke-white"
+ strokeWidth="1.5"
+ strokeLinejoin="round"
+ />
+ <path d="M13.4 13v-1.1a2.6 2.6 0 0 1 5.2 0V13" className="stroke-white" strokeWidth="1.5" strokeLinecap="round" />
+ </svg>
+ )
+}
+
+export function IconBag({ className }) {
+ return (
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className={className}>
+ <path
+ d="M6 8h12l-.8 11.2a1.6 1.6 0 0 1-1.6 1.5H8.4a1.6 1.6 0 0 1-1.6-1.5L6 8Z"
+ stroke="currentColor"
+ strokeWidth="1.6"
+ strokeLinejoin="round"
+ />
+ <path d="M9 8V6.5a3 3 0 0 1 6 0V8" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
+ </svg>
+ )
+}
+
+export function IconStar({ className }) {
+ return (
+ <svg viewBox="0 0 20 20" fill="currentColor" aria-hidden="true" className={className}>
+ <path d="M10 1.8l2.4 4.9 5.4.8-3.9 3.8.9 5.4-4.8-2.5-4.8 2.5.9-5.4L2.5 7.5l5.4-.8L10 1.8Z" />
+ </svg>
+ )
+}
+
+export function IconClose({ className }) {
+ return (
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className={className}>
+ <path d="M6 6l12 12M18 6 6 18" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
+ </svg>
+ )
+}
+
+export function IconCheck({ className }) {
+ return (
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className={className}>
+ <path d="M5 12.5 10 17.5 19 7" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
+ </svg>
+ )
+}
+
+export function IconArrowRight({ className }) {
+ return (
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className={className}>
+ <path d="M5 12h14M13 6l6 6-6 6" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
+ </svg>
+ )
+}
+
+export function IconEye({ className }) {
+ return (
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className={className}>
+ <path
+ d="M2.5 12S6 5.5 12 5.5 21.5 12 21.5 12 18 18.5 12 18.5 2.5 12 2.5 12Z"
+ stroke="currentColor"
+ strokeWidth="1.6"
+ strokeLinejoin="round"
+ />
+ <circle cx="12" cy="12" r="2.8" stroke="currentColor" strokeWidth="1.6" />
+ </svg>
+ )
+}
+
+export function IconLock({ className }) {
+ return (
+ <svg viewBox="0 0 24 24" fill="none" aria-hidden="true" className={className}>
+ <rect x="5" y="10.5" width="14" height="9.5" rx="2" stroke="currentColor" strokeWidth="1.6" />
+ <path d="M8 10.5V8a4 4 0 0 1 8 0v2.5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" />
+ </svg>
+ )
+}
+
+export function Stars({ count, className }) {
+ return (
+ <span className={cx('inline-flex items-center gap-1 text-neutral-500', className)}>
+ <IconStar className="size-3.5 text-amber-400" />
+ <span className="tabular-nums">{count}</span>
+ </span>
+ )
+}
diff --git a/testing/shop/frontend/vite.config.mjs b/testing/shop/frontend/vite.config.mjs
index 4d4ab9cc..9d1ebbea 100644
--- a/testing/shop/frontend/vite.config.mjs
+++ b/testing/shop/frontend/vite.config.mjs
@@ -1,5 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
+import tailwindcss from '@tailwindcss/vite'
import { tracewayDebugIds } from '@tracewayapp/bundler-plugin/vite'
export default defineConfig({
@@ -12,5 +13,5 @@ export default defineConfig({
'/api': 'http://localhost:8090'
}
},
- plugins: [react(), tracewayDebugIds()]
+ plugins: [react(), tailwindcss(), tracewayDebugIds()]
})