mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-17 05:22:23 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 47977e1c57 | |||
| 30e2de45a6 |
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Bump Next.js to 16.4.6 and OpenNext (Cloudflare 1.20.17, AWS 4.1.16), keeping the dev-mode OOM patch.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix horizontal page scroll caused by card carousels bleeding past the viewport.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Remove duplicated declarations from the global stylesheet.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep inline code and highlighted text readable when a paragraph crosses the bottom edge of a background page cover.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
"@gitbook/icons": patch
|
||||
---
|
||||
|
||||
Add a skip link, keyboard navigation between content tabs, focusable table of contents toggles, and hide decorative icons from assistive technologies.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Load the OpenAPI stylesheet only on pages with OpenAPI blocks.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Limit the MCP `searchDocumentation` tool to one language: the one the client passes in the new optional `language` argument, or else the language of the site variant the MCP endpoint is served from.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Flush insights events when the page is hidden, preload the search index at low priority and prioritize the dark page cover on dark-default sites.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix the search button accessible name, hoverable link previews, IME-safe Enter on Safari, cookie banner semantics, active outline item announcement and textarea shrinking.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
"@gitbook/embed": patch
|
||||
---
|
||||
|
||||
Respect reduced motion for enter and exit animations, keep the header separator and input focus visible in forced colors mode, and size mobile surfaces with dynamic viewport units.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Send only the site origin as referrer to third parties, and only let the embedding page open the embed messaging channel.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Remove the ChatGPT-specific plain text response for Markdown and llms.txt routes; these now always serve `text/markdown`.
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Ship short semantic class names instead of Tailwind utility strings on the sidebar, buttons, header, page layout and document blocks, shrinking HTML and RSC payloads.
|
||||
@@ -59,16 +59,6 @@ Run a specific test file:
|
||||
cd packages/gitbook && bun test src/lib/cache.test.ts
|
||||
```
|
||||
|
||||
## Bumping Next.js or OpenNext
|
||||
|
||||
Type checks and unit tests miss runtime regressions: OpenNext 4.1.15 changed the composable cache key format, and every `'use cache'` call silently missed for days. Before committing a bump of `next`, `@opennextjs/aws` or `@opennextjs/cloudflare`, run both runtimes locally from `packages/gitbook`:
|
||||
|
||||
1. **Next**: `bun run build:local && bun run start`, then load several distinct pages under `http://localhost:3000/url/gitbook.com/docs`.
|
||||
2. **OpenNext**: `bun run build:cloudflare`, delete `openNext/customWorkers/.wrangler` (stale cache hits otherwise skip the server), then run `bun run dev:cf:server` and `bun run dev:cf:middleware` and load several distinct pages under `http://127.0.0.1:8771/url/gitbook.com/docs`.
|
||||
3. Diff the changed OpenNext versions' adapters that call our overrides in `openNext/` (incremental, composable and tag cache, queue), e.g. with `npm pack` of the old and new versions.
|
||||
|
||||
The bump is safe when every page returns 200 on both runtimes and the server logs show no cache errors (grep `Failed to` and `regional cache`). Report the pages checked and the log result in the PR.
|
||||
|
||||
## Changesets
|
||||
|
||||
After committing code changes, create a changeset for the affected package:
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
},
|
||||
"packages/embed": {
|
||||
"name": "@gitbook/embed",
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.0",
|
||||
"dependencies": {
|
||||
"@gitbook/api": "catalog:",
|
||||
"bidc": "catalog:",
|
||||
@@ -109,7 +109,7 @@
|
||||
},
|
||||
"packages/gitbook": {
|
||||
"name": "gitbook",
|
||||
"version": "0.28.3",
|
||||
"version": "0.28.2",
|
||||
"dependencies": {
|
||||
"@base-ui/react": "catalog:",
|
||||
"@cloudflare/workers-types": "^4.20251011.0",
|
||||
@@ -227,7 +227,7 @@
|
||||
},
|
||||
"packages/icons": {
|
||||
"name": "@gitbook/icons",
|
||||
"version": "0.6.0",
|
||||
"version": "0.5.0",
|
||||
"bin": {
|
||||
"gitbook-icons": "./bin/gitbook-icons.js",
|
||||
},
|
||||
@@ -265,7 +265,7 @@
|
||||
},
|
||||
"packages/react-contentkit": {
|
||||
"name": "@gitbook/react-contentkit",
|
||||
"version": "0.7.19",
|
||||
"version": "0.7.18",
|
||||
"dependencies": {
|
||||
"@gitbook/api": "catalog:",
|
||||
"@gitbook/icons": "workspace:*",
|
||||
@@ -308,7 +308,7 @@
|
||||
},
|
||||
"packages/react-openapi": {
|
||||
"name": "@gitbook/react-openapi",
|
||||
"version": "2.0.2",
|
||||
"version": "2.0.1",
|
||||
"dependencies": {
|
||||
"@base-ui/react": "catalog:",
|
||||
"@gitbook/expr": "workspace:*",
|
||||
@@ -1020,43 +1020,43 @@
|
||||
|
||||
"@oxfmt/binding-win32-x64-msvc": ["@oxfmt/binding-win32-x64-msvc@0.62.0", "", { "os": "win32", "cpu": "x64" }, "sha512-dlI5SY7XYQCiCBafntWagCR6HcAJB/NpsLtdlPx8x08+Osz8Ok1HHz1GZuusegCe/VoJ6pAnF5a4pd5OZAq7qQ=="],
|
||||
|
||||
"@oxlint/binding-android-arm-eabi": ["@oxlint/binding-android-arm-eabi@1.94.0", "", { "os": "android", "cpu": "arm" }, "sha512-730FKSBsKg/NawYnpI3gXRroXptOVqY32iYBPLUZaSx0vgYzOeiNtwojZL4gJdzo9wDvHUlstShmGRHrWcbRYg=="],
|
||||
"@oxlint/binding-android-arm-eabi": ["@oxlint/binding-android-arm-eabi@1.93.0", "", { "os": "android", "cpu": "arm" }, "sha512-KKw70pbD5Pvq3G2lJ+WQ71XPMjCmg37rkSe2+mDqCRP3PoTSdDMuEi4UOnE8JBtyNM7bek61EC2s0Jt7S7u+Sg=="],
|
||||
|
||||
"@oxlint/binding-android-arm64": ["@oxlint/binding-android-arm64@1.94.0", "", { "os": "android", "cpu": "arm64" }, "sha512-8v8TICIiZpXLot1HSq5+vsG9NEKQ5czQBYlUqJR75OVfFDr3cGOmRU/CtHDWnS4tm8nW+Z4Y357qGToSfYqFvA=="],
|
||||
"@oxlint/binding-android-arm64": ["@oxlint/binding-android-arm64@1.93.0", "", { "os": "android", "cpu": "arm64" }, "sha512-fvr1fTUZGelwRxKDt64pf28aL1WaWgviwz3X+E/FcRYvrlEahH0NECRz/c1SY+K+KWmZk5uAf6h1kQnyBkp/2A=="],
|
||||
|
||||
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.94.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-NePcRMO/ltt1Pnytohl6pl0bd/QyRX8HbpptuDz9LK7FTsFD4lKxDMBt7di9k6IFLO0J05jO2nm7wGqIh6dRHA=="],
|
||||
"@oxlint/binding-darwin-arm64": ["@oxlint/binding-darwin-arm64@1.93.0", "", { "os": "darwin", "cpu": "arm64" }, "sha512-VdvSN9JRf4Es6ZzoAdvEeh8tgKdw8L4H82WmA8MMPVfPdZGCwE/nI27Z1HrRHYQhPxOh4kmnxQEioSUFrOvDaw=="],
|
||||
|
||||
"@oxlint/binding-darwin-x64": ["@oxlint/binding-darwin-x64@1.94.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-QV+m+OaEgLmYyillvP1wKXhMm6tDZEWx3vG7Wjmx9ybg15+6YMfqzvp6e+uPukC6zNywuule0vMn0fZgihZzZA=="],
|
||||
"@oxlint/binding-darwin-x64": ["@oxlint/binding-darwin-x64@1.93.0", "", { "os": "darwin", "cpu": "x64" }, "sha512-QR1V890Ml0YGRG0F/iV0K9igG+pOhe+VWd+aZnxY849rRHZf3F2gEoQks5+GVHf105X9Mh/6HdShTP5juekG2g=="],
|
||||
|
||||
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.94.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-KVZjca581nrV6P71kZ9M1otBib9LH0IMn9rr4mrnbRp18V0HiZhBHbU26gji/Ieq2G34qMacnMc3zrmKmvWqWA=="],
|
||||
"@oxlint/binding-freebsd-x64": ["@oxlint/binding-freebsd-x64@1.93.0", "", { "os": "freebsd", "cpu": "x64" }, "sha512-jDfIbi30zZaKi+rTvig3sge+Xhi8pFFSgHxb0jzovc4qh8ETm/irKV9c7N/JsuwnYc5sbvf4IC8w1vQQ0IL+BA=="],
|
||||
|
||||
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/binding-linux-arm-gnueabihf@1.94.0", "", { "os": "linux", "cpu": "arm" }, "sha512-AMQtgQJk8DgdIV+qaQ5sFoHAko4iKa8zo+gYqELy2grtU8hXWB08DAGB3u90aQL1YSxbd3zqHjgcODBHDFyzBQ=="],
|
||||
"@oxlint/binding-linux-arm-gnueabihf": ["@oxlint/binding-linux-arm-gnueabihf@1.93.0", "", { "os": "linux", "cpu": "arm" }, "sha512-qtxZ714ND/koFgVH00QgxlzZiIbRPmguaPhnHRU5DFFtrtEdOrSnZD4U/H2AzXrXkZ59eQbMBnJwbum5XohrIQ=="],
|
||||
|
||||
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.94.0", "", { "os": "linux", "cpu": "arm" }, "sha512-ZLzoGVGAmQkp9leeB5rNxAXLcvlmkmd/GY71LKd5uikk+28NEApY3S2FB3pq6MkfOCFFnFg6QgD9lJIjd07D0Q=="],
|
||||
"@oxlint/binding-linux-arm-musleabihf": ["@oxlint/binding-linux-arm-musleabihf@1.93.0", "", { "os": "linux", "cpu": "arm" }, "sha512-5pJ9NjMvH7WMUqXB6bTTOSemBm39w2cod27Hu3+Yom/GhbTeNXlYcpDx1o4CgBP6fhp0YHG66TNdVaUm6sHjsA=="],
|
||||
|
||||
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.94.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-N1dW6o7cY90hLVkDsvz8nWIFOwbO+n272pvW7uLYB7u47HagJVnLChfK6QA9dWFdiPudud9zfksVUOciHc5PNA=="],
|
||||
"@oxlint/binding-linux-arm64-gnu": ["@oxlint/binding-linux-arm64-gnu@1.93.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-pRf+7jtbt2fHE23SX7qBxRgnBZicUgsoCK1PVIjnOk+t3a6UBkpt/GrKI99WlxsKUxftz/5nv/kfKvScmYywkw=="],
|
||||
|
||||
"@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.94.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-7tCF4OV/bGDQ2xxgb+sDI97SpmmDrUII4JxTG553voJVA9cnkbXSGSXzo78Ax73BuhEOPoQc2Qi6VrfT0cDG2A=="],
|
||||
"@oxlint/binding-linux-arm64-musl": ["@oxlint/binding-linux-arm64-musl@1.93.0", "", { "os": "linux", "cpu": "arm64" }, "sha512-zM8Fd/K8sqGvsBcJBZ3oVZ3ctGWbszA08IaGt5gFFF5RcunppAI/ZnAXbouABvnWeJ//S44KKlfPZnDDbeiphg=="],
|
||||
|
||||
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.94.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-B5vUHE4wNisVEuaYxwFUn6tY+vw7A+9APxxqGKI+UmP3yKLpkhnt0qsaCrzjpX55F8rCRHBaTvIDdYo32NE36g=="],
|
||||
"@oxlint/binding-linux-ppc64-gnu": ["@oxlint/binding-linux-ppc64-gnu@1.93.0", "", { "os": "linux", "cpu": "ppc64" }, "sha512-7qKCnvhZKDXJG2pdbLazd2hw4FxjJHbZOFrrbzyy5PdHfPLH9vnNUa1le01A8uItZuYKPBPncH+HCoEiFT4SgA=="],
|
||||
|
||||
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.94.0", "", { "os": "linux", "cpu": "none" }, "sha512-/U0b15+c4hTodo8YhEqDlQ6OjnGKvc8igjM/mh23ukqqCUBKiBCaxqUV8bcaofK9uZ+f8wCygkyXLS6LN25YSA=="],
|
||||
"@oxlint/binding-linux-riscv64-gnu": ["@oxlint/binding-linux-riscv64-gnu@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-2pgulxC6G8V5wE750NJE/fRkf9aO6i6yoj10wyaR2EdiNtan4OemsOtsQ0ZTXGdY8Q3IoTmlND3GYvjJsvikYg=="],
|
||||
|
||||
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.94.0", "", { "os": "linux", "cpu": "none" }, "sha512-ba94Vwl0qOnwXIXNDR33AEbLXuX++ckM74t+9Te7CiPSPAHivhOYyeEkUAicrvOEei1pxXkWggLbFeBFFBTuHA=="],
|
||||
"@oxlint/binding-linux-riscv64-musl": ["@oxlint/binding-linux-riscv64-musl@1.93.0", "", { "os": "linux", "cpu": "none" }, "sha512-yWsn6Gg2PnGG5jlyDz5+pHGiMTMiy4adaa4WRMzDgzB8efaShk1JMmTHIBSVLQMh0tYXRs4CN5uJCO79r4Mi4g=="],
|
||||
|
||||
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.94.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-GVwwwms3O8pdgbCiPavwq2vltyB4661GkDz6kJduZ0E5nsSJUDJ0svaP+ePYpuDVYi4+K1qhCKnWa/Ec8I4LUA=="],
|
||||
"@oxlint/binding-linux-s390x-gnu": ["@oxlint/binding-linux-s390x-gnu@1.93.0", "", { "os": "linux", "cpu": "s390x" }, "sha512-WCn5plwp/ezS2RDPQKp0/EXEVRr9/dDexUdRKmsMFqzNM5xBSZ1wbsi3PuMk1VfkMRnI5BuazCsziCWMXRDOlw=="],
|
||||
|
||||
"@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.94.0", "", { "os": "linux", "cpu": "x64" }, "sha512-iUfCFJN8ZIresSnpTfiIkhF3s8X+XA4I9KJ249QwR2QYTMwh0+pla1pj1xaFi+HtR9McjM4Jaemf70HzX7ilOQ=="],
|
||||
"@oxlint/binding-linux-x64-gnu": ["@oxlint/binding-linux-x64-gnu@1.93.0", "", { "os": "linux", "cpu": "x64" }, "sha512-F2CGjb9LAkzH+IYTZSzd1klQ1vk5z6Utjax64WeLByCkYXbVDbsun+Oy2hLfW2MDSKCvW+jwy/9ld0EPgdeu+A=="],
|
||||
|
||||
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.94.0", "", { "os": "linux", "cpu": "x64" }, "sha512-RqWVeWpDACS4Oh0m21OBmy+CQ50CbbhuHFmNNPVS2P/4R3d188MjEuEuV7So82/tAM8UAT+UuMDtRDESd9NJ7g=="],
|
||||
"@oxlint/binding-linux-x64-musl": ["@oxlint/binding-linux-x64-musl@1.93.0", "", { "os": "linux", "cpu": "x64" }, "sha512-plf5DE2objcG8Tf7mXRuRa8tT8rzDkpjqXQtKoGsKHWkpgsialbON1+cCtoSEUTVbQUjXvuAm8vV9+3rR0yCBw=="],
|
||||
|
||||
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.94.0", "", { "os": "none", "cpu": "arm64" }, "sha512-K/2DHOUoypwYVqzxJMRPdMuBKjAetZEAsGPP7rHimd+2+5J1TxM+17pG8kw+ayH4+rqBXiPd+H9wgPcU+fF77A=="],
|
||||
"@oxlint/binding-openharmony-arm64": ["@oxlint/binding-openharmony-arm64@1.93.0", "", { "os": "none", "cpu": "arm64" }, "sha512-Kp2yJrKvoTe9FfKdO/xwLNUbs2bYTMKx0+aoQD1s0h/Tx0kSgtHSdGmrk8tTKdluosjFbo88qYRIaNIX43AfFw=="],
|
||||
|
||||
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.94.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-hYOCaOJiB4ZCGswBWKl3JQrhqu6mnC5DCUw/1UMNzRXgsHIJ0V226J43LAVICVIDGlhFUZTYShFW+wHWpt6qCQ=="],
|
||||
"@oxlint/binding-win32-arm64-msvc": ["@oxlint/binding-win32-arm64-msvc@1.93.0", "", { "os": "win32", "cpu": "arm64" }, "sha512-vigjcHCFsR6KjnWTEVfaCxcMYapEuaK9FZa1MpewwQ1S+Xud3v0okfkj1RySsD6RF1NRHIjSlQSalTnKIaj3nA=="],
|
||||
|
||||
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.94.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-1l1FDlzbPmAeDoZ8UGspOE2dOmz1ZL6SlDsvOmRCmWSQjCdTy5LzUepS8mO/SGpAoz4D6WAt/yNZAUyHqbkmkQ=="],
|
||||
"@oxlint/binding-win32-ia32-msvc": ["@oxlint/binding-win32-ia32-msvc@1.93.0", "", { "os": "win32", "cpu": "ia32" }, "sha512-0Ot3BEe/AAr2/uQhe55r8CmPlperYk2mQmxdutOru7oU0kir6IiEVHb1TG3GORRlfra97lPHVDLhgmihiKzLrg=="],
|
||||
|
||||
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.94.0", "", { "os": "win32", "cpu": "x64" }, "sha512-I3eZdd4bemIJQDNv9XDV/FEofDxIoN32tzCv98wIgLdW05EqxZb5hF4AwPrRzHD/dQhl0n7KgPy5AQPfM0HWrA=="],
|
||||
"@oxlint/binding-win32-x64-msvc": ["@oxlint/binding-win32-x64-msvc@1.93.0", "", { "os": "win32", "cpu": "x64" }, "sha512-ZzzIIVs/Qkm8trUWYKF0OYub5ALlv50/3gsEZbKAvWgz+yNJX6uRmQ8ySPXU2Q0/Y9m4JCOjhpmC8XUYbPHX5Q=="],
|
||||
|
||||
"@panzoom/panzoom": ["@panzoom/panzoom@4.6.1", "", {}, "sha512-ogf/KhHHjj+DYAvHfaf3TXMQ8OE36pJtKpabLlx1OmpjcgtpCvkUoCiNONA8kuVRPGJdLiqMf0n8LRFXj1OyuA=="],
|
||||
|
||||
@@ -2696,7 +2696,7 @@
|
||||
|
||||
"oxfmt": ["oxfmt@0.62.0", "", { "dependencies": { "tinypool": "2.1.0" }, "optionalDependencies": { "@oxfmt/binding-android-arm-eabi": "0.62.0", "@oxfmt/binding-android-arm64": "0.62.0", "@oxfmt/binding-darwin-arm64": "0.62.0", "@oxfmt/binding-darwin-x64": "0.62.0", "@oxfmt/binding-freebsd-x64": "0.62.0", "@oxfmt/binding-linux-arm-gnueabihf": "0.62.0", "@oxfmt/binding-linux-arm-musleabihf": "0.62.0", "@oxfmt/binding-linux-arm64-gnu": "0.62.0", "@oxfmt/binding-linux-arm64-musl": "0.62.0", "@oxfmt/binding-linux-ppc64-gnu": "0.62.0", "@oxfmt/binding-linux-riscv64-gnu": "0.62.0", "@oxfmt/binding-linux-riscv64-musl": "0.62.0", "@oxfmt/binding-linux-s390x-gnu": "0.62.0", "@oxfmt/binding-linux-x64-gnu": "0.62.0", "@oxfmt/binding-linux-x64-musl": "0.62.0", "@oxfmt/binding-openharmony-arm64": "0.62.0", "@oxfmt/binding-win32-arm64-msvc": "0.62.0", "@oxfmt/binding-win32-ia32-msvc": "0.62.0", "@oxfmt/binding-win32-x64-msvc": "0.62.0" }, "peerDependencies": { "svelte": "^5.0.0", "vite-plus": "*" }, "optionalPeers": ["svelte", "vite-plus"], "bin": { "oxfmt": "bin/oxfmt" } }, "sha512-vxgGHTmnDU9j4CX7dDBLzxgmHxfda/yPcgJkGCMUSCwRmz+euo/V08xXLNgXTeqAB9Fhf3Pe2nO1RNKLCVgphQ=="],
|
||||
|
||||
"oxlint": ["oxlint@1.94.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.94.0", "@oxlint/binding-android-arm64": "1.94.0", "@oxlint/binding-darwin-arm64": "1.94.0", "@oxlint/binding-darwin-x64": "1.94.0", "@oxlint/binding-freebsd-x64": "1.94.0", "@oxlint/binding-linux-arm-gnueabihf": "1.94.0", "@oxlint/binding-linux-arm-musleabihf": "1.94.0", "@oxlint/binding-linux-arm64-gnu": "1.94.0", "@oxlint/binding-linux-arm64-musl": "1.94.0", "@oxlint/binding-linux-ppc64-gnu": "1.94.0", "@oxlint/binding-linux-riscv64-gnu": "1.94.0", "@oxlint/binding-linux-riscv64-musl": "1.94.0", "@oxlint/binding-linux-s390x-gnu": "1.94.0", "@oxlint/binding-linux-x64-gnu": "1.94.0", "@oxlint/binding-linux-x64-musl": "1.94.0", "@oxlint/binding-openharmony-arm64": "1.94.0", "@oxlint/binding-win32-arm64-msvc": "1.94.0", "@oxlint/binding-win32-ia32-msvc": "1.94.0", "@oxlint/binding-win32-x64-msvc": "1.94.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2007", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-Fnt+3wSKRhtLmvgRfxgRX0excSPCoyiXRol4eWKZLtXxWMQtwQ3KjKQUYXOw5loyinfnZfGzh4RCYf7opfL0vw=="],
|
||||
"oxlint": ["oxlint@1.93.0", "", { "optionalDependencies": { "@oxlint/binding-android-arm-eabi": "1.93.0", "@oxlint/binding-android-arm64": "1.93.0", "@oxlint/binding-darwin-arm64": "1.93.0", "@oxlint/binding-darwin-x64": "1.93.0", "@oxlint/binding-freebsd-x64": "1.93.0", "@oxlint/binding-linux-arm-gnueabihf": "1.93.0", "@oxlint/binding-linux-arm-musleabihf": "1.93.0", "@oxlint/binding-linux-arm64-gnu": "1.93.0", "@oxlint/binding-linux-arm64-musl": "1.93.0", "@oxlint/binding-linux-ppc64-gnu": "1.93.0", "@oxlint/binding-linux-riscv64-gnu": "1.93.0", "@oxlint/binding-linux-riscv64-musl": "1.93.0", "@oxlint/binding-linux-s390x-gnu": "1.93.0", "@oxlint/binding-linux-x64-gnu": "1.93.0", "@oxlint/binding-linux-x64-musl": "1.93.0", "@oxlint/binding-openharmony-arm64": "1.93.0", "@oxlint/binding-win32-arm64-msvc": "1.93.0", "@oxlint/binding-win32-ia32-msvc": "1.93.0", "@oxlint/binding-win32-x64-msvc": "1.93.0" }, "peerDependencies": { "oxlint-tsgolint": ">=7.0.2005", "vite-plus": "*" }, "optionalPeers": ["oxlint-tsgolint", "vite-plus"], "bin": { "oxlint": "bin/oxlint" } }, "sha512-19JMsQFX+YvEbcUTFQxjTwhvs0Ibg0D6CFneSLgpwnACWcY/6LjhpGpkPodh0T5aIT1pjMTLlYaeBFzaVgugTA=="],
|
||||
|
||||
"p-filter": ["p-filter@2.1.0", "", { "dependencies": { "p-map": "^2.0.0" } }, "sha512-ZBxxZ5sL2HghephhpGAQdoskxplTwr7ICaehZwLIlfL6acuVgZPm8yBNuRAFBGEqtD/hmUeq9eqLg2ys9Xr/yw=="],
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@
|
||||
"devDependencies": {
|
||||
"@changesets/cli": "^2.31.1",
|
||||
"oxfmt": "^0.62.0",
|
||||
"oxlint": "^1.94.0",
|
||||
"oxlint": "^1.93.0",
|
||||
"turbo": "^2.11.11",
|
||||
"vercel": "50.37.3"
|
||||
},
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
# @gitbook/embed
|
||||
|
||||
## 0.7.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 65210b7: Respect reduced motion for enter and exit animations, keep the header separator and input focus visible in forced colors mode, and size mobile surfaces with dynamic viewport units.
|
||||
|
||||
## 0.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"version": "0.7.1",
|
||||
"version": "0.7.0",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@gitbook/api": "catalog:",
|
||||
|
||||
@@ -1,36 +1,5 @@
|
||||
# gitbook
|
||||
|
||||
## 0.28.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ddccd3d: Bump Next.js to 16.4.6 and OpenNext (Cloudflare 1.20.17, AWS 4.1.16), keeping the dev-mode OOM patch.
|
||||
- 0c3a51e: Fix horizontal page scroll caused by card carousels bleeding past the viewport.
|
||||
- c85d84f: Fix `'use cache'` entries never being stored in or read from R2 and the regional cache on Cloudflare.
|
||||
- 5997a66: Remove duplicated declarations from the global stylesheet.
|
||||
- c3df458: Keep inline code and highlighted text readable when a paragraph crosses the bottom edge of a background page cover.
|
||||
- 265ca4b: Add a skip link, keyboard navigation between content tabs, focusable table of contents toggles, and hide decorative icons from assistive technologies.
|
||||
- 9fcde5f: Reduce memory and CPU use of the OpenNext workers: minify the middleware, resolve the site context once per request, cache parsed OpenAPI descriptions across a spec, drop the redis client and the unused force-revalidate route from the server bundle.
|
||||
- 9b5b8c8: Load the OpenAPI stylesheet only on pages with OpenAPI blocks.
|
||||
- adfd921: Limit the MCP `searchDocumentation` tool to one language: the one the client passes in the new optional `language` argument, or else the language of the site variant the MCP endpoint is served from.
|
||||
- 19660ed: Flush insights events when the page is hidden, preload the search index at low priority and prioritize the dark page cover on dark-default sites.
|
||||
- c09da2e: Show H3 headings in the page outline.
|
||||
- 19660ed: Fix the search button accessible name, hoverable link previews, IME-safe Enter on Safari, cookie banner semantics, active outline item announcement and textarea shrinking.
|
||||
- 65210b7: Respect reduced motion for enter and exit animations, keep the header separator and input focus visible in forced colors mode, and size mobile surfaces with dynamic viewport units.
|
||||
- 3e86382: Send only the site origin as referrer to third parties, and only let the embedding page open the embed messaging channel.
|
||||
- 7d1cd9f: Remove the ChatGPT-specific plain text response for Markdown and llms.txt routes; these now always serve `text/markdown`.
|
||||
- b145bfc: Stop caching site search results in the framework cache, so every search reaches the API.
|
||||
- 1c71849: Follow the API's cache lifetime for site data, so a site preview shows layout changes soon after they are saved.
|
||||
- 8dd308b: Ignore tag category references when displaying assigned tags and update filters.
|
||||
- Updated dependencies [9fcde5f]
|
||||
- Updated dependencies [265ca4b]
|
||||
- Updated dependencies [262749a]
|
||||
- Updated dependencies [65210b7]
|
||||
- @gitbook/icons@0.6.0
|
||||
- @gitbook/react-openapi@2.0.2
|
||||
- @gitbook/embed@0.7.1
|
||||
- @gitbook/react-contentkit@0.7.19
|
||||
|
||||
## 0.28.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
@@ -1751,7 +1751,7 @@ const testCases: TestsCase[] = [
|
||||
name: 'Navigation to shared space',
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const sharedSpaceLink = page.locator('a.underline');
|
||||
const sharedSpaceLink = page.locator('a.link');
|
||||
await sharedSpaceLink.click();
|
||||
await expect(
|
||||
page.getByRole('heading', { level: 1, name: 'shared' })
|
||||
@@ -1772,7 +1772,7 @@ const testCases: TestsCase[] = [
|
||||
name: 'Navigation to shared space',
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
await page.locator('a.underline').click();
|
||||
await page.locator('a.link').click();
|
||||
await expect(
|
||||
page.getByRole('heading', { level: 1, name: 'shared' })
|
||||
).toBeVisible();
|
||||
@@ -2308,10 +2308,10 @@ const testCases: TestsCase[] = [
|
||||
},
|
||||
run: async (page) => {
|
||||
const alphaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Alpha users' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Beta users' });
|
||||
await expect(alphaUserPage).toBeVisible();
|
||||
await expect(betaUserPage).toHaveCount(0);
|
||||
@@ -2335,10 +2335,10 @@ const testCases: TestsCase[] = [
|
||||
},
|
||||
run: async (page) => {
|
||||
const alphaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Alpha users' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Beta users' });
|
||||
await expect(betaUserPage).toBeVisible();
|
||||
await expect(alphaUserPage).toHaveCount(0);
|
||||
@@ -2363,10 +2363,10 @@ const testCases: TestsCase[] = [
|
||||
},
|
||||
run: async (page) => {
|
||||
const alphaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Alpha users' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Beta users' });
|
||||
await expect(alphaUserPage).toBeVisible();
|
||||
await expect(betaUserPage).toBeVisible();
|
||||
@@ -2383,14 +2383,12 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(alphaUserPage).toHaveCount(0);
|
||||
@@ -2422,14 +2420,12 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(alphaUserPage).toBeVisible();
|
||||
@@ -2461,14 +2457,12 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(betaUserPage).toBeVisible();
|
||||
@@ -2501,14 +2495,12 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.locator('a.toclink')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(betaUserPage).toBeVisible();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// @ts-check
|
||||
|
||||
import { networkInterfaces } from 'node:os';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
// Next blocks its dev client and HMR when a physical device opens the server over a LAN address.
|
||||
// Needed to hydrate the dev client on physical phones/tablets over the internal network
|
||||
@@ -120,17 +119,6 @@ const nextConfig = {
|
||||
],
|
||||
},
|
||||
|
||||
webpack(config, { isServer }) {
|
||||
if (isServer) {
|
||||
// mcp-handler only needs redis for SSE, which we disable: keep the client out of the server bundle.
|
||||
config.resolve.alias = {
|
||||
...config.resolve.alias,
|
||||
redis$: fileURLToPath(new URL('./src/lib/mcp/redis-stub.ts', import.meta.url)),
|
||||
};
|
||||
}
|
||||
return config;
|
||||
},
|
||||
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
"name": "gitbook-open-v2",
|
||||
"compatibility_date": "2026-04-02",
|
||||
"keep_names": false,
|
||||
"minify": true,
|
||||
"compatibility_flags": [
|
||||
"nodejs_compat",
|
||||
"allow_importable_env",
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
import { createHash } from 'node:crypto';
|
||||
|
||||
import { GitbookIncrementalCache } from './incrementalCache';
|
||||
|
||||
describe('GitbookIncrementalCache.getR2Key', () => {
|
||||
const cache = new GitbookIncrementalCache();
|
||||
|
||||
it('accepts the hashed composable key passed by OpenNext', () => {
|
||||
const storageKey = createHash('sha256').update('["build-id","action",[]]').digest('hex');
|
||||
|
||||
const key = cache.getR2Key(storageKey, 'composable');
|
||||
|
||||
const hash = createHash('sha256').update(storageKey).digest('hex');
|
||||
expect(key).toBe(`incremental-cache/dataCache/${hash}.composable`);
|
||||
});
|
||||
|
||||
it('maps distinct composable keys to distinct R2 keys', () => {
|
||||
expect(cache.getR2Key('a'.repeat(64), 'composable')).not.toBe(
|
||||
cache.getR2Key('b'.repeat(64), 'composable')
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -118,8 +118,15 @@ export class GitbookIncrementalCache implements IncrementalCache {
|
||||
}
|
||||
}
|
||||
|
||||
// OpenNext pre-hashes composable keys with the build ID in them: no reuse across deploys.
|
||||
getR2Key(key: string, cacheType: CacheEntryType = 'cache'): string {
|
||||
// Utility function to generate keys for R2/Cache API
|
||||
getR2Key(initialKey: string, cacheType: CacheEntryType = 'cache'): string {
|
||||
let key = initialKey;
|
||||
if (cacheType === 'composable') {
|
||||
// For composable cache, we need to discard the build ID from the key
|
||||
const [_buildId, ...restOfTheKey] = JSON.parse(initialKey);
|
||||
key = JSON.stringify([...restOfTheKey]);
|
||||
}
|
||||
|
||||
const hash = createHash('sha256').update(key).digest('hex');
|
||||
return `${DEFAULT_PREFIX}/${cacheType === 'cache' ? process.env?.NEXT_BUILD_ID : 'dataCache'}/${hash}.${cacheType}`.replace(
|
||||
/\/+/g,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "0.28.3",
|
||||
"version": "0.28.2",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@base-ui/react": "catalog:",
|
||||
@@ -135,7 +135,7 @@
|
||||
"e2e": "playwright test e2e/internal.spec.ts e2e/cookie-banner.spec.ts e2e/pdf.spec.ts e2e/select.spec.ts e2e/tabs-overflow.spec.ts --project=chromium",
|
||||
"e2e-customers": "playwright test e2e/customers.spec.ts --project=chromium",
|
||||
"e2e-style-perf": "playwright test e2e/style-perf.spec.ts --project=chromium --reporter=list",
|
||||
"unit": "bun run generate:assets && bun test {src,packages,openNext} --preload ./tests/preload-bun.ts",
|
||||
"unit": "bun run generate:assets && bun test {src,packages} --preload ./tests/preload-bun.ts",
|
||||
"e2e-browserless": "bun test ./tests/",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
|
||||
-1
@@ -50,7 +50,6 @@ export async function handleMcpRequest(
|
||||
streamableHttpEndpoint: context.linker.toPathInSite(endpoint),
|
||||
maxDuration: 60,
|
||||
verboseLogs: true,
|
||||
// SSE needs redis, which next.config.mjs stubs out of the server bundle.
|
||||
disableSse: true,
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { jwtDecode } from 'jwt-decode';
|
||||
import { forbidden, notFound } from 'next/navigation';
|
||||
import { cache } from 'react';
|
||||
import rison from 'rison';
|
||||
|
||||
import type { SiteAPIToken } from '@gitbook/api';
|
||||
@@ -28,17 +27,7 @@ export type RouteParams = RouteLayoutParams & {
|
||||
/**
|
||||
* Get the static context when rendering statically a site.
|
||||
*/
|
||||
export function getStaticSiteContext(params: RouteLayoutParams) {
|
||||
return getStaticSiteContextCached(params.mode, params.siteURL, params.siteData);
|
||||
}
|
||||
|
||||
// Layouts, pages and their metadata functions each resolve the context: share it per request.
|
||||
// Keyed on the raw strings as `params` objects aren't guaranteed to be the same reference.
|
||||
const getStaticSiteContextCached = cache((mode: string, siteURL: string, siteData: string) =>
|
||||
resolveStaticSiteContext({ mode, siteURL, siteData })
|
||||
);
|
||||
|
||||
async function resolveStaticSiteContext(params: RouteLayoutParams) {
|
||||
export async function getStaticSiteContext(params: RouteLayoutParams) {
|
||||
const siteURL = getSiteURLFromParams(params);
|
||||
const siteURLData = getSiteURLDataFromParams(params);
|
||||
|
||||
@@ -68,15 +57,7 @@ async function resolveStaticSiteContext(params: RouteLayoutParams) {
|
||||
* Get the site context when rendering dynamically.
|
||||
* The context will depend on the request.
|
||||
*/
|
||||
export function getDynamicSiteContext(params: RouteLayoutParams) {
|
||||
return getDynamicSiteContextCached(params.mode, params.siteURL, params.siteData);
|
||||
}
|
||||
|
||||
const getDynamicSiteContextCached = cache((mode: string, siteURL: string, siteData: string) =>
|
||||
resolveDynamicSiteContext({ mode, siteURL, siteData })
|
||||
);
|
||||
|
||||
async function resolveDynamicSiteContext(params: RouteLayoutParams) {
|
||||
export async function getDynamicSiteContext(params: RouteLayoutParams) {
|
||||
const siteURL = getSiteURLFromParams(params);
|
||||
const siteURLData = getSiteURLDataFromParams(params);
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import { LinkStyles } from '../primitives/styles';
|
||||
import { ANNOUNCEMENT_CSS_CLASS, ANNOUNCEMENT_STORAGE_KEY } from './constants';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
import { setLocalStorageItem } from '@/lib/browser';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { ResolvedContentRef } from '@/lib/references';
|
||||
import { getLocalizedMessage, getLocalizedTitle } from '@/lib/sites';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
@@ -38,20 +39,16 @@ export function AnnouncementBanner(props: {
|
||||
const style = BANNER_STYLES[announcement.style];
|
||||
|
||||
return (
|
||||
<div
|
||||
data-gb-announcement-banner
|
||||
className="pb-2 pt-4 theme-bold:bg-header-background"
|
||||
data-nosnippet=""
|
||||
>
|
||||
<div className="lg:chat-open:pr-(--ai-chat-width) transition-all duration-300 motion-reduce:transition-none">
|
||||
<div className={tcls('relative', CONTAINER_STYLE)}>
|
||||
<div data-gb-announcement-banner className="announcement" data-nosnippet="">
|
||||
<div className="chrome-shift">
|
||||
<div className={cx(CONTAINER_STYLE, 'relative')}>
|
||||
<Tag
|
||||
href={contentRef?.href ?? ''}
|
||||
className={tcls(
|
||||
'flex w-full items-start justify-center overflow-hidden circular-corners:rounded-xl rounded-md straight-corners:rounded-none px-4 py-3 text-neutral-strong text-sm theme-bold:ring-1 theme-gradient:ring-1 ring-inset transition-colors',
|
||||
style.container,
|
||||
closeable && 'pr-12',
|
||||
hasLink && style.hover
|
||||
className={cx(
|
||||
'announcement-box',
|
||||
`announcement-${announcement.style}`,
|
||||
closeable && 'announcement-closeable',
|
||||
hasLink && 'announcement-linked'
|
||||
)}
|
||||
insights={
|
||||
announcement.link
|
||||
@@ -65,10 +62,7 @@ export function AnnouncementBanner(props: {
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Icon
|
||||
icon={style.icon as IconName}
|
||||
className={`mr-3 mt-0.5 size-4 shrink-0 ${style.iconColor}`}
|
||||
/>
|
||||
<Icon icon={style.icon as IconName} className="announcement-icon" />
|
||||
<div>
|
||||
{message}
|
||||
{hasLink ? (
|
||||
@@ -85,7 +79,7 @@ export function AnnouncementBanner(props: {
|
||||
? 'arrow-up-right'
|
||||
: 'chevron-right'
|
||||
}
|
||||
className={tcls('mb-0.5 inline size-3')}
|
||||
className="mb-0.5 inline size-3"
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
@@ -123,35 +117,23 @@ function dismissAnnouncement() {
|
||||
|
||||
const BANNER_STYLES = {
|
||||
info: {
|
||||
container: 'bg-info ring-info-subtle',
|
||||
hover: 'hover:bg-info-hover active:bg-info-active',
|
||||
icon: 'circle-info',
|
||||
iconColor: 'text-info-subtle',
|
||||
close: 'hover:bg-tint-base hover:ring-info-subtle',
|
||||
close: 'hover:ring-info-subtle',
|
||||
link: '',
|
||||
},
|
||||
warning: {
|
||||
container: 'bg-warning decoration-warning/6 ring-warning-subtle',
|
||||
hover: 'hover:bg-warning-hover',
|
||||
icon: 'circle-exclamation',
|
||||
iconColor: 'text-warning-subtle',
|
||||
close: 'hover:bg-tint-base hover:ring-warning-subtle',
|
||||
close: 'hover:ring-warning-subtle',
|
||||
link: 'links-default:text-warning hover:links-default:text-warning-strong links-default:decoration-warning/6 links-accent:decoration-warning',
|
||||
},
|
||||
danger: {
|
||||
container: 'bg-danger decoration-danger/6 ring-danger-subtle',
|
||||
hover: 'hover:bg-danger-hover',
|
||||
icon: 'triangle-exclamation',
|
||||
iconColor: 'text-danger-subtle',
|
||||
close: 'hover:bg-tint-base hover:ring-danger-subtle',
|
||||
close: 'hover:ring-danger-subtle',
|
||||
link: 'links-default:text-danger hover:links-default:text-danger-strong links-default:decoration-danger/6 links-accent:decoration-danger',
|
||||
},
|
||||
success: {
|
||||
container: 'bg-success decoration-success/6 ring-success-subtle',
|
||||
hover: 'hover:bg-success-hover',
|
||||
icon: 'circle-check',
|
||||
iconColor: 'text-success-subtle',
|
||||
close: 'hover:bg-tint-base hover:ring-success-subtle',
|
||||
close: 'hover:ring-success-subtle',
|
||||
link: 'links-default:text-success hover:links-default:text-success-strong links-default:decoration-success/6 links-accent:decoration-success',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ export function AnnotationPopover(props: { children: React.ReactNode; body: Reac
|
||||
>
|
||||
<dfn
|
||||
data-annotation=""
|
||||
className="not-italic cursor-help underline decoration-dotted decoration-1 underline-offset-2"
|
||||
className="cursor-help not-italic underline decoration-dotted decoration-1 underline-offset-2"
|
||||
// oxlint-disable-next-line jsx-a11y/no-noninteractive-tabindex -- we want to be able to focus the definition to open the tooltip
|
||||
tabIndex={0}
|
||||
>
|
||||
|
||||
@@ -34,7 +34,7 @@ import {
|
||||
SkeletonParagraph,
|
||||
SkeletonUpdate,
|
||||
} from '@/components/primitives';
|
||||
import type { ClassValue } from '@/lib/tailwind';
|
||||
import type { ClassValue } from '@/lib/classnames';
|
||||
import { nullIfNever } from '@/lib/typescript';
|
||||
|
||||
export interface BlockProps<Block extends DocumentBlock> extends DocumentContextProps {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
@reference "../RootLayout/globals.css";
|
||||
|
||||
/* This file can be the first stylesheet a route loads, and layer order follows first
|
||||
appearance. Without this, `components` would be created here and Tailwind's `base`
|
||||
only later, letting preflight's `padding: 0` and `border: 0` win over the rules below. */
|
||||
@layer theme, base, components, utilities;
|
||||
|
||||
/* Every block on every page carries these, so they live here rather than in each class attribute. */
|
||||
@layer components {
|
||||
.gb-block {
|
||||
@apply decoration-primary/6;
|
||||
}
|
||||
|
||||
/* Lists opt out: a long list is expected to break across printed pages. */
|
||||
.gb-block:not(.gb-block-list) {
|
||||
@apply print:break-inside-avoid;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
import type { DocumentBlock, JSONDocument } from '@gitbook/api';
|
||||
|
||||
import { CONTENT_STYLE, CONTENT_STYLE_REDUCED } from '../layout';
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { Block } from './Block';
|
||||
import './Blocks.css';
|
||||
import type { DocumentContextProps } from './DocumentView';
|
||||
import { isBlockOffscreen } from './utils';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
/**
|
||||
* Renders a list of blocks with a wrapper element.
|
||||
@@ -25,7 +24,7 @@ export function Blocks<TBlock extends DocumentBlock, Tag extends React.ElementTy
|
||||
const { tag: Tag = 'div', style, wrapperProps, ...blocksProps } = props;
|
||||
|
||||
return (
|
||||
<Tag {...wrapperProps} className={tcls(style)}>
|
||||
<Tag {...wrapperProps} className={cx(style)}>
|
||||
<UnwrappedBlocks {...blocksProps} />
|
||||
</Tag>
|
||||
);
|
||||
@@ -94,9 +93,9 @@ export function UnwrappedBlocks<TBlock extends DocumentBlock>(props: UnwrappedBl
|
||||
key={node.key || `${node.type}-${index}`}
|
||||
block={node}
|
||||
style={[
|
||||
// `gb-block` carries the reduced content width.
|
||||
'gb-block',
|
||||
FULL_WIDTH_BLOCKS.has(node.type) ? CONTENT_STYLE : CONTENT_STYLE_REDUCED,
|
||||
|
||||
FULL_WIDTH_BLOCKS.has(node.type) && CONTENT_STYLE,
|
||||
LIST_BLOCKS.has(node.type) && 'gb-block-list',
|
||||
blockStyle,
|
||||
]}
|
||||
|
||||
@@ -10,15 +10,15 @@ import type {
|
||||
import type { DocumentContextProps } from './DocumentView';
|
||||
import { Inlines } from './Inlines';
|
||||
import { getCommentAnchorProps } from './utils';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import { getNodeFragmentByName, isNodeEmpty } from '@/lib/document';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
export type CaptionAlign = NonNullable<DocumentBlockImages['data']['align']>;
|
||||
|
||||
const captionAlignStyles = {
|
||||
center: 'mx-auto',
|
||||
left: 'mr-auto ml-0',
|
||||
right: 'mr-0 ml-auto',
|
||||
center: 'gb-caption-center',
|
||||
left: 'gb-caption-left',
|
||||
right: 'gb-caption-right',
|
||||
} satisfies Record<CaptionAlign, ClassValue>;
|
||||
|
||||
/**
|
||||
@@ -51,17 +51,10 @@ export function Caption(
|
||||
withBorder = false,
|
||||
withFrame = false,
|
||||
wrapperStyle = [
|
||||
'relative',
|
||||
'overflow-hidden',
|
||||
'after:block',
|
||||
'after:absolute',
|
||||
'after:-inset-0',
|
||||
'after:pointer-events-none',
|
||||
fit ? 'w-fit' : null,
|
||||
withBorder
|
||||
? 'rounded-corners:rounded-sm circular-corners:rounded-2xl after:border-tint-subtle after:border after:rounded circular-corners:after:rounded-2xl rounded-corners:after:rounded-sm dark:after:mix-blend-plus-lighter after:pointer-events-none'
|
||||
: null,
|
||||
withFrame && 'p-2',
|
||||
'gb-caption-media',
|
||||
fit && 'gb-caption-fit',
|
||||
withBorder && 'gb-caption-bordered',
|
||||
withFrame && 'gb-caption-framed',
|
||||
],
|
||||
style,
|
||||
align = 'center',
|
||||
@@ -79,23 +72,16 @@ export function Caption(
|
||||
isNodeEmpty(captionParagraph)
|
||||
) {
|
||||
return (
|
||||
<div {...anchorProps} className={tcls(style, wrapperStyle)}>
|
||||
<div {...anchorProps} className={cx(style, wrapperStyle)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<picture {...anchorProps} className={tcls('relative', style)}>
|
||||
<div className={tcls(wrapperStyle, captionAlignStyles[align])}>{children}</div>
|
||||
<figcaption
|
||||
className={tcls(
|
||||
'text-xs',
|
||||
'text-center',
|
||||
'text-tint',
|
||||
withFrame ? 'mt-0.5 mb-2.5' : 'mt-2'
|
||||
)}
|
||||
>
|
||||
<picture {...anchorProps} className={cx('gb-caption', style)}>
|
||||
<div className={cx(wrapperStyle, captionAlignStyles[align])}>{children}</div>
|
||||
<figcaption className={cx('gb-caption-text', withFrame && 'gb-caption-text-framed')}>
|
||||
<Inlines
|
||||
nodes={captionParagraph.nodes}
|
||||
document={document}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useTrackEvent } from '@/components/Insights';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { isAIChatEnabled } from '@/components/utils/isAIChatEnabled';
|
||||
import { t, useLanguage } from '@/intl/client';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
export function AskAICodeButton(props: {
|
||||
codeId: string;
|
||||
@@ -50,7 +50,7 @@ export function AskAICodeButton(props: {
|
||||
variant="secondary"
|
||||
icon={<AIChatIcon state="default" trademark={config.trademark} className="" />}
|
||||
onClick={onClick}
|
||||
className={tcls(style, 'translate-y-0!', 'print:hidden', '[[data-ai-chat]_&]:hidden')}
|
||||
className={cx(style, 'codeblock-button-ask')}
|
||||
>
|
||||
{t(language, 'ask')}
|
||||
</Button>
|
||||
|
||||
@@ -9,6 +9,7 @@ import { getCommentKeyAttributes } from '../utils/commentAnchors';
|
||||
import { AskAICodeButton } from './AskAICodeButton';
|
||||
import { CopyCodeButton } from './CopyCodeButton';
|
||||
import type { HighlightLine, HighlightTheme, HighlightToken } from './highlight-tokens';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
type CodeBlockRendererProps = Pick<BlockProps<DocumentBlockCode>, 'block' | 'style'> & {
|
||||
@@ -55,28 +56,16 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
id={codeId}
|
||||
{...getCommentKeyAttributes(commentKey)}
|
||||
aria-busy={ariaBusy}
|
||||
className={tcls(
|
||||
'group/codeblock shiki relative flex shrink flex-col overflow-hidden print:overflow-visible',
|
||||
!embedded &&
|
||||
'circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs',
|
||||
!embedded &&
|
||||
'[&:has([data-codeblock-focus]:focus)]:ring-2 [&:has([data-codeblock-focus]:focus)]:ring-primary-hover',
|
||||
style
|
||||
)}
|
||||
className={cx('shiki codeblock', !embedded && 'codeblock-framed', tcls(style))}
|
||||
/* Sets the code theme's mode (light or dark) for the site's theme mode (light or dark).
|
||||
* Used to style UI elements (scrollbars, form controls) correctly and apply the right default to "plain" code blocks. */
|
||||
data-color-scheme={`${theme.themes.light.type} ${theme.themes.dark.type}`}
|
||||
>
|
||||
<span
|
||||
data-codeblock-focus
|
||||
tabIndex={-1}
|
||||
aria-hidden
|
||||
className="pointer-events-none absolute size-0 outline-none"
|
||||
/>
|
||||
<div className="flex items-center justify-start gap-2 text-sm">
|
||||
<span data-codeblock-focus tabIndex={-1} aria-hidden className="codeblock-focus" />
|
||||
<div className="codeblock-header">
|
||||
{withTitle ? (
|
||||
<div
|
||||
className="straight-corners:rounded-t-xs relative top-px z-20 inline-flex items-center justify-center border border-b-0 border-tint-subtle bg-tint-subtle px-3 py-2 text-xs leading-none tracking-wide text-tint theme-bold-tint:bg-tint-base theme-muted:bg-tint-base rounded-corners:rounded-t-lg circular-corners:rounded-t-xl contrast-more:border-tint contrast-more:bg-tint-base [html.theme-bold.sidebar-filled_&]:bg-tint-base"
|
||||
className="codeblock-title"
|
||||
style={{
|
||||
backgroundColor: bg?.color,
|
||||
...bg?.vars,
|
||||
@@ -88,12 +77,12 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="relative flex min-h-0 flex-col">
|
||||
<div className="codeblock-body">
|
||||
{!embedded ? (
|
||||
<div
|
||||
className={tcls(
|
||||
'absolute right-2 z-2 flex items-center gap-1.5 font-sans leading-none opacity-0 group-hover/codeblock:opacity-11 has-[button:focus-visible]:opacity-11',
|
||||
isSingleLine ? 'inset-y-0' : 'top-2'
|
||||
className={cx(
|
||||
'codeblock-actions',
|
||||
isSingleLine && 'codeblock-actions-centered'
|
||||
)}
|
||||
>
|
||||
{!isPrint ? (
|
||||
@@ -101,21 +90,17 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
codeId={codeId}
|
||||
title={title}
|
||||
syntax={block.data.syntax}
|
||||
style="backdrop-blur-md"
|
||||
style="codeblock-button"
|
||||
/>
|
||||
) : null}
|
||||
<CopyCodeButton codeId={codeId} style="backdrop-blur-md" />
|
||||
<CopyCodeButton codeId={codeId} style="codeblock-button" />
|
||||
</div>
|
||||
) : null}
|
||||
<pre
|
||||
className={tcls(
|
||||
'relative overflow-auto py-2.5 text-tint-strong print:overflow-visible',
|
||||
embedded
|
||||
? 'bg-tint-base'
|
||||
: 'border border-tint-subtle bg-tint-subtle theme-bold-tint:bg-tint-base theme-muted:bg-tint-base contrast-more:border-tint contrast-more:bg-tint-base',
|
||||
!embedded &&
|
||||
'circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs depth-subtle:shadow-xs',
|
||||
withTitle && 'rounded-ss-none!'
|
||||
className={cx(
|
||||
'codeblock-pre',
|
||||
embedded ? 'codeblock-pre-embedded' : 'codeblock-pre-framed',
|
||||
withTitle && 'codeblock-pre-titled'
|
||||
)}
|
||||
style={{
|
||||
backgroundColor: codeBackground?.color,
|
||||
@@ -124,13 +109,7 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
...fg?.vars,
|
||||
}}
|
||||
>
|
||||
<code
|
||||
className={tcls(
|
||||
'table max-h-full w-fit min-w-full [counter-reset:line] print:max-h-none print:whitespace-pre-wrap',
|
||||
withWrap && 'whitespace-pre-wrap',
|
||||
'[[aria-expanded=false]_&]:mask-b-from-50%'
|
||||
)}
|
||||
>
|
||||
<code className={cx('codeblock-code', withWrap && 'codeblock-code-wrap')}>
|
||||
{theme.lines.map((line, index) => (
|
||||
<CodeHighlightLine
|
||||
bg={codeBackground}
|
||||
@@ -167,9 +146,9 @@ function CodeHighlightLine(props: {
|
||||
};
|
||||
return (
|
||||
<span
|
||||
className={tcls(
|
||||
className={cx(
|
||||
'highlight-line',
|
||||
embeddedPlainLine && 'bg-transparent! hover:bg-tint-subtle!',
|
||||
embeddedPlainLine && 'highlight-line-plain',
|
||||
line.diff === 'added' && 'diff-added',
|
||||
line.diff === 'deleted' && 'diff-deleted',
|
||||
line.highlighted && 'highlighted'
|
||||
|
||||
@@ -4,7 +4,7 @@ import { getCodeTextFromId } from './utils';
|
||||
import { useCopyToClipboard } from '@/components/hooks';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { t, useLanguage } from '@/intl/client';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
/**
|
||||
* Client component to copy the code of a code block.
|
||||
@@ -26,12 +26,7 @@ export function CopyCodeButton(props: { codeId: string; style: ClassValue }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
size="xsmall"
|
||||
variant="secondary"
|
||||
onClick={onClick}
|
||||
className={tcls(style, 'translate-y-0!', 'print:hidden')}
|
||||
>
|
||||
<Button size="xsmall" variant="secondary" onClick={onClick} className={cx(style)}>
|
||||
{t(language, copied ? 'code_copied' : 'code_copy')}
|
||||
</Button>
|
||||
{/* A label swap on the focused button isn't announced, the live region is. */}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { type DocumentBlockColumns, type Length, VerticalAlignment } from '@gitb
|
||||
import type { BlockProps } from '../Block';
|
||||
import { Blocks } from '../Blocks';
|
||||
import { getCommentMarkerProps } from '../utils';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function Columns(props: BlockProps<DocumentBlockColumns>) {
|
||||
@@ -40,10 +41,7 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
|
||||
<div
|
||||
// The app doesn't allow comments inside columns.
|
||||
{...getCommentMarkerProps(context, 'data-comment-ignore')}
|
||||
className={tcls(
|
||||
'grid w-full @2xl:grid-flow-col @2xl:grid-cols-[repeat(var(--grid-slices),minmax(0,1fr))] grid-cols-1 @2xl:grid-rows-1 gap-x-8 gap-y-4',
|
||||
style
|
||||
)}
|
||||
className={cx('column-set', tcls(style))}
|
||||
style={{ '--grid-slices': COLUMN_DIVISIONS } as React.CSSProperties}
|
||||
>
|
||||
{block.nodes.map((columnBlock, index) => {
|
||||
@@ -65,7 +63,8 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
|
||||
document={document}
|
||||
ancestorBlocks={[...ancestorBlocks, block, columnBlock]}
|
||||
context={context}
|
||||
style="group/column w-full space-y-4 *:max-w-full"
|
||||
// `*:max-w-full` stays a utility to beat the blocks' own `max-w-*`.
|
||||
style="group/column column-set-body *:max-w-full"
|
||||
/>
|
||||
</Column>
|
||||
);
|
||||
@@ -83,13 +82,10 @@ export function Column(props: {
|
||||
const { className, style } = transformLengthToCSS(width) ?? {};
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
'flex flex-col',
|
||||
'@container/column',
|
||||
(verticalAlignment === VerticalAlignment.Top || !verticalAlignment) &&
|
||||
'justify-start',
|
||||
verticalAlignment === VerticalAlignment.Middle && 'justify-center',
|
||||
verticalAlignment === VerticalAlignment.Bottom && 'justify-end',
|
||||
className={cx(
|
||||
'column-set-item',
|
||||
verticalAlignment === VerticalAlignment.Middle && 'column-set-item-middle',
|
||||
verticalAlignment === VerticalAlignment.Bottom && 'column-set-item-bottom',
|
||||
className
|
||||
)}
|
||||
style={style}
|
||||
@@ -107,7 +103,7 @@ export function transformLengthToCSS(length: Length) {
|
||||
}
|
||||
if (length.unit === '%') {
|
||||
return {
|
||||
className: '@2xl:flex-shrink-0 @2xl:[grid-column:var(--grid-col)]',
|
||||
className: 'column-set-item-sized',
|
||||
style: {
|
||||
'--grid-col': `auto / span ${Math.round(length.value * 0.01 * COLUMN_DIVISIONS)}`,
|
||||
} as React.CSSProperties,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { DocumentBlockDivider } from '@gitbook/api';
|
||||
|
||||
import type { BlockProps } from './Block';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
export function Divider(props: BlockProps<DocumentBlockDivider>) {
|
||||
const { style } = props;
|
||||
|
||||
return <hr className={tcls(style, 'border-tint-subtle')} />;
|
||||
return <hr className={cx(style, 'border-tint-subtle')} />;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ import type { JSONDocument } from '@gitbook/api';
|
||||
|
||||
import { BlockSkeleton } from './Block';
|
||||
import { Blocks } from './Blocks';
|
||||
import type { ClassValue } from '@/lib/classnames';
|
||||
import type { GitBookAnyContext } from '@/lib/context';
|
||||
import type { ClassValue } from '@/lib/tailwind';
|
||||
|
||||
export interface DocumentContext {
|
||||
/**
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import React from 'react';
|
||||
|
||||
import { useHash } from '@/components/hooks';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
/**
|
||||
* Details component rendered on client so it can expand dependent on url hash changes.
|
||||
@@ -50,27 +50,7 @@ export function Details(props: {
|
||||
id={id}
|
||||
data-block-key={props.commentKey}
|
||||
open={props.open || openFromHash}
|
||||
className={tcls(
|
||||
className,
|
||||
'group/expandable',
|
||||
'bg-tint-base',
|
||||
'border',
|
||||
'border-b-0',
|
||||
'border-tint-subtle',
|
||||
//all
|
||||
'mt-0!',
|
||||
'mb-0',
|
||||
//select first child
|
||||
'first:mt-5!',
|
||||
'first:rounded-t-lg',
|
||||
//select first in group
|
||||
'[:not(&)_+_&]:mt-5!',
|
||||
'[:not(&)_+_&]:rounded-t-lg',
|
||||
//select last in group
|
||||
'[&:not(:has(+_&))]:mb-5',
|
||||
'[&:not(:has(+_&))]:rounded-b-lg',
|
||||
'[&:not(:has(+_&))]:border-b'
|
||||
)}
|
||||
className={cx('expandable', className)}
|
||||
>
|
||||
{children}
|
||||
</details>
|
||||
|
||||
@@ -10,6 +10,7 @@ import { Details } from './Details';
|
||||
import { ToggleChevron } from '@/components/primitives';
|
||||
import { getSpaceLanguage, tString } from '@/intl/server';
|
||||
import { defaultLanguage } from '@/intl/translations';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { getNodeFragmentByType } from '@/lib/document';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
@@ -40,37 +41,16 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
|
||||
id={id}
|
||||
{...getCommentKeyProp(context, block.key)}
|
||||
open={context.mode === 'print' || isDefaultExpanded}
|
||||
className={tcls('scroll-mt-(--content-scroll-margin)', style)}
|
||||
className={tcls(style)}
|
||||
>
|
||||
<summary
|
||||
{...getCommentAnchorProps(context, titleParagraph.key)}
|
||||
className={tcls(
|
||||
'cursor-pointer',
|
||||
'px-4',
|
||||
// Reserve room for the anchor icon pinned to the right edge
|
||||
showHashLink && 'pr-10',
|
||||
'py-4',
|
||||
'relative',
|
||||
'list-none',
|
||||
'select-none',
|
||||
'transition-colors',
|
||||
'text-tint',
|
||||
'group-hover/expandable:text-tint-strong',
|
||||
'group-open/expandable:text-tint-strong',
|
||||
'[&::-webkit-details-marker]:hidden'
|
||||
)}
|
||||
className={cx('expandable-summary', showHashLink && 'expandable-summary-anchored')}
|
||||
>
|
||||
<ToggleChevron
|
||||
orientation="right-to-down"
|
||||
open={context.mode === 'print'}
|
||||
className={tcls(
|
||||
'inline-block',
|
||||
'size-3',
|
||||
'mr-3',
|
||||
'mb-1',
|
||||
'shrink-0',
|
||||
'group-open/expandable:rotate-90'
|
||||
)}
|
||||
className="expandable-chevron"
|
||||
/>
|
||||
<Inlines
|
||||
nodes={titleParagraph.nodes}
|
||||
@@ -82,28 +62,9 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
|
||||
<a
|
||||
href={`#${id}`}
|
||||
aria-label={tString(language, 'direct_link_to_heading')}
|
||||
className={tcls(
|
||||
'absolute',
|
||||
'top-2',
|
||||
'bottom-2',
|
||||
'right-4',
|
||||
'flex',
|
||||
'items-center',
|
||||
'dark:shadow-none',
|
||||
'dark:ring-0'
|
||||
)}
|
||||
className="expandable-anchor"
|
||||
>
|
||||
<Icon
|
||||
icon="hashtag"
|
||||
className={tcls(
|
||||
'inline-block',
|
||||
'size-3',
|
||||
'transition-colors',
|
||||
'text-transparent',
|
||||
'group-hover/expandable:text-tint-subtle',
|
||||
'contrast-more:group-hover/expandable:text-tint-strong'
|
||||
)}
|
||||
/>
|
||||
<Icon icon="hashtag" className="expandable-anchor-icon" />
|
||||
</a>
|
||||
) : null}
|
||||
</summary>
|
||||
@@ -112,7 +73,7 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
|
||||
document={document}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
context={context}
|
||||
style="space-y-4 px-10 pb-5"
|
||||
style="expandable-body"
|
||||
/>
|
||||
</Details>
|
||||
);
|
||||
|
||||
@@ -41,12 +41,12 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
|
||||
|
||||
return (
|
||||
<Caption {...props} withBorder withBlockKey>
|
||||
<div className="flex flex-wrap items-center gap-5 px-5 py-3">
|
||||
<div className="flex min-h-8 min-w-14 flex-col items-center justify-center gap-1 border-r border-tint-subtle pr-4">
|
||||
<div className="file-block">
|
||||
<div className="file-block-preview">
|
||||
{contentType === 'image' ? (
|
||||
<Image
|
||||
alt={file.name}
|
||||
className="h-auto max-h-10 w-auto max-w-10 rounded object-contain"
|
||||
className="file-block-image"
|
||||
sizes={[{ width: 40 }]}
|
||||
resize={context.contentContext?.imageResizer}
|
||||
sources={{
|
||||
@@ -58,11 +58,11 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
|
||||
loading="lazy"
|
||||
/>
|
||||
) : (
|
||||
<FileIcon contentType={contentType} className="size-5 text-primary" />
|
||||
<FileIcon contentType={contentType} className="file-block-icon" />
|
||||
)}
|
||||
</div>
|
||||
<div className="min-w-24 flex-1">
|
||||
<div className="text-base">
|
||||
<div className="file-block-info">
|
||||
<div className="file-block-name">
|
||||
<Link
|
||||
href={file.downloadURL}
|
||||
target="_blank"
|
||||
@@ -72,13 +72,13 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
|
||||
{file.name}
|
||||
</Link>
|
||||
</div>
|
||||
<div className="text-sm text-tint-subtle">
|
||||
<div className="file-block-meta">
|
||||
{contentType
|
||||
? `${contentType} · ${getHumanFileSize(file.size)}`
|
||||
: getHumanFileSize(file.size)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-wrap gap-2">
|
||||
<div className="file-block-actions">
|
||||
<DownloadButton
|
||||
icon="download"
|
||||
size="xsmall"
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
@reference "../RootLayout/globals.css";
|
||||
|
||||
/* This file can be the first stylesheet a route loads, and layer order follows first
|
||||
appearance. Without this, `components` would be created here and Tailwind's `base`
|
||||
only later, letting preflight's `padding: 0` and `border: 0` win over the rules below. */
|
||||
@layer theme, base, components, utilities;
|
||||
|
||||
/* A page carries one of these per heading, so the shared utilities live here instead of in a class
|
||||
attribute repeated hundreds of times — on a large page that repetition is most of the HTML.
|
||||
They sit in `components` so the utilities passed as props still override them. */
|
||||
@layer components {
|
||||
.hash {
|
||||
@apply relative inline-grid grid-area-1-1 border-0 rounded site-background;
|
||||
@apply pointer-events-none opacity-0 transition-opacity;
|
||||
@apply pointer-fine:h-[1em] pointer-fine:pointer-events-auto;
|
||||
@apply pointer-fine:group-hover/hash:opacity-100 pointer-fine:group-focus-within/hash:opacity-100;
|
||||
@apply [.hash-revealed_&]:pointer-events-auto [.hash-revealed_&]:opacity-100;
|
||||
}
|
||||
|
||||
.hash-link {
|
||||
@apply inline-flex items-center p-1 pointer-fine:h-full pointer-fine:p-0;
|
||||
}
|
||||
|
||||
.hash-icon {
|
||||
@apply size-3 self-center text-transparent transition-colors;
|
||||
@apply pointer-fine:group-hover/hash:text-tint-subtle contrast-more:pointer-fine:group-hover/hash:text-tint-strong;
|
||||
@apply pointer-fine:group-focus-within/hash:text-tint-subtle contrast-more:pointer-fine:group-focus-within/hash:text-tint-strong;
|
||||
@apply [.hash-revealed_&]:text-tint-subtle contrast-more:[.hash-revealed_&]:text-tint-strong;
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,7 @@ import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { Link } from '../primitives';
|
||||
import type { DocumentContext } from './DocumentView';
|
||||
import './HashLinkButton.css';
|
||||
import { getBlockTextStyle } from './spacing';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
/**
|
||||
* Whether blocks should render a visible anchor link icon.
|
||||
@@ -21,10 +19,8 @@ export function shouldShowHashLinks(context: DocumentContext): boolean {
|
||||
|
||||
/**
|
||||
* A hash icon which adds the block or active block item's ID in the URL hash.
|
||||
* The button needs to be wrapped in a container with `hashLinkButtonWrapperStyles`.
|
||||
* Styled in `styles/blocks.css`, it is revealed when hovering its `.heading` parent.
|
||||
*/
|
||||
export const hashLinkButtonWrapperStyles = tcls('relative', 'group/hash');
|
||||
|
||||
export function HashLinkButton(props: {
|
||||
id: string;
|
||||
block: DocumentBlockTabs | DocumentBlockHeading;
|
||||
@@ -32,17 +28,12 @@ export function HashLinkButton(props: {
|
||||
className?: ClassValue;
|
||||
iconClassName?: ClassValue;
|
||||
}) {
|
||||
const { id, block, className, iconClassName, label } = props;
|
||||
const textStyle = getBlockTextStyle(block);
|
||||
const { id, className, iconClassName, label } = props;
|
||||
|
||||
return (
|
||||
<span className={tcls('hash', className)}>
|
||||
<Link
|
||||
href={`#${id}`}
|
||||
aria-label={label}
|
||||
className={tcls('hash-link', textStyle.lineHeight)}
|
||||
>
|
||||
<Icon icon="hashtag" className={tcls('hash-icon', iconClassName)} />
|
||||
<span className={cx('hash', className)}>
|
||||
<Link href={`#${id}`} aria-label={label} className="hash-link">
|
||||
<Icon icon="hashtag" className={cx('hash-icon', iconClassName)} />
|
||||
</Link>
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
import type { DocumentBlockHeading } from '@gitbook/api';
|
||||
|
||||
import type { BlockProps } from './Block';
|
||||
import { HashLinkButton, hashLinkButtonWrapperStyles, shouldShowHashLinks } from './HashLinkButton';
|
||||
import { HashLinkButton, shouldShowHashLinks } from './HashLinkButton';
|
||||
import { HeadingRevealWrapper } from './HeadingRevealWrapper';
|
||||
import { Inlines } from './Inlines';
|
||||
import { getBlockTextStyle } from './spacing';
|
||||
import { getCommentAnchorProps, getTextAlignment } from './utils';
|
||||
import { getSpaceLanguage, tString } from '@/intl/server';
|
||||
import { defaultLanguage } from '@/intl/translations';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
export async function Heading(props: BlockProps<DocumentBlockHeading>) {
|
||||
const { block, style, context, ...rest } = props;
|
||||
|
||||
const textStyle = getBlockTextStyle(block);
|
||||
|
||||
const Tag = TAGS[block.type];
|
||||
|
||||
let id = block.meta?.id ?? '';
|
||||
@@ -31,38 +28,20 @@ export async function Heading(props: BlockProps<DocumentBlockHeading>) {
|
||||
as={Tag}
|
||||
id={id}
|
||||
{...getCommentAnchorProps(context, block.key)}
|
||||
className={tcls(
|
||||
textStyle.textSize,
|
||||
className={cx(
|
||||
'heading',
|
||||
block.type,
|
||||
'font-heading',
|
||||
'pdf-heading',
|
||||
'block',
|
||||
// Reserve room for the absolutely positioned anchor icon on coarse pointers
|
||||
showHashLink && 'pr-6',
|
||||
'pointer-fine:flex',
|
||||
'pointer-fine:items-baseline',
|
||||
'pointer-fine:pr-0',
|
||||
'scroll-mt-(--content-scroll-margin)',
|
||||
getTextAlignment(block.data.align),
|
||||
hashLinkButtonWrapperStyles,
|
||||
style,
|
||||
textStyle.marginTop
|
||||
style
|
||||
)}
|
||||
>
|
||||
<span
|
||||
// Cover-aware contrast text applies only to the page body, not to documents
|
||||
// rendered in overlays (search answers, AI chat) on a background-cover page.
|
||||
data-cover-aware-text={context.isPageBody ? '' : undefined}
|
||||
className={tcls(
|
||||
'pointer-fine:flex-1',
|
||||
'z-1',
|
||||
'justify-self-start',
|
||||
'max-w-full',
|
||||
'break-words',
|
||||
// Cover-aware contrast text applies only to the page body, not to documents
|
||||
// rendered in overlays (search answers, AI chat) on a background-cover page.
|
||||
context.isPageBody && 'page-cover-background:text-contrast-cover',
|
||||
getTextAlignment(block.data.align),
|
||||
textStyle.lineHeight
|
||||
)}
|
||||
className={cx('heading-text', getTextAlignment(block.data.align))}
|
||||
>
|
||||
<Inlines {...rest} context={context} nodes={block.nodes} ancestorInlines={[]} />
|
||||
</span>
|
||||
@@ -71,15 +50,6 @@ export async function Heading(props: BlockProps<DocumentBlockHeading>) {
|
||||
<HashLinkButton
|
||||
id={id}
|
||||
block={block}
|
||||
className={tcls(
|
||||
'absolute',
|
||||
block.type === 'heading-1'
|
||||
? '[transform:translateY(0.125em)]'
|
||||
: '[transform:translateY(0.17em)]',
|
||||
'pointer-fine:-ml-6 pointer-fine:relative pointer-fine:order-first pointer-fine:self-center pointer-fine:pr-2 pointer-fine:[transform:none]',
|
||||
'pointer-fine:[.flip-heading-hash_&]:order-last pointer-fine:[.flip-heading-hash_&]:ml-1 pointer-fine:[.flip-heading-hash_&]:pl-2'
|
||||
)}
|
||||
iconClassName={tcls('size-4')}
|
||||
label={tString(language, 'direct_link_to_heading')}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { useSyncExternalStore } from 'react';
|
||||
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
const HEADING_ATTR = 'data-heading-reveal-wrapper';
|
||||
|
||||
@@ -87,7 +87,7 @@ export function HeadingRevealWrapper(props: {
|
||||
return (
|
||||
<Tag
|
||||
id={id}
|
||||
className={tcls(className, revealed && 'hash-revealed')}
|
||||
className={cx(className, revealed && 'hash-revealed')}
|
||||
onPointerUp={handlePointerUp}
|
||||
{...{ [HEADING_ATTR]: true }}
|
||||
{...rest}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { DocumentBlockHint } from '@gitbook/api';
|
||||
import { Icon, type IconName } from '@gitbook/icons';
|
||||
import { validateIconName } from '@gitbook/icons/validateIconName';
|
||||
import { validateIconName } from '@gitbook/icons/icons';
|
||||
|
||||
import { Block, type BlockProps } from './Block';
|
||||
import { Blocks } from './Blocks';
|
||||
import { getBlockTextStyle } from './spacing';
|
||||
import { BLOCK_LINE_HEIGHT, getBlockTextKind } from './spacing';
|
||||
import { getSpaceLanguage, tString } from '@/intl/server';
|
||||
import { defaultLanguage } from '@/intl/translations';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import { isHeadingBlock } from '@/lib/document';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
export async function Hint({
|
||||
block,
|
||||
@@ -22,7 +22,7 @@ export async function Hint({
|
||||
const icon = customIcon && validateIconName(customIcon) ? customIcon : hintStyle.icon;
|
||||
|
||||
const firstNode = block.nodes[0]!;
|
||||
const firstLine = getBlockTextStyle(firstNode);
|
||||
const firstLineHeight = BLOCK_LINE_HEIGHT[getBlockTextKind(firstNode)];
|
||||
const hasHeading = isHeadingBlock(firstNode);
|
||||
|
||||
const language = contextProps.context.contentContext
|
||||
@@ -33,42 +33,25 @@ export async function Hint({
|
||||
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
className={cx(
|
||||
'hint',
|
||||
'transition-colors',
|
||||
'rounded-corners:rounded-md',
|
||||
'circular-corners:rounded-xl',
|
||||
hasHeading ? 'circular-corners:rounded-l-none rounded-corners:rounded-l-none' : '',
|
||||
'overflow-hidden',
|
||||
hasHeading ? ['border-l-2', hintStyle.containerWithHeader] : hintStyle.container,
|
||||
|
||||
'text-sm',
|
||||
|
||||
'grid',
|
||||
'grid-cols-[auto_1fr]',
|
||||
hasHeading ? 'grid-rows-[auto_auto]' : '',
|
||||
|
||||
hasHeading && 'hint-titled',
|
||||
// Kept as utilities: `AskAIParagraphButton` matches `.hint.bg-*`.
|
||||
hasHeading ? hintStyle.containerWithHeader : hintStyle.container,
|
||||
style
|
||||
)}
|
||||
aria-label={label}
|
||||
role="note"
|
||||
>
|
||||
<div
|
||||
className={tcls(
|
||||
'py-4',
|
||||
'pl-4',
|
||||
hasHeading ? hintStyle.header : null,
|
||||
hintStyle.iconColor
|
||||
)}
|
||||
>
|
||||
<Icon icon={icon} className={tcls('size-[1.2em]', 'mt-px', firstLine.lineHeight)} />
|
||||
<div className={cx('hint-aside', hasHeading && hintStyle.header, hintStyle.iconColor)}>
|
||||
<Icon icon={icon} className={cx('hint-icon', firstLineHeight)} />
|
||||
</div>
|
||||
{hasHeading ? (
|
||||
<Block
|
||||
style={tcls(
|
||||
'w-full items-start py-4! pl-3 text-[1em]! *:flex-none',
|
||||
// Heading hash styles
|
||||
'flip-heading-hash pr-8 [&_.hash]:bg-transparent',
|
||||
style={cx(
|
||||
'hint-heading flip-heading-hash',
|
||||
// A utility, to beat the themed backgrounds of `.hash`.
|
||||
'[&_.hash]:bg-transparent',
|
||||
hintStyle.header
|
||||
)}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
@@ -80,27 +63,13 @@ export async function Hint({
|
||||
{...contextProps}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
nodes={hasHeading ? block.nodes.slice(1) : block.nodes}
|
||||
blockStyle={tcls(
|
||||
blockStyle={cx(
|
||||
hintStyle.body,
|
||||
// render hash icon on the other side of the heading
|
||||
'flip-heading-hash'
|
||||
)}
|
||||
style={[
|
||||
'p-4',
|
||||
'pl-3',
|
||||
'empty:p-0',
|
||||
'-row-end-1',
|
||||
'-col-end-1',
|
||||
// Allow the grid track to shrink below its content's min-content size so wide
|
||||
// nested blocks (e.g. code blocks, tables) scroll internally instead of
|
||||
// overflowing the hint. Without this, the `1fr` column keeps its default
|
||||
// `min-width: auto` and grows past the hint's width.
|
||||
'min-w-0',
|
||||
'space-y-3',
|
||||
'[&_.hint]:border',
|
||||
'[&_pre]:border',
|
||||
'[&_pre]:border-neutral',
|
||||
]}
|
||||
// Descendant rules stay utilities so they keep beating the nested blocks' own classes.
|
||||
style="hint-content [&_.hint]:border [&_pre]:border [&_pre]:border-neutral"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -5,8 +5,8 @@ import { Caption, type CaptionAlign } from './Caption';
|
||||
import type { DocumentContext } from './DocumentView';
|
||||
import { getCommentAnchorProps } from './utils';
|
||||
import { Image, type ImageResponsiveSize } from '@/components/utils';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import { resolveContentRefInDocument } from '@/lib/references';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
export function Images(props: BlockProps<DocumentBlockImages>) {
|
||||
const { document, block, style, context, isEstimatedOffscreen } = props;
|
||||
@@ -17,30 +17,18 @@ export function Images(props: BlockProps<DocumentBlockImages>) {
|
||||
return (
|
||||
<div
|
||||
{...getCommentAnchorProps(context, block.key)}
|
||||
className={tcls(
|
||||
className={cx(
|
||||
style,
|
||||
'flex',
|
||||
'w-full',
|
||||
align === 'center' && 'justify-center',
|
||||
align === 'right' && 'justify-end',
|
||||
align === 'left' && 'justify-start'
|
||||
'gb-images',
|
||||
align === 'right' && 'gb-images-right',
|
||||
align === 'left' && 'gb-images-left'
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={tcls(
|
||||
'flex',
|
||||
'flex-row',
|
||||
'gap-3',
|
||||
hasMultipleImages && ['grid', 'grid-flow-col'],
|
||||
withFrame && [
|
||||
'rounded-2xl',
|
||||
'border',
|
||||
'border-[rgb(234,235,238)]',
|
||||
'dark:border-[rgb(45,50,58)]',
|
||||
'relative',
|
||||
'overflow-hidden',
|
||||
'w-fit',
|
||||
]
|
||||
className={cx(
|
||||
'gb-images-row',
|
||||
hasMultipleImages && 'gb-images-multi',
|
||||
withFrame && 'gb-images-framed'
|
||||
)}
|
||||
>
|
||||
{block.nodes.map((node: any, _i: number) => (
|
||||
@@ -100,7 +88,7 @@ async function ImageBlock(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={tcls('relative', 'overflow-hidden')}>
|
||||
<div className="gb-image">
|
||||
<Caption {...props} fit align={align}>
|
||||
<Image
|
||||
alt={block.data.alt ?? ''}
|
||||
|
||||
@@ -2,8 +2,8 @@ import type { DocumentInlineIcon } from '@gitbook/api';
|
||||
import { Icon, type IconName } from '@gitbook/icons';
|
||||
|
||||
import type { InlineProps } from './Inline';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { textColorToStyle } from '@/lib/colors';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export async function InlineIcon(props: InlineProps<DocumentInlineIcon>) {
|
||||
const { inline } = props;
|
||||
@@ -12,7 +12,7 @@ export async function InlineIcon(props: InlineProps<DocumentInlineIcon>) {
|
||||
return (
|
||||
<Icon
|
||||
icon={icon as IconName}
|
||||
className={tcls('inline size-[1em]', color ? textColorToStyle[color] : null)}
|
||||
className={cx('inline-icon', color ? textColorToStyle[color] : null)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import type { DocumentInlineImage } from '@gitbook/api';
|
||||
|
||||
import { Image } from '../utils';
|
||||
import type { InlineProps } from './Inline';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookBaseContext } from '@/lib/context';
|
||||
import { type ResolvedContentRef, resolveContentRefInDocument } from '@/lib/references';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export async function InlineImage(props: InlineProps<DocumentInlineImage>) {
|
||||
const { document, inline, context, ancestorInlines } = props;
|
||||
@@ -30,11 +30,7 @@ export async function InlineImage(props: InlineProps<DocumentInlineImage>) {
|
||||
|
||||
return (
|
||||
/* Ensure images dont expand to the size of the container where this Image may be nested in. Now it's always nested in a size-restricted container */
|
||||
<span
|
||||
className={tcls(
|
||||
size !== 'line' ? ['inline-flex', 'max-w-[300px]', 'align-middle'] : null
|
||||
)}
|
||||
>
|
||||
<span className={cx(size !== 'line' && 'inline-flex max-w-[300px] align-middle')}>
|
||||
<Image
|
||||
alt={inline.data.alt ?? inline.data.caption ?? ''}
|
||||
sizes={sizes}
|
||||
|
||||
@@ -93,15 +93,9 @@ function InlineLinkAnchor(props: {
|
||||
>
|
||||
{children}
|
||||
{isMailto ? (
|
||||
<Icon
|
||||
icon="envelope"
|
||||
className="ml-1 inline size-3 links-accent:text-tint-subtle"
|
||||
/>
|
||||
<Icon icon="envelope" className="inline-link-icon inline-link-mail" />
|
||||
) : isExternal ? (
|
||||
<Icon
|
||||
icon="arrow-up-right"
|
||||
className="ml-0.5 inline size-3 links-accent:text-tint-subtle"
|
||||
/>
|
||||
<Icon icon="arrow-up-right" className="inline-link-icon" />
|
||||
) : null}
|
||||
</StyledLink>
|
||||
);
|
||||
|
||||
@@ -22,7 +22,7 @@ export function List(
|
||||
tag={getListTag(block.type)}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style={['min-w-0 space-y-2', style]}
|
||||
style={['gb-list', style]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ import type {
|
||||
|
||||
import type { BlockProps } from './Block';
|
||||
import { Blocks } from './Blocks';
|
||||
import { getBlockTextStyle } from './spacing';
|
||||
import { getBlockTextKind } from './spacing';
|
||||
import { getCommentAnchorProps } from './utils';
|
||||
import { Checkbox } from '@/components/primitives';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
export function ListItem(props: BlockProps<DocumentBlockListItem>) {
|
||||
const { block, ancestorBlocks, ...contextProps } = props;
|
||||
@@ -32,16 +32,8 @@ export function ListItem(props: BlockProps<DocumentBlockListItem>) {
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
blockStyle={tcls(
|
||||
'min-h-lh',
|
||||
// remove margin-top for the first heading in a list
|
||||
'[h2]:pt-0',
|
||||
'[h3]:pt-0',
|
||||
'[h4]:pt-0',
|
||||
// Override the "mx-auto" class from UnwrappedBlocks
|
||||
'mx-0'
|
||||
)}
|
||||
style="flex min-w-0 flex-1 flex-col space-y-2"
|
||||
blockStyle="gb-list-child"
|
||||
style="gb-list-body"
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -59,7 +51,7 @@ export function ListItem(props: BlockProps<DocumentBlockListItem>) {
|
||||
/>
|
||||
</ListItemPrefix>
|
||||
|
||||
<label htmlFor={block.key} className={tcls('flex-1')}>
|
||||
<label htmlFor={block.key} className="flex-1">
|
||||
{blocksElement}
|
||||
</label>
|
||||
</ListItemLI>
|
||||
@@ -130,27 +122,20 @@ function ListItemLI(props: {
|
||||
anchorProps: ReturnType<typeof getCommentAnchorProps>;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const textStyle = getBlockTextStyle(props.block);
|
||||
const kind = getBlockTextKind(props.block);
|
||||
return (
|
||||
<li {...props.anchorProps} className={tcls(textStyle.lineHeight, 'flex items-start')}>
|
||||
<li
|
||||
{...props.anchorProps}
|
||||
className={cx('gb-list-item', kind !== 'body' && `gb-list-item-${kind}`)}
|
||||
>
|
||||
{props.children}
|
||||
</li>
|
||||
);
|
||||
}
|
||||
|
||||
// Sized after the item's first line through the `gb-list-item-*` modifier of its parent.
|
||||
function ListItemPrefix(props: { block: DocumentBlockListItem; children: React.ReactNode }) {
|
||||
const textStyle = getBlockTextStyle(props.block);
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
textStyle.textSize,
|
||||
textStyle.lineHeight,
|
||||
'mr-1 flex min-h-lh min-w-6 items-center justify-center text-tint'
|
||||
)}
|
||||
>
|
||||
{props.children}
|
||||
</div>
|
||||
);
|
||||
return <div className="gb-list-prefix">{props.children}</div>;
|
||||
}
|
||||
|
||||
function getUnorderedListItemsPrefixContent(input: { depth: number }): string {
|
||||
@@ -173,7 +158,7 @@ function PseudoBefore(props: {
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className="before:content-(--pseudoBefore--content) before:font-var"
|
||||
className="gb-list-marker"
|
||||
style={
|
||||
{
|
||||
'--pseudoBefore--content': `'${props.content}'`,
|
||||
|
||||
@@ -5,8 +5,8 @@ import type { BlockProps } from './Block';
|
||||
import { Inlines } from './Inlines';
|
||||
import { getTextAlignment } from './utils';
|
||||
import { getCommentAnchorProps } from './utils';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { getNodeText } from '@/lib/document';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function Paragraph(props: BlockProps<DocumentBlockParagraph>) {
|
||||
const { block, style, ancestorBlocks, ...contextProps } = props;
|
||||
@@ -21,7 +21,7 @@ export function Paragraph(props: BlockProps<DocumentBlockParagraph>) {
|
||||
// rendered in overlays (search answers, AI chat) on a background-cover page.
|
||||
data-cover-aware-text={context.isPageBody ? '' : undefined}
|
||||
// Paragraph styles live in globals.css (`.paragraph`) to keep the class attribute short.
|
||||
className={tcls('paragraph', style, getTextAlignment(block.data?.align))}
|
||||
className={cx('paragraph', style, getTextAlignment(block.data?.align))}
|
||||
>
|
||||
<Inlines {...contextProps} nodes={block.nodes} ancestorInlines={[]} />
|
||||
</p>
|
||||
@@ -45,11 +45,7 @@ export function Paragraph(props: BlockProps<DocumentBlockParagraph>) {
|
||||
<div
|
||||
// The shared `AskAIParagraphButton` portals itself into the hovered wrapper.
|
||||
data-ask-ai-paragraph=""
|
||||
className={tcls(
|
||||
'group/ask-ai relative',
|
||||
style,
|
||||
getTextAlignment(block.data?.align)
|
||||
)}
|
||||
className={cx('group/ask-ai relative', style, getTextAlignment(block.data?.align))}
|
||||
>
|
||||
{paragraph}
|
||||
</div>
|
||||
|
||||
@@ -4,14 +4,14 @@ import {
|
||||
type DocumentBlockPrompt,
|
||||
type SiteCustomizationSettings,
|
||||
} from '@gitbook/api';
|
||||
import { validateIconName } from '@gitbook/icons/validateIconName';
|
||||
import { validateIconName } from '@gitbook/icons/icons';
|
||||
|
||||
import type { BlockProps } from '../Block';
|
||||
import { CodeBlock } from '../CodeBlock';
|
||||
import { getPlainCodeBlock } from '../CodeBlock/highlight-tokens';
|
||||
import { COMMENT_IGNORE_CLASSNAME, getCommentKeyProp } from '../utils';
|
||||
import { PromptClient } from './PromptClient';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
const PROMPT_COLLAPSED_LINE_COUNT = 10;
|
||||
|
||||
@@ -44,7 +44,7 @@ export function Prompt(props: BlockProps<DocumentBlockPrompt>) {
|
||||
{...getCommentKeyProp(context, block.key)}
|
||||
// Only the comment marker: the prompt keeps its own width rather than the block styles.
|
||||
className={
|
||||
tcls(style).split(' ').includes(COMMENT_IGNORE_CLASSNAME)
|
||||
cx(style).split(' ').includes(COMMENT_IGNORE_CLASSNAME)
|
||||
? COMMENT_IGNORE_CLASSNAME
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@ import {
|
||||
} from '@/components/primitives';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
import { AI_AGENTS, getAIAgent } from '@/lib/ai-agents';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/** How long the copy button shows its confirmation. */
|
||||
const COPIED_MESSAGE_DURATION = 1000;
|
||||
@@ -64,7 +63,7 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
|
||||
|
||||
return (
|
||||
// Lifted above the header's overlay button, which otherwise swallows the clicks.
|
||||
<div className="relative z-20 flex shrink-0 items-center gap-2">
|
||||
<div className="prompt-actions">
|
||||
{openInAIProviders ? (
|
||||
<ButtonGroup>
|
||||
{mainButton}
|
||||
@@ -124,16 +123,8 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
|
||||
function AgentIconStack() {
|
||||
return (
|
||||
<span className="flex items-center">
|
||||
{AI_AGENTS.map((agent, index) => (
|
||||
<span
|
||||
key={agent.id}
|
||||
className={tcls(
|
||||
'flex size-4 shrink-0 items-center justify-center rounded-full border border-tint bg-tint-base',
|
||||
// Each chip's border cuts into the one behind it, so the marks stay legible
|
||||
// however tightly they are stacked.
|
||||
index > 0 && '-ms-1.5'
|
||||
)}
|
||||
>
|
||||
{AI_AGENTS.map((agent) => (
|
||||
<span key={agent.id} className="prompt-agent">
|
||||
<Icon icon={agent.icon} className="size-2.5" />
|
||||
</span>
|
||||
))}
|
||||
|
||||
@@ -8,7 +8,7 @@ import { Icon, type IconName } from '@gitbook/icons';
|
||||
import { PromptActions } from './PromptActions';
|
||||
import { ToggleChevron } from '@/components/primitives';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
type PromptClientProps = DocumentBlockPrompt['data'] & {
|
||||
contentIcon: IconName | null;
|
||||
@@ -44,18 +44,13 @@ export function PromptClient(props: PromptClientProps) {
|
||||
<div
|
||||
data-block-key={commentKey}
|
||||
data-comment-block={commentKey ? '' : undefined}
|
||||
className={tcls(
|
||||
'relative flex w-full flex-col overflow-hidden circular-corners:rounded-2xl rounded-corners:rounded-xl straight-corners:rounded-xs text-tint-strong',
|
||||
'border border-tint-subtle contrast-more:border-tint',
|
||||
'transition',
|
||||
expanded ? 'bg-tint depth-subtle:shadow-xs' : 'bg-tint-base',
|
||||
className
|
||||
)}
|
||||
className={cx('prompt-block', expanded && 'prompt-block-expanded', className)}
|
||||
>
|
||||
<div
|
||||
className={tcls(
|
||||
'group/prompt-header relative flex min-h-9 flex-row items-center justify-between gap-4 p-3 transition-colors',
|
||||
!isPartiallyExpanded && (open ? 'hover:bg-tint-hover' : 'hover:bg-tint-subtle')
|
||||
className={cx(
|
||||
// The marker stays for the chevron's `group-hover/prompt-header`.
|
||||
'group/prompt-header prompt-header',
|
||||
!isPartiallyExpanded && (open ? 'prompt-header-open' : 'prompt-header-closed')
|
||||
)}
|
||||
>
|
||||
{!isPartiallyExpanded ? (
|
||||
@@ -64,15 +59,12 @@ export function PromptClient(props: PromptClientProps) {
|
||||
aria-controls={promptId}
|
||||
aria-expanded={open}
|
||||
aria-label={tString(language, 'view')}
|
||||
className={tcls(
|
||||
'absolute inset-0 z-10 cursor-pointer outline-hidden',
|
||||
'focus-visible:ring-2 focus-visible:ring-primary-hover'
|
||||
)}
|
||||
className="prompt-toggle"
|
||||
disabled={!prompt}
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
/>
|
||||
) : null}
|
||||
<div className="pointer-events-none relative z-0 flex min-w-0 flex-row items-center gap-2 text-tint-strong">
|
||||
<div className="prompt-title">
|
||||
{!isPartiallyExpanded ? (
|
||||
<ToggleChevron
|
||||
open={open}
|
||||
@@ -86,7 +78,7 @@ export function PromptClient(props: PromptClientProps) {
|
||||
<PromptActions prompt={prompt} openInAIProviders={openInAIProviders} />
|
||||
</div>
|
||||
{isPartiallyExpanded || open ? (
|
||||
<div id={promptId} className="border-t border-tint-subtle bg-tint-base">
|
||||
<div id={promptId} className="prompt-body">
|
||||
{children}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -2,6 +2,7 @@ import type { DocumentBlockQuote } from '@gitbook/api';
|
||||
|
||||
import type { BlockProps } from './Block';
|
||||
import { Blocks } from './Blocks';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function Quote(props: BlockProps<DocumentBlockQuote>) {
|
||||
const { block, style, ancestorBlocks, ...contextProps } = props;
|
||||
@@ -12,7 +13,8 @@ export function Quote(props: BlockProps<DocumentBlockQuote>) {
|
||||
tag="blockquote"
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style={[style, 'text-tint', 'border-l-2', 'pl-6', 'py-3', 'border-tint', 'space-y-4']}
|
||||
// Merged here: `text-tint` must beat a hint's `text-neutral-strong` passed in `style`.
|
||||
style={tcls(style, 'text-tint border-l-2 pl-6 py-3 border-tint space-y-4')}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import type { DocumentBlockStepperStep } from '@gitbook/api';
|
||||
import type { BlockProps } from './Block';
|
||||
import { Blocks } from './Blocks';
|
||||
import { getCommentAnchorProps } from './utils';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function StepperStep(props: BlockProps<DocumentBlockStepperStep>) {
|
||||
@@ -36,24 +37,19 @@ export function StepperStep(props: BlockProps<DocumentBlockStepperStep>) {
|
||||
return (
|
||||
<div
|
||||
{...getCommentAnchorProps(context, block.key)}
|
||||
className={tcls('flex flex-row gap-4 md:gap-8', style)}
|
||||
className={cx('stepper-item', tcls(style))}
|
||||
>
|
||||
<div className="relative select-none">
|
||||
<div
|
||||
className={tcls(
|
||||
'can-override-bg can-override-text flex size-[calc(1.75rem+1px)] items-center justify-center rounded-full bg-primary-solid theme-muted:bg-tint-base tabular-nums contrast-more:bg-primary-11',
|
||||
'font-medium text-contrast-primary-solid theme-muted:text-tint contrast-more:text-contrast-primary-11'
|
||||
)}
|
||||
>
|
||||
<div className="stepper-step-marker">
|
||||
<div className="can-override-bg can-override-text stepper-step-number">
|
||||
{index + 1}
|
||||
</div>
|
||||
<div className="can-override-bg absolute bottom-2 left-3.5 top-9 w-px bg-primary-7 theme-muted:bg-tint-6" />
|
||||
<div className="can-override-bg stepper-step-line" />
|
||||
</div>
|
||||
<Blocks
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style={['min-w-0 flex-1 pb-6 [&>*+*]:mt-5', marginAdjustClassName]}
|
||||
style={['stepper-step-body', marginAdjustClassName]}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { TableGridViewProps } from './Table';
|
||||
import { TableHoverTable } from './TableHoverTable';
|
||||
import { TableSearchTableBody } from './TableSearch';
|
||||
import { getColumnAlignment, getColumnVerticalAlignment, type VerticalAlignment } from './utils';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/** Semantic table renderer used when a cell spans multiple records. */
|
||||
@@ -26,7 +27,7 @@ export function NativeViewGrid(props: TableGridViewProps) {
|
||||
{...props}
|
||||
stickyHeader={withStickyHeader}
|
||||
stickyFirstColumn={withStickyFirstColumn}
|
||||
className={tcls(
|
||||
className={cx(
|
||||
withStickyHeader
|
||||
? [
|
||||
'mb-0 border-t border-r border-l',
|
||||
@@ -50,7 +51,7 @@ export function NativeViewGrid(props: TableGridViewProps) {
|
||||
if (withStickyHeader || withStickyFirstColumn) {
|
||||
return (
|
||||
<StickyViewGrid
|
||||
className={tcls(style, 'relative mx-auto grid w-full min-w-0')}
|
||||
className={cx(tcls(style), 'table-view')}
|
||||
stickyHeader={withStickyHeader}
|
||||
tableClassName={tableContainerClassName}
|
||||
withTableRole={false}
|
||||
@@ -62,9 +63,9 @@ export function NativeViewGrid(props: TableGridViewProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={tcls(style, 'relative mx-auto grid w-full min-w-0')}>
|
||||
<div className="w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle">
|
||||
<div className={tcls('flex flex-col', tableContainerClassName)}>
|
||||
<div className={cx(tcls(style), 'table-view')}>
|
||||
<div className="table-scroll">
|
||||
<div className={cx('table-stack', tableContainerClassName)}>
|
||||
{header}
|
||||
{body}
|
||||
</div>
|
||||
@@ -86,13 +87,13 @@ function NativeViewGridHeader(
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className={tcls(
|
||||
'mb-1 rounded-lg border border-tint-subtle bg-tint',
|
||||
stickyHeader || !stickyFirstColumn ? 'overflow-hidden' : undefined,
|
||||
className={cx(
|
||||
'table-native-header',
|
||||
(stickyHeader || !stickyFirstColumn) && 'table-header-clip',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<table className="w-full table-fixed border-separate border-spacing-0">
|
||||
<table className="table-native">
|
||||
<NativeViewGridColumns {...props} />
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -108,12 +109,12 @@ function NativeViewGridHeader(
|
||||
<th
|
||||
key={column}
|
||||
scope="col"
|
||||
className={tcls(
|
||||
'relative px-3 py-2 font-medium text-sm text-tint-strong',
|
||||
className={cx(
|
||||
'table-header-cell',
|
||||
isStickyFirstColumn
|
||||
? stickyHeader
|
||||
? 'z-20 bg-tint'
|
||||
: 'sticky left-0 z-20 bg-tint'
|
||||
? 'table-header-cell-pinned'
|
||||
: 'table-header-cell-sticky'
|
||||
: undefined,
|
||||
getColumnAlignment(definition)
|
||||
)}
|
||||
@@ -149,14 +150,7 @@ function NativeViewGridBody(
|
||||
const recordIndexes = new Map(records.map((record, index) => [record[0], index] as const));
|
||||
|
||||
return (
|
||||
<TableHoverTable
|
||||
className={tcls(
|
||||
'w-full table-fixed border-separate border-spacing-0',
|
||||
'[&>tbody>tr>td[data-table-hovered]]:bg-tint-hover',
|
||||
'[&>tbody>tr+tr>td]:border-t',
|
||||
'[&>tbody+tbody>tr:first-child>td]:border-t'
|
||||
)}
|
||||
>
|
||||
<TableHoverTable className="table-native table-native-body">
|
||||
<NativeViewGridColumns {...props} />
|
||||
{withHeader ? (
|
||||
<thead className="sr-only">
|
||||
@@ -225,15 +219,11 @@ function NativeViewGridBody(
|
||||
data-table-row-end={
|
||||
recordIndex + (cellMerge?.merge.rowSpan ?? 1) - 1
|
||||
}
|
||||
className={tcls(
|
||||
'relative px-3 py-2 text-sm transition-colors',
|
||||
!isLastColumn
|
||||
? 'border-tint-subtle border-r'
|
||||
: undefined,
|
||||
className={cx(
|
||||
'table-native-cell',
|
||||
!isLastColumn && 'table-native-cell-divider',
|
||||
getNativeCellVerticalAlignment(verticalAlignment),
|
||||
isStickyFirstColumn
|
||||
? 'sticky left-0 z-10 bg-tint-base'
|
||||
: undefined
|
||||
isStickyFirstColumn && 'table-native-cell-sticky'
|
||||
)}
|
||||
>
|
||||
<RecordColumnValue
|
||||
|
||||
@@ -7,13 +7,12 @@ import {
|
||||
|
||||
import { isRecordColumnEmpty } from './isRecordColumnEmpty';
|
||||
import { RecordColumnValue } from './RecordColumnValue';
|
||||
import { RecordCardStyles } from './styles';
|
||||
import type { TableRecordKV, TableViewProps } from './Table';
|
||||
import { getRecordCardCovers } from './utils';
|
||||
import { LinkBox, LinkOverlay } from '@/components/primitives';
|
||||
import { Image } from '@/components/utils';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { type ResolvedContentRef, resolveContentRefInDocument } from '@/lib/references';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export async function RecordCard(
|
||||
props: TableViewProps<DocumentTableViewCards> & {
|
||||
@@ -57,36 +56,14 @@ export async function RecordCard(
|
||||
// Marks the card body so overflow-clipped affordances (e.g. the paragraph "Ask"
|
||||
// button) can opt out of rendering inside it.
|
||||
data-card=""
|
||||
className={tcls(
|
||||
'grid-area-1-1',
|
||||
'relative',
|
||||
'grid',
|
||||
'bg-tint-base',
|
||||
'w-[calc(100%+2px)]',
|
||||
'h-[calc(100%+2px)]',
|
||||
'-inset-px',
|
||||
'rounded-sm',
|
||||
'straight-corners:rounded-none',
|
||||
'circular-corners:rounded-xl',
|
||||
'overflow-hidden',
|
||||
'[&_.heading>div:first-child]:hidden',
|
||||
'[&_.heading>div]:text-[.8em]',
|
||||
'@xl:[&_.heading>div]:text-[1em]',
|
||||
'[&_.blocks:first-child_.heading]:pt-0', // Remove padding-top on first heading in card
|
||||
|
||||
// On mobile, check if we can display the cover responsively or not:
|
||||
// - If the file has a landscape aspect ratio, we display it normally
|
||||
// - If the file is square or portrait, we display it left with 40% of the card width
|
||||
className={cx(
|
||||
'record-card-body',
|
||||
lightCoverIsSquareOrPortrait || darkCoverIsSquareOrPortrait
|
||||
? [
|
||||
lightCoverIsSquareOrPortrait
|
||||
? '@sm:grid-cols-none grid-cols-[40%__1fr] @sm:grid-rows-[auto_1fr]'
|
||||
: '',
|
||||
darkCoverIsSquareOrPortrait
|
||||
? 'dark:@sm:grid-cols-none dark:grid-cols-[40%__1fr] dark:@sm:grid-rows-[auto_1fr]'
|
||||
: '',
|
||||
].filter(Boolean)
|
||||
: 'grid-rows-[auto_1fr]'
|
||||
lightCoverIsSquareOrPortrait && 'record-card-body-portrait',
|
||||
darkCoverIsSquareOrPortrait && 'record-card-body-portrait-dark',
|
||||
]
|
||||
: 'record-card-body-landscape'
|
||||
)}
|
||||
>
|
||||
{lightCover ? (
|
||||
@@ -116,37 +93,20 @@ export async function RecordCard(
|
||||
},
|
||||
]}
|
||||
resize={context.contentContext?.imageResizer}
|
||||
className={tcls(
|
||||
'min-w-0',
|
||||
'w-full',
|
||||
'h-full',
|
||||
'bg-tint-subtle',
|
||||
className={cx(
|
||||
'record-card-cover',
|
||||
lightCoverIsSquareOrPortrait || darkCoverIsSquareOrPortrait
|
||||
? [
|
||||
lightCoverIsSquareOrPortrait ? '@sm:aspect-video @sm:h-auto' : '',
|
||||
darkCoverIsSquareOrPortrait
|
||||
? 'dark:@sm:aspect-video dark:@sm:h-auto'
|
||||
: '',
|
||||
].filter(Boolean)
|
||||
: ['h-auto', 'aspect-video'],
|
||||
lightCoverIsSquareOrPortrait && 'record-card-cover-portrait',
|
||||
darkCoverIsSquareOrPortrait && 'record-card-cover-portrait-dark',
|
||||
]
|
||||
: 'record-card-cover-landscape',
|
||||
objectFits
|
||||
)}
|
||||
loading={isOffscreen && context.mode !== 'print' ? 'lazy' : 'eager'}
|
||||
/>
|
||||
) : null}
|
||||
<div
|
||||
className={tcls(
|
||||
'min-w-0',
|
||||
'w-full',
|
||||
'flex',
|
||||
'flex-col',
|
||||
'place-self-start',
|
||||
'gap-3',
|
||||
'p-4',
|
||||
'text-sm',
|
||||
'text-tint-strong'
|
||||
)}
|
||||
>
|
||||
<div className="record-card-content">
|
||||
{view.columns.map((column) => {
|
||||
const definition = block.data.definition[column];
|
||||
|
||||
@@ -163,8 +123,8 @@ export async function RecordCard(
|
||||
if (!view.hideColumnTitle && definition.title) {
|
||||
const ariaLabelledBy = `${block.key}-${column}-title`;
|
||||
return (
|
||||
<div key={column} className="flex flex-col gap-1">
|
||||
<div id={ariaLabelledBy} className="text-sm text-tint">
|
||||
<div key={column} className="record-card-field">
|
||||
<div id={ariaLabelledBy} className="record-card-field-title">
|
||||
{definition.title}
|
||||
</div>
|
||||
<RecordColumnValue
|
||||
@@ -203,7 +163,7 @@ export async function RecordCard(
|
||||
);
|
||||
}
|
||||
|
||||
return <div className={tcls(RecordCardStyles)}>{body}</div>;
|
||||
return <div className="record-card">{body}</div>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,10 +22,10 @@ import {
|
||||
import { Checkbox } from '@/components/primitives';
|
||||
import { StyledLink } from '@/components/primitives';
|
||||
import { Image } from '@/components/utils';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { getNodeFragmentByName } from '@/lib/document';
|
||||
import { getSimplifiedContentType } from '@/lib/files';
|
||||
import { resolveContentRefInDocument } from '@/lib/references';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { filterOutNullable } from '@/lib/typescript';
|
||||
|
||||
const alignmentMap: Record<'text-left' | 'text-center' | 'text-right', string> = {
|
||||
@@ -75,7 +75,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
return (
|
||||
<Checkbox
|
||||
className={tcls('w-5', 'h-5')}
|
||||
className="h-5 w-5"
|
||||
checked={value}
|
||||
disabled={true}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
@@ -90,16 +90,12 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
const max = definition.max;
|
||||
|
||||
return (
|
||||
<Tag className={tcls('inline-grid')}>
|
||||
<Tag className="record-rating">
|
||||
{value ? (
|
||||
<>
|
||||
<span className={tcls('inline-flex', 'grid-area-1-1', 'gap-0.5')}>
|
||||
<span className="record-rating-stars">
|
||||
{Array.from({ length: max }).map((_, i) => (
|
||||
<Icon
|
||||
key={i}
|
||||
icon="star"
|
||||
className={tcls('size-[15px]', 'text-primary/5')}
|
||||
/>
|
||||
<Icon key={i} icon="star" className="record-rating-star" />
|
||||
))}
|
||||
</span>
|
||||
<span
|
||||
@@ -109,14 +105,14 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
aria-valuenow={rating}
|
||||
aria-valuemin={1}
|
||||
aria-valuemax={definition.max}
|
||||
className={tcls('inline-flex', 'grid-area-1-1', 'gap-0.5')}
|
||||
className="record-rating-stars"
|
||||
>
|
||||
{Array.from({ length: rating }).map((_, i) => (
|
||||
<Icon
|
||||
key={i}
|
||||
icon="star"
|
||||
iconStyle={IconStyle.SharpSolid}
|
||||
className={tcls('size-[15px]', 'text-primary')}
|
||||
className="record-rating-star-filled"
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
@@ -130,10 +126,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Tag
|
||||
className={tcls('text-base', 'tabular-nums', 'tracking-tighter')}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
>{`${value}`}</Tag>
|
||||
<Tag className="record-number" aria-labelledby={ariaLabelledBy}>{`${value}`}</Tag>
|
||||
);
|
||||
}
|
||||
case 'text': {
|
||||
@@ -142,7 +135,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
const fragment = getNodeFragmentByName(block, value);
|
||||
if (!fragment) {
|
||||
return <Tag className={tcls(['w-full', verticalAlignment])}>{''}</Tag>;
|
||||
return <Tag className={cx('w-full', verticalAlignment)}>{''}</Tag>;
|
||||
}
|
||||
|
||||
const horizontalAlignment = getColumnAlignment(definition);
|
||||
@@ -154,15 +147,8 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
document={document}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
nodes={fragment.nodes}
|
||||
style={[
|
||||
'blocks',
|
||||
'w-full',
|
||||
'space-y-2',
|
||||
'lg:space-y-3',
|
||||
'leading-normal',
|
||||
verticalAlignment,
|
||||
horizontalClasses,
|
||||
]}
|
||||
// Alignment stays as utilities: they must beat the alignment set by the blocks inside.
|
||||
style={['blocks record-text', verticalAlignment, horizontalClasses]}
|
||||
context={context}
|
||||
blockStyle={['w-full', 'max-w-[unset]']}
|
||||
wrapperProps={{
|
||||
@@ -191,7 +177,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
);
|
||||
|
||||
return (
|
||||
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
|
||||
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
|
||||
{files.filter(filterOutNullable).map((ref, index) => {
|
||||
const contentType = ref.file
|
||||
? getSimplifiedContentType(ref.file.contentType)
|
||||
@@ -201,7 +187,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
<StyledLink
|
||||
key={index}
|
||||
href={ref.href}
|
||||
className="flex flex-row items-center gap-2"
|
||||
className="record-file-link"
|
||||
insights={
|
||||
ref.file
|
||||
? {
|
||||
@@ -235,10 +221,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
loading={context.mode === 'print' ? 'eager' : 'lazy'}
|
||||
/>
|
||||
) : (
|
||||
<FileIcon
|
||||
contentType={contentType}
|
||||
className={tcls('size-4')}
|
||||
/>
|
||||
<FileIcon contentType={contentType} className="size-4" />
|
||||
)}
|
||||
{ref.text}
|
||||
</StyledLink>
|
||||
@@ -259,10 +242,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
})
|
||||
: null;
|
||||
return (
|
||||
<Tag
|
||||
className={tcls('text-base', 'text-balance', 'flex', 'items-center')}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
>
|
||||
<Tag className="record-ref" aria-labelledby={ariaLabelledBy}>
|
||||
{resolved?.icon ?? null}
|
||||
{resolved ? (
|
||||
<StyledLink
|
||||
@@ -311,7 +291,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
);
|
||||
|
||||
return (
|
||||
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
|
||||
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
|
||||
{resolved.filter(filterOutNullable).map(([contentRef, resolved], index) => (
|
||||
<StyledLink
|
||||
key={index}
|
||||
@@ -336,7 +316,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
return (
|
||||
<Tag aria-labelledby={ariaLabelledBy}>
|
||||
<span className={tcls('inline-flex', 'gap-2', 'flex-wrap')}>
|
||||
<span className="record-select">
|
||||
{value.map((selectId) => {
|
||||
const option = definition.options.find(
|
||||
(option) => option.value === selectId
|
||||
@@ -347,18 +327,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
key={option.value}
|
||||
className={tcls(
|
||||
'text-sm',
|
||||
'whitespace-pre',
|
||||
'rounded-sm',
|
||||
'py-1',
|
||||
'px-2',
|
||||
'bg-primary',
|
||||
'text-primary-strong'
|
||||
)}
|
||||
>
|
||||
<span key={option.value} className="record-select-option">
|
||||
{option.label}
|
||||
</span>
|
||||
);
|
||||
@@ -385,10 +354,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
|
||||
return (
|
||||
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
|
||||
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
|
||||
<StyledLink
|
||||
href={image.href}
|
||||
className="flex flex-row items-center gap-2"
|
||||
className="record-file-link"
|
||||
insights={
|
||||
image.file
|
||||
? {
|
||||
|
||||
@@ -6,7 +6,7 @@ import type { TableGridViewProps, TableRecordKV } from './Table';
|
||||
import { TableSearchRecord } from './TableSearch';
|
||||
import './styles.css';
|
||||
import { getColumnVerticalAlignment } from './utils';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
export function RecordRow(
|
||||
props: TableGridViewProps & {
|
||||
@@ -24,7 +24,7 @@ export function RecordRow(
|
||||
role="row"
|
||||
recordId={record[0]}
|
||||
visibleClassName="flex"
|
||||
className={tcls('group/row', 'table-grid-row')}
|
||||
className="table-grid-row"
|
||||
>
|
||||
{view.columns.map((column) => {
|
||||
const cellMerge = getTableCellMerge(cellMergeLayout, record[0], column);
|
||||
@@ -53,7 +53,7 @@ export function RecordRow(
|
||||
role="cell"
|
||||
{...getCommentCellProps(context, record[0], column)}
|
||||
aria-colspan={cellMerge?.merge.colSpan}
|
||||
className={tcls(
|
||||
className={cx(
|
||||
'table-grid-cell',
|
||||
isStickyFirstColumnCell ? 'table-grid-cell-sticky' : undefined
|
||||
)}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import { type ReactNode, useCallback, useEffect, useLayoutEffect, useRef } from 'react';
|
||||
|
||||
import { useScrollListener } from '@/components/hooks/useScrollListener';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
interface StickyViewGridProps {
|
||||
className?: string;
|
||||
@@ -31,12 +31,9 @@ function DefaultHeaderScrollGrid({
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div
|
||||
role={withTableRole ? 'table' : undefined}
|
||||
className="group/table relative flex w-full min-w-0 max-w-full flex-col rounded-lg border-tint-subtle"
|
||||
>
|
||||
<div className="w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle">
|
||||
<div className={tcls('flex', 'flex-col', resolvedTableClassName)}>
|
||||
<div role={withTableRole ? 'table' : undefined} className="group/table table-sticky">
|
||||
<div className="table-scroll">
|
||||
<div className={cx('table-stack', resolvedTableClassName)}>
|
||||
{header}
|
||||
{children}
|
||||
</div>
|
||||
@@ -142,27 +139,14 @@ function StickyHeaderOverlayScrollGrid({
|
||||
<div className={className}>
|
||||
<div
|
||||
ref={rootRef}
|
||||
className="group/table relative flex w-full min-w-0 max-w-full flex-col rounded-lg border-tint-subtle data-[scrollable=true]:border"
|
||||
className="group/table table-sticky"
|
||||
data-scrollable="false"
|
||||
role={withTableRole ? 'table' : undefined}
|
||||
>
|
||||
{header ? (
|
||||
<div
|
||||
ref={stickyHeaderRef}
|
||||
className={tcls(
|
||||
'sticky z-20 w-full min-w-0 max-w-full overflow-hidden rounded-t-[inherit]',
|
||||
'[top:var(--toc-top-offset,var(--outline-top-offset,0px))]'
|
||||
)}
|
||||
>
|
||||
<div ref={stickyHeaderRef} className="table-sticky-header">
|
||||
<div
|
||||
className={tcls(
|
||||
'flex',
|
||||
'flex-col',
|
||||
resolvedTableClassName,
|
||||
// The sticky header is rendered outside the scroll container, so it
|
||||
// needs to mirror the body's horizontal scroll position.
|
||||
'[transform:translateX(var(--table-sticky-scroll-left,0px))]'
|
||||
)}
|
||||
className={cx('table-sticky-header-track', resolvedTableClassName)}
|
||||
style={{ width: 'var(--table-sticky-table-width)' }}
|
||||
>
|
||||
{header}
|
||||
@@ -170,14 +154,8 @@ function StickyHeaderOverlayScrollGrid({
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div
|
||||
ref={bodyScrollRef}
|
||||
className="w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle group-data-[scrollable=true]/table:mx-px group-data-[scrollable=true]/table:rounded-none group-data-[scrollable=true]/table:border-0"
|
||||
>
|
||||
<div
|
||||
ref={bodyTableRef}
|
||||
className={tcls('flex', 'flex-col', resolvedTableClassName)}
|
||||
>
|
||||
<div ref={bodyScrollRef} className="table-scroll table-sticky-scroll">
|
||||
<div ref={bodyTableRef} className={cx('table-stack', resolvedTableClassName)}>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,6 +23,7 @@ import {
|
||||
} from './TableSearch';
|
||||
import { ViewCards } from './ViewCards';
|
||||
import { ViewGrid, ViewGridHeader } from './ViewGrid';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export type { TableRecordKV };
|
||||
@@ -78,7 +79,7 @@ export function Table(props: BlockProps<DocumentBlockTable>) {
|
||||
{...getCommentAnchorProps(context, block.key)}
|
||||
// Owns clicks inside, e.g. on blocks of a record's own document; cells still win.
|
||||
{...getCommentMarkerProps(context, 'data-comment-block')}
|
||||
className={tcls(style, 'flex flex-col gap-3')}
|
||||
className={cx(tcls(style), 'table-block')}
|
||||
>
|
||||
{showSearch ? (
|
||||
<TableSearchInput
|
||||
@@ -155,7 +156,7 @@ function TableView({
|
||||
if (withStickyHeader || withStickyFirstColumn) {
|
||||
return (
|
||||
<StickyViewGrid
|
||||
className={tcls(style, 'relative mx-auto grid w-full min-w-0')}
|
||||
className={cx(tcls(style), 'table-view')}
|
||||
stickyHeader={withStickyHeader}
|
||||
tableClassName={tableContainerClassName}
|
||||
header={
|
||||
@@ -163,7 +164,7 @@ function TableView({
|
||||
<ViewGridHeader
|
||||
{...gridProps}
|
||||
tableClassName={tableContainerClassName}
|
||||
className={tcls(
|
||||
className={cx(
|
||||
withStickyHeader
|
||||
? [
|
||||
'mb-0 border-t border-r border-l',
|
||||
@@ -184,21 +185,13 @@ function TableView({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={tcls(style, 'relative mx-auto grid w-full min-w-0')}>
|
||||
<div
|
||||
className={tcls(
|
||||
'w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-none border-tint-subtle '
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={tcls('flex', 'flex-col', tableContainerClassName)}
|
||||
role="table"
|
||||
>
|
||||
<div className={cx(tcls(style), 'table-view')}>
|
||||
<div className="table-scroll">
|
||||
<div className={cx('table-stack', tableContainerClassName)} role="table">
|
||||
{withHeader ? (
|
||||
<ViewGridHeader
|
||||
{...gridProps}
|
||||
tableClassName={tableContainerClassName}
|
||||
className={tableContainerClassName}
|
||||
/>
|
||||
) : null}
|
||||
<ViewGrid {...gridProps} tableClassName={tableContainerClassName} />
|
||||
|
||||
@@ -47,9 +47,9 @@ describe('ViewCards', () => {
|
||||
expect(markup).toContain('-mx-4 sm:-mx-6 md:-mx-8 2xl:-mx-12');
|
||||
expect(markup).toContain('scroll-px-4');
|
||||
expect(markup).toContain('2xl:scroll-px-12');
|
||||
expect(markup).toContain('left-0');
|
||||
expect(markup).toContain('scroll-container-prev-x');
|
||||
expect(markup).toContain('2xl:ml-8');
|
||||
expect(markup).toContain('right-0');
|
||||
expect(markup).toContain('scroll-container-next-x');
|
||||
expect(markup).toContain('2xl:mr-8');
|
||||
expect(markup).not.toContain('before:bg-linear-to-r');
|
||||
expect(markup).not.toContain('after:bg-linear-to-l');
|
||||
@@ -59,6 +59,6 @@ describe('ViewCards', () => {
|
||||
it('renders the wrapping grid by default', () => {
|
||||
const markup = renderWithContext(<ViewCards {...makeProps(true)} />);
|
||||
|
||||
expect(markup).toContain('inline-grid');
|
||||
expect(markup).toContain('record-cards');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,6 +4,7 @@ import { RecordCard } from './RecordCard';
|
||||
import type { TableViewProps } from './Table';
|
||||
import { TableSearchRecord } from './TableSearch';
|
||||
import { ScrollContainer } from '@/components/primitives/ScrollContainer';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function ViewCards(props: TableViewProps<DocumentTableViewCards>) {
|
||||
@@ -25,12 +26,10 @@ function CardsGrid(props: TableViewProps<DocumentTableViewCards>) {
|
||||
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
style,
|
||||
'inline-grid',
|
||||
'gap-4',
|
||||
'grid-cols-1',
|
||||
view.cardSize === 'large' ? '@xl:grid-cols-2' : '@2xl:grid-cols-3 @sm:grid-cols-2', // Large cards break earlier to avoid becoming *too* big.
|
||||
className={cx(
|
||||
tcls(style),
|
||||
'record-cards',
|
||||
view.cardSize === 'large' ? 'record-cards-large' : 'record-cards-medium',
|
||||
block.data.fullWidth ? 'large:flex-column' : null
|
||||
)}
|
||||
>
|
||||
@@ -70,12 +69,10 @@ const PEEK = {
|
||||
function CardsCarousel(props: TableViewProps<DocumentTableViewCards>) {
|
||||
const { view, records } = props;
|
||||
|
||||
// Cards need a fixed width so the row overflows and scrolls; mirror the grid's
|
||||
// medium/large sizing.
|
||||
const cardWidth =
|
||||
view.cardSize === 'large'
|
||||
? 'w-[90%] @sm:w-[calc(45%-0.5rem)] @5xl:w-[calc(50%-0.5rem)]'
|
||||
: 'w-[90%] @sm:w-[calc(45%-0.5rem)] @xl:w-[calc(30%-0.66rem)] @5xl:w-[calc(33.33%-0.66rem)]';
|
||||
const itemClassName = cx(
|
||||
'record-carousel-item',
|
||||
view.cardSize === 'large' ? 'record-carousel-item-large' : 'record-carousel-item-medium'
|
||||
);
|
||||
|
||||
return (
|
||||
<ScrollContainer
|
||||
@@ -108,15 +105,7 @@ function CardsCarousel(props: TableViewProps<DocumentTableViewCards>) {
|
||||
<TableSearchRecord
|
||||
key={record[0]}
|
||||
recordId={record[0]}
|
||||
// `grid grid-cols-1` stretches the card to fill the fixed-width,
|
||||
// equal-height track; `snap-start` aligns it to the left edge.
|
||||
visibleClassName={tcls(
|
||||
'grid',
|
||||
'grid-cols-1',
|
||||
'shrink-0',
|
||||
'snap-start',
|
||||
cardWidth
|
||||
)}
|
||||
visibleClassName={itemClassName}
|
||||
>
|
||||
<RecordCard {...props} record={record} />
|
||||
</TableSearchRecord>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { getColumnWidth, getViewGridLayout } from './layout';
|
||||
import { RecordRow } from './RecordRow';
|
||||
import type { TableGridViewProps } from './Table';
|
||||
import { getColumnAlignment } from './utils';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
interface ViewGridHeaderProps extends TableGridViewProps {
|
||||
className?: string;
|
||||
@@ -27,14 +27,14 @@ export function ViewGridHeader(props: ViewGridHeaderProps) {
|
||||
return (
|
||||
<div
|
||||
role="rowgroup"
|
||||
className={tcls(
|
||||
className={cx(
|
||||
tableClassName ?? tableWidth,
|
||||
'mb-1 flex flex-col rounded-lg border border-tint-subtle bg-tint',
|
||||
withStickyHeader || !stickyFirstColumn ? 'overflow-hidden' : undefined,
|
||||
'table-grid-header',
|
||||
(withStickyHeader || !stickyFirstColumn) && 'table-header-clip',
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div role="row" className={tcls('flex', 'w-full')}>
|
||||
<div role="row" className="table-grid-header-row">
|
||||
{view.columns.map((column) => {
|
||||
const definition = block.data.definition[column];
|
||||
if (!definition) {
|
||||
@@ -45,12 +45,12 @@ export function ViewGridHeader(props: ViewGridHeaderProps) {
|
||||
<div
|
||||
key={column}
|
||||
role="columnheader"
|
||||
className={tcls(
|
||||
'relative px-3 py-2 font-medium text-sm text-tint-strong',
|
||||
className={cx(
|
||||
'table-header-cell',
|
||||
stickyFirstColumn && column === firstVisibleColumn
|
||||
? withStickyHeader
|
||||
? 'z-20 bg-tint'
|
||||
: 'sticky left-0 z-20 bg-tint'
|
||||
? 'table-header-cell-pinned'
|
||||
: 'table-header-cell-sticky'
|
||||
: undefined,
|
||||
getColumnAlignment(definition)
|
||||
)}
|
||||
@@ -89,10 +89,7 @@ export function ViewGrid(props: ViewGridProps) {
|
||||
});
|
||||
|
||||
const body = (
|
||||
<div
|
||||
role="rowgroup"
|
||||
className={tcls('flex', 'flex-col', tableClassName ?? tableWidth, '[&>*+*]:border-t')}
|
||||
>
|
||||
<div role="rowgroup" className={cx('table-grid-body', tableClassName ?? tableWidth)}>
|
||||
{records.map((record) => (
|
||||
<RecordRow
|
||||
key={record[0]}
|
||||
@@ -105,5 +102,5 @@ export function ViewGrid(props: ViewGridProps) {
|
||||
</div>
|
||||
);
|
||||
|
||||
return <div className={tcls('flex', 'flex-col', tableClassName ?? tableWidth)}>{body}</div>;
|
||||
return <div className={cx('table-stack', tableClassName ?? tableWidth)}>{body}</div>;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@
|
||||
}
|
||||
|
||||
.table-grid-cell-sticky {
|
||||
@apply sticky left-0 z-10 bg-tint-base group-hover/row:bg-tint-hover;
|
||||
@apply sticky left-0 z-10 bg-tint-base;
|
||||
|
||||
@media (hover: hover) {
|
||||
.table-grid-row:hover > & {
|
||||
@apply bg-tint-hover;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import type { ClassValue } from '@/lib/tailwind';
|
||||
|
||||
export const RecordCardStyles = [
|
||||
'group',
|
||||
'grid',
|
||||
'shadow-1xs',
|
||||
'shadow-tint-9/1',
|
||||
'depth-flat:shadow-none',
|
||||
'rounded-sm',
|
||||
'straight-corners:rounded-none',
|
||||
'circular-corners:rounded-xl',
|
||||
'dark:shadow-transparent',
|
||||
|
||||
'before:pointer-events-none',
|
||||
'before:grid-area-1-1',
|
||||
'before:transition-shadow',
|
||||
'before:w-full',
|
||||
'before:h-full',
|
||||
'before:rounded-[inherit]',
|
||||
'before:ring-1',
|
||||
'before:ring-tint-12/2',
|
||||
'before:z-10',
|
||||
'before:relative',
|
||||
] as ClassValue;
|
||||
|
||||
export const RecordCardLinkStyles = ['hover:before:ring-primary-hover'] as ClassValue;
|
||||
@@ -10,6 +10,7 @@ import { DropdownMenu, DropdownMenuItem } from '@/components/primitives';
|
||||
import { useResolvedSlug, useSelect } from '@/components/Select';
|
||||
import { useLanguage } from '@/intl/client';
|
||||
import { tString } from '@/intl/translate';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import {
|
||||
SELECT_DEFAULT_ATTR,
|
||||
SELECT_GROUP_ATTR,
|
||||
@@ -17,7 +18,6 @@ import {
|
||||
SELECT_PINNED_ATTR,
|
||||
SELECT_UNPINNED_ATTR,
|
||||
} from '@/lib/select';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { resolveAnchorURL } from '@/lib/urls';
|
||||
|
||||
export interface TabsItem {
|
||||
@@ -81,17 +81,7 @@ export function DynamicTabs(props: { tabs: TabsItem[]; setClassName: string; cla
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
{...{ [SELECT_GROUP_ATTR]: '' }}
|
||||
className={tcls(
|
||||
'rounded-lg',
|
||||
'straight-corners:rounded-xs',
|
||||
'ring-1 ring-tint-subtle ring-inset',
|
||||
'flex min-w-0 flex-col',
|
||||
setClassName,
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div {...{ [SELECT_GROUP_ATTR]: '' }} className={cx('tabs-block', setClassName, className)}>
|
||||
<TabItemList tabs={tabs} activeTabId={activeTabId} onSelect={selectTab} />
|
||||
{tabs.map((tab, index) => (
|
||||
<TabPanel
|
||||
@@ -128,9 +118,9 @@ const TabPanel = memo(function TabPanel(props: {
|
||||
role="tabpanel"
|
||||
id={tab.id}
|
||||
aria-labelledby={getTabButtonId(tab.id)}
|
||||
className="scroll-mt-[calc(var(--content-scroll-margin)+var(--spacing)*20)]"
|
||||
className="tabs-panel"
|
||||
>
|
||||
<div className="px-8 py-6">{tab.body}</div>
|
||||
<div className="tabs-panel-body">{tab.body}</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -160,18 +150,7 @@ const TabItemList = memo(function TabItemList(props: {
|
||||
ref={containerRef}
|
||||
role="tablist"
|
||||
onKeyDown={moveFocusBetweenTabs}
|
||||
className={tcls(
|
||||
'group/tabs',
|
||||
'overflow-hidden',
|
||||
'rounded-t-lg',
|
||||
'straight-corners:rounded-t-xs',
|
||||
'inline-flex',
|
||||
'self-stretch',
|
||||
'after:flex-1',
|
||||
'after:bg-tint-12/1',
|
||||
// if last tab is selected, apply rounded to :after element
|
||||
'[&:has(button.active-tab:last-of-type):after]:rounded-bl-md'
|
||||
)}
|
||||
className="tabs-list"
|
||||
>
|
||||
{/* When we measure, we add the menu at start to be sure everything's fit. */}
|
||||
{isMeasuring ? (
|
||||
@@ -265,19 +244,18 @@ const TabItem = memo(function TabItem(props: {
|
||||
onClick={() => onSelect(tab.id)}
|
||||
wrapperClassName={
|
||||
isActive
|
||||
? // Keeps room for the overflow menu button.
|
||||
'max-w-[calc(100%-3rem)]'
|
||||
? 'tabs-item-current'
|
||||
: isMeasuring
|
||||
? // Measured after the active tab, at their narrowest, so the menu only takes
|
||||
// the tabs that can't fit even truncated.
|
||||
'order-1 max-w-28'
|
||||
'tabs-item-measuring'
|
||||
: // Equal shares capped at their own width, so no tab drops below that
|
||||
// narrowest size; the high grow leaves the strip's filler only the leftover.
|
||||
'min-w-0 max-w-max basis-0 grow-[1000]'
|
||||
'tabs-item-fluid'
|
||||
}
|
||||
>
|
||||
{tab.icon && <Icon icon={tab.icon} className="size-4 shrink-0" />}
|
||||
<span className="min-w-0 truncate">{tab.title}</span>
|
||||
{tab.icon && <Icon icon={tab.icon} className="tabs-button-icon" />}
|
||||
<span className="tabs-button-label">{tab.title}</span>
|
||||
</TabButton>
|
||||
);
|
||||
});
|
||||
@@ -294,59 +272,13 @@ function TabButton(
|
||||
const { isActive, wrapperClassName, ...rest } = props;
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
'relative',
|
||||
'flex items-center',
|
||||
|
||||
//prev from active-tab
|
||||
'[&:has(+_.active-tab)]:rounded-br-md',
|
||||
|
||||
//next from active-tab
|
||||
'[.active-tab+&]:rounded-bl-md',
|
||||
|
||||
//next from active-tab
|
||||
'[.active-tab_+_:after]:rounded-br-md',
|
||||
|
||||
'after:transition-colors',
|
||||
'after:border-r',
|
||||
'after:absolute',
|
||||
'after:left-[unset]',
|
||||
'after:right-0',
|
||||
'after:border-tint',
|
||||
'after:top-[15%]',
|
||||
'after:h-[70%]',
|
||||
'after:w-px',
|
||||
|
||||
'last:after:border-transparent',
|
||||
|
||||
'text-tint',
|
||||
'bg-tint-12/1',
|
||||
'hover:text-tint-strong',
|
||||
'max-w-full',
|
||||
'shrink-0',
|
||||
'truncate',
|
||||
|
||||
props['aria-selected'] || props['aria-expanded'] || isActive
|
||||
? [
|
||||
'active-tab',
|
||||
'text-tint-strong',
|
||||
'bg-transparent',
|
||||
'[&.active-tab]:after:border-transparent',
|
||||
'[:has(+_&.active-tab)]:after:border-transparent',
|
||||
'[:has(&_+)]:after:border-transparent',
|
||||
]
|
||||
: null,
|
||||
className={cx(
|
||||
'tabs-item',
|
||||
(props['aria-selected'] || props['aria-expanded'] || isActive) && 'active-tab',
|
||||
wrapperClassName
|
||||
)}
|
||||
>
|
||||
<button
|
||||
{...rest}
|
||||
type="button"
|
||||
className={tcls(
|
||||
'relative inline-flex min-w-0 max-w-full items-center gap-1.5 px-4 py-2.5 font-medium text-sm transition-[color]',
|
||||
props.className
|
||||
)}
|
||||
/>
|
||||
<button {...rest} type="button" className={cx('tabs-button', props.className)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { DocumentBlockTabs } from '@gitbook/api';
|
||||
import type { IconName } from '@gitbook/icons';
|
||||
import { validateIconName } from '@gitbook/icons/validateIconName';
|
||||
import { validateIconName } from '@gitbook/icons/icons';
|
||||
|
||||
import type { BlockProps } from '../Block';
|
||||
import { Blocks } from '../Blocks';
|
||||
@@ -41,7 +41,7 @@ export function Tabs(props: BlockProps<DocumentBlockTabs>) {
|
||||
ancestorBlocks={[...ancestorBlocks, block, tab]}
|
||||
context={context}
|
||||
blockStyle="flip-heading-hash"
|
||||
style="w-full space-y-4"
|
||||
style="tabs-panel-blocks"
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
@@ -13,8 +13,8 @@ import type {
|
||||
DocumentTextMark,
|
||||
} from '@gitbook/api';
|
||||
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { backgroundColorToStyle, textColorToStyle } from '@/lib/colors';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function Text(props: { text: DocumentText }) {
|
||||
const { text } = props;
|
||||
@@ -94,31 +94,7 @@ function Subscript(props: MarkedLeafProps<DocumentMarkSubscript>) {
|
||||
}
|
||||
|
||||
function Code(props: MarkedLeafProps<DocumentMarkCode>) {
|
||||
return (
|
||||
<code
|
||||
className={tcls(
|
||||
'py-px',
|
||||
'px-1.5',
|
||||
'min-w-6.5',
|
||||
'justify-center',
|
||||
'items-center',
|
||||
'leading-normal',
|
||||
'ring-1',
|
||||
'ring-inset',
|
||||
'ring-tint',
|
||||
'bg-tint',
|
||||
'rounded-sm',
|
||||
// Text size is proportional to the font-size of the parent element
|
||||
'text-[.875em]',
|
||||
// We ensure that the code is not making the parent bigger, especially in headings
|
||||
'leading-[calc(max(1.20em,1.25rem))]',
|
||||
'break-words',
|
||||
'hyphens-none'
|
||||
)}
|
||||
>
|
||||
{props.children}
|
||||
</code>
|
||||
);
|
||||
return <code className="inline-code">{props.children}</code>;
|
||||
}
|
||||
|
||||
function Color(props: MarkedLeafProps<DocumentMarkColor>) {
|
||||
@@ -128,10 +104,10 @@ function Color(props: MarkedLeafProps<DocumentMarkColor>) {
|
||||
data-highlight={
|
||||
mark.data.background && mark.data.background !== 'default' ? '' : undefined
|
||||
}
|
||||
className={tcls([
|
||||
className={cx(
|
||||
textColorToStyle[mark.data.text ?? 'default'],
|
||||
backgroundColorToStyle[mark.data.background ?? 'default'],
|
||||
])}
|
||||
backgroundColorToStyle[mark.data.background ?? 'default']
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
getNumericDateFormatter,
|
||||
getShortDateFormatter,
|
||||
} from '@/components/utils/dates';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { getRevisionTags, resolveBlockTags } from '@/lib/tags';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
@@ -48,23 +49,18 @@ export function Update(props: BlockProps<DocumentBlockUpdate>) {
|
||||
return (
|
||||
<FilteredUpdate
|
||||
tagSlugs={resolvedTags.map((tag) => tag.slug)}
|
||||
className={tcls('relative flex flex-col gap-2 md:flex-row md:gap-4 lg:gap-8', style)}
|
||||
className={cx('update-block', tcls(style))}
|
||||
>
|
||||
<div
|
||||
className={tcls(
|
||||
// Date is only sticky on larger screens when we use flex-row layout, with 0px fallback to prevent flicker and flaky tests before JS sets the variable
|
||||
'h-fit w-40 min-w-40 shrink-0 md:sticky md:top-[calc(var(--toc-top-offset,0px)+8px)]!'
|
||||
)}
|
||||
>
|
||||
<div className="update-block-aside">
|
||||
<time
|
||||
// Adding a dateTime attribute for accessibility (and SEO)
|
||||
dateTime={date}
|
||||
className="inline-flex items-center text-sm font-medium tracking-wide text-neutral-10"
|
||||
className="update-block-date"
|
||||
>
|
||||
{dateFormatter.format(parsedDate)}
|
||||
</time>
|
||||
{resolvedTags.length > 0 ? (
|
||||
<div className="mt-2 flex flex-wrap gap-1.5">
|
||||
<div className="update-block-tags">
|
||||
{resolvedTags.map((tag) => (
|
||||
<Tag key={tag.slug} tag={tag} />
|
||||
))}
|
||||
@@ -75,7 +71,7 @@ export function Update(props: BlockProps<DocumentBlockUpdate>) {
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style="flex flex-1 flex-col [&>*+*]:mt-5 [&>*:first-child]:!pt-0"
|
||||
style="update-block-body"
|
||||
/>
|
||||
</FilteredUpdate>
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ export function Updates(props: BlockProps<DocumentBlockUpdates>) {
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style={[style, 'updates-block flex flex-col gap-20']}
|
||||
style={[style, 'updates-block']}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { TagIcon } from '../Tag';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import {
|
||||
UPDATES_FILTER_KEY_ATTR,
|
||||
UPDATES_FILTER_SEARCH_PARAM,
|
||||
@@ -171,9 +170,9 @@ export function UpdatesTagFilters(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="shrink-0 border-b border-tint-subtle pb-4 pt-px">
|
||||
<div className="mb-3 ml-3 flex items-center justify-between gap-2">
|
||||
<div className="leading-wider flex items-center gap-1 text-xs font-semibold uppercase text-tint">
|
||||
<div className="updates-filter">
|
||||
<div className="updates-filter-header">
|
||||
<div className="updates-filter-label">
|
||||
<Icon icon="tags" className="size-3" />
|
||||
{tagsLabel}
|
||||
</div>
|
||||
@@ -188,7 +187,7 @@ export function UpdatesTagFilters(props: {
|
||||
className="pointer-events-none invisible text-xs"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-1.5 px-3">
|
||||
<div className="updates-filter-tags">
|
||||
{tags.map((tag) => (
|
||||
<TagChip key={tag.slug} tag={tag} onToggle={toggleTag} />
|
||||
))}
|
||||
@@ -197,12 +196,6 @@ export function UpdatesTagFilters(props: {
|
||||
);
|
||||
}
|
||||
|
||||
const CHIP_CLASS =
|
||||
'inline-flex max-w-full rounded-full circular-corners:rounded-2xl straight-corners:rounded-xs not-focus-visible:outline-0 focus-visible:ring-2 focus-visible:ring-primary';
|
||||
|
||||
const CHIP_VARIANT_CLASS =
|
||||
'max-w-full items-center gap-1 rounded-full px-2 py-1 font-medium text-xs leading-normal transition-colors circular-corners:rounded-2xl straight-corners:rounded-xs';
|
||||
|
||||
function TagChip(props: { tag: RevisionTag; onToggle: (tag: string) => void }) {
|
||||
const { tag, onToggle } = props;
|
||||
const { selectedTagSet } = useUpdatesFilter();
|
||||
@@ -213,34 +206,25 @@ function TagChip(props: { tag: RevisionTag; onToggle: (tag: string) => void }) {
|
||||
type="button"
|
||||
aria-pressed={selectedTagSet.has(tag.slug)}
|
||||
onClick={onClick}
|
||||
className={CHIP_CLASS}
|
||||
className="updates-chip"
|
||||
>
|
||||
<span
|
||||
{...{ [UPDATES_TAG_CHIP_SELECTED_ATTR]: tag.slug }}
|
||||
className={tcls(
|
||||
CHIP_VARIANT_CLASS,
|
||||
'hidden bg-primary-original text-contrast-primary-original hover:bg-primary-solid-hover'
|
||||
)}
|
||||
className="updates-chip-face updates-chip-selected"
|
||||
>
|
||||
<TagIcon tag={tag} />
|
||||
<span className="truncate">{tag.label}</span>
|
||||
</span>
|
||||
<span
|
||||
{...{ [UPDATES_TAG_CHIP_UNSELECTED_DIMMED_ATTR]: tag.slug }}
|
||||
className={tcls(
|
||||
CHIP_VARIANT_CLASS,
|
||||
'hidden bg-tint-5 text-tint-strong opacity-8 hover:bg-tint-hover hover:opacity-11'
|
||||
)}
|
||||
className="updates-chip-face updates-chip-dimmed"
|
||||
>
|
||||
<TagIcon tag={tag} />
|
||||
<span className="truncate">{tag.label}</span>
|
||||
</span>
|
||||
<span
|
||||
{...{ [UPDATES_TAG_CHIP_UNSELECTED_PLAIN_ATTR]: tag.slug }}
|
||||
className={tcls(
|
||||
CHIP_VARIANT_CLASS,
|
||||
'flex bg-tint-5 text-tint-strong hover:bg-tint-hover'
|
||||
)}
|
||||
className="updates-chip-face updates-chip-plain"
|
||||
>
|
||||
<TagIcon tag={tag} />
|
||||
<span className="truncate">{tag.label}</span>
|
||||
|
||||
@@ -1,55 +1,35 @@
|
||||
import type { DocumentBlock } from '@gitbook/api';
|
||||
|
||||
/**
|
||||
* Get the line height of a block
|
||||
* Text style of a block's first line. Elements aligned on it (list prefixes, hint icons) pick
|
||||
* their size and line height from it, via the matching modifier classes in `styles/blocks.css`.
|
||||
*/
|
||||
export function getBlockTextStyle(block: DocumentBlock): {
|
||||
/** Tailwind class for the text size */
|
||||
textSize: string;
|
||||
/** Tailwind class for the height (h-*) */
|
||||
lineHeight: string;
|
||||
/** Tailwind class for the margin top (mt-*) */
|
||||
marginTop?: string;
|
||||
} {
|
||||
export type BlockTextKind = 'body' | 'heading-1' | 'heading-2' | 'heading-3' | 'divider';
|
||||
|
||||
export function getBlockTextKind(block: DocumentBlock): BlockTextKind {
|
||||
switch (block.type) {
|
||||
case 'paragraph':
|
||||
return {
|
||||
textSize: 'text-base',
|
||||
lineHeight: 'leading-normal',
|
||||
};
|
||||
case 'heading-1':
|
||||
return {
|
||||
textSize: 'text-xl @xs:text-2xl @lg:text-3xl font-semibold',
|
||||
lineHeight: 'leading-tight',
|
||||
marginTop: 'column-first-of-type:pt-0 pt-[1em]',
|
||||
};
|
||||
case 'heading-2':
|
||||
return {
|
||||
textSize: 'text-lg @xs:text-xl @lg:text-2xl font-semibold',
|
||||
lineHeight: 'leading-snug',
|
||||
marginTop: 'column-first-of-type:pt-0 pt-[0.75em]',
|
||||
};
|
||||
case 'heading-3':
|
||||
return {
|
||||
textSize: 'text-base @xs:text-lg @lg:text-xl font-semibold',
|
||||
lineHeight: 'leading-snug',
|
||||
marginTop: 'column-first-of-type:pt-0 pt-[0.5em]',
|
||||
};
|
||||
case 'divider':
|
||||
return {
|
||||
textSize: '',
|
||||
lineHeight: 'leading-none',
|
||||
};
|
||||
return block.type;
|
||||
case 'list-ordered':
|
||||
case 'list-tasks':
|
||||
case 'list-unordered':
|
||||
return getBlockTextStyle(block.nodes[0]!);
|
||||
case 'list-item':
|
||||
return getBlockTextStyle(block.nodes[0]!);
|
||||
return getBlockTextKind(block.nodes[0]!);
|
||||
default:
|
||||
return {
|
||||
textSize: 'text-base',
|
||||
lineHeight: 'leading-normal',
|
||||
};
|
||||
return 'body';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Line height utility of each text kind.
|
||||
*/
|
||||
export const BLOCK_LINE_HEIGHT: Record<BlockTextKind, string> = {
|
||||
body: 'leading-normal',
|
||||
'heading-1': 'leading-tight',
|
||||
'heading-2': 'leading-snug',
|
||||
'heading-3': 'leading-snug',
|
||||
divider: 'leading-none',
|
||||
};
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
import { CONTAINER_STYLE, CONTENT_STYLE } from '../layout';
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { ThemeToggler } from '../ThemeToggler';
|
||||
import { FooterLinksGroup } from './FooterLinksGroup';
|
||||
import { SocialAccountButton } from './SocialAccounts';
|
||||
import { Image } from '@/components/utils';
|
||||
import { partition } from '@/lib/arrays';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
const FOOTER_COLUMNS = 4;
|
||||
|
||||
@@ -26,41 +26,14 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
!hasLogo && !hasGroups && !hasCopyright && !socialLinks.length && hasThemeToggle;
|
||||
|
||||
return (
|
||||
<footer
|
||||
data-gb-site-footer
|
||||
className={tcls(
|
||||
'border-tint-subtle border-t',
|
||||
// If the footer only contains a mode toggle, we only show it where the outline
|
||||
// column — which carries its own toggle — isn't pinned open.
|
||||
mobileOnly
|
||||
? 'layout-default:xl:chat-closed:hidden layout-default:3xl:hidden layout-wide:3xl:chat-closed:hidden page-api-block:page-has-outline:min-[96rem]:hidden'
|
||||
: null
|
||||
)}
|
||||
>
|
||||
<div className="lg:chat-open:pr-(--ai-chat-width) transition-[padding] duration-300 motion-reduce:transition-none">
|
||||
<div
|
||||
className={tcls(
|
||||
CONTAINER_STYLE,
|
||||
'px-4',
|
||||
'py-8',
|
||||
'@4xl:py-12',
|
||||
'mx-auto',
|
||||
'@container/footer'
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={tcls(
|
||||
CONTENT_STYLE,
|
||||
'flex @xs:grid @4xl:max-w-none! flex-col justify-between gap-12',
|
||||
'grid-cols-[auto_auto]',
|
||||
'@4xl:grid-cols-[18rem_minmax(auto,48rem)_auto]',
|
||||
'@7xl:grid-cols-[18rem_minmax(auto,48rem)_14rem]'
|
||||
)}
|
||||
>
|
||||
<footer data-gb-site-footer className={cx('footer', mobileOnly && 'footer-toggle-only')}>
|
||||
<div className="chrome-shift-padding">
|
||||
<div className="footer-container">
|
||||
<div className={cx(CONTENT_STYLE, 'footer-grid')}>
|
||||
{
|
||||
// Footer Logo
|
||||
customization.footer.logo ? (
|
||||
<div className="col-start-1 row-start-1">
|
||||
<div className="footer-logo">
|
||||
<Image
|
||||
alt="Logo"
|
||||
resize={context.imageResizer}
|
||||
@@ -75,17 +48,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
: null,
|
||||
}}
|
||||
loading="lazy"
|
||||
style={[
|
||||
'w-auto',
|
||||
'max-w-40',
|
||||
'@4xl:max-w-64',
|
||||
'max-h-10',
|
||||
'@4xl:max-h-12',
|
||||
'object-contain',
|
||||
'object-left',
|
||||
'rounded-sm',
|
||||
'straight-corners:rounded-xs',
|
||||
]}
|
||||
style="footer-logo-img"
|
||||
sizes={[
|
||||
{
|
||||
width: 320,
|
||||
@@ -101,7 +64,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
customization.themes.toggeable ? (
|
||||
// Hidden where the outline column is pinned open (see PageAside),
|
||||
// since that column carries its own toggle.
|
||||
<div className="page-api-block:page-has-outline:min-[96rem]:hidden -col-start-2 row-start-1 flex items-start @xs:justify-end layout-default:xl:chat-closed:hidden layout-default:3xl:hidden layout-wide:3xl:chat-closed:hidden">
|
||||
<div className="footer-toggle">
|
||||
<React.Suspense fallback={null}>
|
||||
<ThemeToggler />
|
||||
</React.Suspense>
|
||||
@@ -112,14 +75,11 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
{
|
||||
// Navigation groups (split into equal columns)
|
||||
customization.footer.groups?.length > 0 ? (
|
||||
<div className={tcls('col-span-2')}>
|
||||
<div className="mx-auto flex flex-col gap-10 @xl:flex-row @xl:gap-6">
|
||||
<div className="footer-groups">
|
||||
<div className="footer-columns">
|
||||
{partition(customization.footer.groups, FOOTER_COLUMNS).map(
|
||||
(column, columnIndex) => (
|
||||
<div
|
||||
key={columnIndex}
|
||||
className="flex flex-1 grow flex-col gap-10"
|
||||
>
|
||||
<div key={columnIndex} className="footer-column">
|
||||
{column.map((group, groupIndex) => (
|
||||
<FooterLinksGroup
|
||||
key={groupIndex}
|
||||
@@ -138,7 +98,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
{
|
||||
// Social Links
|
||||
socialLinks.length > 0 ? (
|
||||
<div className="col-span-full flex w-full grow items-center justify-center gap-2">
|
||||
<div className="footer-social">
|
||||
{socialLinks.map((account) => (
|
||||
<SocialAccountButton
|
||||
key={`${account.platform}-${account.handle}`}
|
||||
@@ -153,7 +113,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
{
|
||||
// Legal
|
||||
customization.footer.copyright ? (
|
||||
<div className="order-last col-span-full flex w-full grow flex-col items-center gap-2 text-center text-xs text-tint">
|
||||
<div className="footer-legal">
|
||||
<p>{customization.footer.copyright}</p>
|
||||
</div>
|
||||
) : null
|
||||
|
||||
@@ -8,7 +8,6 @@ import { Link } from '../primitives';
|
||||
import type { GitBookAnyContext } from '@/lib/context';
|
||||
import { resolveContentRef } from '@/lib/references';
|
||||
import { getLocalizedTitle } from '@/lib/sites';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function FooterLinksGroup(props: {
|
||||
group: CustomizationFooterGroup;
|
||||
@@ -18,9 +17,9 @@ export function FooterLinksGroup(props: {
|
||||
const title = getLocalizedTitle(group, context.locale);
|
||||
|
||||
return (
|
||||
<nav className="flex flex-col gap-4 text-sm">
|
||||
<h4 className="font-heading font-semibold">{title}</h4>
|
||||
<ul className="flex flex-col items-start gap-4">
|
||||
<nav className="footer-group">
|
||||
<h4 className="footer-group-title">{title}</h4>
|
||||
<ul className="footer-group-links">
|
||||
{group.links.map((link, index) => {
|
||||
return (
|
||||
<li key={index}>
|
||||
@@ -41,21 +40,7 @@ async function FooterLink(props: { link: CustomizationContentLink; context: GitB
|
||||
return (
|
||||
<Link
|
||||
href={resolved?.href ?? '#'}
|
||||
className={tcls(
|
||||
'font-normal',
|
||||
'text-tint',
|
||||
'links-default:hover:text-primary',
|
||||
'links-default:tint:hover:text-tint-strong',
|
||||
|
||||
'contrast-more:underline',
|
||||
'contrast-more:text-tint-strong',
|
||||
'underline-offset-2',
|
||||
|
||||
'links-accent:hover:underline',
|
||||
'links-accent:underline-offset-4',
|
||||
'links-accent:decoration-primary-subtle',
|
||||
'links-accent:decoration-[3px]'
|
||||
)}
|
||||
className="footer-link"
|
||||
insights={{
|
||||
type: 'link_click',
|
||||
link: {
|
||||
|
||||
@@ -13,10 +13,10 @@ import { HeaderLinks } from './HeaderLinks';
|
||||
import { HeaderLogo } from './HeaderLogo';
|
||||
import { HeaderMobileMenu } from './HeaderMobileMenu';
|
||||
import { TranslationsDropdown } from './SpacesDropdown';
|
||||
import { CONTAINER_STYLE, HEADER_HEIGHT_DESKTOP } from '@/components/layout';
|
||||
import { CONTAINER_STYLE } from '@/components/layout';
|
||||
import { getSpaceLanguage, t } from '@/intl/server';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Render the header for the space.
|
||||
@@ -35,6 +35,8 @@ export async function Header(props: {
|
||||
const language = await getSpaceLanguage(context);
|
||||
|
||||
const withSections = shouldRenderSiteSectionNavigation(visibleSections);
|
||||
const prominentSearch =
|
||||
'search' in customization.styling && customization.styling.search === 'prominent';
|
||||
|
||||
const headerSocialAccounts = customization.socialAccounts.filter(
|
||||
(account) => account.display.header === true
|
||||
@@ -43,70 +45,19 @@ export async function Header(props: {
|
||||
return (
|
||||
<header
|
||||
data-gb-site-header
|
||||
className={tcls(
|
||||
'flex',
|
||||
'flex-col',
|
||||
`h-[${HEADER_HEIGHT_DESKTOP}px]`,
|
||||
'sticky',
|
||||
'top-0',
|
||||
'pt-[env(safe-area-inset-top)]',
|
||||
'z-30',
|
||||
'w-full',
|
||||
'flex-none',
|
||||
'shadow-[0px_1px_0px]',
|
||||
'shadow-tint-12/2',
|
||||
// Box shadows are dropped in forced colors mode, the separator needs a real border.
|
||||
'forced-colors:border-b',
|
||||
|
||||
'bg-tint-base/9',
|
||||
'theme-muted:bg-tint-subtle/9',
|
||||
'[html.sidebar-filled.theme-bold.tint_&]:bg-tint-subtle/9',
|
||||
'theme-gradient:bg-gradient-primary',
|
||||
'theme-gradient-tint:bg-gradient-tint',
|
||||
'contrast-more:bg-tint-base',
|
||||
|
||||
withTopHeader ? null : 'mobile-only lg:hidden',
|
||||
'text-sm',
|
||||
'backdrop-blur-lg'
|
||||
)}
|
||||
className={cx('header-bar', withTopHeader ? null : 'mobile-only')}
|
||||
>
|
||||
<div
|
||||
className={tcls(
|
||||
'site-header:theme-bold:bg-header-background',
|
||||
'site-header:theme-bold:shadow-[0px_1px_0px]',
|
||||
'site-header:theme-bold:shadow-tint-12/2'
|
||||
)}
|
||||
>
|
||||
<div className="lg:chat-open:pr-(--ai-chat-width) transition-all duration-300 motion-reduce:transition-none">
|
||||
<div
|
||||
data-gb-header-content
|
||||
className={tcls(
|
||||
'gap-4',
|
||||
'lg:gap-6',
|
||||
'flex',
|
||||
'items-center',
|
||||
'justify-between',
|
||||
'w-full',
|
||||
'py-3',
|
||||
'min-h-16',
|
||||
'sm:h-16',
|
||||
CONTAINER_STYLE,
|
||||
'transition-[max-width] duration-300 motion-reduce:transition-none',
|
||||
'@container/header'
|
||||
)}
|
||||
>
|
||||
<div className="header-inner">
|
||||
<div className="chrome-shift">
|
||||
<div data-gb-header-content className={cx(CONTAINER_STYLE, 'header-content')}>
|
||||
<div
|
||||
className={tcls(
|
||||
'flex max-w-full',
|
||||
'min-w-0 shrink items-center justify-start gap-2 lg:gap-4',
|
||||
'search' in customization.styling &&
|
||||
customization.styling.search === 'prominent'
|
||||
? 'lg:@2xl:basis-72'
|
||||
: null
|
||||
className={cx(
|
||||
'header-start',
|
||||
prominentSearch && 'header-start-prominent'
|
||||
)}
|
||||
>
|
||||
<HeaderMobileMenu
|
||||
className={tcls(
|
||||
className={cx(
|
||||
'-ml-2',
|
||||
'text-tint-strong',
|
||||
'site-header:theme-bold:text-header-link',
|
||||
@@ -121,29 +72,9 @@ export async function Header(props: {
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={tcls(
|
||||
'flex',
|
||||
'grow-0',
|
||||
'shrink-0',
|
||||
'md:@2xl:basis-56',
|
||||
'justify-self-end',
|
||||
'items-center',
|
||||
'gap-2',
|
||||
'transition-[margin] duration-300 motion-reduce:transition-none',
|
||||
'search' in customization.styling &&
|
||||
customization.styling.search === 'prominent'
|
||||
? [
|
||||
'md:@2xl:grow-[0.8]',
|
||||
'md:@4xl:basis-40',
|
||||
'md:@2xl:max-w-[50%]',
|
||||
'md:@4xl:max-w-lg',
|
||||
'lg:@2xl:ml-[max(calc((100%-18rem-48rem)/2),1.5rem)]', // container (100%) - sidebar (18rem) - content (48rem)
|
||||
'chat-closed:xl:ml-[max(calc((100%-18rem-48rem-14rem-3rem)/2),1.5rem)]', // container (100%) - sidebar (18rem) - content (48rem) - outline (14rem) - margin (3rem)
|
||||
'md:@2xl:mr-auto',
|
||||
'order-last',
|
||||
'md:@2xl:order-[unset]',
|
||||
]
|
||||
: ['order-last']
|
||||
className={cx(
|
||||
'header-search',
|
||||
prominentSearch && 'header-search-prominent'
|
||||
)}
|
||||
>
|
||||
<SearchContainer
|
||||
@@ -167,7 +98,7 @@ export async function Header(props: {
|
||||
);
|
||||
})}
|
||||
{headerSocialAccounts.length > 0 ? (
|
||||
<div className="flex items-center gap-1">
|
||||
<div className="header-social">
|
||||
{headerSocialAccounts.map((account) => {
|
||||
return (
|
||||
<SocialAccountButton
|
||||
@@ -208,7 +139,7 @@ export async function Header(props: {
|
||||
</div>
|
||||
|
||||
{visibleSections && withSections ? (
|
||||
<div className="lg:chat-open:pr-(--ai-chat-width) transition-[padding] duration-300 motion-reduce:transition-none">
|
||||
<div className="chrome-shift-padding">
|
||||
<SiteSectionTabs sections={encodeClientSiteSections(context, visibleSections)}>
|
||||
{variants.translations.length > 1 ? (
|
||||
<TranslationsDropdown
|
||||
|
||||
@@ -8,6 +8,7 @@ import { DropdownMenuItem } from '../primitives/DropdownMenu';
|
||||
import { SiteAuthLoginDropdownMenuItem } from '../SiteAuth/SiteAuthLoginLink';
|
||||
import { HeaderLinkDropdown, HeaderLinkNavItem } from './HeaderLinkDropdown';
|
||||
import { isSiteAuthLoginHref } from '@/lib/auth-login-link';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { resolveContentRef } from '@/lib/references';
|
||||
import { getLocalizedTitle } from '@/lib/sites';
|
||||
@@ -36,7 +37,10 @@ export async function HeaderLink(props: {
|
||||
isSiteAuthLoginHref={
|
||||
target ? isSiteAuthLoginHref(context.linker, target.href) : false
|
||||
}
|
||||
dropdownClassName={`shrink ${customization.styling.search === 'prominent' ? 'right-0 left-auto' : null}`}
|
||||
dropdownClassName={cx(
|
||||
'shrink',
|
||||
customization.styling.search === 'prominent' && 'right-0 left-auto'
|
||||
)}
|
||||
>
|
||||
{link.links.map((subLink, index) => (
|
||||
<SubHeaderLink key={index} {...props} link={subLink} />
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
import { Button, Link, ToggleChevron } from '../primitives';
|
||||
import { type DropdownButtonProps, DropdownMenu } from '../primitives/DropdownMenu';
|
||||
import { SiteAuthLoginButton, SiteAuthLoginLink } from '../SiteAuth/SiteAuthLoginLink';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
/**
|
||||
* Client component wrapping the DropdownMenu for header links.
|
||||
@@ -137,31 +137,6 @@ function HeaderItemButton(
|
||||
);
|
||||
}
|
||||
|
||||
function getHeaderLinkClassName(_props: { headerPreset: CustomizationHeaderPreset }) {
|
||||
return tcls(
|
||||
'flex items-center gap-1',
|
||||
'shrink',
|
||||
'contrast-more:underline',
|
||||
'truncate',
|
||||
|
||||
'text-tint',
|
||||
'links-default:hover:text-primary',
|
||||
'links-default:aria-expanded:text-primary',
|
||||
'links-default:tint:hover:text-tint-strong',
|
||||
'links-default:tint:aria-expanded:text-tint-strong',
|
||||
'underline-offset-2',
|
||||
'links-accent:hover:underline',
|
||||
'links-accent:aria-expanded:underline',
|
||||
'links-accent:underline-offset-4',
|
||||
'links-accent:decoration-primary-subtle',
|
||||
'links-accent:decoration-[3px]',
|
||||
'links-accent:py-0.5', // Prevent underline from being cut off at the bottom
|
||||
|
||||
'theme-bold:text-header-link',
|
||||
'hover:theme-bold:text-header-link/7!'
|
||||
);
|
||||
}
|
||||
|
||||
function HeaderItemLink(props: Omit<HeaderLinkNavItemProps, 'linkStyle'>) {
|
||||
const {
|
||||
linkTarget,
|
||||
@@ -175,7 +150,7 @@ function HeaderItemLink(props: Omit<HeaderLinkNavItemProps, 'linkStyle'>) {
|
||||
} = props;
|
||||
const sharedProps = {
|
||||
href: href ?? '#',
|
||||
className: tcls(getHeaderLinkClassName({ headerPreset }), className),
|
||||
className: cx('header-link', className),
|
||||
insights: {
|
||||
type: 'link_click' as const,
|
||||
link: {
|
||||
@@ -207,10 +182,7 @@ function HeaderItemDropdown(
|
||||
) {
|
||||
const { headerPreset, title, className, ...rest } = props;
|
||||
return (
|
||||
<span
|
||||
className={tcls(getHeaderLinkClassName({ headerPreset }), 'cursor-default', className)}
|
||||
{...rest}
|
||||
>
|
||||
<span className={cx('header-link header-link-static', className)} {...rest}>
|
||||
{title}
|
||||
<ToggleChevron />
|
||||
</span>
|
||||
|
||||
@@ -16,10 +16,10 @@ import {
|
||||
import { SiteAuthLoginDropdownMenuItem } from '../SiteAuth/SiteAuthLoginLink';
|
||||
import { HeaderLinkMoreDropdown } from './HeaderLinkMoreClient';
|
||||
import { isSiteAuthLoginHref } from '@/lib/auth-login-link';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { resolveContentRef } from '@/lib/references';
|
||||
import { getLocalizedTitle } from '@/lib/sites';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Dropdown menu for header links hidden at small screen size.
|
||||
@@ -33,10 +33,10 @@ export function HeaderLinkMore(props: {
|
||||
const { label, links, context, socialAccounts } = props;
|
||||
|
||||
return (
|
||||
<div className="header-links-ellipsis z-20 items-center">
|
||||
<div className="header-links-ellipsis">
|
||||
<HeaderLinkMoreDropdown
|
||||
label={label}
|
||||
dropdownClassName={tcls(
|
||||
dropdownClassName={cx(
|
||||
'max-md:right-0 max-md:left-auto',
|
||||
context.customization.styling.search === 'prominent' && 'right-0 left-auto'
|
||||
)}
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { ToggleChevron } from '../primitives';
|
||||
import { DropdownMenu } from '../primitives/DropdownMenu';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import type { ClassValue } from '@/lib/classnames';
|
||||
|
||||
/**
|
||||
* Client component for the "More" header link dropdown.
|
||||
@@ -23,21 +23,9 @@ export function HeaderLinkMoreDropdown(props: {
|
||||
return (
|
||||
<DropdownMenu
|
||||
button={
|
||||
<button
|
||||
type="button"
|
||||
className={tcls(
|
||||
'text-tint',
|
||||
'hover:text-primary',
|
||||
'dark:hover:text-primary',
|
||||
'theme-bold:text-header-link',
|
||||
'theme-bold:hover:text-header-link/8',
|
||||
'flex',
|
||||
'gap-1',
|
||||
'items-center'
|
||||
)}
|
||||
>
|
||||
<button type="button" className="header-more">
|
||||
<span className="sr-only">{label}</span>
|
||||
<Icon icon="ellipsis" className={tcls('size-4')} />
|
||||
<Icon icon="ellipsis" className="size-4" />
|
||||
<ToggleChevron />
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type React from 'react';
|
||||
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
interface HeaderLinksProps {
|
||||
children: React.ReactNode;
|
||||
@@ -8,15 +8,5 @@ interface HeaderLinksProps {
|
||||
}
|
||||
|
||||
export async function HeaderLinks({ children, style }: HeaderLinksProps) {
|
||||
return (
|
||||
<nav
|
||||
className={tcls(
|
||||
'header-links',
|
||||
'@4xl:[&>.button+.button]:-ml-2 z-20 ml-auto flex min-w-9 shrink grow @7xl:grow-0 items-center justify-end @4xl:gap-x-6 gap-x-4',
|
||||
style
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</nav>
|
||||
);
|
||||
return <nav className={cx('header-links', style)}>{children}</nav>;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ import { CurrentContentIcon } from './CurrentContentIcon';
|
||||
import { Image } from '@/components/utils';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { resolveContentRef } from '@/lib/references';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
interface HeaderLogoProps {
|
||||
context: GitBookSiteContext;
|
||||
@@ -22,10 +21,7 @@ export async function HeaderLogo(props: HeaderLogoProps) {
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Link
|
||||
href={primaryLink?.href ?? linker.toPathInSite('')}
|
||||
className={tcls('group/headerlogo', 'min-w-0', 'shrink', 'flex', 'items-center')}
|
||||
>
|
||||
<Link href={primaryLink?.href ?? linker.toPathInSite('')} className="header-logo">
|
||||
{customization.header.logo ? (
|
||||
<Image
|
||||
alt="Logo"
|
||||
@@ -50,19 +46,7 @@ export async function HeaderLogo(props: HeaderLogoProps) {
|
||||
},
|
||||
]}
|
||||
preload
|
||||
style={tcls(
|
||||
'overflow-hidden',
|
||||
'shrink',
|
||||
'min-w-0',
|
||||
'max-w-40',
|
||||
'lg:max-w-64',
|
||||
'lg:site-header-none:page-no-toc:max-w-56',
|
||||
'max-h-8',
|
||||
'h-full',
|
||||
'w-full',
|
||||
'object-contain',
|
||||
'object-left'
|
||||
)}
|
||||
style="header-logo-img"
|
||||
/>
|
||||
) : (
|
||||
<LogoFallback {...props} />
|
||||
@@ -81,27 +65,10 @@ function LogoFallback(props: HeaderLogoProps) {
|
||||
context={context}
|
||||
alt=""
|
||||
sizes={[{ width: 32 }]}
|
||||
style={['object-contain', 'size-8']}
|
||||
style="header-logo-icon"
|
||||
fetchPriority="high"
|
||||
/>
|
||||
<div
|
||||
className={tcls(
|
||||
'text-pretty',
|
||||
'line-clamp-2',
|
||||
'tracking-tight',
|
||||
'max-w-[18ch]',
|
||||
'lg:max-w-[24ch]',
|
||||
'font-heading',
|
||||
'font-semibold',
|
||||
'ms-3',
|
||||
'text-base/tight',
|
||||
'lg:text-lg/tight',
|
||||
'text-tint-strong',
|
||||
'theme-bold:text-header-link'
|
||||
)}
|
||||
>
|
||||
{site.title}
|
||||
</div>
|
||||
<div className="header-logo-text">{site.title}</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import type { IconName } from '@gitbook/icons';
|
||||
import type { ButtonProps } from '../primitives';
|
||||
import { getTargetURLForSiteSpace } from '../SiteSections/encodeClientSiteSections';
|
||||
import { SpacesDropdownClient } from './SpacesDropdownClient';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { getLocalizedTitle } from '@/lib/sites';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
@@ -35,7 +36,7 @@ export function SpacesDropdown(
|
||||
} = props;
|
||||
const currentLanguage = context.locale;
|
||||
|
||||
const dropdownClassName = tcls(
|
||||
const dropdownClassName = cx(
|
||||
'group-hover/dropdown:invisible', // Prevent hover from opening the dropdown, as it's annoying in this context
|
||||
'group-focus-within/dropdown:group-hover/dropdown:visible' // When the dropdown is already open, it should remain visible when hovered
|
||||
);
|
||||
@@ -84,7 +85,7 @@ export function TranslationsDropdown(
|
||||
asEmbeddable={asEmbeddable}
|
||||
variant="blank"
|
||||
className={tcls(
|
||||
'bg-transparent lg:max-w-64 max-md:[&_.button-content]:hidden',
|
||||
'translations-dropdown max-md:[&_.button-content]:hidden',
|
||||
hasEmojiPrefix
|
||||
? 'md:[&_.button-leading-icon]:hidden' // If the title starts with an emoji, don't show the icon (on desktop)
|
||||
: '',
|
||||
|
||||
@@ -5,7 +5,7 @@ import type { IconName } from '@gitbook/icons';
|
||||
import { Button, type ButtonProps, ToggleChevron } from '../primitives';
|
||||
import { DropdownMenu } from '../primitives/DropdownMenu';
|
||||
import { SpacesDropdownMenuItems } from './SpacesDropdownMenuItem';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
/**
|
||||
* Client component that creates the Button trigger and DropdownMenu internally, avoiding
|
||||
@@ -38,7 +38,7 @@ export function SpacesDropdownClient(props: {
|
||||
size="small"
|
||||
variant={variant}
|
||||
trailing={<ToggleChevron />}
|
||||
className={tcls('bg-tint-base', className)}
|
||||
className={cx('spaces-dropdown-button', className)}
|
||||
>
|
||||
<span className="button-content">{title}</span>
|
||||
</Button>
|
||||
|
||||
@@ -18,9 +18,9 @@ import { PageAsideCloseButton } from './PageAsideButton';
|
||||
import { ScrollSectionsList } from './ScrollSectionsList';
|
||||
import { ScrollToTopButton } from './ScrollToTopButton';
|
||||
import { getSpaceLanguage, t, tString } from '@/intl/server';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { getDocumentSections } from '@/lib/document-sections';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Aside listing the headings in the document.
|
||||
@@ -44,77 +44,13 @@ export async function PageAside(props: {
|
||||
toggleClass="outline-open"
|
||||
withOverlay
|
||||
withCloseButton
|
||||
className={tcls(
|
||||
'group/aside',
|
||||
'order-last',
|
||||
|
||||
'xl:sticky',
|
||||
'w-64',
|
||||
|
||||
// Without header
|
||||
'lg:top-0',
|
||||
'lg:max-h-screen',
|
||||
|
||||
// With header
|
||||
'lg:site-header:top-16',
|
||||
'lg:site-header:max-h-[calc(100vh-4rem)]',
|
||||
|
||||
// With header & sections
|
||||
'lg:site-header-sections:top-27',
|
||||
'lg:site-header-sections:max-h-[calc(100vh-6.75rem)]',
|
||||
|
||||
// Client-side dynamic positioning (CSS vars applied by script)
|
||||
'lg:[html[style*="--outline-top-offset"]_&]:top-(--outline-top-offset)!',
|
||||
'lg:[html[style*="--outline-height"]_&]:max-h-(--outline-height)!',
|
||||
|
||||
'layout-default:max-xl:border-l',
|
||||
'layout-wide:max-3xl:border-l',
|
||||
'border-tint-subtle',
|
||||
|
||||
'p-4',
|
||||
'pt-8',
|
||||
'ml-4',
|
||||
|
||||
'break-anywhere', // To prevent long words in headings from breaking the layout
|
||||
|
||||
'lg:z-10',
|
||||
'lg:hover:z-12',
|
||||
'layout-default:xl:chat-closed:pr-0',
|
||||
'layout-default:xl:chat-closed:pl-8',
|
||||
'layout-default:xl:chat-closed:flex!',
|
||||
'layout-default:xl:chat-closed:animate-none!',
|
||||
'layout-default:3xl:flex!',
|
||||
'layout-default:3xl:animate-none!',
|
||||
|
||||
// In layout-wide mode, hide outline when viewport is too narrow
|
||||
// or when chat is open and viewport is narrow, to prevent layout overflow
|
||||
'layout-wide:xl:-mr-68',
|
||||
'layout-wide:3xl:chat-closed:flex!',
|
||||
'layout-wide:3xl:chat-closed:animate-none!',
|
||||
|
||||
// Show outline if page has OpenAPI block
|
||||
// TODO: remove this in favour of a nicer, more immediately accessible solution in the future.
|
||||
'page-api-block:page-has-outline:min-[96rem]:max-3xl:-mr-[max(calc((100vw-90rem)/2),0rem)]',
|
||||
'page-api-block:page-has-outline:min-[96rem]:flex!',
|
||||
'page-api-block:page-has-outline:min-[96rem]:animate-none!',
|
||||
'page-api-block:page-has-outline:min-[96rem]:border-l-0',
|
||||
'page-api-block:page-has-outline:min-[96rem]:pl-8',
|
||||
|
||||
// Only add a background once the element is positioned correctly, to prevent
|
||||
// overlapping the page cover. Kept opaque wherever the outline is a toggleable
|
||||
// overlay (below xl in any layout, and xl–3xl in wide layout, where it opens as
|
||||
// a desktop SideSheet), but dropped for the permanent outline column so a bleeding
|
||||
// cards carousel can scroll behind it.
|
||||
'max-xl:hydrated:site-background',
|
||||
'layout-wide:max-3xl:hydrated:site-background',
|
||||
'text-tint',
|
||||
'contrast-more:text-tint-strong'
|
||||
// The cover-aware text color lives on the individual rows below, not here: the
|
||||
// outline column is tall enough to always cross the cover's bottom edge, and a
|
||||
// container can't carry a single correct color for text on both sides of it.
|
||||
className={cx(
|
||||
'page-aside',
|
||||
// Kept as utilities so they win over SideSheet's own `fixed inset-y-0 z-41`.
|
||||
'xl:sticky lg:top-0 lg:site-header:top-16 lg:site-header-sections:top-27 lg:z-10 lg:hover:z-12'
|
||||
)}
|
||||
>
|
||||
<div className="flex h-full w-full shrink-0 flex-col overflow-hidden">
|
||||
<div className="page-aside-inner">
|
||||
{page.layout.outline ? (
|
||||
<>
|
||||
{filterableTags.length > 0 ? (
|
||||
@@ -125,21 +61,18 @@ export async function PageAside(props: {
|
||||
/>
|
||||
) : null}
|
||||
<div
|
||||
className={tcls(
|
||||
'mb-3 ml-3 flex page-no-outline:hidden items-center justify-between max-lg:hidden',
|
||||
filterableTags.length > 0 && 'mt-4'
|
||||
className={cx(
|
||||
'page-aside-header',
|
||||
filterableTags.length > 0 && 'page-aside-header-tags'
|
||||
)}
|
||||
>
|
||||
<ScrollToTopButton
|
||||
data-cover-aware-text
|
||||
className="leading-wider xl:page-cover-background:text-contrast-cover flex cursor-pointer items-center gap-1 text-xs font-semibold uppercase text-tint"
|
||||
>
|
||||
<ScrollToTopButton data-cover-aware-text className="page-aside-title">
|
||||
<Icon icon="block-quote" className="size-3" />{' '}
|
||||
{t(language, 'on_this_page')}
|
||||
</ScrollToTopButton>
|
||||
<PageAsideCloseButton className="page-api-block:min-[96rem]:hidden layout-default:xl:hidden layout-wide:3xl:hidden" />
|
||||
</div>
|
||||
<div className="flex shrink flex-col overflow-hidden">
|
||||
<div className="page-aside-scroll">
|
||||
{document ? (
|
||||
<React.Suspense fallback={null}>
|
||||
<PageAsideSections document={document} context={context} />
|
||||
@@ -163,7 +96,7 @@ async function PageAsideSections(props: { document: JSONDocument; context: GitBo
|
||||
const sections = await getDocumentSections(context, document);
|
||||
|
||||
return sections.length > 1 ? (
|
||||
<div data-gb-page-outline className="overflow-y-auto">
|
||||
<div data-gb-page-outline className="page-aside-outline">
|
||||
<ScrollSectionsList sections={sections} />
|
||||
</div>
|
||||
) : null;
|
||||
@@ -173,14 +106,7 @@ function PageAsideActions(props: { withPageFeedback: boolean; page: RevisionPage
|
||||
const { page, withPageFeedback } = props;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
'flex flex-col gap-3',
|
||||
'border-tint-subtle border-t first:border-none',
|
||||
'sidebar-list-default:px-3 pt-5 first:pt-0',
|
||||
'empty:hidden'
|
||||
)}
|
||||
>
|
||||
<div className="page-aside-actions">
|
||||
{withPageFeedback ? (
|
||||
<React.Suspense fallback={null}>
|
||||
<PageFeedbackForm pageId={page.id} />
|
||||
@@ -195,16 +121,10 @@ async function PageAsideFooter(props: { context: GitBookSiteContext }) {
|
||||
const { customization, site, space } = context;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
'sticky bottom-0 z-10 mt-auto flex flex-col',
|
||||
'border-tint-subtle',
|
||||
'pt-4'
|
||||
)}
|
||||
>
|
||||
<div className="page-aside-footer">
|
||||
{/* Mode Switcher */}
|
||||
{customization.themes.toggeable ? (
|
||||
<div className="flex items-center justify-end">
|
||||
<div className="page-aside-theme">
|
||||
<React.Suspense fallback={null}>
|
||||
<ThemeToggler />
|
||||
</React.Suspense>
|
||||
|
||||
@@ -8,7 +8,6 @@ import { useUpdatesFilter } from '@/components/DocumentView/UpdatesFilter';
|
||||
import { useScrollActiveId } from '@/components/hooks';
|
||||
import { useBodyLoaded } from '@/components/primitives';
|
||||
import type { DocumentSection } from '@/lib/document-sections';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { UPDATES_TAG_SECTION_ATTR } from '@/lib/updates';
|
||||
|
||||
/**
|
||||
@@ -58,27 +57,11 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
|
||||
}, [activeId]);
|
||||
|
||||
return (
|
||||
<ul
|
||||
className="relative flex flex-col border-tint-subtle pb-5 sidebar-list-line:border-l"
|
||||
ref={scrollContainerRef}
|
||||
>
|
||||
<ul className="page-outline" ref={scrollContainerRef}>
|
||||
{sections.map((section) => (
|
||||
<li
|
||||
key={section.id}
|
||||
className={tcls(
|
||||
'flex',
|
||||
'flex-row',
|
||||
'relative',
|
||||
'h-fit',
|
||||
'mt-2',
|
||||
'first:mt-0',
|
||||
'mb-0.5',
|
||||
section.depth > 1 && [
|
||||
section.depth > 2 ? 'ml-6' : 'ml-3',
|
||||
'my-0',
|
||||
'sidebar-list-line:ml-0',
|
||||
]
|
||||
)}
|
||||
className="page-outline-item"
|
||||
ref={activeId === section.id ? activeItemRef : null}
|
||||
{...(section.tags !== undefined
|
||||
? { [UPDATES_TAG_SECTION_ATTR]: section.tags.join(' ') }
|
||||
@@ -88,73 +71,9 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
|
||||
href={`#${section.id}`}
|
||||
aria-current={activeId === section.id ? 'true' : undefined}
|
||||
data-cover-aware-text
|
||||
className={tcls(
|
||||
'relative',
|
||||
'z-10',
|
||||
'text-sm',
|
||||
|
||||
'w-full',
|
||||
'py-1',
|
||||
'px-3',
|
||||
|
||||
'transition-all',
|
||||
'motion-reduce:transition-none',
|
||||
'duration-200',
|
||||
|
||||
'rounded-md',
|
||||
'straight-corners:rounded-none',
|
||||
'circular-corners:rounded-2xl',
|
||||
'sidebar-list-line:rounded-l-none!',
|
||||
|
||||
'hover:bg-tint-hover',
|
||||
'theme-gradient:hover:bg-tint-12/1',
|
||||
'hover:text-tint-strong',
|
||||
'contrast-more:hover:ring-1',
|
||||
'contrast-more:hover:ring-inset',
|
||||
'contrast-more:hover:ring-current',
|
||||
|
||||
'sidebar-list-line:border-l-2',
|
||||
'border-transparent',
|
||||
'sidebar-list-line:-left-px',
|
||||
'xl:page-cover-background:text-contrast-cover',
|
||||
|
||||
// The method badge no longer has a right margin, so lay the row out with a gap
|
||||
section.tag && ['flex', 'items-baseline', 'gap-2'],
|
||||
|
||||
section.depth > 1 && [
|
||||
'subitem',
|
||||
section.depth > 2
|
||||
? 'sidebar-list-line:pl-9'
|
||||
: 'sidebar-list-line:pl-6',
|
||||
'opacity-8',
|
||||
'contrast-more:opacity-11',
|
||||
|
||||
'sidebar-list-default:rounded-l-none!',
|
||||
'sidebar-list-default:border-l',
|
||||
'sidebar-list-default:border-tint',
|
||||
],
|
||||
|
||||
activeId === section.id && [
|
||||
'text-primary-subtle',
|
||||
'hover:text-primary',
|
||||
'contrast-more:text-primary',
|
||||
'contrast-more:hover:text-primary-strong',
|
||||
'hover:bg-primary-hover',
|
||||
|
||||
'theme-muted:hover:bg-primary-active',
|
||||
'[html.sidebar-filled.theme-bold.tint_&]:hover:bg-primary-active',
|
||||
'theme-gradient:hover:bg-primary-active',
|
||||
'tint:font-semibold',
|
||||
'contrast-more:font-semibold',
|
||||
|
||||
'sidebar-list-line:border-primary-9',
|
||||
'sidebar-list-default:border-tint',
|
||||
|
||||
'sidebar-list-pill:bg-primary',
|
||||
'[html.theme-muted.sidebar-list-pill_&]:bg-primary-hover',
|
||||
'[html.theme-gradient.sidebar-list-pill_&]:bg-primary-active',
|
||||
]
|
||||
)}
|
||||
className={
|
||||
section.depth > 1 ? 'page-outline-link subitem' : 'page-outline-link'
|
||||
}
|
||||
>
|
||||
{section.tag ? (
|
||||
<OpenAPIMethodBadge
|
||||
@@ -166,13 +85,7 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
|
||||
) : null}
|
||||
|
||||
<span
|
||||
className={tcls(
|
||||
section.deprecated && [
|
||||
'line-through',
|
||||
'opacity-50',
|
||||
'contrast-more:opacity-60',
|
||||
]
|
||||
)}
|
||||
className={section.deprecated ? 'page-outline-deprecated' : undefined}
|
||||
>
|
||||
{section.title}
|
||||
</span>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { PageIcon } from '../PageIcon';
|
||||
import { StyledLink } from '../primitives';
|
||||
import { DropdownMenu, DropdownMenuItem } from '../primitives/DropdownMenu';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
export type BreadcrumbSibling = {
|
||||
id: string;
|
||||
@@ -46,10 +46,7 @@ export function BreadcrumbItemDropdown(props: {
|
||||
const content = (
|
||||
<>
|
||||
{emoji || icon ? (
|
||||
<PageIcon
|
||||
page={{ emoji, icon }}
|
||||
style="mb-0.5 mr-1 inline-block size-[1em] shrink-0"
|
||||
/>
|
||||
<PageIcon page={{ emoji, icon }} style="page-breadcrumbs-icon" />
|
||||
) : null}
|
||||
{label}
|
||||
</>
|
||||
@@ -60,13 +57,11 @@ export function BreadcrumbItemDropdown(props: {
|
||||
// normalize "" to "/" the way the table of contents does.
|
||||
const trigger =
|
||||
href !== undefined ? (
|
||||
<StyledLink href={href || '/'} role="link" className={tcls(linkClassName)}>
|
||||
<StyledLink href={href || '/'} role="link" className={cx(linkClassName)}>
|
||||
{content}
|
||||
</StyledLink>
|
||||
) : (
|
||||
<span className={tcls(linkClassName, 'cursor-default hover:no-underline')}>
|
||||
{content}
|
||||
</span>
|
||||
<span className={cx(linkClassName, 'page-breadcrumbs-label')}>{content}</span>
|
||||
);
|
||||
|
||||
// No dropdown when there is nowhere else to go at this level.
|
||||
@@ -92,7 +87,7 @@ export function BreadcrumbItemDropdown(props: {
|
||||
sibling.emoji || sibling.icon ? (
|
||||
<PageIcon
|
||||
page={{ emoji: sibling.emoji, icon: sibling.icon }}
|
||||
style="size-3 shrink-0 text-tint-subtle"
|
||||
style="page-breadcrumbs-menu-icon"
|
||||
/>
|
||||
) : undefined
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
import { DocumentView, DocumentViewSkeleton } from '../DocumentView';
|
||||
import { CurrentPageProvider } from '../hooks/useCurrentPage';
|
||||
import { TrackPageViewEvent } from '../Insights';
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { PageFeedbackForm } from '../PageFeedback';
|
||||
import { DateRelative, SuspenseLoadedHint } from '../primitives';
|
||||
import OptionalSuspense from './OptionalSuspense';
|
||||
@@ -19,6 +18,7 @@ import { PreservePageLayout } from './PreservePageLayout';
|
||||
import { MAIN_CONTENT_ID } from '@/components/layout';
|
||||
import { getSpaceLanguage } from '@/intl/server';
|
||||
import { t } from '@/intl/translate';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import {
|
||||
hasAPIBlock,
|
||||
@@ -29,7 +29,6 @@ import {
|
||||
} from '@/lib/document';
|
||||
import { getLLMsTxtURL, getPageMarkdownURL } from '@/lib/llms-directive';
|
||||
import type { AncestorRevisionPage } from '@/lib/pages';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { getPageRSSURL } from '@/routes/rss';
|
||||
|
||||
const LINK_PREVIEW_MAX_COUNT = 500;
|
||||
@@ -107,16 +106,8 @@ export async function PageBody(props: {
|
||||
id={MAIN_CONTENT_ID}
|
||||
// Comments on the whole page target anywhere in it that isn't a block.
|
||||
{...(withCommentAnchors ? { 'data-comment-page': '' } : {})}
|
||||
className={tcls(
|
||||
'relative min-w-0 flex-1',
|
||||
'break-anywhere', // Allow words to break if they are too long.
|
||||
'py-8',
|
||||
'layout-wide:no-sidebar:lg:max-xl:pb-20', // Add padding to prevent overlap of minimised trademark
|
||||
'@container',
|
||||
// Flex column so the growing content wrapper below fills the page: the footer
|
||||
// navigation settles at the bottom, and a full-page cover shows behind the content.
|
||||
'flex flex-col',
|
||||
CONTENT_STYLE,
|
||||
className={cx(
|
||||
'page-main',
|
||||
pageHasToc ? 'page-has-toc' : 'page-no-toc',
|
||||
wideLayout ? 'layout-wide' : 'layout-default'
|
||||
)}
|
||||
@@ -173,14 +164,9 @@ export async function PageBody(props: {
|
||||
) : null}
|
||||
|
||||
{page.layout.metadata ? (
|
||||
<div
|
||||
className={tcls(
|
||||
CONTENT_STYLE,
|
||||
'mt-6 flex flex-row flex-wrap items-center gap-4 text-tint contrast-more:text-tint-strong'
|
||||
)}
|
||||
>
|
||||
<div className="page-meta">
|
||||
{updatedAt ? (
|
||||
<p className="mr-auto text-sm">
|
||||
<p className="page-meta-date">
|
||||
{t(
|
||||
language,
|
||||
'page_last_modified',
|
||||
|
||||
@@ -4,12 +4,10 @@ import {
|
||||
SiteInsightsLinkPosition,
|
||||
} from '@gitbook/api';
|
||||
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { PageIcon } from '../PageIcon';
|
||||
import { Card } from '@/components/primitives';
|
||||
import type { GitBookAnyContext } from '@/lib/context';
|
||||
import { resolveContentRef } from '@/lib/references';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Blankslate when the page has no document or the document is empty.
|
||||
@@ -29,7 +27,7 @@ export async function PageBodyBlankslate(props: {
|
||||
|
||||
const pageElements = await Promise.all(
|
||||
pages.map(async (child) => {
|
||||
const icon = <PageIcon page={child} style={['text-base', 'text-tint']} />;
|
||||
const icon = <PageIcon page={child} style="page-blankslate-icon" />;
|
||||
|
||||
if (child.type === RevisionPageType.Computed) {
|
||||
throw new Error(
|
||||
@@ -73,18 +71,5 @@ export async function PageBodyBlankslate(props: {
|
||||
})
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
CONTENT_STYLE,
|
||||
'grid',
|
||||
'gap-4',
|
||||
'grid-cols-1',
|
||||
'sm:grid-cols-2',
|
||||
'md:layout-wide:grid-cols-3'
|
||||
)}
|
||||
>
|
||||
{pageElements}
|
||||
</div>
|
||||
);
|
||||
return <div className="page-blankslate">{pageElements}</div>;
|
||||
}
|
||||
|
||||
@@ -7,14 +7,12 @@ import {
|
||||
type RevisionPageDocumentCover,
|
||||
} from '@gitbook/api';
|
||||
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { getCoverHeight } from './coverHeight';
|
||||
import defaultPageCoverSVG from './default-page-cover.svg';
|
||||
import { PageCoverImage } from './PageCoverImage';
|
||||
import { getImageAttributes } from '@/components/utils';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { type ResolvedContentRef, resolveContentRef } from '@/lib/references';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
const defaultPageCover = defaultPageCoverSVG as StaticImageData;
|
||||
|
||||
@@ -91,54 +89,7 @@ export async function PageCover(props: {
|
||||
data-cover-text-color-dark={cover.textColorDark}
|
||||
data-cover-type={as}
|
||||
data-full={String(as === 'full')}
|
||||
className={tcls(
|
||||
'overflow-hidden',
|
||||
// Negative margin to balance the container padding
|
||||
'-mx-4',
|
||||
|
||||
// Full-width cover: extend to edges, disregard TOC where possible
|
||||
as === 'full' || as === 'background'
|
||||
? [
|
||||
'sm:-mx-6',
|
||||
'md:-mx-8',
|
||||
'lg:-ml-12',
|
||||
|
||||
// Extend the full-width cover
|
||||
'layout-default:page-no-toc:lg:-ml-92', // Extend into the left sidebar if there's no TOC...
|
||||
'layout-wide:2xl:-mr-[clamp(2rem,calc((100vw-90rem)/2+2rem),18rem)]', // ...and to the right if there's no outline.
|
||||
'layout-wide:page-no-toc:2xl:-mx-[max(calc((100vw-90rem)/2+2rem),2rem)]', // Span full width if the page content is centered.
|
||||
'layout-wide:has-sidebar:page-no-toc:lg:-ml-[max(calc((100vw-90rem)/2+23rem),23rem)]', // If there's still a sidebar, we have to factor it in too.
|
||||
|
||||
// Corner rounding: we round once the page is wide enough to have space around the cover.
|
||||
'layout-default:2xl:rounded-corners:rounded-b-xl',
|
||||
'layout-default:2xl:circular-corners:rounded-b-3xl',
|
||||
'layout-wide:3xl:circular-corners:rounded-b-3xl',
|
||||
'layout-wide:3xl:rounded-corners:rounded-b-xl',
|
||||
// Round the bottom left corner once the sidebar is shown next to it
|
||||
'has-sidebar:lg:rounded-corners:rounded-bl-xl',
|
||||
'has-sidebar:lg:circular-corners:rounded-bl-3xl',
|
||||
]
|
||||
: null,
|
||||
|
||||
as === 'hero'
|
||||
? [
|
||||
// Regular cover: size regularly along with other content
|
||||
CONTENT_STYLE,
|
||||
'max-sm:-mx-4',
|
||||
'sm:rounded-corners:rounded-xl',
|
||||
'sm:circular-corners:rounded-3xl',
|
||||
'mb-8',
|
||||
'max-sm:w-screen',
|
||||
'max-sm:-mt-8',
|
||||
]
|
||||
: null,
|
||||
|
||||
as === 'background'
|
||||
? [
|
||||
'-z-1 absolute inset-x-0 contrast-more:opacity-5 *:contrast-more:blur-md',
|
||||
]
|
||||
: null
|
||||
)}
|
||||
className="page-cover"
|
||||
>
|
||||
<PageCoverImage
|
||||
imgs={{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
import type { ImageSize } from '../utils';
|
||||
import { useCoverPosition } from './useCoverPosition';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
interface ImageAttributes {
|
||||
src: string;
|
||||
@@ -40,21 +40,21 @@ export function PageCoverImage(props: PageCoverImageProps) {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="h-full w-full overflow-hidden">
|
||||
<div className="h-full w-full animate-pulse bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-800 dark:to-gray-900" />
|
||||
<div className="page-cover-loading">
|
||||
<div className="page-cover-skeleton" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-full w-full overflow-hidden @container" style={{ height }}>
|
||||
<div className="page-cover-frame" style={{ height }}>
|
||||
<img
|
||||
src={imgs.light.src}
|
||||
srcSet={imgs.light.srcSet}
|
||||
sizes={imgs.light.sizes}
|
||||
fetchPriority={darkFirst ? 'auto' : 'high'}
|
||||
alt="Page cover"
|
||||
className={tcls('w-full', 'object-cover', imgs.dark ? 'dark:hidden' : '')}
|
||||
className={cx('page-cover-img', imgs.dark && 'page-cover-img-light')}
|
||||
style={{
|
||||
aspectRatio: height
|
||||
? undefined
|
||||
@@ -75,7 +75,7 @@ export function PageCoverImage(props: PageCoverImageProps) {
|
||||
sizes={imgs.dark.sizes}
|
||||
fetchPriority={darkFirst ? 'high' : 'low'}
|
||||
alt="Page cover"
|
||||
className={tcls('w-full', 'object-cover', 'dark:inline', 'hidden')}
|
||||
className="page-cover-img page-cover-img-dark"
|
||||
style={{
|
||||
aspectRatio: height
|
||||
? undefined
|
||||
|
||||
@@ -3,12 +3,11 @@ import type React from 'react';
|
||||
import { type RevisionPageDocument, SiteInsightsLinkPosition } from '@gitbook/api';
|
||||
import { Icon, type IconName } from '@gitbook/icons';
|
||||
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { Link, type LinkInsightsProps } from '../primitives';
|
||||
import { getSpaceLanguage, t } from '@/intl/server';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext } from '@/lib/context';
|
||||
import { resolvePrevNextPages } from '@/lib/pages';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Show cards to go to previous/next pages at the bottom.
|
||||
@@ -27,7 +26,7 @@ export async function PageFooterNavigation(props: {
|
||||
const nextHref = next ? linker.toPathForPage({ pages: revision.pages, page: next }) : '';
|
||||
|
||||
return (
|
||||
<div className={tcls(CONTENT_STYLE, 'mt-6 flex @xl:flex-row flex-col gap-3 text-tint')}>
|
||||
<div className="page-nav">
|
||||
{previous ? (
|
||||
<NavigationCard
|
||||
icon="chevron-left"
|
||||
@@ -84,24 +83,12 @@ function NavigationCard(
|
||||
<Link
|
||||
href={href}
|
||||
insights={insights}
|
||||
className={tcls(
|
||||
'group flex flex-1 items-center @xl:gap-3 gap-2 text-pretty circular-corners:rounded-2xl rounded-corners:rounded-xl border border-tint-subtle @xl:p-4 p-3 @xl:text-base text-sm text-tint outline-tint-12 transition-colors hover:border-primary-hover contrast-more:border-tint-12 contrast-more:text-tint-strong contrast-more:hover:border-primary-12 contrast-more:hover:outline-2',
|
||||
reversed ? 'flex-row-reverse text-end' : 'text-start'
|
||||
)}
|
||||
className={cx('page-nav-card', reversed && 'page-nav-next')}
|
||||
>
|
||||
<Icon icon={icon} className="size-3" />
|
||||
<div className="flex flex-col">
|
||||
<span
|
||||
className={tcls(
|
||||
'flex items-center gap-1 text-xs',
|
||||
reversed ? 'flex-row-reverse' : 'flex-row'
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</span>
|
||||
<span className="line-clamp-2 leading-snug text-tint-strong transition-colors group-hover:text-primary contrast-more:group-hover:text-primary-strong">
|
||||
{title}
|
||||
</span>
|
||||
<div className="page-nav-body">
|
||||
<span className="page-nav-label">{label}</span>
|
||||
<span className="page-nav-title">{title}</span>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { SpacesDropdownMenuItems, type VariantSpace } from '../Header/SpacesDropdownMenuItem';
|
||||
import { CONTENT_STYLE, CONTENT_STYLE_REDUCED } from '../layout';
|
||||
import {
|
||||
PageActionsDropdown,
|
||||
type PageActionsDropdownURLs,
|
||||
@@ -26,11 +25,11 @@ import {
|
||||
import { categorizeVariants } from '../SpaceLayout/categorizeVariants';
|
||||
import { BreadcrumbItemDropdown, type BreadcrumbSibling } from './BreadcrumbItemDropdown';
|
||||
import { PageTags } from './PageTags';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import type { GitBookSiteContext, SiteStructureNode } from '@/lib/context';
|
||||
import { hasAdaptiveMcpEndpoint } from '@/lib/mcp/endpoints';
|
||||
import { type AncestorRevisionPage, resolveFirstDocument } from '@/lib/pages';
|
||||
import { getLocalizedTitle } from '@/lib/sites';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { getPageRSSURL } from '@/routes/rss';
|
||||
|
||||
export async function PageHeader(props: {
|
||||
@@ -162,9 +161,9 @@ export async function PageHeader(props: {
|
||||
|
||||
const pageActions = (
|
||||
<div
|
||||
className={tcls(
|
||||
'float-right ml-4 flex gap-2',
|
||||
showBreadcrumbs ? '-mb-1 -mt-1.5' : '-mt-3 xs:mt-2',
|
||||
className={cx(
|
||||
'page-header-actions',
|
||||
!showBreadcrumbs && 'page-header-actions-solo',
|
||||
// On desktop API pages these actions are pulled out of <header> (rendered as its
|
||||
// preceding sibling, see below) so their sticky containing block is the tall,
|
||||
// growing content wrapper in <main> — a plain block — rather than the short header.
|
||||
@@ -173,12 +172,7 @@ export async function PageHeader(props: {
|
||||
// offset tracks the header height (banner, cover…) via the same --toc-top-offset the
|
||||
// outline and code samples use. Hidden while the outline drawer is open (drawer
|
||||
// widths only) so it doesn't overlap the sheet.
|
||||
hasAPIBlocks && [
|
||||
'page-api-block:lg:sticky',
|
||||
'page-api-block:lg:top-[calc(var(--toc-top-offset,4rem)+1rem)]',
|
||||
'page-api-block:lg:z-20',
|
||||
'lg:max-[96rem]:[body.outline-open:has(.openapi-block)_&]:hidden',
|
||||
]
|
||||
hasAPIBlocks && 'page-header-actions-api'
|
||||
)}
|
||||
>
|
||||
{hasPageActions ? (
|
||||
@@ -209,11 +203,11 @@ export async function PageHeader(props: {
|
||||
// overlaps it: mark it here so it is never briefly unstyled before hydration.
|
||||
data-cover-aware-text
|
||||
data-over-cover
|
||||
className="page-cover-background:text-contrast-cover flow-root text-xs leading-relaxed text-tint layout-wide:page-no-toc:hidden page-cover-background:opacity-9"
|
||||
className="page-breadcrumbs"
|
||||
>
|
||||
<ol className="inline">
|
||||
<ol>
|
||||
{contextCrumbs.map((crumb, index) => (
|
||||
<li key={crumb.key} className="inline">
|
||||
<li key={crumb.key}>
|
||||
<ContextCrumb crumb={crumb} />
|
||||
{(index !== contextCrumbs.length - 1 || hasAncestors) && (
|
||||
<BreadcrumbSeparator />
|
||||
@@ -232,7 +226,7 @@ export async function PageHeader(props: {
|
||||
page: target,
|
||||
});
|
||||
return (
|
||||
<li key={breadcrumb.id} className="inline">
|
||||
<li key={breadcrumb.id}>
|
||||
<BreadcrumbItemDropdown
|
||||
href={href}
|
||||
label={breadcrumb.title}
|
||||
@@ -259,46 +253,21 @@ export async function PageHeader(props: {
|
||||
{...(context.changeRequest ? { 'data-comment-page-title': '' } : {})}
|
||||
data-cover-aware-text
|
||||
data-over-cover
|
||||
className={tcls(
|
||||
'text-2xl',
|
||||
'@xs:text-3xl',
|
||||
'@lg:text-4xl',
|
||||
'leading-tight',
|
||||
'font-heading',
|
||||
'font-bold',
|
||||
'flex',
|
||||
'items-center',
|
||||
'gap-[.5em]',
|
||||
'grow',
|
||||
'text-pretty',
|
||||
'clear-right',
|
||||
'xs:clear-none',
|
||||
'page-cover-background:text-contrast-cover'
|
||||
)}
|
||||
className="page-title"
|
||||
>
|
||||
<PageIcon page={page} style={['text-tint-subtle', 'shrink-0']} />
|
||||
<PageIcon page={page} style="page-title-icon" />
|
||||
{page.title}
|
||||
</h1>
|
||||
) : null}
|
||||
{page.description && page.layout.description ? (
|
||||
<p
|
||||
data-cover-aware-text
|
||||
data-over-cover
|
||||
className={tcls(
|
||||
CONTENT_STYLE_REDUCED,
|
||||
'text-lg',
|
||||
'page-cover-background:text-contrast-cover',
|
||||
'text-tint contrast-more:text-tint-strong',
|
||||
'clear-both'
|
||||
)}
|
||||
>
|
||||
<p data-cover-aware-text data-over-cover className="page-description">
|
||||
{page.description}
|
||||
</p>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
|
||||
const headerClassName = tcls(CONTENT_STYLE, 'mb-6 space-y-3 after:clear-both after:block');
|
||||
const headerClassName = 'page-header';
|
||||
|
||||
// On API pages the actions are pulled out of <header> so their sticky containing block is the
|
||||
// full-height <main> rather than the short header (a sticky element can't outlive its containing
|
||||
@@ -321,16 +290,7 @@ export async function PageHeader(props: {
|
||||
* Shared styling for the individual breadcrumb links. Uses normal casing/weight to match the way
|
||||
* breadcrumbs are rendered in search results.
|
||||
*/
|
||||
const BREADCRUMB_LINK_CLASSES = [
|
||||
'inline',
|
||||
'no-underline',
|
||||
'hover:underline',
|
||||
'text-xs',
|
||||
'font-normal',
|
||||
'items-center',
|
||||
'contrast-more:underline',
|
||||
'contrast-more:decoration-current',
|
||||
];
|
||||
const BREADCRUMB_LINK_CLASSES = 'page-breadcrumbs-link';
|
||||
|
||||
/** A section-group, section or variant crumb shown at the start of the breadcrumbs. */
|
||||
type BreadcrumbContextCrumb = {
|
||||
@@ -512,13 +472,7 @@ function getPageSiblings(
|
||||
* Separator rendered between two breadcrumb items.
|
||||
*/
|
||||
function BreadcrumbSeparator() {
|
||||
return (
|
||||
<Icon
|
||||
aria-hidden
|
||||
icon="chevron-right"
|
||||
className="mx-2 inline-flex size-2 text-tint-subtle"
|
||||
/>
|
||||
);
|
||||
return <Icon aria-hidden icon="chevron-right" className="page-breadcrumbs-sep" />;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,7 @@ import { useTrackEvent } from '../Insights';
|
||||
import { Button, ButtonGroup, Input } from '../primitives';
|
||||
import { useLanguage } from '@/intl/client';
|
||||
import { t, tString } from '@/intl/translate';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { cx } from '@/lib/classnames';
|
||||
|
||||
const MIN_COMMENT_LENGTH = 3;
|
||||
const MAX_COMMENT_LENGTH = 512;
|
||||
@@ -56,8 +56,8 @@ export function PageFeedbackForm(props: { pageId: string; className?: string })
|
||||
}, [rating]);
|
||||
|
||||
return (
|
||||
<div className={tcls('flex flex-col gap-3 text-sm', className)}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<div className={cx('page-feedback', className)}>
|
||||
<div className="page-feedback-row">
|
||||
<p>{t(languages, 'was_this_helpful')}</p>
|
||||
<ButtonGroup className="rounded-full border border-tint bg-tint-base">
|
||||
<RatingButton
|
||||
@@ -85,7 +85,7 @@ export function PageFeedbackForm(props: { pageId: string; className?: string })
|
||||
</div>
|
||||
{rating ? (
|
||||
submitted ? (
|
||||
<div className="animate-blur-in-display-slow flex items-center gap-1 p-1.5 text-success-subtle">
|
||||
<div className="page-feedback-thanks">
|
||||
<Icon icon="check-circle" className="size-4" />
|
||||
{tString(languages, 'was_this_helpful_thank_you')}
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { RevisionPage } from '@gitbook/api';
|
||||
import { Icon, type IconName } from '@gitbook/icons';
|
||||
|
||||
import { Emoji } from '@/components/primitives';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
|
||||
export function PageIcon(props: {
|
||||
page: Pick<RevisionPage, 'emoji' | 'icon'>;
|
||||
@@ -25,7 +25,7 @@ export function PageIcon(props: {
|
||||
}
|
||||
|
||||
if (page.icon) {
|
||||
return <Icon icon={page.icon as IconName} className={tcls('size-[1em]', style)} />;
|
||||
return <Icon icon={page.icon as IconName} className={cx('page-icon', style)} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -1,9 +1,30 @@
|
||||
@import "tailwindcss";
|
||||
/* Tailwind is split so the component stylesheets land in the utilities layer ahead of the
|
||||
generated utilities: specificity then decides, as it did when they were utility classes. */
|
||||
@layer theme, base, components, utilities;
|
||||
@import "tailwindcss/theme.css" layer(theme);
|
||||
@import "tailwindcss/preflight.css" layer(base);
|
||||
|
||||
@config '../../../tailwind.config.ts';
|
||||
|
||||
/* For the component stylesheets: as utilities, `contrast-more:` sorted after a caller's plain utility
|
||||
and won. Ahead of the utilities it needs one more point of specificity to keep winning. */
|
||||
@custom-variant contrast-more-strong {
|
||||
@media (prefers-contrast: more) {
|
||||
&:is(html *) {
|
||||
@slot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@import "./prose.css";
|
||||
@import "../DocumentView/OpenAPI/method-badge.css";
|
||||
@import "./styles/primitives.css";
|
||||
@import "./styles/chrome.css";
|
||||
@import "./styles/page.css";
|
||||
@import "./styles/toc.css";
|
||||
@import "./styles/blocks.css";
|
||||
@import "./styles/rich-blocks.css";
|
||||
@import "tailwindcss/utilities.css" layer(utilities);
|
||||
|
||||
/*
|
||||
The default border color has changed to `currentcolor` in Tailwind CSS v4,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user