mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-11-17 13:32:29 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 91ec127e01 |
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Fix horizontal page scroll caused by card carousels bleeding past the viewport.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Remove duplicated declarations from the global stylesheet.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Keep inline code and highlighted text readable when a paragraph crosses the bottom edge of a background page cover.
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
"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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Load the OpenAPI stylesheet only on pages with OpenAPI blocks.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"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.
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
"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.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"gitbook": patch
|
||||
---
|
||||
|
||||
Send only the site origin as referrer to third parties, and only let the embedding page open the embed messaging channel.
|
||||
@@ -1,5 +0,0 @@
|
||||
---
|
||||
"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.
|
||||
@@ -4,11 +4,6 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
# A newer run for the same PR supersedes the previous one. Each push to main gets a group of its
|
||||
# own, so main runs are never queued behind or cancelled by another run.
|
||||
concurrency:
|
||||
group: ${{ github.event_name == 'pull_request_target' && format('preview-pr-{0}', github.event.pull_request.number) || format('preview-run-{0}', github.run_id) }}
|
||||
cancel-in-progress: ${{ github.event_name == 'pull_request_target' }}
|
||||
jobs:
|
||||
approval:
|
||||
# Ensure that external contributors' PRs are manually approved before deployment
|
||||
@@ -23,9 +18,8 @@ jobs:
|
||||
deploy-v2-vercel:
|
||||
name: Deploy v2 to Vercel (preview)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
needs: approval
|
||||
if: ${{ !cancelled() && (needs.approval.result == 'success' || needs.approval.result == 'skipped') }}
|
||||
if: ${{ always() && (needs.approval.result == 'success' || needs.approval.result == 'skipped') }}
|
||||
environment:
|
||||
name: 2v-preview
|
||||
url: ${{ steps.deploy.outputs.deployment-url }}
|
||||
@@ -50,9 +44,8 @@ jobs:
|
||||
deploy-v2-cloudflare:
|
||||
name: Deploy v2 to Cloudflare Worker (preview)
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
needs: approval
|
||||
if: ${{ !cancelled() && (needs.approval.result == 'success' || needs.approval.result == 'skipped') }}
|
||||
if: ${{ always() && (needs.approval.result == 'success' || needs.approval.result == 'skipped') }}
|
||||
environment:
|
||||
name: 2c-preview
|
||||
url: ${{ steps.deploy.outputs.deployment-url }}
|
||||
@@ -89,7 +82,7 @@ jobs:
|
||||
comment-deployments:
|
||||
runs-on: ubuntu-latest
|
||||
name: Comment Deployments (preview)
|
||||
if: ${{ !cancelled() && github.event_name != 'push' }}
|
||||
if: always() && github.event_name != 'push'
|
||||
needs:
|
||||
- deploy-v2-vercel
|
||||
- deploy-v2-cloudflare
|
||||
@@ -102,25 +95,6 @@ jobs:
|
||||
comment-author: 'github-actions[bot]'
|
||||
body-includes: 'Summary of the deployments'
|
||||
|
||||
# A deploy that didn't succeed has no URL (e.g. a re-run hitting Vercel's "deploymentId
|
||||
# already exists"), so keep the URL the comment already shows instead of blanking it.
|
||||
- name: Resolve deployment URLs
|
||||
id: urls
|
||||
env:
|
||||
PREVIOUS_COMMENT: ${{ steps.fc.outputs.comment-body }}
|
||||
VERCEL_RESULT: ${{ needs.deploy-v2-vercel.result }}
|
||||
VERCEL_URL: ${{ needs.deploy-v2-vercel.outputs.deployment-url }}
|
||||
CLOUDFLARE_RESULT: ${{ needs.deploy-v2-cloudflare.result }}
|
||||
CLOUDFLARE_URL: ${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}
|
||||
run: |
|
||||
previous_url() {
|
||||
sed -n "s/^| $1 | \[\([^]]*\)\].*/\1/p" <<<"$PREVIOUS_COMMENT" | head -n 1
|
||||
}
|
||||
if [ "$VERCEL_RESULT" != success ]; then VERCEL_URL=$(previous_url Vercel); fi
|
||||
if [ "$CLOUDFLARE_RESULT" != success ]; then CLOUDFLARE_URL=$(previous_url Cloudflare); fi
|
||||
echo "vercel=$VERCEL_URL" >> "$GITHUB_OUTPUT"
|
||||
echo "cloudflare=$CLOUDFLARE_URL" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Create or update GitHub comment
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
with:
|
||||
@@ -131,21 +105,21 @@ jobs:
|
||||
|
||||
| Version | URL | Status |
|
||||
| --- | --- | --- |
|
||||
| Vercel | [${{ steps.urls.outputs.vercel }}](${{ steps.urls.outputs.vercel }}) | ${{ needs.deploy-v2-vercel.result == 'success' && '✅' || '❌' }} |
|
||||
| Cloudflare | [${{ steps.urls.outputs.cloudflare }}](${{ steps.urls.outputs.cloudflare }}) | ${{ needs.deploy-v2-cloudflare.result == 'success' && '✅' || '❌' }} |
|
||||
| Vercel | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}](${{ needs.deploy-v2-vercel.outputs.deployment-url }}) | ${{ needs.deploy-v2-vercel.result == 'success' && '✅' || '❌' }} |
|
||||
| Cloudflare | [${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}](${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}) | ${{ needs.deploy-v2-cloudflare.result == 'success' && '✅' || '❌' }} |
|
||||
|
||||
### Test content
|
||||
|
||||
| Site | `2v` | `2c` |
|
||||
| --- | --- | --- |
|
||||
| GitBook | [${{ steps.urls.outputs.vercel }}/url/gitbook.com/docs](${{ steps.urls.outputs.vercel }}/url/gitbook.com/docs) | [${{ steps.urls.outputs.cloudflare }}/url/gitbook.com/docs](${{ steps.urls.outputs.cloudflare }}/url/gitbook.com/docs) |
|
||||
| E2E | [${{ steps.urls.outputs.vercel }}/url/gitbook.gitbook.io/test-gitbook-open](${{ steps.urls.outputs.vercel }}/url/gitbook.gitbook.io/test-gitbook-open) | [${{ steps.urls.outputs.cloudflare }}/url/gitbook.gitbook.io/test-gitbook-open](${{ steps.urls.outputs.cloudflare }}/url/gitbook.gitbook.io/test-gitbook-open) |
|
||||
| GitBook | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}/url/gitbook.com/docs](${{ needs.deploy-v2-vercel.outputs.deployment-url }}/url/gitbook.com/docs) | [${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}/url/gitbook.com/docs](${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}/url/gitbook.com/docs) |
|
||||
| E2E | [${{ needs.deploy-v2-vercel.outputs.deployment-url }}/url/gitbook.gitbook.io/test-gitbook-open](${{ needs.deploy-v2-vercel.outputs.deployment-url }}/url/gitbook.gitbook.io/test-gitbook-open) | [${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}/url/gitbook.gitbook.io/test-gitbook-open](${{ needs.deploy-v2-cloudflare.outputs.deployment-url }}/url/gitbook.gitbook.io/test-gitbook-open) |
|
||||
edit-mode: replace
|
||||
visual-testing-v2-vercel:
|
||||
runs-on: ubuntu-latest
|
||||
name: Visual Testing v2
|
||||
needs: deploy-v2-vercel
|
||||
if: ${{ !cancelled() && needs.deploy-v2-vercel.result == 'success' }}
|
||||
if: ${{ always() && needs.deploy-v2-vercel.result == 'success' }}
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -169,7 +143,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Visual Testing v2 (Cloudflare)
|
||||
needs: deploy-v2-cloudflare
|
||||
if: ${{ !cancelled() && needs.deploy-v2-cloudflare.result == 'success' }}
|
||||
if: ${{ always() && needs.deploy-v2-cloudflare.result == 'success' }}
|
||||
timeout-minutes: 15
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -193,7 +167,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Visual Testing Customers v2
|
||||
needs: deploy-v2-vercel
|
||||
if: ${{ !cancelled() && needs.deploy-v2-vercel.result == 'success' }}
|
||||
if: ${{ always() && needs.deploy-v2-vercel.result == 'success' }}
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -217,7 +191,7 @@ jobs:
|
||||
# Style recalc depends on the client bundle, not the host, so this runs here only and
|
||||
# not in the Cloudflare job. Kept out of `e2e-customers`, which is a visual suite.
|
||||
- name: Run style invalidation tests
|
||||
if: ${{ !cancelled() }}
|
||||
if: always()
|
||||
working-directory: packages/gitbook
|
||||
run: bun run e2e-style-perf
|
||||
env:
|
||||
@@ -226,7 +200,7 @@ jobs:
|
||||
|
||||
# Runs on failure too: a blown style budget is exactly when the numbers are worth seeing.
|
||||
- name: Build style invalidation report
|
||||
if: ${{ !cancelled() && github.event_name != 'push' }}
|
||||
if: always() && github.event_name != 'push'
|
||||
id: style-perf
|
||||
working-directory: packages/gitbook
|
||||
run: |
|
||||
@@ -245,7 +219,7 @@ jobs:
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Find style invalidation comment
|
||||
if: ${{ !cancelled() && github.event_name != 'push' && steps.style-perf.outputs.body != '' }}
|
||||
if: always() && github.event_name != 'push' && steps.style-perf.outputs.body != ''
|
||||
uses: peter-evans/find-comment@v3
|
||||
id: fc-style-perf
|
||||
with:
|
||||
@@ -254,7 +228,7 @@ jobs:
|
||||
body-includes: 'Style invalidation on a large API reference'
|
||||
|
||||
- name: Create or update style invalidation comment
|
||||
if: ${{ !cancelled() && github.event_name != 'push' && steps.style-perf.outputs.body != '' }}
|
||||
if: always() && github.event_name != 'push' && steps.style-perf.outputs.body != ''
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
with:
|
||||
comment-id: ${{ steps.fc-style-perf.outputs.comment-id }}
|
||||
@@ -265,7 +239,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Visual Testing Customers v2 (Cloudflare)
|
||||
needs: deploy-v2-cloudflare
|
||||
if: ${{ !cancelled() && needs.deploy-v2-cloudflare.result == 'success' }}
|
||||
if: ${{ always() && needs.deploy-v2-cloudflare.result == 'success' }}
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -289,7 +263,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
name: Browserless Testing v2 (Vercel)
|
||||
needs: deploy-v2-vercel
|
||||
if: ${{ !cancelled() && needs.deploy-v2-vercel.result == 'success' }}
|
||||
if: ${{ always() && needs.deploy-v2-vercel.result == 'success' }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
"@changesets/cli": "^2.31.1",
|
||||
"oxfmt": "^0.62.0",
|
||||
"oxlint": "^1.93.0",
|
||||
"turbo": "^2.11.11",
|
||||
"turbo": "^2.11.10",
|
||||
"vercel": "50.37.3",
|
||||
},
|
||||
},
|
||||
@@ -128,8 +128,8 @@
|
||||
"@gitbook/react-openapi": "workspace:*",
|
||||
"@mermaid-js/mermaid-zenuml": "^0.2.2",
|
||||
"@modelcontextprotocol/sdk": "1.17.5",
|
||||
"@opennextjs/aws": "4.1.16",
|
||||
"@opennextjs/cloudflare": "1.20.17",
|
||||
"@opennextjs/aws": "4.1.15",
|
||||
"@opennextjs/cloudflare": "1.20.16",
|
||||
"@panzoom/panzoom": "^4.6.1",
|
||||
"@sindresorhus/fnv1a": "^3.1.0",
|
||||
"@tailwindcss/container-queries": "^0.1.1",
|
||||
@@ -159,7 +159,7 @@
|
||||
"micromark-extension-gfm": "^3.0.0",
|
||||
"motion": "^12.23.24",
|
||||
"negotiator": "^1.0.0",
|
||||
"next": "^16.4.6",
|
||||
"next": "^16.4.5",
|
||||
"next-themes": "^0.4.6",
|
||||
"nuqs": "^2.2.3",
|
||||
"object-hash": "^3.0.0",
|
||||
@@ -341,9 +341,9 @@
|
||||
},
|
||||
"patchedDependencies": {
|
||||
"decode-named-character-reference@1.0.2": "patches/decode-named-character-reference@1.0.2.patch",
|
||||
"next@16.4.5": "patches/next@16.4.5.patch",
|
||||
"@shikijs/langs@3.21.0": "patches/@shikijs%2Flangs@3.21.0.patch",
|
||||
"mermaid@11.16.1": "patches/mermaid@11.16.1.patch",
|
||||
"next@16.4.6": "patches/next@16.4.6.patch",
|
||||
},
|
||||
"overrides": {
|
||||
"@codemirror/state": "6.4.1",
|
||||
@@ -888,29 +888,29 @@
|
||||
|
||||
"@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.0.6", "", { "dependencies": { "@emnapi/core": "^1.5.0", "@emnapi/runtime": "^1.5.0", "@tybys/wasm-util": "^0.10.1" } }, "sha512-DXj75ewm11LIWUk198QSKUTxjyRjsBwk09MuMk5DGK+GDUtyPhhEHOGP/Xwwj3DjQXXkivoBirmOnKrLfc0+9g=="],
|
||||
|
||||
"@next/env": ["@next/env@16.4.6", "", {}, "sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA=="],
|
||||
"@next/env": ["@next/env@16.4.5", "", {}, "sha512-JwSPwpdkZL5VMl2jA/q+JI8MZdweAL3xmw5/tb9y/TLtmS0YXZnmYDzSihwk8xTj1OL+WM53gTqaj96yuLp6Xw=="],
|
||||
|
||||
"@next/swc-darwin-arm64": ["@next/swc-darwin-arm64@16.4.6", "", { "os": "darwin", "cpu": "arm64" }, "sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg=="],
|
||||
"@next/swc-darwin-arm64": ["@next/swc-darwin-arm64@16.4.5", "", { "os": "darwin", "cpu": "arm64" }, "sha512-W5TniBzWKASbNNwHZ/S/f1MxQUXU/LdjklVMWA0Ujbfl7SZnUzFls45hO0i/sF7Bx1jJBWp7WWmoQajXtX/O8A=="],
|
||||
|
||||
"@next/swc-darwin-x64": ["@next/swc-darwin-x64@16.4.6", "", { "os": "darwin", "cpu": "x64" }, "sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA=="],
|
||||
"@next/swc-darwin-x64": ["@next/swc-darwin-x64@16.4.5", "", { "os": "darwin", "cpu": "x64" }, "sha512-uWq4qkHapBDS1oFltWS4YxTb9pLHAtLNcpbuK6SmRsebLYZqpBML/j/C0op+50JYGTpZgVL/DWNt/6oWlamrrw=="],
|
||||
|
||||
"@next/swc-linux-arm64-gnu": ["@next/swc-linux-arm64-gnu@16.4.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA=="],
|
||||
"@next/swc-linux-arm64-gnu": ["@next/swc-linux-arm64-gnu@16.4.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-FdRcyOx5u5P51mlAqLB9EXdd8jZO5fsdHtk4BAQSkqOywCsbTNN/rmw+jO7pnmjNdAtu2AG46NzbCL2FPDrrgw=="],
|
||||
|
||||
"@next/swc-linux-arm64-musl": ["@next/swc-linux-arm64-musl@16.4.6", "", { "os": "linux", "cpu": "arm64" }, "sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA=="],
|
||||
"@next/swc-linux-arm64-musl": ["@next/swc-linux-arm64-musl@16.4.5", "", { "os": "linux", "cpu": "arm64" }, "sha512-cyvmmgtRXR8aGVT86wi9Py53IlfyCx7P2fZxuAXAoTummDnhKtUyjrMeXfapqp4qgD+gT5RqyGD/VfA16jEK7Q=="],
|
||||
|
||||
"@next/swc-linux-x64-gnu": ["@next/swc-linux-x64-gnu@16.4.6", "", { "os": "linux", "cpu": "x64" }, "sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ=="],
|
||||
"@next/swc-linux-x64-gnu": ["@next/swc-linux-x64-gnu@16.4.5", "", { "os": "linux", "cpu": "x64" }, "sha512-hPc+Fl+N22DAvqZHq559NmamXboOX5Lu8I5Wl0DezfrhTk1Zz21NQeYoZDmNI/NjTcrdsVxM72Fzn2lI+Q+vAw=="],
|
||||
|
||||
"@next/swc-linux-x64-musl": ["@next/swc-linux-x64-musl@16.4.6", "", { "os": "linux", "cpu": "x64" }, "sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA=="],
|
||||
"@next/swc-linux-x64-musl": ["@next/swc-linux-x64-musl@16.4.5", "", { "os": "linux", "cpu": "x64" }, "sha512-gbACYE8IP/jlprNTpiWXHb8N9CofOzpnEwH2SrIz1dUbiJf1FbDssDupCAPeP1Taxe8mgG20sGZamJI7KFOdZw=="],
|
||||
|
||||
"@next/swc-win32-arm64-msvc": ["@next/swc-win32-arm64-msvc@16.4.6", "", { "os": "win32", "cpu": "arm64" }, "sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ=="],
|
||||
"@next/swc-win32-arm64-msvc": ["@next/swc-win32-arm64-msvc@16.4.5", "", { "os": "win32", "cpu": "arm64" }, "sha512-+8gj++ZMo8H20Xh2ijjNqyFk5LPLw0AC4Fs4Tq/G94rjjQXhOjN4jgSWsWKPFsyY26hfIeemJIwKtMxOsp5GBA=="],
|
||||
|
||||
"@next/swc-win32-x64-msvc": ["@next/swc-win32-x64-msvc@16.4.6", "", { "os": "win32", "cpu": "x64" }, "sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g=="],
|
||||
"@next/swc-win32-x64-msvc": ["@next/swc-win32-x64-msvc@16.4.5", "", { "os": "win32", "cpu": "x64" }, "sha512-qNZj66pYXnaWLiF9R9GUbfBdrCv7kC6TaZfIwB2KH5WPc/8pEM3nVOj8hpQhWJU8S94rlH5MPDcX15+RrgUhiw=="],
|
||||
|
||||
"@node-minify/core": ["@node-minify/core@10.5.0", "", { "dependencies": { "@node-minify/utils": "10.5.0" } }, "sha512-duptyliRQY+fXszqbm5CP+NauASUwkOlx/c4bwlT7tj5AQWhG9F26D3bfU/okKto9RDTGJy3cLwPvJC/j9lCkA=="],
|
||||
"@node-minify/core": ["@node-minify/core@9.0.2", "", { "dependencies": { "@node-minify/utils": "9.0.1", "glob": "10.3.3", "mkdirp": "3.0.1" } }, "sha512-FNhv29Wom6wKrrFKaeAfmZqz7TX5A1E6P+bpd0VIc+DYWMLUIhAViS8riaZg3A1oD0s06s+5BG2Fg7RqMKiKHw=="],
|
||||
|
||||
"@node-minify/terser": ["@node-minify/terser@10.5.0", "", { "dependencies": { "@node-minify/utils": "10.5.0", "terser": "5.46.0" } }, "sha512-NvR9vYMQ/exd2lNKQ9TtoJD98gqpzQu0+bIZRqA3mci38hmacPr7H5cP4coh1vz5ZZp+WkYSrOwCm2FiC2P5MQ=="],
|
||||
"@node-minify/terser": ["@node-minify/terser@9.0.1", "", { "dependencies": { "@node-minify/utils": "9.0.1", "terser": "5.36.0" } }, "sha512-WF78Ex+/xNZZDYvzwB7+sLUYQbJzyyS36ZjMhVqhORejHOsoOcTjQ9TdOgKZoY7wlfxjnLxeMKkO8R/R1KL9aQ=="],
|
||||
|
||||
"@node-minify/utils": ["@node-minify/utils@10.5.0", "", { "dependencies": { "fast-glob": "^3.3.3", "gzip-size": "7.0.0" } }, "sha512-3DZEYgersSgia5V/cee35sw6B7TTZlcCKyAGiuhT274/r1obMEtHt1lRmyCd52uX5QlZqDOTrD4bqHCxKzIYLg=="],
|
||||
"@node-minify/utils": ["@node-minify/utils@9.0.1", "", { "dependencies": { "gzip-size": "6.0.0" } }, "sha512-aC1+mhKTP3IMa2VcuGl3ui92LO/7CPQWldNGzu3BVGKiMNJ70AKJW/R6huuYCSuQyHDGM9oFwiVClsZnFxn67g=="],
|
||||
|
||||
"@nodelib/fs.scandir": ["@nodelib/fs.scandir@2.1.5", "", { "dependencies": { "@nodelib/fs.stat": "2.0.5", "run-parallel": "^1.1.9" } }, "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g=="],
|
||||
|
||||
@@ -934,9 +934,9 @@
|
||||
|
||||
"@octokit/types": ["@octokit/types@14.1.0", "", { "dependencies": { "@octokit/openapi-types": "^25.1.0" } }, "sha512-1y6DgTy8Jomcpu33N+p5w58l6xyt55Ar2I91RPiIA0xCJBXyUAhXCcmZaDWSANiha7R9a6qJJ2CRomGPZ6f46g=="],
|
||||
|
||||
"@opennextjs/aws": ["@opennextjs/aws@4.1.16", "", { "dependencies": { "@ast-grep/napi": "^0.45.3", "@aws-sdk/client-cloudfront": "3.984.0", "@aws-sdk/client-dynamodb": "3.984.0", "@aws-sdk/client-lambda": "3.984.0", "@aws-sdk/client-s3": "3.984.0", "@aws-sdk/client-sqs": "3.984.0", "@node-minify/core": "^10.5.0", "@node-minify/terser": "^10.5.0", "@tsconfig/node18": "^18.2.7", "aws4fetch": "^1.0.20", "chalk": "^5.6.2", "cookie": "^1.1.1", "esbuild": "0.28.2", "express": "^5.2.1", "path-to-regexp": "^6.3.0", "urlpattern-polyfill": "^10.1.0", "yaml": "^2.9.1" }, "peerDependencies": { "diff": "^9.0.0", "next": ">=15.5.29 <16 || >=16.4.5" }, "optionalPeers": ["diff"], "bin": { "open-next": "dist/index.js" } }, "sha512-eHb6/LCrpr+3DmbmE+/q5GkcrbSs5IRpO/O0kcay7FK5WYDhcML0K5NhO7I9H62z42wscVIi75Hv3ASsXDeEGw=="],
|
||||
"@opennextjs/aws": ["@opennextjs/aws@4.1.15", "", { "dependencies": { "@ast-grep/napi": "^0.45.3", "@aws-sdk/client-cloudfront": "3.984.0", "@aws-sdk/client-dynamodb": "3.984.0", "@aws-sdk/client-lambda": "3.984.0", "@aws-sdk/client-s3": "3.984.0", "@aws-sdk/client-sqs": "3.984.0", "@node-minify/core": "^9.0.2", "@node-minify/terser": "^9.0.1", "@tsconfig/node18": "^18.2.7", "aws4fetch": "^1.0.20", "chalk": "^5.6.2", "cookie": "^1.1.1", "esbuild": "0.28.2", "express": "^5.2.1", "path-to-regexp": "^6.3.0", "urlpattern-polyfill": "^10.1.0", "yaml": "^2.9.1" }, "peerDependencies": { "diff": "^9.0.0", "next": ">=15.5.29 <16 || >=16.4.5" }, "optionalPeers": ["diff"], "bin": { "open-next": "dist/index.js" } }, "sha512-ulv7rFEAeieD0d/zDMnw4IFPU+zY/atVUhn7ezgFqIurLB5oBYeHCUGlcGk3Pg7uMPeI03SNRjHW1+xL9EwMPw=="],
|
||||
|
||||
"@opennextjs/cloudflare": ["@opennextjs/cloudflare@1.20.17", "", { "dependencies": { "@ast-grep/napi": "^0.45.3", "@dotenvx/dotenvx": "^2.33.0", "@opennextjs/aws": "4.1.16", "ci-info": "^4.2.0", "cloudflare": "^4.4.1", "comment-json": "^4.5.1", "enquirer": "^2.4.1", "glob": "^13.0.6", "resolve.exports": "^2.0.4", "ts-tqdm": "^0.8.6", "yargs": "^18.2.0" }, "peerDependencies": { "next": ">=15.5.29 <16 || >=16.4.5", "rclone.js": "^0.6.6", "wrangler": "^4.148.0" }, "optionalPeers": ["rclone.js"], "bin": { "opennextjs-cloudflare": "dist/cli/index.js" } }, "sha512-jGEC9ue8LLHvOFXp62LjDUSSz7JpD+PQB+Y3r0lU78PtQ84wI16+EMF9TXEDkTek3g3fGWTLTI07pbZt8/gj8w=="],
|
||||
"@opennextjs/cloudflare": ["@opennextjs/cloudflare@1.20.16", "", { "dependencies": { "@ast-grep/napi": "^0.45.3", "@dotenvx/dotenvx": "^2.33.0", "@opennextjs/aws": "4.1.15", "ci-info": "^4.2.0", "cloudflare": "^4.4.1", "comment-json": "^4.5.1", "enquirer": "^2.4.1", "glob": "^13.0.6", "ts-tqdm": "^0.8.6", "yargs": "^18.2.0" }, "peerDependencies": { "next": ">=15.5.29 <16 || >=16.4.5", "rclone.js": "^0.6.6", "wrangler": "^4.148.0" }, "optionalPeers": ["rclone.js"], "bin": { "opennextjs-cloudflare": "dist/cli/index.js" } }, "sha512-3c1Cwex5e2jXy4o4RZAusy8o9Uz4eowuPCjdVLYEZ/MnkAzN2jh9dOgsRjgu3wjigXuNe8rmPECmOTo+xKQHsw=="],
|
||||
|
||||
"@opentelemetry/api": ["@opentelemetry/api@1.9.0", "", {}, "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg=="],
|
||||
|
||||
@@ -2124,7 +2124,7 @@
|
||||
|
||||
"focus-trap": ["focus-trap@7.6.1", "", { "dependencies": { "tabbable": "^6.2.0" } }, "sha512-nB8y4nQl8PshahLpGKZOq1sb0xrMVFSn6at7u/qOsBZTlZRzaapISGENcB6mOkoezbClZyiMwEF/dGY8AZ00rA=="],
|
||||
|
||||
"foreground-child": ["foreground-child@3.3.0", "", { "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" } }, "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg=="],
|
||||
"foreground-child": ["foreground-child@3.3.1", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="],
|
||||
|
||||
"form-data": ["form-data@4.0.1", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "mime-types": "^2.1.12" } }, "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw=="],
|
||||
|
||||
@@ -2190,7 +2190,7 @@
|
||||
|
||||
"graceful-fs": ["graceful-fs@4.2.11", "", {}, "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ=="],
|
||||
|
||||
"gzip-size": ["gzip-size@7.0.0", "", { "dependencies": { "duplexer": "^0.1.2" } }, "sha512-O1Ld7Dr+nqPnmGpdhzLmMTQ4vAsD+rHwMm1NLUmoUFFymBOMKxCCrtDxqdBRYXdeEPEi3SyoR4TizJLQrnKBNA=="],
|
||||
"gzip-size": ["gzip-size@6.0.0", "", { "dependencies": { "duplexer": "^0.1.2" } }, "sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q=="],
|
||||
|
||||
"hachure-fill": ["hachure-fill@0.5.2", "", {}, "sha512-3GKBOn+m2LX9iq+JC1064cSFprJY4jL1jCXTcpnfER5HYE2l/4EfWSGzkPa/ZDBmYI0ZOEj5VHV/eKnPGkHuOg=="],
|
||||
|
||||
@@ -2338,7 +2338,7 @@
|
||||
|
||||
"isexe": ["isexe@2.0.0", "", {}, "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw=="],
|
||||
|
||||
"jackspeak": ["jackspeak@3.4.3", "", { "dependencies": { "@isaacs/cliui": "^8.0.2" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw=="],
|
||||
"jackspeak": ["jackspeak@2.3.6", "", { "dependencies": { "@isaacs/cliui": "^8.0.2" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ=="],
|
||||
|
||||
"jiti": ["jiti@2.5.1", "", { "bin": { "jiti": "lib/jiti-cli.mjs" } }, "sha512-twQoecYPiVA5K/h6SxtORw/Bs3ar+mLUtoPSc7iMXzQzK8d7eJ/R09wmTwAjiamETn1cXYPGfNnu7DMoHgu12w=="],
|
||||
|
||||
@@ -2636,7 +2636,7 @@
|
||||
|
||||
"netmask": ["netmask@2.0.2", "", {}, "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg=="],
|
||||
|
||||
"next": ["next@16.4.6", "", { "dependencies": { "@next/env": "16.4.6", "@swc/helpers": "0.5.23", "baseline-browser-mapping": "^2.9.19", "caniuse-lite": "^1.0.30001579", "postcss": "8.5.23", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "16.4.6", "@next/swc-darwin-x64": "16.4.6", "@next/swc-linux-arm64-gnu": "16.4.6", "@next/swc-linux-arm64-musl": "16.4.6", "@next/swc-linux-x64-gnu": "16.4.6", "@next/swc-linux-x64-musl": "16.4.6", "@next/swc-win32-arm64-msvc": "16.4.6", "@next/swc-win32-x64-msvc": "16.4.6", "sharp": "^0.35.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.51.1", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": { "next": "dist/bin/next" } }, "sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA=="],
|
||||
"next": ["next@16.4.5", "", { "dependencies": { "@next/env": "16.4.5", "@swc/helpers": "0.5.23", "baseline-browser-mapping": "^2.9.19", "caniuse-lite": "^1.0.30001579", "postcss": "8.5.23", "styled-jsx": "5.1.6" }, "optionalDependencies": { "@next/swc-darwin-arm64": "16.4.5", "@next/swc-darwin-x64": "16.4.5", "@next/swc-linux-arm64-gnu": "16.4.5", "@next/swc-linux-arm64-musl": "16.4.5", "@next/swc-linux-x64-gnu": "16.4.5", "@next/swc-linux-x64-musl": "16.4.5", "@next/swc-win32-arm64-msvc": "16.4.5", "@next/swc-win32-x64-msvc": "16.4.5", "sharp": "^0.35.5" }, "peerDependencies": { "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.51.1", "babel-plugin-react-compiler": "*", "react": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "react-dom": "^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0", "sass": "^1.3.0" }, "optionalPeers": ["@opentelemetry/api", "@playwright/test", "babel-plugin-react-compiler", "sass"], "bin": { "next": "dist/bin/next" } }, "sha512-rmdfsWosjTUO+6R0S3KokoIk6Kj0sWDRTe86tZHdqaWH/oXq/udX3/4xb+YQi7aWbyEFoglDU54kaifLCdXbBw=="],
|
||||
|
||||
"next-themes": ["next-themes@0.4.6", "", { "peerDependencies": { "react": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc", "react-dom": "^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc" } }, "sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA=="],
|
||||
|
||||
@@ -2902,7 +2902,7 @@
|
||||
|
||||
"resolve-pkg-maps": ["resolve-pkg-maps@1.0.0", "", {}, "sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw=="],
|
||||
|
||||
"resolve.exports": ["resolve.exports@2.0.4", "", {}, "sha512-zepuGL0ulf+nt+XaFrlKeaiTJeyPFPLLY62+ncq1/VTHBdt3HsfXOH60priZ6tnXQozdGcDeIF5JVTanvIcYWQ=="],
|
||||
"resolve.exports": ["resolve.exports@2.0.3", "", {}, "sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A=="],
|
||||
|
||||
"retry": ["retry@0.13.1", "", {}, "sha512-XQBQ3I8W1Cge0Seh+6gjj03LbmRFWuoszgK9ooCpwYIrhhoO80pfq4cUkU5DkknwfOfFteRwlZ56PYOGYyFWdg=="],
|
||||
|
||||
@@ -3072,7 +3072,7 @@
|
||||
|
||||
"term-size": ["term-size@2.2.1", "", {}, "sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg=="],
|
||||
|
||||
"terser": ["terser@5.46.0", "", { "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.15.0", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, "bin": { "terser": "bin/terser" } }, "sha512-jTwoImyr/QbOWFFso3YoU3ik0jBBDJ6JTOQiy/J2YxVJdZCc+5u7skhNwiOR3FQIygFqVUPHl7qbbxtjW2K3Qg=="],
|
||||
"terser": ["terser@5.36.0", "", { "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.8.2", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, "bin": { "terser": "bin/terser" } }, "sha512-IYV9eNMuFAV4THUspIRXkLakHnV6XO7FEdtKjf/mDyrnqUg9LnlOn6/RwRvM9SZjR4GUq8Nk8zj67FzVARr74w=="],
|
||||
|
||||
"thenify": ["thenify@3.3.1", "", { "dependencies": { "any-promise": "^1.0.0" } }, "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw=="],
|
||||
|
||||
@@ -3448,6 +3448,8 @@
|
||||
|
||||
"@modelcontextprotocol/sdk/zod-to-json-schema": ["zod-to-json-schema@3.24.5", "", { "peerDependencies": { "zod": "^3.24.1" } }, "sha512-/AuWwMP+YqiPbsJx5D6TfgRTc4kTLjsh5SOcd4bLsfUg2RcEXrFMJl1DGgdHy2aCfsIA/cr/1JM0xcB2GZji8g=="],
|
||||
|
||||
"@node-minify/core/glob": ["glob@10.3.3", "", { "dependencies": { "foreground-child": "^3.1.0", "jackspeak": "^2.0.3", "minimatch": "^9.0.1", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0", "path-scurry": "^1.10.1" }, "bin": { "glob": "dist/cjs/src/bin.js" } }, "sha512-92vPiMb/iqpmEgsOoIDvTjc50wf9CCCvMzsi6W0JLPeUKE8TWP1a73PgqSrqy7iAZxaSD1YdzU7QZR5LF51MJw=="],
|
||||
|
||||
"@opennextjs/aws/express": ["express@5.2.1", "", { "dependencies": { "accepts": "^2.0.0", "body-parser": "^2.2.1", "content-disposition": "^1.0.0", "content-type": "^1.0.5", "cookie": "^0.7.1", "cookie-signature": "^1.2.1", "debug": "^4.4.0", "depd": "^2.0.0", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "finalhandler": "^2.1.0", "fresh": "^2.0.0", "http-errors": "^2.0.0", "merge-descriptors": "^2.0.0", "mime-types": "^3.0.0", "on-finished": "^2.4.1", "once": "^1.4.0", "parseurl": "^1.3.3", "proxy-addr": "^2.0.7", "qs": "^6.14.0", "range-parser": "^1.2.1", "router": "^2.2.0", "send": "^1.1.0", "serve-static": "^2.2.0", "statuses": "^2.0.1", "type-is": "^2.0.1", "vary": "^1.1.2" } }, "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw=="],
|
||||
|
||||
"@oxc-transform/binding-wasm32-wasi/@napi-rs/wasm-runtime": ["@napi-rs/wasm-runtime@1.1.1", "", { "dependencies": { "@emnapi/core": "^1.7.1", "@emnapi/runtime": "^1.7.1", "@tybys/wasm-util": "^0.10.1" } }, "sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A=="],
|
||||
@@ -3614,8 +3616,6 @@
|
||||
|
||||
"@vercel/backends/path-to-regexp": ["path-to-regexp@8.3.0", "", {}, "sha512-7jdwVIRtsP8MYpdXSwOS0YdD0Du+qOoF/AEPIt88PcCFrZCzx41oxku1jD88hZBwbNUIEfpqvuhjFaMAqMTWnA=="],
|
||||
|
||||
"@vercel/backends/resolve.exports": ["resolve.exports@2.0.3", "", {}, "sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A=="],
|
||||
|
||||
"@vercel/backends/rolldown": ["rolldown@1.0.0-rc.1", "", { "dependencies": { "@oxc-project/types": "=0.110.0", "@rolldown/pluginutils": "1.0.0-rc.1" }, "optionalDependencies": { "@rolldown/binding-android-arm64": "1.0.0-rc.1", "@rolldown/binding-darwin-arm64": "1.0.0-rc.1", "@rolldown/binding-darwin-x64": "1.0.0-rc.1", "@rolldown/binding-freebsd-x64": "1.0.0-rc.1", "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.1", "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.1", "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.1", "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.1", "@rolldown/binding-linux-x64-musl": "1.0.0-rc.1", "@rolldown/binding-openharmony-arm64": "1.0.0-rc.1", "@rolldown/binding-wasm32-wasi": "1.0.0-rc.1", "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.1", "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.1" }, "bin": { "rolldown": "bin/cli.mjs" } }, "sha512-M3AeZjYE6UclblEf531Hch0WfVC/NOL43Cc+WdF3J50kk5/fvouHhDumSGTh0oRjbZ8C4faaVr5r6Nx1xMqDGg=="],
|
||||
|
||||
"@vercel/backends/zod": ["zod@3.22.4", "", {}, "sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg=="],
|
||||
@@ -3790,6 +3790,8 @@
|
||||
|
||||
"finalhandler/encodeurl": ["encodeurl@1.0.2", "", {}, "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w=="],
|
||||
|
||||
"foreground-child/cross-spawn": ["cross-spawn@7.0.6", "", { "dependencies": { "path-key": "^3.1.0", "shebang-command": "^2.0.0", "which": "^2.0.1" } }, "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA=="],
|
||||
|
||||
"global-prefix/which": ["which@1.3.1", "", { "dependencies": { "isexe": "^2.0.0" }, "bin": { "which": "./bin/which" } }, "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ=="],
|
||||
|
||||
"globby/fast-glob": ["fast-glob@3.3.2", "", { "dependencies": { "@nodelib/fs.stat": "^2.0.2", "@nodelib/fs.walk": "^1.2.3", "glob-parent": "^5.1.2", "merge2": "^1.3.0", "micromatch": "^4.0.4" } }, "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow=="],
|
||||
@@ -4058,6 +4060,10 @@
|
||||
|
||||
"@jridgewell/source-map/@jridgewell/trace-mapping/@jridgewell/sourcemap-codec": ["@jridgewell/sourcemap-codec@1.5.0", "", {}, "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ=="],
|
||||
|
||||
"@node-minify/core/glob/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
|
||||
|
||||
"@node-minify/core/glob/path-scurry": ["path-scurry@1.11.1", "", { "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" } }, "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA=="],
|
||||
|
||||
"@opennextjs/aws/express/body-parser": ["body-parser@2.2.1", "", { "dependencies": { "bytes": "^3.1.2", "content-type": "^1.0.5", "debug": "^4.4.3", "http-errors": "^2.0.0", "iconv-lite": "^0.7.0", "on-finished": "^2.4.1", "qs": "^6.14.0", "raw-body": "^3.0.1", "type-is": "^2.0.1" } }, "sha512-nfDwkulwiZYQIGwxdy0RUmowMhKcFVcYXUU7m4QlKYim1rUtg83xm2yjZ40QjDuc291AJjjeSc9b++AWHSgSHw=="],
|
||||
|
||||
"@opennextjs/aws/express/cookie": ["cookie@0.7.1", "", {}, "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w=="],
|
||||
@@ -4420,6 +4426,10 @@
|
||||
|
||||
"remark-gfm/mdast-util-gfm/mdast-util-to-markdown": ["mdast-util-to-markdown@2.1.0", "", { "dependencies": { "@types/mdast": "^4.0.0", "@types/unist": "^3.0.0", "longest-streak": "^3.0.0", "mdast-util-phrasing": "^4.0.0", "mdast-util-to-string": "^4.0.0", "micromark-util-decode-string": "^2.0.0", "unist-util-visit": "^5.0.0", "zwitch": "^2.0.0" } }, "sha512-SR2VnIEdVNCJbP6y7kVTJgPLifdr8WEU440fQec7qHoHOUz/oJ2jmNRqdDQ3rbiStOXb2mCDGTuwsK5OPUgYlQ=="],
|
||||
|
||||
"rimraf/glob/foreground-child": ["foreground-child@3.3.0", "", { "dependencies": { "cross-spawn": "^7.0.0", "signal-exit": "^4.0.1" } }, "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg=="],
|
||||
|
||||
"rimraf/glob/jackspeak": ["jackspeak@3.4.3", "", { "dependencies": { "@isaacs/cliui": "^8.0.2" }, "optionalDependencies": { "@pkgjs/parseargs": "^0.11.0" } }, "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw=="],
|
||||
|
||||
"rimraf/glob/minimatch": ["minimatch@9.0.5", "", { "dependencies": { "brace-expansion": "^2.0.1" } }, "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow=="],
|
||||
|
||||
"rimraf/glob/minipass": ["minipass@7.1.2", "", {}, "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw=="],
|
||||
@@ -4472,6 +4482,12 @@
|
||||
|
||||
"@headlessui/react/@floating-ui/react/@floating-ui/react-dom/@floating-ui/dom": ["@floating-ui/dom@1.7.5", "", { "dependencies": { "@floating-ui/core": "^1.7.4", "@floating-ui/utils": "^0.2.10" } }, "sha512-N0bD2kIPInNHUHehXhMke1rBGs1dwqvC9O9KYMyyjK7iXt7GAhnro7UlcuYcGdS/yYOlq0MAVgrow8IbWJwyqg=="],
|
||||
|
||||
"@node-minify/core/glob/minimatch/brace-expansion": ["brace-expansion@2.0.1", "", { "dependencies": { "balanced-match": "^1.0.0" } }, "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA=="],
|
||||
|
||||
"@node-minify/core/glob/path-scurry/lru-cache": ["lru-cache@10.4.3", "", {}, "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ=="],
|
||||
|
||||
"@node-minify/core/glob/path-scurry/minipass": ["minipass@7.1.2", "", {}, "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw=="],
|
||||
|
||||
"@opennextjs/aws/express/body-parser/raw-body": ["raw-body@3.0.2", "", { "dependencies": { "bytes": "~3.1.2", "http-errors": "~2.0.1", "iconv-lite": "~0.7.0", "unpipe": "~1.0.0" } }, "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA=="],
|
||||
|
||||
"@opennextjs/aws/express/mime-types/mime-db": ["mime-db@1.53.0", "", {}, "sha512-oHlN/w+3MQ3rba9rqFr6V/ypF10LSkdwUysQL7GkXoTgIWeV+tcXGA852TBxH+gsh8UWoyhR1hKcoMJTuWflpg=="],
|
||||
@@ -4554,6 +4570,8 @@
|
||||
|
||||
"@headlessui/react/@floating-ui/react/@floating-ui/react-dom/@floating-ui/dom/@floating-ui/core": ["@floating-ui/core@1.7.4", "", { "dependencies": { "@floating-ui/utils": "^0.2.10" } }, "sha512-C3HlIdsBxszvm5McXlB8PeOEWfBhcGBTZGkGlWc2U0KFY5IwG5OQEuQ8rq52DZmcHDlPLd+YFBK+cZcytwIFWg=="],
|
||||
|
||||
"@node-minify/core/glob/minimatch/brace-expansion/balanced-match": ["balanced-match@1.0.2", "", {}, "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="],
|
||||
|
||||
"@opennextjs/aws/express/body-parser/raw-body/http-errors": ["http-errors@2.0.1", "", { "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", "setprototypeof": "~1.2.0", "statuses": "~2.0.2", "toidentifier": "~1.0.1" } }, "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ=="],
|
||||
|
||||
"@opennextjs/aws/express/qs/side-channel/object-inspect": ["object-inspect@1.13.4", "", {}, "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew=="],
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@
|
||||
"decode-named-character-reference@1.0.2": "patches/decode-named-character-reference@1.0.2.patch",
|
||||
"@vercel/next@4.4.2": "patches/@vercel%2Fnext@4.4.2.patch",
|
||||
"mermaid@11.16.1": "patches/mermaid@11.16.1.patch",
|
||||
"next@16.4.6": "patches/next@16.4.6.patch",
|
||||
"next@16.4.5": "patches/next@16.4.5.patch",
|
||||
"@shikijs/langs@3.21.0": "patches/@shikijs%2Flangs@3.21.0.patch"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,8 +158,6 @@
|
||||
z-index: 9998;
|
||||
width: calc(min(var(--gitbook-widget-window-width), calc(100vw - var(--gitbook-widget-right) - var(--gitbook-widget-left))));
|
||||
height: calc(min(var(--gitbook-widget-window-height), calc(100vh - var(--gitbook-widget-window-bottom) - var(--gitbook-widget-top))));
|
||||
/* stylelint-disable-next-line plugin/no-unsupported-browser-features -- the `vh` declaration above is the fallback on host pages whose browser lacks `dvh` */
|
||||
height: calc(min(var(--gitbook-widget-window-height), calc(100dvh - var(--gitbook-widget-window-bottom) - var(--gitbook-widget-top))));
|
||||
background-color: var(--gitbook-widget-background-translucent);
|
||||
backdrop-filter: blur(48px);
|
||||
border: 1px solid var(--gitbook-widget-border-color);
|
||||
|
||||
@@ -1751,7 +1751,7 @@ const testCases: TestsCase[] = [
|
||||
name: 'Navigation to shared space',
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const sharedSpaceLink = page.locator('a.link');
|
||||
const sharedSpaceLink = page.locator('a.underline');
|
||||
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.link').click();
|
||||
await page.locator('a.underline').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.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Alpha users' });
|
||||
const betaUserPage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/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.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Alpha users' });
|
||||
const betaUserPage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/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.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Alpha users' });
|
||||
const betaUserPage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta users' });
|
||||
await expect(alphaUserPage).toBeVisible();
|
||||
await expect(betaUserPage).toBeVisible();
|
||||
@@ -2383,12 +2383,14 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(alphaUserPage).toHaveCount(0);
|
||||
@@ -2420,12 +2422,14 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(alphaUserPage).toBeVisible();
|
||||
@@ -2457,12 +2461,14 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(betaUserPage).toBeVisible();
|
||||
@@ -2495,12 +2501,14 @@ const testCases: TestsCase[] = [
|
||||
url: '',
|
||||
run: async (page) => {
|
||||
const welcomePage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Welcome Page' });
|
||||
const alphaUserPage = page
|
||||
.locator('a.toclink')
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Alpha User' });
|
||||
const betaUserPage = page.locator('a.toclink').filter({ hasText: 'Beta User' });
|
||||
const betaUserPage = page
|
||||
.locator('a[class*="group\\/toclink"]')
|
||||
.filter({ hasText: 'Beta User' });
|
||||
|
||||
await expect(welcomePage).toBeVisible();
|
||||
await expect(betaUserPage).toBeVisible();
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"@gitbook/react-openapi": "workspace:*",
|
||||
"@mermaid-js/mermaid-zenuml": "^0.2.2",
|
||||
"@modelcontextprotocol/sdk": "1.17.5",
|
||||
"@opennextjs/aws": "4.1.16",
|
||||
"@opennextjs/cloudflare": "1.20.17",
|
||||
"@opennextjs/aws": "4.1.15",
|
||||
"@opennextjs/cloudflare": "1.20.16",
|
||||
"@panzoom/panzoom": "^4.6.1",
|
||||
"@sindresorhus/fnv1a": "^3.1.0",
|
||||
"@tailwindcss/container-queries": "^0.1.1",
|
||||
@@ -51,7 +51,7 @@
|
||||
"micromark-extension-gfm": "^3.0.0",
|
||||
"motion": "^12.23.24",
|
||||
"negotiator": "^1.0.0",
|
||||
"next": "^16.4.6",
|
||||
"next": "^16.4.5",
|
||||
"next-themes": "^0.4.6",
|
||||
"nuqs": "^2.2.3",
|
||||
"object-hash": "^3.0.0",
|
||||
|
||||
+19
-47
@@ -1,13 +1,10 @@
|
||||
import { type NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
import { orderSearchResultGroups } from './orderSearchResults';
|
||||
import type {
|
||||
OrderedComputedResult,
|
||||
SearchSiteContentRequest,
|
||||
} from '@/components/Search/search-types';
|
||||
import type { SearchSiteContentRequest } from '@/components/Search/search-types';
|
||||
import { throwIfDataError } from '@/lib/data';
|
||||
import { getSiteURLDataFromMiddleware } from '@/lib/middleware';
|
||||
import { transformSitePageResult } from '@/lib/search';
|
||||
import { computeSearchResults } from '@/lib/search-results';
|
||||
import { getServerActionBaseContext } from '@/lib/server-actions';
|
||||
import { findSiteSpaceBy, getLinkerForSiteSpace } from '@/lib/sites';
|
||||
|
||||
@@ -56,49 +53,24 @@ export async function POST(request: NextRequest) {
|
||||
? getLinkerForSiteSpace(context.linker, currentSiteSpace.siteSpace, revision.pages)
|
||||
: context.linker;
|
||||
|
||||
const results = orderSearchResultGroups<OrderedComputedResult>(
|
||||
searchResults.map((resultItem) => {
|
||||
if (resultItem.type === 'record') {
|
||||
const result: OrderedComputedResult = {
|
||||
type: 'record',
|
||||
id: resultItem.id,
|
||||
title: resultItem.title,
|
||||
description: resultItem.description,
|
||||
href: resultItem.url,
|
||||
score: resultItem.score,
|
||||
};
|
||||
const results = computeSearchResults(searchResults, (spaceItem, pageItem) => {
|
||||
const isCurrentRevisionSpace = Boolean(revision && spaceItem.id === siteURLData.space);
|
||||
const found =
|
||||
isCurrentRevisionSpace && currentSiteSpace
|
||||
? currentSiteSpace
|
||||
: findSiteSpaceBy(structure, (siteSpace) => siteSpace.space.id === spaceItem.id);
|
||||
|
||||
return { type: 'context' as const, results: [result] };
|
||||
}
|
||||
|
||||
const isCurrentRevisionSpace = Boolean(revision && resultItem.id === siteURLData.space);
|
||||
const found =
|
||||
isCurrentRevisionSpace && currentSiteSpace
|
||||
? currentSiteSpace
|
||||
: findSiteSpaceBy(
|
||||
structure,
|
||||
(siteSpace) => siteSpace.space.id === resultItem.id
|
||||
);
|
||||
|
||||
return {
|
||||
type: 'pages' as const,
|
||||
results: resultItem.pages.flatMap((pageItem) => {
|
||||
const result = transformSitePageResult({
|
||||
asEmbeddable: Boolean(asEmbeddable),
|
||||
linker: isCurrentRevisionSpace ? revisionLinker : context.linker,
|
||||
pageItem,
|
||||
spaceItem: resultItem,
|
||||
siteSpace: found?.siteSpace,
|
||||
siteSection: found?.siteSection ?? undefined,
|
||||
siteSectionGroup: found?.siteSectionGroup ?? undefined,
|
||||
revisionPages: isCurrentRevisionSpace ? revision?.pages : undefined,
|
||||
});
|
||||
|
||||
return result ? [{ rank: pageItem.rank, result }] : [];
|
||||
}),
|
||||
};
|
||||
})
|
||||
);
|
||||
return transformSitePageResult({
|
||||
asEmbeddable: Boolean(asEmbeddable),
|
||||
linker: isCurrentRevisionSpace ? revisionLinker : context.linker,
|
||||
pageItem,
|
||||
spaceItem,
|
||||
siteSpace: found?.siteSpace,
|
||||
siteSection: found?.siteSection ?? undefined,
|
||||
siteSectionGroup: found?.siteSectionGroup ?? undefined,
|
||||
revisionPages: isCurrentRevisionSpace ? revision?.pages : undefined,
|
||||
});
|
||||
});
|
||||
|
||||
return NextResponse.json(results);
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ 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';
|
||||
@@ -39,16 +38,20 @@ export function AnnouncementBanner(props: {
|
||||
const style = BANNER_STYLES[announcement.style];
|
||||
|
||||
return (
|
||||
<div data-gb-announcement-banner className="announcement" data-nosnippet="">
|
||||
<div className="chrome-shift">
|
||||
<div className={cx(CONTAINER_STYLE, 'relative')}>
|
||||
<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)}>
|
||||
<Tag
|
||||
href={contentRef?.href ?? ''}
|
||||
className={cx(
|
||||
'announcement-box',
|
||||
`announcement-${announcement.style}`,
|
||||
closeable && 'announcement-closeable',
|
||||
hasLink && 'announcement-linked'
|
||||
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
|
||||
)}
|
||||
insights={
|
||||
announcement.link
|
||||
@@ -62,7 +65,10 @@ export function AnnouncementBanner(props: {
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Icon icon={style.icon as IconName} className="announcement-icon" />
|
||||
<Icon
|
||||
icon={style.icon as IconName}
|
||||
className={`mr-3 mt-0.5 size-4 shrink-0 ${style.iconColor}`}
|
||||
/>
|
||||
<div>
|
||||
{message}
|
||||
{hasLink ? (
|
||||
@@ -79,7 +85,7 @@ export function AnnouncementBanner(props: {
|
||||
? 'arrow-up-right'
|
||||
: 'chevron-right'
|
||||
}
|
||||
className="mb-0.5 inline size-3"
|
||||
className={tcls('mb-0.5 inline size-3')}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
@@ -117,23 +123,35 @@ function dismissAnnouncement() {
|
||||
|
||||
const BANNER_STYLES = {
|
||||
info: {
|
||||
container: 'bg-info ring-info-subtle',
|
||||
hover: 'hover:bg-info-hover active:bg-info-active',
|
||||
icon: 'circle-info',
|
||||
close: 'hover:ring-info-subtle',
|
||||
iconColor: 'text-info-subtle',
|
||||
close: 'hover:bg-tint-base hover:ring-info-subtle',
|
||||
link: '',
|
||||
},
|
||||
warning: {
|
||||
container: 'bg-warning decoration-warning/6 ring-warning-subtle',
|
||||
hover: 'hover:bg-warning-hover',
|
||||
icon: 'circle-exclamation',
|
||||
close: 'hover:ring-warning-subtle',
|
||||
iconColor: 'text-warning-subtle',
|
||||
close: 'hover:bg-tint-base 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',
|
||||
close: 'hover:ring-danger-subtle',
|
||||
iconColor: 'text-danger-subtle',
|
||||
close: 'hover:bg-tint-base 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',
|
||||
close: 'hover:ring-success-subtle',
|
||||
iconColor: 'text-success-subtle',
|
||||
close: 'hover:bg-tint-base hover:ring-success-subtle',
|
||||
link: 'links-default:text-success hover:links-default:text-success-strong links-default:decoration-success/6 links-accent:decoration-success',
|
||||
},
|
||||
};
|
||||
|
||||
@@ -57,6 +57,7 @@ export function CookiesToast(props: { privacyPolicy?: string }) {
|
||||
<div
|
||||
role="dialog"
|
||||
data-testid="cookies-dialog"
|
||||
aria-modal="true"
|
||||
aria-label={tString(language, 'cookies_title')}
|
||||
aria-describedby={describedById}
|
||||
className={tcls(
|
||||
|
||||
@@ -19,7 +19,7 @@ export function AnnotationPopover(props: { children: React.ReactNode; body: Reac
|
||||
>
|
||||
<dfn
|
||||
data-annotation=""
|
||||
className="cursor-help not-italic underline decoration-dotted decoration-1 underline-offset-2"
|
||||
className="not-italic cursor-help 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/classnames';
|
||||
import type { ClassValue } from '@/lib/tailwind';
|
||||
import { nullIfNever } from '@/lib/typescript';
|
||||
|
||||
export interface BlockProps<Block extends DocumentBlock> extends DocumentContextProps {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
@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,10 +1,11 @@
|
||||
import type { DocumentBlock, JSONDocument } from '@gitbook/api';
|
||||
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { CONTENT_STYLE, CONTENT_STYLE_REDUCED } from '../layout';
|
||||
import { Block } from './Block';
|
||||
import './Blocks.css';
|
||||
import type { DocumentContextProps } from './DocumentView';
|
||||
import { isBlockOffscreen } from './utils';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Renders a list of blocks with a wrapper element.
|
||||
@@ -24,7 +25,7 @@ export function Blocks<TBlock extends DocumentBlock, Tag extends React.ElementTy
|
||||
const { tag: Tag = 'div', style, wrapperProps, ...blocksProps } = props;
|
||||
|
||||
return (
|
||||
<Tag {...wrapperProps} className={cx(style)}>
|
||||
<Tag {...wrapperProps} className={tcls(style)}>
|
||||
<UnwrappedBlocks {...blocksProps} />
|
||||
</Tag>
|
||||
);
|
||||
@@ -93,9 +94,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,
|
||||
FULL_WIDTH_BLOCKS.has(node.type) ? CONTENT_STYLE : CONTENT_STYLE_REDUCED,
|
||||
|
||||
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: 'gb-caption-center',
|
||||
left: 'gb-caption-left',
|
||||
right: 'gb-caption-right',
|
||||
center: 'mx-auto',
|
||||
left: 'mr-auto ml-0',
|
||||
right: 'mr-0 ml-auto',
|
||||
} satisfies Record<CaptionAlign, ClassValue>;
|
||||
|
||||
/**
|
||||
@@ -51,10 +51,17 @@ export function Caption(
|
||||
withBorder = false,
|
||||
withFrame = false,
|
||||
wrapperStyle = [
|
||||
'gb-caption-media',
|
||||
fit && 'gb-caption-fit',
|
||||
withBorder && 'gb-caption-bordered',
|
||||
withFrame && 'gb-caption-framed',
|
||||
'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',
|
||||
],
|
||||
style,
|
||||
align = 'center',
|
||||
@@ -72,16 +79,23 @@ export function Caption(
|
||||
isNodeEmpty(captionParagraph)
|
||||
) {
|
||||
return (
|
||||
<div {...anchorProps} className={cx(style, wrapperStyle)}>
|
||||
<div {...anchorProps} className={tcls(style, wrapperStyle)}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<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')}>
|
||||
<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'
|
||||
)}
|
||||
>
|
||||
<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, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
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={cx(style, 'codeblock-button-ask')}
|
||||
className={tcls(style, 'translate-y-0!', 'print:hidden', '[[data-ai-chat]_&]:hidden')}
|
||||
>
|
||||
{t(language, 'ask')}
|
||||
</Button>
|
||||
|
||||
@@ -9,7 +9,6 @@ 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'> & {
|
||||
@@ -56,16 +55,28 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
id={codeId}
|
||||
{...getCommentKeyAttributes(commentKey)}
|
||||
aria-busy={ariaBusy}
|
||||
className={cx('shiki codeblock', !embedded && 'codeblock-framed', tcls(style))}
|
||||
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
|
||||
)}
|
||||
/* 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="codeblock-focus" />
|
||||
<div className="codeblock-header">
|
||||
<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">
|
||||
{withTitle ? (
|
||||
<div
|
||||
className="codeblock-title"
|
||||
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"
|
||||
style={{
|
||||
backgroundColor: bg?.color,
|
||||
...bg?.vars,
|
||||
@@ -77,12 +88,12 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="codeblock-body">
|
||||
<div className="relative flex min-h-0 flex-col">
|
||||
{!embedded ? (
|
||||
<div
|
||||
className={cx(
|
||||
'codeblock-actions',
|
||||
isSingleLine && 'codeblock-actions-centered'
|
||||
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'
|
||||
)}
|
||||
>
|
||||
{!isPrint ? (
|
||||
@@ -90,17 +101,21 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
codeId={codeId}
|
||||
title={title}
|
||||
syntax={block.data.syntax}
|
||||
style="codeblock-button"
|
||||
style="backdrop-blur-md"
|
||||
/>
|
||||
) : null}
|
||||
<CopyCodeButton codeId={codeId} style="codeblock-button" />
|
||||
<CopyCodeButton codeId={codeId} style="backdrop-blur-md" />
|
||||
</div>
|
||||
) : null}
|
||||
<pre
|
||||
className={cx(
|
||||
'codeblock-pre',
|
||||
embedded ? 'codeblock-pre-embedded' : 'codeblock-pre-framed',
|
||||
withTitle && 'codeblock-pre-titled'
|
||||
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!'
|
||||
)}
|
||||
style={{
|
||||
backgroundColor: codeBackground?.color,
|
||||
@@ -109,7 +124,13 @@ export const CodeBlockRenderer = forwardRef(function CodeBlockRenderer(
|
||||
...fg?.vars,
|
||||
}}
|
||||
>
|
||||
<code className={cx('codeblock-code', withWrap && 'codeblock-code-wrap')}>
|
||||
<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%'
|
||||
)}
|
||||
>
|
||||
{theme.lines.map((line, index) => (
|
||||
<CodeHighlightLine
|
||||
bg={codeBackground}
|
||||
@@ -146,9 +167,9 @@ function CodeHighlightLine(props: {
|
||||
};
|
||||
return (
|
||||
<span
|
||||
className={cx(
|
||||
className={tcls(
|
||||
'highlight-line',
|
||||
embeddedPlainLine && 'highlight-line-plain',
|
||||
embeddedPlainLine && 'bg-transparent! hover:bg-tint-subtle!',
|
||||
line.diff === 'added' && 'diff-added',
|
||||
line.diff === 'deleted' && 'diff-deleted',
|
||||
line.highlighted && 'highlighted'
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
'use client';
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import { getCodeTextFromId } from './utils';
|
||||
import { useCopyToClipboard } from '@/components/hooks';
|
||||
import { Button } from '@/components/primitives';
|
||||
import { t, useLanguage } from '@/intl/client';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Client component to copy the code of a code block.
|
||||
@@ -14,25 +15,41 @@ export function CopyCodeButton(props: { codeId: string; style: ClassValue }) {
|
||||
const { codeId, style } = props;
|
||||
|
||||
const language = useLanguage();
|
||||
const { copied, copy } = useCopyToClipboard();
|
||||
const [copied, setCopied] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!copied) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
setCopied(false);
|
||||
}, 1000);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [copied]);
|
||||
|
||||
const onClick = () => {
|
||||
const codeText = getCodeTextFromId(codeId);
|
||||
if (codeText === null) {
|
||||
return;
|
||||
}
|
||||
copy(codeText);
|
||||
|
||||
navigator.clipboard.writeText(codeText);
|
||||
|
||||
setCopied(true);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<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. */}
|
||||
<span role="status" className="sr-only">
|
||||
{copied ? t(language, 'code_copied') : null}
|
||||
</span>
|
||||
</>
|
||||
<Button
|
||||
size="xsmall"
|
||||
variant="secondary"
|
||||
onClick={onClick}
|
||||
className={tcls(style, 'translate-y-0!', 'print:hidden')}
|
||||
>
|
||||
{t(language, copied ? 'code_copied' : 'code_copy')}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ 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>) {
|
||||
@@ -41,7 +40,10 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
|
||||
<div
|
||||
// The app doesn't allow comments inside columns.
|
||||
{...getCommentMarkerProps(context, 'data-comment-ignore')}
|
||||
className={cx('column-set', tcls(style))}
|
||||
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
|
||||
)}
|
||||
style={{ '--grid-slices': COLUMN_DIVISIONS } as React.CSSProperties}
|
||||
>
|
||||
{block.nodes.map((columnBlock, index) => {
|
||||
@@ -63,8 +65,7 @@ export function Columns(props: BlockProps<DocumentBlockColumns>) {
|
||||
document={document}
|
||||
ancestorBlocks={[...ancestorBlocks, block, columnBlock]}
|
||||
context={context}
|
||||
// `*:max-w-full` stays a utility to beat the blocks' own `max-w-*`.
|
||||
style="group/column column-set-body *:max-w-full"
|
||||
style="group/column w-full space-y-4 *:max-w-full"
|
||||
/>
|
||||
</Column>
|
||||
);
|
||||
@@ -82,10 +83,13 @@ export function Column(props: {
|
||||
const { className, style } = transformLengthToCSS(width) ?? {};
|
||||
return (
|
||||
<div
|
||||
className={cx(
|
||||
'column-set-item',
|
||||
verticalAlignment === VerticalAlignment.Middle && 'column-set-item-middle',
|
||||
verticalAlignment === VerticalAlignment.Bottom && 'column-set-item-bottom',
|
||||
className={tcls(
|
||||
'flex flex-col',
|
||||
'@container/column',
|
||||
(verticalAlignment === VerticalAlignment.Top || !verticalAlignment) &&
|
||||
'justify-start',
|
||||
verticalAlignment === VerticalAlignment.Middle && 'justify-center',
|
||||
verticalAlignment === VerticalAlignment.Bottom && 'justify-end',
|
||||
className
|
||||
)}
|
||||
style={style}
|
||||
@@ -103,7 +107,7 @@ export function transformLengthToCSS(length: Length) {
|
||||
}
|
||||
if (length.unit === '%') {
|
||||
return {
|
||||
className: 'column-set-item-sized',
|
||||
className: '@2xl:flex-shrink-0 @2xl:[grid-column:var(--grid-col)]',
|
||||
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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function Divider(props: BlockProps<DocumentBlockDivider>) {
|
||||
const { style } = props;
|
||||
|
||||
return <hr className={cx(style, 'border-tint-subtle')} />;
|
||||
return <hr className={tcls(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, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Details component rendered on client so it can expand dependent on url hash changes.
|
||||
@@ -50,7 +50,27 @@ export function Details(props: {
|
||||
id={id}
|
||||
data-block-key={props.commentKey}
|
||||
open={props.open || openFromHash}
|
||||
className={cx('expandable', className)}
|
||||
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'
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</details>
|
||||
|
||||
@@ -10,7 +10,6 @@ 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';
|
||||
|
||||
@@ -41,16 +40,37 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
|
||||
id={id}
|
||||
{...getCommentKeyProp(context, block.key)}
|
||||
open={context.mode === 'print' || isDefaultExpanded}
|
||||
className={tcls(style)}
|
||||
className={tcls('scroll-mt-(--content-scroll-margin)', style)}
|
||||
>
|
||||
<summary
|
||||
{...getCommentAnchorProps(context, titleParagraph.key)}
|
||||
className={cx('expandable-summary', showHashLink && 'expandable-summary-anchored')}
|
||||
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'
|
||||
)}
|
||||
>
|
||||
<ToggleChevron
|
||||
orientation="right-to-down"
|
||||
open={context.mode === 'print'}
|
||||
className="expandable-chevron"
|
||||
className={tcls(
|
||||
'inline-block',
|
||||
'size-3',
|
||||
'mr-3',
|
||||
'mb-1',
|
||||
'shrink-0',
|
||||
'group-open/expandable:rotate-90'
|
||||
)}
|
||||
/>
|
||||
<Inlines
|
||||
nodes={titleParagraph.nodes}
|
||||
@@ -62,9 +82,28 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
|
||||
<a
|
||||
href={`#${id}`}
|
||||
aria-label={tString(language, 'direct_link_to_heading')}
|
||||
className="expandable-anchor"
|
||||
className={tcls(
|
||||
'absolute',
|
||||
'top-2',
|
||||
'bottom-2',
|
||||
'right-4',
|
||||
'flex',
|
||||
'items-center',
|
||||
'dark:shadow-none',
|
||||
'dark:ring-0'
|
||||
)}
|
||||
>
|
||||
<Icon icon="hashtag" className="expandable-anchor-icon" />
|
||||
<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'
|
||||
)}
|
||||
/>
|
||||
</a>
|
||||
) : null}
|
||||
</summary>
|
||||
@@ -73,7 +112,7 @@ export async function Expandable(props: BlockProps<DocumentBlockExpandable>) {
|
||||
document={document}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
context={context}
|
||||
style="expandable-body"
|
||||
style="space-y-4 px-10 pb-5"
|
||||
/>
|
||||
</Details>
|
||||
);
|
||||
|
||||
@@ -41,12 +41,12 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
|
||||
|
||||
return (
|
||||
<Caption {...props} withBorder withBlockKey>
|
||||
<div className="file-block">
|
||||
<div className="file-block-preview">
|
||||
<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">
|
||||
{contentType === 'image' ? (
|
||||
<Image
|
||||
alt={file.name}
|
||||
className="file-block-image"
|
||||
className="h-auto max-h-10 w-auto max-w-10 rounded object-contain"
|
||||
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="file-block-icon" />
|
||||
<FileIcon contentType={contentType} className="size-5 text-primary" />
|
||||
)}
|
||||
</div>
|
||||
<div className="file-block-info">
|
||||
<div className="file-block-name">
|
||||
<div className="min-w-24 flex-1">
|
||||
<div className="text-base">
|
||||
<Link
|
||||
href={file.downloadURL}
|
||||
target="_blank"
|
||||
@@ -72,13 +72,13 @@ export async function File(props: BlockProps<DocumentBlockFile>) {
|
||||
{file.name}
|
||||
</Link>
|
||||
</div>
|
||||
<div className="file-block-meta">
|
||||
<div className="text-sm text-tint-subtle">
|
||||
{contentType
|
||||
? `${contentType} · ${getHumanFileSize(file.size)}`
|
||||
: getHumanFileSize(file.size)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="file-block-actions">
|
||||
<div className="flex shrink-0 flex-wrap gap-2">
|
||||
<DownloadButton
|
||||
icon="download"
|
||||
size="xsmall"
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
@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,7 +3,9 @@ import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { Link } from '../primitives';
|
||||
import type { DocumentContext } from './DocumentView';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import './HashLinkButton.css';
|
||||
import { getBlockTextStyle } from './spacing';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Whether blocks should render a visible anchor link icon.
|
||||
@@ -19,8 +21,10 @@ export function shouldShowHashLinks(context: DocumentContext): boolean {
|
||||
|
||||
/**
|
||||
* A hash icon which adds the block or active block item's ID in the URL hash.
|
||||
* Styled in `styles/blocks.css`, it is revealed when hovering its `.heading` parent.
|
||||
* The button needs to be wrapped in a container with `hashLinkButtonWrapperStyles`.
|
||||
*/
|
||||
export const hashLinkButtonWrapperStyles = tcls('relative', 'group/hash');
|
||||
|
||||
export function HashLinkButton(props: {
|
||||
id: string;
|
||||
block: DocumentBlockTabs | DocumentBlockHeading;
|
||||
@@ -28,12 +32,17 @@ export function HashLinkButton(props: {
|
||||
className?: ClassValue;
|
||||
iconClassName?: ClassValue;
|
||||
}) {
|
||||
const { id, className, iconClassName, label } = props;
|
||||
const { id, block, className, iconClassName, label } = props;
|
||||
const textStyle = getBlockTextStyle(block);
|
||||
|
||||
return (
|
||||
<span className={cx('hash', className)}>
|
||||
<Link href={`#${id}`} aria-label={label} className="hash-link">
|
||||
<Icon icon="hashtag" className={cx('hash-icon', iconClassName)} />
|
||||
<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)} />
|
||||
</Link>
|
||||
</span>
|
||||
);
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import type { DocumentBlockHeading } from '@gitbook/api';
|
||||
|
||||
import type { BlockProps } from './Block';
|
||||
import { HashLinkButton, shouldShowHashLinks } from './HashLinkButton';
|
||||
import { HashLinkButton, hashLinkButtonWrapperStyles, 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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
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 ?? '';
|
||||
@@ -28,20 +31,38 @@ export async function Heading(props: BlockProps<DocumentBlockHeading>) {
|
||||
as={Tag}
|
||||
id={id}
|
||||
{...getCommentAnchorProps(context, block.key)}
|
||||
className={cx(
|
||||
className={tcls(
|
||||
textStyle.textSize,
|
||||
'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),
|
||||
style
|
||||
hashLinkButtonWrapperStyles,
|
||||
style,
|
||||
textStyle.marginTop
|
||||
)}
|
||||
>
|
||||
<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={cx('heading-text', getTextAlignment(block.data.align))}
|
||||
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
|
||||
)}
|
||||
>
|
||||
<Inlines {...rest} context={context} nodes={block.nodes} ancestorInlines={[]} />
|
||||
</span>
|
||||
@@ -50,6 +71,15 @@ 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, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
const HEADING_ATTR = 'data-heading-reveal-wrapper';
|
||||
|
||||
@@ -87,7 +87,7 @@ export function HeadingRevealWrapper(props: {
|
||||
return (
|
||||
<Tag
|
||||
id={id}
|
||||
className={cx(className, revealed && 'hash-revealed')}
|
||||
className={tcls(className, revealed && 'hash-revealed')}
|
||||
onPointerUp={handlePointerUp}
|
||||
{...{ [HEADING_ATTR]: true }}
|
||||
{...rest}
|
||||
|
||||
@@ -4,11 +4,11 @@ import { validateIconName } from '@gitbook/icons/icons';
|
||||
|
||||
import { Block, type BlockProps } from './Block';
|
||||
import { Blocks } from './Blocks';
|
||||
import { BLOCK_LINE_HEIGHT, getBlockTextKind } from './spacing';
|
||||
import { getBlockTextStyle } 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 firstLineHeight = BLOCK_LINE_HEIGHT[getBlockTextKind(firstNode)];
|
||||
const firstLine = getBlockTextStyle(firstNode);
|
||||
const hasHeading = isHeadingBlock(firstNode);
|
||||
|
||||
const language = contextProps.context.contentContext
|
||||
@@ -33,25 +33,42 @@ export async function Hint({
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cx(
|
||||
className={tcls(
|
||||
'hint',
|
||||
hasHeading && 'hint-titled',
|
||||
// Kept as utilities: `AskAIParagraphButton` matches `.hint.bg-*`.
|
||||
hasHeading ? hintStyle.containerWithHeader : hintStyle.container,
|
||||
'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]' : '',
|
||||
|
||||
style
|
||||
)}
|
||||
aria-label={label}
|
||||
role="note"
|
||||
>
|
||||
<div className={cx('hint-aside', hasHeading && hintStyle.header, hintStyle.iconColor)}>
|
||||
<Icon icon={icon} className={cx('hint-icon', firstLineHeight)} />
|
||||
<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>
|
||||
{hasHeading ? (
|
||||
<Block
|
||||
style={cx(
|
||||
'hint-heading flip-heading-hash',
|
||||
// A utility, to beat the themed backgrounds of `.hash`.
|
||||
'[&_.hash]:bg-transparent',
|
||||
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',
|
||||
hintStyle.header
|
||||
)}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
@@ -63,13 +80,27 @@ export async function Hint({
|
||||
{...contextProps}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
nodes={hasHeading ? block.nodes.slice(1) : block.nodes}
|
||||
blockStyle={cx(
|
||||
blockStyle={tcls(
|
||||
hintStyle.body,
|
||||
// render hash icon on the other side of the heading
|
||||
'flip-heading-hash'
|
||||
)}
|
||||
// Descendant rules stay utilities so they keep beating the nested blocks' own classes.
|
||||
style="hint-content [&_.hint]:border [&_pre]:border [&_pre]:border-neutral"
|
||||
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',
|
||||
]}
|
||||
/>
|
||||
</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,18 +17,30 @@ export function Images(props: BlockProps<DocumentBlockImages>) {
|
||||
return (
|
||||
<div
|
||||
{...getCommentAnchorProps(context, block.key)}
|
||||
className={cx(
|
||||
className={tcls(
|
||||
style,
|
||||
'gb-images',
|
||||
align === 'right' && 'gb-images-right',
|
||||
align === 'left' && 'gb-images-left'
|
||||
'flex',
|
||||
'w-full',
|
||||
align === 'center' && 'justify-center',
|
||||
align === 'right' && 'justify-end',
|
||||
align === 'left' && 'justify-start'
|
||||
)}
|
||||
>
|
||||
<div
|
||||
className={cx(
|
||||
'gb-images-row',
|
||||
hasMultipleImages && 'gb-images-multi',
|
||||
withFrame && 'gb-images-framed'
|
||||
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',
|
||||
]
|
||||
)}
|
||||
>
|
||||
{block.nodes.map((node: any, _i: number) => (
|
||||
@@ -88,7 +100,7 @@ async function ImageBlock(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="gb-image">
|
||||
<div className={tcls('relative', 'overflow-hidden')}>
|
||||
<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={cx('inline-icon', color ? textColorToStyle[color] : null)}
|
||||
className={tcls('inline size-[1em]', 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,7 +30,11 @@ 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={cx(size !== 'line' && 'inline-flex max-w-[300px] align-middle')}>
|
||||
<span
|
||||
className={tcls(
|
||||
size !== 'line' ? ['inline-flex', 'max-w-[300px]', 'align-middle'] : null
|
||||
)}
|
||||
>
|
||||
<Image
|
||||
alt={inline.data.alt ?? inline.data.caption ?? ''}
|
||||
sizes={sizes}
|
||||
|
||||
@@ -93,9 +93,15 @@ function InlineLinkAnchor(props: {
|
||||
>
|
||||
{children}
|
||||
{isMailto ? (
|
||||
<Icon icon="envelope" className="inline-link-icon inline-link-mail" />
|
||||
<Icon
|
||||
icon="envelope"
|
||||
className="ml-1 inline size-3 links-accent:text-tint-subtle"
|
||||
/>
|
||||
) : isExternal ? (
|
||||
<Icon icon="arrow-up-right" className="inline-link-icon" />
|
||||
<Icon
|
||||
icon="arrow-up-right"
|
||||
className="ml-0.5 inline size-3 links-accent:text-tint-subtle"
|
||||
/>
|
||||
) : null}
|
||||
</StyledLink>
|
||||
);
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
.contentkit-modal {
|
||||
@apply flex flex-col gap-6 relative z-50 bg-tint
|
||||
rounded shadow-lg opacity-0 transition-opacity duration-300 border border-tint
|
||||
w-full max-w-[768px] max-h-[90dvh] overflow-y-auto;
|
||||
w-full max-w-[768px] max-h-[90vh] overflow-y-auto;
|
||||
}
|
||||
.contentkit-modal.contentkit-modal-opened {
|
||||
@apply opacity-[1];
|
||||
|
||||
@@ -22,7 +22,7 @@ export function List(
|
||||
tag={getListTag(block.type)}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style={['gb-list', style]}
|
||||
style={['min-w-0 space-y-2', style]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,10 @@ import type {
|
||||
|
||||
import type { BlockProps } from './Block';
|
||||
import { Blocks } from './Blocks';
|
||||
import { getBlockTextKind } from './spacing';
|
||||
import { getBlockTextStyle } from './spacing';
|
||||
import { getCommentAnchorProps } from './utils';
|
||||
import { Checkbox } from '@/components/primitives';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function ListItem(props: BlockProps<DocumentBlockListItem>) {
|
||||
const { block, ancestorBlocks, ...contextProps } = props;
|
||||
@@ -32,8 +32,16 @@ export function ListItem(props: BlockProps<DocumentBlockListItem>) {
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
blockStyle="gb-list-child"
|
||||
style="gb-list-body"
|
||||
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"
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -51,7 +59,7 @@ export function ListItem(props: BlockProps<DocumentBlockListItem>) {
|
||||
/>
|
||||
</ListItemPrefix>
|
||||
|
||||
<label htmlFor={block.key} className="flex-1">
|
||||
<label htmlFor={block.key} className={tcls('flex-1')}>
|
||||
{blocksElement}
|
||||
</label>
|
||||
</ListItemLI>
|
||||
@@ -122,20 +130,27 @@ function ListItemLI(props: {
|
||||
anchorProps: ReturnType<typeof getCommentAnchorProps>;
|
||||
children: React.ReactNode;
|
||||
}) {
|
||||
const kind = getBlockTextKind(props.block);
|
||||
const textStyle = getBlockTextStyle(props.block);
|
||||
return (
|
||||
<li
|
||||
{...props.anchorProps}
|
||||
className={cx('gb-list-item', kind !== 'body' && `gb-list-item-${kind}`)}
|
||||
>
|
||||
<li {...props.anchorProps} className={tcls(textStyle.lineHeight, 'flex items-start')}>
|
||||
{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 }) {
|
||||
return <div className="gb-list-prefix">{props.children}</div>;
|
||||
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>
|
||||
);
|
||||
}
|
||||
|
||||
function getUnorderedListItemsPrefixContent(input: { depth: number }): string {
|
||||
@@ -158,7 +173,7 @@ function PseudoBefore(props: {
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className="gb-list-marker"
|
||||
className="before:content-(--pseudoBefore--content) before:font-var"
|
||||
style={
|
||||
{
|
||||
'--pseudoBefore--content': `'${props.content}'`,
|
||||
|
||||
@@ -16,8 +16,6 @@ import { matchesText } from '../Table/searchMatch';
|
||||
import { MIN_RECORDS_FOR_SEARCH } from '../Table/shouldShowSearch';
|
||||
import { Input } from '@/components/primitives';
|
||||
import { tString, useLanguage } from '@/intl/client';
|
||||
// Imported here, behind the `next/dynamic` boundary, so only pages with OpenAPI blocks load it.
|
||||
import './style.css';
|
||||
|
||||
// Only what survives the RSC boundary. Rebuilding the renderers on the client is what lets this
|
||||
// whole subtree sit behind a `next/dynamic` chunk instead of the route's eager entry.
|
||||
|
||||
@@ -17,6 +17,7 @@ import { PlainCodeBlock } from '../CodeBlock';
|
||||
import { DocumentView } from '../DocumentView';
|
||||
import { Heading } from '../Heading';
|
||||
import type { OpenAPIBlockClientContextProps } from './OpenAPIBlockClient';
|
||||
import './style.css';
|
||||
import { SCALAR_RUNTIME_PATH } from './scalar-runtime-path';
|
||||
import { DEFAULT_LOCALE, getSpaceLocale } from '@/intl/server';
|
||||
import { getAssetURL } from '@/lib/assets';
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/* Global, not in style.css: badges also show in the sidebar and outline of pages without OpenAPI blocks. */
|
||||
.openapi-method,
|
||||
.openapi-statuscode {
|
||||
@apply m-0 h-5 min-w-9 justify-center rounded-md text-xs straight-corners:rounded-none circular-corners:rounded-lg uppercase font-mono items-center shrink-0 font-semibold px-1.5 py-0.5 text-tint-12/8 leading-tight align-middle inline-flex whitespace-nowrap;
|
||||
}
|
||||
|
||||
.openapi-method-small {}
|
||||
|
||||
.openapi-method-medium {
|
||||
@apply m-0 px-2.5 py-1 h-6 text-[0.813rem];
|
||||
}
|
||||
|
||||
.toclink .openapi-method {
|
||||
@apply text-[0.625rem] flex items-center justify-center;
|
||||
}
|
||||
|
||||
.openapi-method-get,
|
||||
.openapi-statuscode-success {
|
||||
@apply bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100;
|
||||
}
|
||||
|
||||
.openapi-method-post,
|
||||
.openapi-statuscode-redirection {
|
||||
@apply bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-100;
|
||||
}
|
||||
|
||||
.openapi-method-put,
|
||||
.openapi-statuscode-informational {
|
||||
@apply bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-100;
|
||||
}
|
||||
|
||||
.openapi-method-patch {
|
||||
@apply bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-100;
|
||||
}
|
||||
|
||||
.openapi-method-delete,
|
||||
.openapi-statuscode-error {
|
||||
@apply bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100;
|
||||
}
|
||||
|
||||
.openapi-method-head,
|
||||
.openapi-method-options,
|
||||
.openapi-method-trace,
|
||||
.openapi-method-hook {
|
||||
@apply bg-tint;
|
||||
}
|
||||
@@ -143,6 +143,53 @@ button.openapi-mcp {
|
||||
@apply !mb-0;
|
||||
}
|
||||
|
||||
/* Method Tags */
|
||||
.openapi-method,
|
||||
.openapi-statuscode {
|
||||
@apply m-0 h-5 min-w-9 justify-center rounded-md text-xs straight-corners:rounded-none circular-corners:rounded-lg uppercase font-mono items-center shrink-0 font-semibold px-1.5 py-0.5 text-tint-12/8 leading-tight align-middle inline-flex whitespace-nowrap;
|
||||
}
|
||||
|
||||
.openapi-method-small {}
|
||||
|
||||
.openapi-method-medium {
|
||||
@apply m-0 px-2.5 py-1 h-6 text-[0.813rem];
|
||||
}
|
||||
|
||||
.toclink .openapi-method {
|
||||
@apply text-[0.625rem] flex items-center justify-center;
|
||||
}
|
||||
|
||||
.openapi-method-get,
|
||||
.openapi-statuscode-success {
|
||||
@apply bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100;
|
||||
}
|
||||
|
||||
.openapi-method-post,
|
||||
.openapi-statuscode-redirection {
|
||||
@apply bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-100;
|
||||
}
|
||||
|
||||
.openapi-method-put,
|
||||
.openapi-statuscode-informational {
|
||||
@apply bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-100;
|
||||
}
|
||||
|
||||
.openapi-method-patch {
|
||||
@apply bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-100;
|
||||
}
|
||||
|
||||
.openapi-method-delete,
|
||||
.openapi-statuscode-error {
|
||||
@apply bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100;
|
||||
}
|
||||
|
||||
.openapi-method-head,
|
||||
.openapi-method-options,
|
||||
.openapi-method-trace,
|
||||
.openapi-method-hook {
|
||||
@apply bg-tint;
|
||||
}
|
||||
|
||||
/* URL */
|
||||
.openapi-url {
|
||||
@apply font-mono text-sm text-tint;
|
||||
|
||||
@@ -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={cx('paragraph', style, getTextAlignment(block.data?.align))}
|
||||
className={tcls('paragraph', style, getTextAlignment(block.data?.align))}
|
||||
>
|
||||
<Inlines {...contextProps} nodes={block.nodes} ancestorInlines={[]} />
|
||||
</p>
|
||||
@@ -45,7 +45,11 @@ export function Paragraph(props: BlockProps<DocumentBlockParagraph>) {
|
||||
<div
|
||||
// The shared `AskAIParagraphButton` portals itself into the hovered wrapper.
|
||||
data-ask-ai-paragraph=""
|
||||
className={cx('group/ask-ai relative', style, getTextAlignment(block.data?.align))}
|
||||
className={tcls(
|
||||
'group/ask-ai relative',
|
||||
style,
|
||||
getTextAlignment(block.data?.align)
|
||||
)}
|
||||
>
|
||||
{paragraph}
|
||||
</div>
|
||||
|
||||
@@ -11,7 +11,7 @@ import { CodeBlock } from '../CodeBlock';
|
||||
import { getPlainCodeBlock } from '../CodeBlock/highlight-tokens';
|
||||
import { COMMENT_IGNORE_CLASSNAME, getCommentKeyProp } from '../utils';
|
||||
import { PromptClient } from './PromptClient';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
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={
|
||||
cx(style).split(' ').includes(COMMENT_IGNORE_CLASSNAME)
|
||||
tcls(style).split(' ').includes(COMMENT_IGNORE_CLASSNAME)
|
||||
? COMMENT_IGNORE_CLASSNAME
|
||||
: undefined
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import React from 'react';
|
||||
import { Icon } from '@gitbook/icons';
|
||||
|
||||
import { type PromptActionId, setPromptAction, usePromptAction } from './promptAction';
|
||||
import { useCopyToClipboard } from '@/components/hooks';
|
||||
import {
|
||||
Button,
|
||||
ButtonGroup,
|
||||
@@ -15,6 +14,7 @@ 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;
|
||||
@@ -27,10 +27,25 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
|
||||
const { prompt, openInAIProviders } = props;
|
||||
const language = useLanguage();
|
||||
const selectedAction = usePromptAction();
|
||||
const { copied, copy } = useCopyToClipboard(COPIED_MESSAGE_DURATION);
|
||||
const [copied, setCopied] = React.useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!copied) {
|
||||
return;
|
||||
}
|
||||
|
||||
const timeout = setTimeout(() => {
|
||||
setCopied(false);
|
||||
}, COPIED_MESSAGE_DURATION);
|
||||
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
}, [copied]);
|
||||
|
||||
const copyPrompt = () => {
|
||||
copy(prompt);
|
||||
navigator.clipboard.writeText(prompt);
|
||||
setCopied(true);
|
||||
};
|
||||
|
||||
// The pick follows the visitor from site to site, so fall back to copying wherever the agent
|
||||
@@ -63,7 +78,7 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
|
||||
|
||||
return (
|
||||
// Lifted above the header's overlay button, which otherwise swallows the clicks.
|
||||
<div className="prompt-actions">
|
||||
<div className="relative z-20 flex shrink-0 items-center gap-2">
|
||||
{openInAIProviders ? (
|
||||
<ButtonGroup>
|
||||
{mainButton}
|
||||
@@ -123,8 +138,16 @@ export function PromptActions(props: { prompt: string; openInAIProviders: boolea
|
||||
function AgentIconStack() {
|
||||
return (
|
||||
<span className="flex items-center">
|
||||
{AI_AGENTS.map((agent) => (
|
||||
<span key={agent.id} className="prompt-agent">
|
||||
{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'
|
||||
)}
|
||||
>
|
||||
<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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
type PromptClientProps = DocumentBlockPrompt['data'] & {
|
||||
contentIcon: IconName | null;
|
||||
@@ -44,13 +44,18 @@ export function PromptClient(props: PromptClientProps) {
|
||||
<div
|
||||
data-block-key={commentKey}
|
||||
data-comment-block={commentKey ? '' : undefined}
|
||||
className={cx('prompt-block', expanded && 'prompt-block-expanded', className)}
|
||||
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
|
||||
)}
|
||||
>
|
||||
<div
|
||||
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')
|
||||
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')
|
||||
)}
|
||||
>
|
||||
{!isPartiallyExpanded ? (
|
||||
@@ -59,12 +64,15 @@ export function PromptClient(props: PromptClientProps) {
|
||||
aria-controls={promptId}
|
||||
aria-expanded={open}
|
||||
aria-label={tString(language, 'view')}
|
||||
className="prompt-toggle"
|
||||
className={tcls(
|
||||
'absolute inset-0 z-10 cursor-pointer outline-hidden',
|
||||
'focus-visible:ring-2 focus-visible:ring-primary-hover'
|
||||
)}
|
||||
disabled={!prompt}
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
/>
|
||||
) : null}
|
||||
<div className="prompt-title">
|
||||
<div className="pointer-events-none relative z-0 flex min-w-0 flex-row items-center gap-2 text-tint-strong">
|
||||
{!isPartiallyExpanded ? (
|
||||
<ToggleChevron
|
||||
open={open}
|
||||
@@ -78,7 +86,7 @@ export function PromptClient(props: PromptClientProps) {
|
||||
<PromptActions prompt={prompt} openInAIProviders={openInAIProviders} />
|
||||
</div>
|
||||
{isPartiallyExpanded || open ? (
|
||||
<div id={promptId} className="prompt-body">
|
||||
<div id={promptId} className="border-t border-tint-subtle bg-tint-base">
|
||||
{children}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -2,7 +2,6 @@ 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;
|
||||
@@ -13,8 +12,7 @@ export function Quote(props: BlockProps<DocumentBlockQuote>) {
|
||||
tag="blockquote"
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
// 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')}
|
||||
style={[style, 'text-tint', 'border-l-2', 'pl-6', 'py-3', 'border-tint', 'space-y-4']}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ 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>) {
|
||||
@@ -37,19 +36,24 @@ export function StepperStep(props: BlockProps<DocumentBlockStepperStep>) {
|
||||
return (
|
||||
<div
|
||||
{...getCommentAnchorProps(context, block.key)}
|
||||
className={cx('stepper-item', tcls(style))}
|
||||
className={tcls('flex flex-row gap-4 md:gap-8', style)}
|
||||
>
|
||||
<div className="stepper-step-marker">
|
||||
<div className="can-override-bg can-override-text stepper-step-number">
|
||||
<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'
|
||||
)}
|
||||
>
|
||||
{index + 1}
|
||||
</div>
|
||||
<div className="can-override-bg stepper-step-line" />
|
||||
<div className="can-override-bg absolute bottom-2 left-3.5 top-9 w-px bg-primary-7 theme-muted:bg-tint-6" />
|
||||
</div>
|
||||
<Blocks
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style={['stepper-step-body', marginAdjustClassName]}
|
||||
style={['min-w-0 flex-1 pb-6 [&>*+*]:mt-5', marginAdjustClassName]}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -7,7 +7,6 @@ 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. */
|
||||
@@ -27,7 +26,7 @@ export function NativeViewGrid(props: TableGridViewProps) {
|
||||
{...props}
|
||||
stickyHeader={withStickyHeader}
|
||||
stickyFirstColumn={withStickyFirstColumn}
|
||||
className={cx(
|
||||
className={tcls(
|
||||
withStickyHeader
|
||||
? [
|
||||
'mb-0 border-t border-r border-l',
|
||||
@@ -51,7 +50,7 @@ export function NativeViewGrid(props: TableGridViewProps) {
|
||||
if (withStickyHeader || withStickyFirstColumn) {
|
||||
return (
|
||||
<StickyViewGrid
|
||||
className={cx(tcls(style), 'table-view')}
|
||||
className={tcls(style, 'relative mx-auto grid w-full min-w-0')}
|
||||
stickyHeader={withStickyHeader}
|
||||
tableClassName={tableContainerClassName}
|
||||
withTableRole={false}
|
||||
@@ -63,9 +62,9 @@ export function NativeViewGrid(props: TableGridViewProps) {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={cx(tcls(style), 'table-view')}>
|
||||
<div className="table-scroll">
|
||||
<div className={cx('table-stack', tableContainerClassName)}>
|
||||
<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)}>
|
||||
{header}
|
||||
{body}
|
||||
</div>
|
||||
@@ -87,13 +86,13 @@ function NativeViewGridHeader(
|
||||
return (
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className={cx(
|
||||
'table-native-header',
|
||||
(stickyHeader || !stickyFirstColumn) && 'table-header-clip',
|
||||
className={tcls(
|
||||
'mb-1 rounded-lg border border-tint-subtle bg-tint',
|
||||
stickyHeader || !stickyFirstColumn ? 'overflow-hidden' : undefined,
|
||||
className
|
||||
)}
|
||||
>
|
||||
<table className="table-native">
|
||||
<table className="w-full table-fixed border-separate border-spacing-0">
|
||||
<NativeViewGridColumns {...props} />
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -109,12 +108,12 @@ function NativeViewGridHeader(
|
||||
<th
|
||||
key={column}
|
||||
scope="col"
|
||||
className={cx(
|
||||
'table-header-cell',
|
||||
className={tcls(
|
||||
'relative px-3 py-2 font-medium text-sm text-tint-strong',
|
||||
isStickyFirstColumn
|
||||
? stickyHeader
|
||||
? 'table-header-cell-pinned'
|
||||
: 'table-header-cell-sticky'
|
||||
? 'z-20 bg-tint'
|
||||
: 'sticky left-0 z-20 bg-tint'
|
||||
: undefined,
|
||||
getColumnAlignment(definition)
|
||||
)}
|
||||
@@ -150,7 +149,14 @@ function NativeViewGridBody(
|
||||
const recordIndexes = new Map(records.map((record, index) => [record[0], index] as const));
|
||||
|
||||
return (
|
||||
<TableHoverTable className="table-native table-native-body">
|
||||
<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'
|
||||
)}
|
||||
>
|
||||
<NativeViewGridColumns {...props} />
|
||||
{withHeader ? (
|
||||
<thead className="sr-only">
|
||||
@@ -219,11 +225,15 @@ function NativeViewGridBody(
|
||||
data-table-row-end={
|
||||
recordIndex + (cellMerge?.merge.rowSpan ?? 1) - 1
|
||||
}
|
||||
className={cx(
|
||||
'table-native-cell',
|
||||
!isLastColumn && 'table-native-cell-divider',
|
||||
className={tcls(
|
||||
'relative px-3 py-2 text-sm transition-colors',
|
||||
!isLastColumn
|
||||
? 'border-tint-subtle border-r'
|
||||
: undefined,
|
||||
getNativeCellVerticalAlignment(verticalAlignment),
|
||||
isStickyFirstColumn && 'table-native-cell-sticky'
|
||||
isStickyFirstColumn
|
||||
? 'sticky left-0 z-10 bg-tint-base'
|
||||
: undefined
|
||||
)}
|
||||
>
|
||||
<RecordColumnValue
|
||||
|
||||
@@ -7,12 +7,13 @@ 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> & {
|
||||
@@ -56,14 +57,36 @@ 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={cx(
|
||||
'record-card-body',
|
||||
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
|
||||
lightCoverIsSquareOrPortrait || darkCoverIsSquareOrPortrait
|
||||
? [
|
||||
lightCoverIsSquareOrPortrait && 'record-card-body-portrait',
|
||||
darkCoverIsSquareOrPortrait && 'record-card-body-portrait-dark',
|
||||
]
|
||||
: 'record-card-body-landscape'
|
||||
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]'
|
||||
)}
|
||||
>
|
||||
{lightCover ? (
|
||||
@@ -93,20 +116,37 @@ export async function RecordCard(
|
||||
},
|
||||
]}
|
||||
resize={context.contentContext?.imageResizer}
|
||||
className={cx(
|
||||
'record-card-cover',
|
||||
className={tcls(
|
||||
'min-w-0',
|
||||
'w-full',
|
||||
'h-full',
|
||||
'bg-tint-subtle',
|
||||
lightCoverIsSquareOrPortrait || darkCoverIsSquareOrPortrait
|
||||
? [
|
||||
lightCoverIsSquareOrPortrait && 'record-card-cover-portrait',
|
||||
darkCoverIsSquareOrPortrait && 'record-card-cover-portrait-dark',
|
||||
]
|
||||
: 'record-card-cover-landscape',
|
||||
lightCoverIsSquareOrPortrait ? '@sm:aspect-video @sm:h-auto' : '',
|
||||
darkCoverIsSquareOrPortrait
|
||||
? 'dark:@sm:aspect-video dark:@sm:h-auto'
|
||||
: '',
|
||||
].filter(Boolean)
|
||||
: ['h-auto', 'aspect-video'],
|
||||
objectFits
|
||||
)}
|
||||
loading={isOffscreen && context.mode !== 'print' ? 'lazy' : 'eager'}
|
||||
/>
|
||||
) : null}
|
||||
<div className="record-card-content">
|
||||
<div
|
||||
className={tcls(
|
||||
'min-w-0',
|
||||
'w-full',
|
||||
'flex',
|
||||
'flex-col',
|
||||
'place-self-start',
|
||||
'gap-3',
|
||||
'p-4',
|
||||
'text-sm',
|
||||
'text-tint-strong'
|
||||
)}
|
||||
>
|
||||
{view.columns.map((column) => {
|
||||
const definition = block.data.definition[column];
|
||||
|
||||
@@ -123,8 +163,8 @@ export async function RecordCard(
|
||||
if (!view.hideColumnTitle && definition.title) {
|
||||
const ariaLabelledBy = `${block.key}-${column}-title`;
|
||||
return (
|
||||
<div key={column} className="record-card-field">
|
||||
<div id={ariaLabelledBy} className="record-card-field-title">
|
||||
<div key={column} className="flex flex-col gap-1">
|
||||
<div id={ariaLabelledBy} className="text-sm text-tint">
|
||||
{definition.title}
|
||||
</div>
|
||||
<RecordColumnValue
|
||||
@@ -163,7 +203,7 @@ export async function RecordCard(
|
||||
);
|
||||
}
|
||||
|
||||
return <div className="record-card">{body}</div>;
|
||||
return <div className={tcls(RecordCardStyles)}>{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="h-5 w-5"
|
||||
className={tcls('w-5', 'h-5')}
|
||||
checked={value}
|
||||
disabled={true}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
@@ -90,12 +90,16 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
const max = definition.max;
|
||||
|
||||
return (
|
||||
<Tag className="record-rating">
|
||||
<Tag className={tcls('inline-grid')}>
|
||||
{value ? (
|
||||
<>
|
||||
<span className="record-rating-stars">
|
||||
<span className={tcls('inline-flex', 'grid-area-1-1', 'gap-0.5')}>
|
||||
{Array.from({ length: max }).map((_, i) => (
|
||||
<Icon key={i} icon="star" className="record-rating-star" />
|
||||
<Icon
|
||||
key={i}
|
||||
icon="star"
|
||||
className={tcls('size-[15px]', 'text-primary/5')}
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
<span
|
||||
@@ -105,14 +109,14 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
aria-valuenow={rating}
|
||||
aria-valuemin={1}
|
||||
aria-valuemax={definition.max}
|
||||
className="record-rating-stars"
|
||||
className={tcls('inline-flex', 'grid-area-1-1', 'gap-0.5')}
|
||||
>
|
||||
{Array.from({ length: rating }).map((_, i) => (
|
||||
<Icon
|
||||
key={i}
|
||||
icon="star"
|
||||
iconStyle={IconStyle.SharpSolid}
|
||||
className="record-rating-star-filled"
|
||||
className={tcls('size-[15px]', 'text-primary')}
|
||||
/>
|
||||
))}
|
||||
</span>
|
||||
@@ -126,7 +130,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<Tag className="record-number" aria-labelledby={ariaLabelledBy}>{`${value}`}</Tag>
|
||||
<Tag
|
||||
className={tcls('text-base', 'tabular-nums', 'tracking-tighter')}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
>{`${value}`}</Tag>
|
||||
);
|
||||
}
|
||||
case 'text': {
|
||||
@@ -135,7 +142,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
const fragment = getNodeFragmentByName(block, value);
|
||||
if (!fragment) {
|
||||
return <Tag className={cx('w-full', verticalAlignment)}>{''}</Tag>;
|
||||
return <Tag className={tcls(['w-full', verticalAlignment])}>{''}</Tag>;
|
||||
}
|
||||
|
||||
const horizontalAlignment = getColumnAlignment(definition);
|
||||
@@ -147,8 +154,15 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
document={document}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
nodes={fragment.nodes}
|
||||
// Alignment stays as utilities: they must beat the alignment set by the blocks inside.
|
||||
style={['blocks record-text', verticalAlignment, horizontalClasses]}
|
||||
style={[
|
||||
'blocks',
|
||||
'w-full',
|
||||
'space-y-2',
|
||||
'lg:space-y-3',
|
||||
'leading-normal',
|
||||
verticalAlignment,
|
||||
horizontalClasses,
|
||||
]}
|
||||
context={context}
|
||||
blockStyle={['w-full', 'max-w-[unset]']}
|
||||
wrapperProps={{
|
||||
@@ -177,7 +191,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
);
|
||||
|
||||
return (
|
||||
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
|
||||
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
|
||||
{files.filter(filterOutNullable).map((ref, index) => {
|
||||
const contentType = ref.file
|
||||
? getSimplifiedContentType(ref.file.contentType)
|
||||
@@ -187,7 +201,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
<StyledLink
|
||||
key={index}
|
||||
href={ref.href}
|
||||
className="record-file-link"
|
||||
className="flex flex-row items-center gap-2"
|
||||
insights={
|
||||
ref.file
|
||||
? {
|
||||
@@ -221,7 +235,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
loading={context.mode === 'print' ? 'eager' : 'lazy'}
|
||||
/>
|
||||
) : (
|
||||
<FileIcon contentType={contentType} className="size-4" />
|
||||
<FileIcon
|
||||
contentType={contentType}
|
||||
className={tcls('size-4')}
|
||||
/>
|
||||
)}
|
||||
{ref.text}
|
||||
</StyledLink>
|
||||
@@ -242,7 +259,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
})
|
||||
: null;
|
||||
return (
|
||||
<Tag className="record-ref" aria-labelledby={ariaLabelledBy}>
|
||||
<Tag
|
||||
className={tcls('text-base', 'text-balance', 'flex', 'items-center')}
|
||||
aria-labelledby={ariaLabelledBy}
|
||||
>
|
||||
{resolved?.icon ?? null}
|
||||
{resolved ? (
|
||||
<StyledLink
|
||||
@@ -291,7 +311,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
);
|
||||
|
||||
return (
|
||||
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
|
||||
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
|
||||
{resolved.filter(filterOutNullable).map(([contentRef, resolved], index) => (
|
||||
<StyledLink
|
||||
key={index}
|
||||
@@ -316,7 +336,7 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
return (
|
||||
<Tag aria-labelledby={ariaLabelledBy}>
|
||||
<span className="record-select">
|
||||
<span className={tcls('inline-flex', 'gap-2', 'flex-wrap')}>
|
||||
{value.map((selectId) => {
|
||||
const option = definition.options.find(
|
||||
(option) => option.value === selectId
|
||||
@@ -327,7 +347,18 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
|
||||
return (
|
||||
<span key={option.value} className="record-select-option">
|
||||
<span
|
||||
key={option.value}
|
||||
className={tcls(
|
||||
'text-sm',
|
||||
'whitespace-pre',
|
||||
'rounded-sm',
|
||||
'py-1',
|
||||
'px-2',
|
||||
'bg-primary',
|
||||
'text-primary-strong'
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
</span>
|
||||
);
|
||||
@@ -354,10 +385,10 @@ export async function RecordColumnValue<Tag extends React.ElementType = 'div'>(
|
||||
}
|
||||
|
||||
return (
|
||||
<Tag className="text-base" aria-labelledby={ariaLabelledBy}>
|
||||
<Tag className={tcls('text-base')} aria-labelledby={ariaLabelledBy}>
|
||||
<StyledLink
|
||||
href={image.href}
|
||||
className="record-file-link"
|
||||
className="flex flex-row items-center gap-2"
|
||||
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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
export function RecordRow(
|
||||
props: TableGridViewProps & {
|
||||
@@ -24,7 +24,7 @@ export function RecordRow(
|
||||
role="row"
|
||||
recordId={record[0]}
|
||||
visibleClassName="flex"
|
||||
className="table-grid-row"
|
||||
className={tcls('group/row', '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={cx(
|
||||
className={tcls(
|
||||
'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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
interface StickyViewGridProps {
|
||||
className?: string;
|
||||
@@ -31,9 +31,12 @@ function DefaultHeaderScrollGrid({
|
||||
|
||||
return (
|
||||
<div className={className}>
|
||||
<div role={withTableRole ? 'table' : undefined} className="group/table table-sticky">
|
||||
<div className="table-scroll">
|
||||
<div className={cx('table-stack', resolvedTableClassName)}>
|
||||
<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)}>
|
||||
{header}
|
||||
{children}
|
||||
</div>
|
||||
@@ -139,14 +142,27 @@ function StickyHeaderOverlayScrollGrid({
|
||||
<div className={className}>
|
||||
<div
|
||||
ref={rootRef}
|
||||
className="group/table table-sticky"
|
||||
className="group/table relative flex w-full min-w-0 max-w-full flex-col rounded-lg border-tint-subtle data-[scrollable=true]:border"
|
||||
data-scrollable="false"
|
||||
role={withTableRole ? 'table' : undefined}
|
||||
>
|
||||
{header ? (
|
||||
<div ref={stickyHeaderRef} className="table-sticky-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
|
||||
className={cx('table-sticky-header-track', resolvedTableClassName)}
|
||||
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))]'
|
||||
)}
|
||||
style={{ width: 'var(--table-sticky-table-width)' }}
|
||||
>
|
||||
{header}
|
||||
@@ -154,8 +170,14 @@ function StickyHeaderOverlayScrollGrid({
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div ref={bodyScrollRef} className="table-scroll table-sticky-scroll">
|
||||
<div ref={bodyTableRef} className={cx('table-stack', resolvedTableClassName)}>
|
||||
<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)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -23,7 +23,6 @@ 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 };
|
||||
@@ -79,7 +78,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={cx(tcls(style), 'table-block')}
|
||||
className={tcls(style, 'flex flex-col gap-3')}
|
||||
>
|
||||
{showSearch ? (
|
||||
<TableSearchInput
|
||||
@@ -156,7 +155,7 @@ function TableView({
|
||||
if (withStickyHeader || withStickyFirstColumn) {
|
||||
return (
|
||||
<StickyViewGrid
|
||||
className={cx(tcls(style), 'table-view')}
|
||||
className={tcls(style, 'relative mx-auto grid w-full min-w-0')}
|
||||
stickyHeader={withStickyHeader}
|
||||
tableClassName={tableContainerClassName}
|
||||
header={
|
||||
@@ -164,7 +163,7 @@ function TableView({
|
||||
<ViewGridHeader
|
||||
{...gridProps}
|
||||
tableClassName={tableContainerClassName}
|
||||
className={cx(
|
||||
className={tcls(
|
||||
withStickyHeader
|
||||
? [
|
||||
'mb-0 border-t border-r border-l',
|
||||
@@ -185,13 +184,21 @@ function TableView({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={cx(tcls(style), 'table-view')}>
|
||||
<div className="table-scroll">
|
||||
<div className={cx('table-stack', tableContainerClassName)} role="table">
|
||||
<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"
|
||||
>
|
||||
{withHeader ? (
|
||||
<ViewGridHeader
|
||||
{...gridProps}
|
||||
tableClassName={tableContainerClassName}
|
||||
className={tableContainerClassName}
|
||||
/>
|
||||
) : null}
|
||||
<ViewGrid {...gridProps} tableClassName={tableContainerClassName} />
|
||||
|
||||
@@ -43,14 +43,13 @@ describe('ViewCards', () => {
|
||||
it('renders the carousel with a symmetric peek and conditional edge masks', () => {
|
||||
const markup = renderWithContext(<ViewCards {...makeProps(false)} />);
|
||||
|
||||
// Gutter-sized peek, the full 3rem from `2xl`.
|
||||
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('scroll-container-prev-x');
|
||||
expect(markup).toContain('2xl:ml-8');
|
||||
expect(markup).toContain('scroll-container-next-x');
|
||||
expect(markup).toContain('2xl:mr-8');
|
||||
expect(markup).toContain('-mx-12');
|
||||
expect(markup).toContain('px-12');
|
||||
expect(markup).toContain('scroll-px-12');
|
||||
expect(markup).toContain('left-0');
|
||||
expect(markup).toContain('ml-8');
|
||||
expect(markup).toContain('right-0');
|
||||
expect(markup).toContain('mr-8');
|
||||
expect(markup).not.toContain('before:bg-linear-to-r');
|
||||
expect(markup).not.toContain('after:bg-linear-to-l');
|
||||
expect(markup).toContain('snap-mandatory');
|
||||
@@ -59,6 +58,6 @@ describe('ViewCards', () => {
|
||||
it('renders the wrapping grid by default', () => {
|
||||
const markup = renderWithContext(<ViewCards {...makeProps(true)} />);
|
||||
|
||||
expect(markup).toContain('record-cards');
|
||||
expect(markup).toContain('inline-grid');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -4,7 +4,6 @@ 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>) {
|
||||
@@ -26,10 +25,12 @@ function CardsGrid(props: TableViewProps<DocumentTableViewCards>) {
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cx(
|
||||
tcls(style),
|
||||
'record-cards',
|
||||
view.cardSize === 'large' ? 'record-cards-large' : 'record-cards-medium',
|
||||
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.
|
||||
block.data.fullWidth ? 'large:flex-column' : null
|
||||
)}
|
||||
>
|
||||
@@ -48,16 +49,6 @@ function CardsGrid(props: TableViewProps<DocumentTableViewCards>) {
|
||||
);
|
||||
}
|
||||
|
||||
// The peek fits the page gutter (`CONTAINER_STYLE`) so the fade stays on screen; from `2xl` the
|
||||
// cards fill the row exactly and need the full 3rem to show the next one.
|
||||
const PEEK = {
|
||||
margin: '-mx-4 sm:-mx-6 md:-mx-8 2xl:-mx-12',
|
||||
padding:
|
||||
'px-4 scroll-px-4 sm:px-6 sm:scroll-px-6 md:px-8 md:scroll-px-8 2xl:px-12 2xl:scroll-px-12',
|
||||
leadingButton: 'ml-0 sm:ml-2 md:ml-4 2xl:ml-8',
|
||||
trailingButton: 'mr-0 sm:mr-2 md:mr-4 2xl:mr-8',
|
||||
};
|
||||
|
||||
/**
|
||||
* The carousel layout: cards lay out in a single horizontally-scrolling row that
|
||||
* snaps to the leftmost card. Reuses ScrollContainer for the scroll buttons.
|
||||
@@ -69,15 +60,17 @@ const PEEK = {
|
||||
function CardsCarousel(props: TableViewProps<DocumentTableViewCards>) {
|
||||
const { view, records } = props;
|
||||
|
||||
const itemClassName = cx(
|
||||
'record-carousel-item',
|
||||
view.cardSize === 'large' ? 'record-carousel-item-large' : 'record-carousel-item-medium'
|
||||
);
|
||||
// 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)]';
|
||||
|
||||
return (
|
||||
<ScrollContainer
|
||||
orientation="horizontal"
|
||||
className={tcls(PEEK.margin, 'hover:z-11')}
|
||||
className={tcls('-mx-12', 'hover:z-11')}
|
||||
// `py-1` keeps the card ring/shadow from being clipped by the scroll overflow;
|
||||
// `snap-mandatory` + the scroll-padding snap each card to the content edge.
|
||||
contentClassName={tcls(
|
||||
@@ -86,18 +79,19 @@ function CardsCarousel(props: TableViewProps<DocumentTableViewCards>) {
|
||||
'-mt-px',
|
||||
'pb-6',
|
||||
'-mb-6',
|
||||
PEEK.padding,
|
||||
'px-12',
|
||||
'scroll-px-12',
|
||||
'snap-x',
|
||||
'snap-mandatory'
|
||||
)}
|
||||
scrollByVisibleItems
|
||||
leading={{
|
||||
fade: true,
|
||||
button: { size: 'small', className: PEEK.leadingButton },
|
||||
button: { size: 'small', className: 'ml-8' },
|
||||
}}
|
||||
trailing={{
|
||||
fade: true,
|
||||
button: { size: 'small', className: PEEK.trailingButton },
|
||||
button: { size: 'small', className: 'mr-8' },
|
||||
}}
|
||||
>
|
||||
{records.map((record) => {
|
||||
@@ -105,7 +99,15 @@ function CardsCarousel(props: TableViewProps<DocumentTableViewCards>) {
|
||||
<TableSearchRecord
|
||||
key={record[0]}
|
||||
recordId={record[0]}
|
||||
visibleClassName={itemClassName}
|
||||
// `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
|
||||
)}
|
||||
>
|
||||
<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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
interface ViewGridHeaderProps extends TableGridViewProps {
|
||||
className?: string;
|
||||
@@ -27,14 +27,14 @@ export function ViewGridHeader(props: ViewGridHeaderProps) {
|
||||
return (
|
||||
<div
|
||||
role="rowgroup"
|
||||
className={cx(
|
||||
className={tcls(
|
||||
tableClassName ?? tableWidth,
|
||||
'table-grid-header',
|
||||
(withStickyHeader || !stickyFirstColumn) && 'table-header-clip',
|
||||
'mb-1 flex flex-col rounded-lg border border-tint-subtle bg-tint',
|
||||
withStickyHeader || !stickyFirstColumn ? 'overflow-hidden' : undefined,
|
||||
className
|
||||
)}
|
||||
>
|
||||
<div role="row" className="table-grid-header-row">
|
||||
<div role="row" className={tcls('flex', 'w-full')}>
|
||||
{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={cx(
|
||||
'table-header-cell',
|
||||
className={tcls(
|
||||
'relative px-3 py-2 font-medium text-sm text-tint-strong',
|
||||
stickyFirstColumn && column === firstVisibleColumn
|
||||
? withStickyHeader
|
||||
? 'table-header-cell-pinned'
|
||||
: 'table-header-cell-sticky'
|
||||
? 'z-20 bg-tint'
|
||||
: 'sticky left-0 z-20 bg-tint'
|
||||
: undefined,
|
||||
getColumnAlignment(definition)
|
||||
)}
|
||||
@@ -89,7 +89,10 @@ export function ViewGrid(props: ViewGridProps) {
|
||||
});
|
||||
|
||||
const body = (
|
||||
<div role="rowgroup" className={cx('table-grid-body', tableClassName ?? tableWidth)}>
|
||||
<div
|
||||
role="rowgroup"
|
||||
className={tcls('flex', 'flex-col', tableClassName ?? tableWidth, '[&>*+*]:border-t')}
|
||||
>
|
||||
{records.map((record) => (
|
||||
<RecordRow
|
||||
key={record[0]}
|
||||
@@ -102,5 +105,5 @@ export function ViewGrid(props: ViewGridProps) {
|
||||
</div>
|
||||
);
|
||||
|
||||
return <div className={cx('table-stack', tableClassName ?? tableWidth)}>{body}</div>;
|
||||
return <div className={tcls('flex', 'flex-col', tableClassName ?? tableWidth)}>{body}</div>;
|
||||
}
|
||||
|
||||
@@ -23,12 +23,6 @@
|
||||
}
|
||||
|
||||
.table-grid-cell-sticky {
|
||||
@apply sticky left-0 z-10 bg-tint-base;
|
||||
|
||||
@media (hover: hover) {
|
||||
.table-grid-row:hover > & {
|
||||
@apply bg-tint-hover;
|
||||
}
|
||||
}
|
||||
@apply sticky left-0 z-10 bg-tint-base group-hover/row:bg-tint-hover;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
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;
|
||||
@@ -1,26 +0,0 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
|
||||
import { getNextTabIndex } from './DynamicTabs';
|
||||
|
||||
describe('getNextTabIndex', () => {
|
||||
it('moves with the arrow keys and wraps around', () => {
|
||||
expect(getNextTabIndex('ArrowRight', 0, 3)).toBe(1);
|
||||
expect(getNextTabIndex('ArrowRight', 2, 3)).toBe(0);
|
||||
expect(getNextTabIndex('ArrowLeft', 0, 3)).toBe(2);
|
||||
});
|
||||
|
||||
it('jumps to the first and last tab', () => {
|
||||
expect(getNextTabIndex('Home', 2, 3)).toBe(0);
|
||||
expect(getNextTabIndex('End', 0, 3)).toBe(2);
|
||||
});
|
||||
|
||||
it('mirrors the arrows in right-to-left', () => {
|
||||
expect(getNextTabIndex('ArrowLeft', 0, 3, true)).toBe(1);
|
||||
expect(getNextTabIndex('ArrowRight', 0, 3, true)).toBe(2);
|
||||
});
|
||||
|
||||
it('ignores other keys and an unknown tab', () => {
|
||||
expect(getNextTabIndex('Enter', 0, 3)).toBeNull();
|
||||
expect(getNextTabIndex('ArrowRight', -1, 3)).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -10,7 +10,6 @@ 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,
|
||||
@@ -18,6 +17,7 @@ import {
|
||||
SELECT_PINNED_ATTR,
|
||||
SELECT_UNPINNED_ATTR,
|
||||
} from '@/lib/select';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
import { resolveAnchorURL } from '@/lib/urls';
|
||||
|
||||
export interface TabsItem {
|
||||
@@ -81,7 +81,17 @@ export function DynamicTabs(props: { tabs: TabsItem[]; setClassName: string; cla
|
||||
);
|
||||
|
||||
return (
|
||||
<div {...{ [SELECT_GROUP_ATTR]: '' }} className={cx('tabs-block', setClassName, className)}>
|
||||
<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
|
||||
)}
|
||||
>
|
||||
<TabItemList tabs={tabs} activeTabId={activeTabId} onSelect={selectTab} />
|
||||
{tabs.map((tab, index) => (
|
||||
<TabPanel
|
||||
@@ -118,9 +128,9 @@ const TabPanel = memo(function TabPanel(props: {
|
||||
role="tabpanel"
|
||||
id={tab.id}
|
||||
aria-labelledby={getTabButtonId(tab.id)}
|
||||
className="tabs-panel"
|
||||
className="scroll-mt-[calc(var(--content-scroll-margin)+var(--spacing)*20)]"
|
||||
>
|
||||
<div className="tabs-panel-body">{tab.body}</div>
|
||||
<div className="px-8 py-6">{tab.body}</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
@@ -141,16 +151,22 @@ const TabItemList = memo(function TabItemList(props: {
|
||||
}).filter((x) => x !== undefined),
|
||||
[overflowing, tabs]
|
||||
);
|
||||
// Roving tabindex: one tab stop for the strip, the active tab when it isn't in the overflow menu.
|
||||
const visibleTabs = tabs.filter((tab) => !overflowing.has(getTabButtonId(tab.id)));
|
||||
const focusableTabId =
|
||||
visibleTabs.find((tab) => tab.id === activeTabId)?.id ?? visibleTabs[0]?.id ?? null;
|
||||
return (
|
||||
<div
|
||||
ref={containerRef}
|
||||
role="tablist"
|
||||
onKeyDown={moveFocusBetweenTabs}
|
||||
className="tabs-list"
|
||||
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'
|
||||
)}
|
||||
>
|
||||
{/* When we measure, we add the menu at start to be sure everything's fit. */}
|
||||
{isMeasuring ? (
|
||||
@@ -166,7 +182,6 @@ const TabItemList = memo(function TabItemList(props: {
|
||||
key={tab.id}
|
||||
ref={itemRef}
|
||||
isActive={tab.id === activeTabId}
|
||||
isFocusable={tab.id === focusableTabId}
|
||||
isMeasuring={isMeasuring}
|
||||
tab={tab}
|
||||
onSelect={onSelect}
|
||||
@@ -226,36 +241,35 @@ function TabsDropdownMenu(props: {
|
||||
const TabItem = memo(function TabItem(props: {
|
||||
ref: React.Ref<HTMLButtonElement>;
|
||||
isActive: boolean;
|
||||
isFocusable: boolean;
|
||||
isMeasuring: boolean;
|
||||
tab: TabsItem;
|
||||
onSelect: (tabId: string) => void;
|
||||
}) {
|
||||
const { ref, tab, isActive, isFocusable, isMeasuring, onSelect } = props;
|
||||
const { ref, tab, isActive, isMeasuring, onSelect } = props;
|
||||
return (
|
||||
<TabButton
|
||||
ref={ref}
|
||||
role="tab"
|
||||
aria-selected={isActive}
|
||||
tabIndex={isFocusable ? 0 : -1}
|
||||
aria-controls={tab.id}
|
||||
id={getTabButtonId(tab.id)}
|
||||
title={tab.title}
|
||||
onClick={() => onSelect(tab.id)}
|
||||
wrapperClassName={
|
||||
isActive
|
||||
? 'tabs-item-current'
|
||||
? // Keeps room for the overflow menu button.
|
||||
'max-w-[calc(100%-3rem)]'
|
||||
: isMeasuring
|
||||
? // Measured after the active tab, at their narrowest, so the menu only takes
|
||||
// the tabs that can't fit even truncated.
|
||||
'tabs-item-measuring'
|
||||
'order-1 max-w-28'
|
||||
: // 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.
|
||||
'tabs-item-fluid'
|
||||
'min-w-0 max-w-max basis-0 grow-[1000]'
|
||||
}
|
||||
>
|
||||
{tab.icon && <Icon icon={tab.icon} className="tabs-button-icon" />}
|
||||
<span className="tabs-button-label">{tab.title}</span>
|
||||
{tab.icon && <Icon icon={tab.icon} className="size-4 shrink-0" />}
|
||||
<span className="min-w-0 truncate">{tab.title}</span>
|
||||
</TabButton>
|
||||
);
|
||||
});
|
||||
@@ -272,66 +286,63 @@ function TabButton(
|
||||
const { isActive, wrapperClassName, ...rest } = props;
|
||||
return (
|
||||
<div
|
||||
className={cx(
|
||||
'tabs-item',
|
||||
(props['aria-selected'] || props['aria-expanded'] || isActive) && 'active-tab',
|
||||
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,
|
||||
wrapperClassName
|
||||
)}
|
||||
>
|
||||
<button {...rest} type="button" className={cx('tabs-button', props.className)} />
|
||||
<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
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Arrow keys, Home and End move focus between the tabs of a tablist; Enter or Space then selects.
|
||||
*/
|
||||
function moveFocusBetweenTabs(event: React.KeyboardEvent<HTMLElement>) {
|
||||
const current = event.target instanceof HTMLElement ? event.target : null;
|
||||
if (current?.getAttribute('role') !== 'tab') {
|
||||
return;
|
||||
}
|
||||
const tabs = Array.from(
|
||||
event.currentTarget.querySelectorAll<HTMLElement>('[role="tab"]:not([disabled])')
|
||||
);
|
||||
const index = tabs.indexOf(current);
|
||||
const isRTL = getComputedStyle(event.currentTarget).direction === 'rtl';
|
||||
const next = getNextTabIndex(event.key, index, tabs.length, isRTL);
|
||||
if (next === null) {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
tabs[next]?.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Index of the tab to focus for a key press, or null when the key doesn't move focus.
|
||||
*/
|
||||
export function getNextTabIndex(
|
||||
key: string,
|
||||
index: number,
|
||||
count: number,
|
||||
isRTL = false
|
||||
): number | null {
|
||||
if (index < 0 || count === 0) {
|
||||
return null;
|
||||
}
|
||||
const forward = isRTL ? 'ArrowLeft' : 'ArrowRight';
|
||||
const backward = isRTL ? 'ArrowRight' : 'ArrowLeft';
|
||||
switch (key) {
|
||||
case forward:
|
||||
return (index + 1) % count;
|
||||
case backward:
|
||||
return (index - 1 + count) % count;
|
||||
case 'Home':
|
||||
return 0;
|
||||
case 'End':
|
||||
return count - 1;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID for a tab button.
|
||||
*/
|
||||
|
||||
@@ -41,7 +41,7 @@ export function Tabs(props: BlockProps<DocumentBlockTabs>) {
|
||||
ancestorBlocks={[...ancestorBlocks, block, tab]}
|
||||
context={context}
|
||||
blockStyle="flip-heading-hash"
|
||||
style="tabs-panel-blocks"
|
||||
style="w-full space-y-4"
|
||||
/>
|
||||
),
|
||||
};
|
||||
|
||||
@@ -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,20 +94,41 @@ function Subscript(props: MarkedLeafProps<DocumentMarkSubscript>) {
|
||||
}
|
||||
|
||||
function Code(props: MarkedLeafProps<DocumentMarkCode>) {
|
||||
return <code className="inline-code">{props.children}</code>;
|
||||
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>
|
||||
);
|
||||
}
|
||||
|
||||
function Color(props: MarkedLeafProps<DocumentMarkColor>) {
|
||||
const { mark, children } = props;
|
||||
return (
|
||||
<span
|
||||
data-highlight={
|
||||
mark.data.background && mark.data.background !== 'default' ? '' : undefined
|
||||
}
|
||||
className={cx(
|
||||
className={tcls([
|
||||
textColorToStyle[mark.data.text ?? 'default'],
|
||||
backgroundColorToStyle[mark.data.background ?? 'default']
|
||||
)}
|
||||
backgroundColorToStyle[mark.data.background ?? 'default'],
|
||||
])}
|
||||
>
|
||||
{children}
|
||||
</span>
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
getNumericDateFormatter,
|
||||
getShortDateFormatter,
|
||||
} from '@/components/utils/dates';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { getRevisionTags, resolveBlockTags } from '@/lib/tags';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
@@ -49,18 +48,23 @@ export function Update(props: BlockProps<DocumentBlockUpdate>) {
|
||||
return (
|
||||
<FilteredUpdate
|
||||
tagSlugs={resolvedTags.map((tag) => tag.slug)}
|
||||
className={cx('update-block', tcls(style))}
|
||||
className={tcls('relative flex flex-col gap-2 md:flex-row md:gap-4 lg:gap-8', style)}
|
||||
>
|
||||
<div className="update-block-aside">
|
||||
<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)]!'
|
||||
)}
|
||||
>
|
||||
<time
|
||||
// Adding a dateTime attribute for accessibility (and SEO)
|
||||
dateTime={date}
|
||||
className="update-block-date"
|
||||
className="inline-flex items-center text-sm font-medium tracking-wide text-neutral-10"
|
||||
>
|
||||
{dateFormatter.format(parsedDate)}
|
||||
</time>
|
||||
{resolvedTags.length > 0 ? (
|
||||
<div className="update-block-tags">
|
||||
<div className="mt-2 flex flex-wrap gap-1.5">
|
||||
{resolvedTags.map((tag) => (
|
||||
<Tag key={tag.slug} tag={tag} />
|
||||
))}
|
||||
@@ -71,7 +75,7 @@ export function Update(props: BlockProps<DocumentBlockUpdate>) {
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style="update-block-body"
|
||||
style="flex flex-1 flex-col [&>*+*]:mt-5 [&>*:first-child]:!pt-0"
|
||||
/>
|
||||
</FilteredUpdate>
|
||||
);
|
||||
|
||||
@@ -11,7 +11,7 @@ export function Updates(props: BlockProps<DocumentBlockUpdates>) {
|
||||
{...contextProps}
|
||||
nodes={block.nodes}
|
||||
ancestorBlocks={[...ancestorBlocks, block]}
|
||||
style={[style, 'updates-block']}
|
||||
style={[style, 'updates-block flex flex-col gap-20']}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ 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,
|
||||
@@ -170,9 +171,9 @@ export function UpdatesTagFilters(props: {
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="updates-filter">
|
||||
<div className="updates-filter-header">
|
||||
<div className="updates-filter-label">
|
||||
<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">
|
||||
<Icon icon="tags" className="size-3" />
|
||||
{tagsLabel}
|
||||
</div>
|
||||
@@ -187,7 +188,7 @@ export function UpdatesTagFilters(props: {
|
||||
className="pointer-events-none invisible text-xs"
|
||||
/>
|
||||
</div>
|
||||
<div className="updates-filter-tags">
|
||||
<div className="flex flex-wrap gap-1.5 px-3">
|
||||
{tags.map((tag) => (
|
||||
<TagChip key={tag.slug} tag={tag} onToggle={toggleTag} />
|
||||
))}
|
||||
@@ -196,6 +197,12 @@ 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();
|
||||
@@ -206,25 +213,34 @@ function TagChip(props: { tag: RevisionTag; onToggle: (tag: string) => void }) {
|
||||
type="button"
|
||||
aria-pressed={selectedTagSet.has(tag.slug)}
|
||||
onClick={onClick}
|
||||
className="updates-chip"
|
||||
className={CHIP_CLASS}
|
||||
>
|
||||
<span
|
||||
{...{ [UPDATES_TAG_CHIP_SELECTED_ATTR]: tag.slug }}
|
||||
className="updates-chip-face updates-chip-selected"
|
||||
className={tcls(
|
||||
CHIP_VARIANT_CLASS,
|
||||
'hidden bg-primary-original text-contrast-primary-original hover:bg-primary-solid-hover'
|
||||
)}
|
||||
>
|
||||
<TagIcon tag={tag} />
|
||||
<span className="truncate">{tag.label}</span>
|
||||
</span>
|
||||
<span
|
||||
{...{ [UPDATES_TAG_CHIP_UNSELECTED_DIMMED_ATTR]: tag.slug }}
|
||||
className="updates-chip-face updates-chip-dimmed"
|
||||
className={tcls(
|
||||
CHIP_VARIANT_CLASS,
|
||||
'hidden bg-tint-5 text-tint-strong opacity-8 hover:bg-tint-hover hover:opacity-11'
|
||||
)}
|
||||
>
|
||||
<TagIcon tag={tag} />
|
||||
<span className="truncate">{tag.label}</span>
|
||||
</span>
|
||||
<span
|
||||
{...{ [UPDATES_TAG_CHIP_UNSELECTED_PLAIN_ATTR]: tag.slug }}
|
||||
className="updates-chip-face updates-chip-plain"
|
||||
className={tcls(
|
||||
CHIP_VARIANT_CLASS,
|
||||
'flex bg-tint-5 text-tint-strong hover:bg-tint-hover'
|
||||
)}
|
||||
>
|
||||
<TagIcon tag={tag} />
|
||||
<span className="truncate">{tag.label}</span>
|
||||
|
||||
@@ -1,35 +1,55 @@
|
||||
import type { DocumentBlock } from '@gitbook/api';
|
||||
|
||||
/**
|
||||
* 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`.
|
||||
* Get the line height of a block
|
||||
*/
|
||||
export type BlockTextKind = 'body' | 'heading-1' | 'heading-2' | 'heading-3' | 'divider';
|
||||
|
||||
export function getBlockTextKind(block: DocumentBlock): BlockTextKind {
|
||||
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;
|
||||
} {
|
||||
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 block.type;
|
||||
return {
|
||||
textSize: '',
|
||||
lineHeight: 'leading-none',
|
||||
};
|
||||
case 'list-ordered':
|
||||
case 'list-tasks':
|
||||
case 'list-unordered':
|
||||
return getBlockTextStyle(block.nodes[0]!);
|
||||
case 'list-item':
|
||||
return getBlockTextKind(block.nodes[0]!);
|
||||
return getBlockTextStyle(block.nodes[0]!);
|
||||
default:
|
||||
return 'body';
|
||||
return {
|
||||
textSize: 'text-base',
|
||||
lineHeight: 'leading-normal',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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,25 +0,0 @@
|
||||
import { describe, expect, it } from 'bun:test';
|
||||
|
||||
import { isForeignHandshake } from './channel';
|
||||
|
||||
describe('isForeignHandshake', () => {
|
||||
const parent = {} as MessageEventSource;
|
||||
const other = {} as MessageEventSource;
|
||||
|
||||
it('accepts a handshake from the expected window', () => {
|
||||
expect(isForeignHandshake({ data: { type: 'bidc-connect' }, source: parent }, parent)).toBe(
|
||||
false
|
||||
);
|
||||
});
|
||||
|
||||
it('rejects a handshake from another window', () => {
|
||||
expect(isForeignHandshake({ data: { type: 'bidc-connect' }, source: other }, parent)).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
it('ignores messages that are not handshakes', () => {
|
||||
expect(isForeignHandshake({ data: { type: 'other' }, source: other }, parent)).toBe(false);
|
||||
expect(isForeignHandshake({ data: null, source: other }, parent)).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -9,33 +9,11 @@ export function log(...data: any[]) {
|
||||
console.log(...data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether a message is a bidc handshake sent by a window other than the expected one.
|
||||
*/
|
||||
export function isForeignHandshake(
|
||||
event: Pick<MessageEvent, 'data' | 'source'>,
|
||||
expectedSource: MessageEventSource
|
||||
): boolean {
|
||||
return event.data?.type === 'bidc-connect' && event.source !== expectedSource;
|
||||
}
|
||||
|
||||
export const getChannel = memoize(() => {
|
||||
if (typeof window === 'undefined' || window.parent === window) {
|
||||
return null;
|
||||
}
|
||||
log('[gitbook] create channel with parent window');
|
||||
|
||||
// bidc accepts a handshake from any window; registered first and in capture so it runs before
|
||||
// bidc's own listener and only the embedding page can open the channel.
|
||||
window.addEventListener(
|
||||
'message',
|
||||
(event) => {
|
||||
if (isForeignHandshake(event, window.parent)) {
|
||||
event.stopImmediatePropagation();
|
||||
}
|
||||
},
|
||||
true
|
||||
);
|
||||
|
||||
return createChannel();
|
||||
});
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React from 'react';
|
||||
|
||||
import { CONTENT_STYLE } from '../layout';
|
||||
import { CONTAINER_STYLE, 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,14 +26,41 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
!hasLogo && !hasGroups && !hasCopyright && !socialLinks.length && hasThemeToggle;
|
||||
|
||||
return (
|
||||
<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
|
||||
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 Logo
|
||||
customization.footer.logo ? (
|
||||
<div className="footer-logo">
|
||||
<div className="col-start-1 row-start-1">
|
||||
<Image
|
||||
alt="Logo"
|
||||
resize={context.imageResizer}
|
||||
@@ -48,7 +75,17 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
: null,
|
||||
}}
|
||||
loading="lazy"
|
||||
style="footer-logo-img"
|
||||
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',
|
||||
]}
|
||||
sizes={[
|
||||
{
|
||||
width: 320,
|
||||
@@ -64,7 +101,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="footer-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">
|
||||
<React.Suspense fallback={null}>
|
||||
<ThemeToggler />
|
||||
</React.Suspense>
|
||||
@@ -75,11 +112,14 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
{
|
||||
// Navigation groups (split into equal columns)
|
||||
customization.footer.groups?.length > 0 ? (
|
||||
<div className="footer-groups">
|
||||
<div className="footer-columns">
|
||||
<div className={tcls('col-span-2')}>
|
||||
<div className="mx-auto flex flex-col gap-10 @xl:flex-row @xl:gap-6">
|
||||
{partition(customization.footer.groups, FOOTER_COLUMNS).map(
|
||||
(column, columnIndex) => (
|
||||
<div key={columnIndex} className="footer-column">
|
||||
<div
|
||||
key={columnIndex}
|
||||
className="flex flex-1 grow flex-col gap-10"
|
||||
>
|
||||
{column.map((group, groupIndex) => (
|
||||
<FooterLinksGroup
|
||||
key={groupIndex}
|
||||
@@ -98,7 +138,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
{
|
||||
// Social Links
|
||||
socialLinks.length > 0 ? (
|
||||
<div className="footer-social">
|
||||
<div className="col-span-full flex w-full grow items-center justify-center gap-2">
|
||||
{socialLinks.map((account) => (
|
||||
<SocialAccountButton
|
||||
key={`${account.platform}-${account.handle}`}
|
||||
@@ -113,7 +153,7 @@ export function Footer(props: { context: GitBookSiteContext }) {
|
||||
{
|
||||
// Legal
|
||||
customization.footer.copyright ? (
|
||||
<div className="footer-legal">
|
||||
<div className="order-last col-span-full flex w-full grow flex-col items-center gap-2 text-center text-xs text-tint">
|
||||
<p>{customization.footer.copyright}</p>
|
||||
</div>
|
||||
) : null
|
||||
|
||||
@@ -8,6 +8,7 @@ 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;
|
||||
@@ -17,9 +18,9 @@ export function FooterLinksGroup(props: {
|
||||
const title = getLocalizedTitle(group, context.locale);
|
||||
|
||||
return (
|
||||
<nav className="footer-group">
|
||||
<h4 className="footer-group-title">{title}</h4>
|
||||
<ul className="footer-group-links">
|
||||
<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">
|
||||
{group.links.map((link, index) => {
|
||||
return (
|
||||
<li key={index}>
|
||||
@@ -40,7 +41,21 @@ async function FooterLink(props: { link: CustomizationContentLink; context: GitB
|
||||
return (
|
||||
<Link
|
||||
href={resolved?.href ?? '#'}
|
||||
className="footer-link"
|
||||
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]'
|
||||
)}
|
||||
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 } from '@/components/layout';
|
||||
import { CONTAINER_STYLE, HEADER_HEIGHT_DESKTOP } 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,8 +35,6 @@ 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
|
||||
@@ -45,19 +43,68 @@ export async function Header(props: {
|
||||
return (
|
||||
<header
|
||||
data-gb-site-header
|
||||
className={cx('header-bar', withTopHeader ? null : 'mobile-only')}
|
||||
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',
|
||||
|
||||
'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'
|
||||
)}
|
||||
>
|
||||
<div className="header-inner">
|
||||
<div className="chrome-shift">
|
||||
<div data-gb-header-content className={cx(CONTAINER_STYLE, 'header-content')}>
|
||||
<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={cx(
|
||||
'header-start',
|
||||
prominentSearch && 'header-start-prominent'
|
||||
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
|
||||
)}
|
||||
>
|
||||
<HeaderMobileMenu
|
||||
className={cx(
|
||||
className={tcls(
|
||||
'-ml-2',
|
||||
'text-tint-strong',
|
||||
'site-header:theme-bold:text-header-link',
|
||||
@@ -72,9 +119,29 @@ export async function Header(props: {
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={cx(
|
||||
'header-search',
|
||||
prominentSearch && 'header-search-prominent'
|
||||
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']
|
||||
)}
|
||||
>
|
||||
<SearchContainer
|
||||
@@ -98,7 +165,7 @@ export async function Header(props: {
|
||||
);
|
||||
})}
|
||||
{headerSocialAccounts.length > 0 ? (
|
||||
<div className="header-social">
|
||||
<div className="flex items-center gap-1">
|
||||
{headerSocialAccounts.map((account) => {
|
||||
return (
|
||||
<SocialAccountButton
|
||||
@@ -139,7 +206,7 @@ export async function Header(props: {
|
||||
</div>
|
||||
|
||||
{visibleSections && withSections ? (
|
||||
<div className="chrome-shift-padding">
|
||||
<div className="lg:chat-open:pr-(--ai-chat-width) transition-[padding] duration-300 motion-reduce:transition-none">
|
||||
<SiteSectionTabs sections={encodeClientSiteSections(context, visibleSections)}>
|
||||
{variants.translations.length > 1 ? (
|
||||
<TranslationsDropdown
|
||||
|
||||
@@ -8,7 +8,6 @@ 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';
|
||||
@@ -37,10 +36,7 @@ export async function HeaderLink(props: {
|
||||
isSiteAuthLoginHref={
|
||||
target ? isSiteAuthLoginHref(context.linker, target.href) : false
|
||||
}
|
||||
dropdownClassName={cx(
|
||||
'shrink',
|
||||
customization.styling.search === 'prominent' && 'right-0 left-auto'
|
||||
)}
|
||||
dropdownClassName={`shrink ${customization.styling.search === 'prominent' ? 'right-0 left-auto' : null}`}
|
||||
>
|
||||
{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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Client component wrapping the DropdownMenu for header links.
|
||||
@@ -137,6 +137,31 @@ 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,
|
||||
@@ -150,7 +175,7 @@ function HeaderItemLink(props: Omit<HeaderLinkNavItemProps, 'linkStyle'>) {
|
||||
} = props;
|
||||
const sharedProps = {
|
||||
href: href ?? '#',
|
||||
className: cx('header-link', className),
|
||||
className: tcls(getHeaderLinkClassName({ headerPreset }), className),
|
||||
insights: {
|
||||
type: 'link_click' as const,
|
||||
link: {
|
||||
@@ -182,7 +207,10 @@ function HeaderItemDropdown(
|
||||
) {
|
||||
const { headerPreset, title, className, ...rest } = props;
|
||||
return (
|
||||
<span className={cx('header-link header-link-static', className)} {...rest}>
|
||||
<span
|
||||
className={tcls(getHeaderLinkClassName({ headerPreset }), 'cursor-default', 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">
|
||||
<div className="header-links-ellipsis z-20 items-center">
|
||||
<HeaderLinkMoreDropdown
|
||||
label={label}
|
||||
dropdownClassName={cx(
|
||||
dropdownClassName={tcls(
|
||||
'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 } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* Client component for the "More" header link dropdown.
|
||||
@@ -23,9 +23,21 @@ export function HeaderLinkMoreDropdown(props: {
|
||||
return (
|
||||
<DropdownMenu
|
||||
button={
|
||||
<button type="button" className="header-more">
|
||||
<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'
|
||||
)}
|
||||
>
|
||||
<span className="sr-only">{label}</span>
|
||||
<Icon icon="ellipsis" className="size-4" />
|
||||
<Icon icon="ellipsis" className={tcls('size-4')} />
|
||||
<ToggleChevron />
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type React from 'react';
|
||||
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
interface HeaderLinksProps {
|
||||
children: React.ReactNode;
|
||||
@@ -8,5 +8,15 @@ interface HeaderLinksProps {
|
||||
}
|
||||
|
||||
export async function HeaderLinks({ children, style }: HeaderLinksProps) {
|
||||
return <nav className={cx('header-links', style)}>{children}</nav>;
|
||||
return (
|
||||
<div
|
||||
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}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ 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;
|
||||
@@ -21,7 +22,10 @@ export async function HeaderLogo(props: HeaderLogoProps) {
|
||||
: null;
|
||||
|
||||
return (
|
||||
<Link href={primaryLink?.href ?? linker.toPathInSite('')} className="header-logo">
|
||||
<Link
|
||||
href={primaryLink?.href ?? linker.toPathInSite('')}
|
||||
className={tcls('group/headerlogo', 'min-w-0', 'shrink', 'flex', 'items-center')}
|
||||
>
|
||||
{customization.header.logo ? (
|
||||
<Image
|
||||
alt="Logo"
|
||||
@@ -46,7 +50,19 @@ export async function HeaderLogo(props: HeaderLogoProps) {
|
||||
},
|
||||
]}
|
||||
preload
|
||||
style="header-logo-img"
|
||||
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'
|
||||
)}
|
||||
/>
|
||||
) : (
|
||||
<LogoFallback {...props} />
|
||||
@@ -65,10 +81,27 @@ function LogoFallback(props: HeaderLogoProps) {
|
||||
context={context}
|
||||
alt=""
|
||||
sizes={[{ width: 32 }]}
|
||||
style="header-logo-icon"
|
||||
style={['object-contain', 'size-8']}
|
||||
fetchPriority="high"
|
||||
/>
|
||||
<div className="header-logo-text">{site.title}</div>
|
||||
<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>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ 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';
|
||||
@@ -36,7 +35,7 @@ export function SpacesDropdown(
|
||||
} = props;
|
||||
const currentLanguage = context.locale;
|
||||
|
||||
const dropdownClassName = cx(
|
||||
const dropdownClassName = tcls(
|
||||
'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
|
||||
);
|
||||
@@ -85,7 +84,7 @@ export function TranslationsDropdown(
|
||||
asEmbeddable={asEmbeddable}
|
||||
variant="blank"
|
||||
className={tcls(
|
||||
'translations-dropdown max-md:[&_.button-content]:hidden',
|
||||
'bg-transparent lg:max-w-64 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, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
/**
|
||||
* 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={cx('spaces-dropdown-button', className)}
|
||||
className={tcls('bg-tint-base', className)}
|
||||
>
|
||||
<span className="button-content">{title}</span>
|
||||
</Button>
|
||||
|
||||
@@ -193,18 +193,13 @@ export function InsightsProvider(props: InsightsProviderProps) {
|
||||
}
|
||||
);
|
||||
|
||||
// `beforeunload` doesn't fire reliably on mobile, hiding the page is the last dependable signal.
|
||||
/**
|
||||
* When the page is unloaded, flush all events.
|
||||
*/
|
||||
React.useEffect(() => {
|
||||
const flushWhenHidden = () => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
flushEventsSync();
|
||||
}
|
||||
};
|
||||
document.addEventListener('visibilitychange', flushWhenHidden);
|
||||
window.addEventListener('pagehide', flushEventsSync);
|
||||
window.addEventListener('beforeunload', flushEventsSync);
|
||||
return () => {
|
||||
document.removeEventListener('visibilitychange', flushWhenHidden);
|
||||
window.removeEventListener('pagehide', flushEventsSync);
|
||||
window.removeEventListener('beforeunload', flushEventsSync);
|
||||
};
|
||||
}, [flushEventsSync]);
|
||||
|
||||
|
||||
@@ -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,13 +44,77 @@ export async function PageAside(props: {
|
||||
toggleClass="outline-open"
|
||||
withOverlay
|
||||
withCloseButton
|
||||
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'
|
||||
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.
|
||||
)}
|
||||
>
|
||||
<div className="page-aside-inner">
|
||||
<div className="flex h-full w-full shrink-0 flex-col overflow-hidden">
|
||||
{page.layout.outline ? (
|
||||
<>
|
||||
{filterableTags.length > 0 ? (
|
||||
@@ -61,18 +125,21 @@ export async function PageAside(props: {
|
||||
/>
|
||||
) : null}
|
||||
<div
|
||||
className={cx(
|
||||
'page-aside-header',
|
||||
filterableTags.length > 0 && 'page-aside-header-tags'
|
||||
className={tcls(
|
||||
'mb-3 ml-3 flex page-no-outline:hidden items-center justify-between max-lg:hidden',
|
||||
filterableTags.length > 0 && 'mt-4'
|
||||
)}
|
||||
>
|
||||
<ScrollToTopButton data-cover-aware-text className="page-aside-title">
|
||||
<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"
|
||||
>
|
||||
<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="page-aside-scroll">
|
||||
<div className="flex shrink flex-col overflow-hidden">
|
||||
{document ? (
|
||||
<React.Suspense fallback={null}>
|
||||
<PageAsideSections document={document} context={context} />
|
||||
@@ -96,7 +163,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="page-aside-outline">
|
||||
<div data-gb-page-outline className="overflow-y-auto">
|
||||
<ScrollSectionsList sections={sections} />
|
||||
</div>
|
||||
) : null;
|
||||
@@ -106,7 +173,14 @@ function PageAsideActions(props: { withPageFeedback: boolean; page: RevisionPage
|
||||
const { page, withPageFeedback } = props;
|
||||
|
||||
return (
|
||||
<div className="page-aside-actions">
|
||||
<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'
|
||||
)}
|
||||
>
|
||||
{withPageFeedback ? (
|
||||
<React.Suspense fallback={null}>
|
||||
<PageFeedbackForm pageId={page.id} />
|
||||
@@ -121,10 +195,16 @@ async function PageAsideFooter(props: { context: GitBookSiteContext }) {
|
||||
const { customization, site, space } = context;
|
||||
|
||||
return (
|
||||
<div className="page-aside-footer">
|
||||
<div
|
||||
className={tcls(
|
||||
'sticky bottom-0 z-10 mt-auto flex flex-col',
|
||||
'border-tint-subtle',
|
||||
'pt-4'
|
||||
)}
|
||||
>
|
||||
{/* Mode Switcher */}
|
||||
{customization.themes.toggeable ? (
|
||||
<div className="page-aside-theme">
|
||||
<div className="flex items-center justify-end">
|
||||
<React.Suspense fallback={null}>
|
||||
<ThemeToggler />
|
||||
</React.Suspense>
|
||||
|
||||
@@ -8,6 +8,7 @@ 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';
|
||||
|
||||
/**
|
||||
@@ -57,11 +58,23 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
|
||||
}, [activeId]);
|
||||
|
||||
return (
|
||||
<ul className="page-outline" ref={scrollContainerRef}>
|
||||
<ul
|
||||
className="relative flex flex-col border-tint-subtle pb-5 sidebar-list-line:border-l"
|
||||
ref={scrollContainerRef}
|
||||
>
|
||||
{sections.map((section) => (
|
||||
<li
|
||||
key={section.id}
|
||||
className="page-outline-item"
|
||||
className={tcls(
|
||||
'flex',
|
||||
'flex-row',
|
||||
'relative',
|
||||
'h-fit',
|
||||
'mt-2',
|
||||
'first:mt-0',
|
||||
'mb-0.5',
|
||||
section.depth > 1 && ['ml-3', 'my-0', 'sidebar-list-line:ml-0']
|
||||
)}
|
||||
ref={activeId === section.id ? activeItemRef : null}
|
||||
{...(section.tags !== undefined
|
||||
? { [UPDATES_TAG_SECTION_ATTR]: section.tags.join(' ') }
|
||||
@@ -69,11 +82,72 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
|
||||
>
|
||||
<a
|
||||
href={`#${section.id}`}
|
||||
aria-current={activeId === section.id ? 'true' : undefined}
|
||||
data-cover-aware-text
|
||||
className={
|
||||
section.depth > 1 ? 'page-outline-link subitem' : 'page-outline-link'
|
||||
}
|
||||
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',
|
||||
'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',
|
||||
]
|
||||
)}
|
||||
>
|
||||
{section.tag ? (
|
||||
<OpenAPIMethodBadge
|
||||
@@ -85,7 +159,13 @@ export function ScrollSectionsList({ sections }: { sections: DocumentSection[] }
|
||||
) : null}
|
||||
|
||||
<span
|
||||
className={section.deprecated ? 'page-outline-deprecated' : undefined}
|
||||
className={tcls(
|
||||
section.deprecated && [
|
||||
'line-through',
|
||||
'opacity-50',
|
||||
'contrast-more:opacity-60',
|
||||
]
|
||||
)}
|
||||
>
|
||||
{section.title}
|
||||
</span>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { PageIcon } from '../PageIcon';
|
||||
import { StyledLink } from '../primitives';
|
||||
import { DropdownMenu, DropdownMenuItem } from '../primitives/DropdownMenu';
|
||||
import { type ClassValue, cx } from '@/lib/classnames';
|
||||
import { type ClassValue, tcls } from '@/lib/tailwind';
|
||||
|
||||
export type BreadcrumbSibling = {
|
||||
id: string;
|
||||
@@ -46,7 +46,10 @@ export function BreadcrumbItemDropdown(props: {
|
||||
const content = (
|
||||
<>
|
||||
{emoji || icon ? (
|
||||
<PageIcon page={{ emoji, icon }} style="page-breadcrumbs-icon" />
|
||||
<PageIcon
|
||||
page={{ emoji, icon }}
|
||||
style="mb-0.5 mr-1 inline-block size-[1em] shrink-0"
|
||||
/>
|
||||
) : null}
|
||||
{label}
|
||||
</>
|
||||
@@ -57,11 +60,13 @@ export function BreadcrumbItemDropdown(props: {
|
||||
// normalize "" to "/" the way the table of contents does.
|
||||
const trigger =
|
||||
href !== undefined ? (
|
||||
<StyledLink href={href || '/'} role="link" className={cx(linkClassName)}>
|
||||
<StyledLink href={href || '/'} role="link" className={tcls(linkClassName)}>
|
||||
{content}
|
||||
</StyledLink>
|
||||
) : (
|
||||
<span className={cx(linkClassName, 'page-breadcrumbs-label')}>{content}</span>
|
||||
<span className={tcls(linkClassName, 'cursor-default hover:no-underline')}>
|
||||
{content}
|
||||
</span>
|
||||
);
|
||||
|
||||
// No dropdown when there is nowhere else to go at this level.
|
||||
@@ -87,7 +92,7 @@ export function BreadcrumbItemDropdown(props: {
|
||||
sibling.emoji || sibling.icon ? (
|
||||
<PageIcon
|
||||
page={{ emoji: sibling.emoji, icon: sibling.icon }}
|
||||
style="page-breadcrumbs-menu-icon"
|
||||
style="size-3 shrink-0 text-tint-subtle"
|
||||
/>
|
||||
) : undefined
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ 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';
|
||||
@@ -15,10 +16,8 @@ import { PageCover } from './PageCover';
|
||||
import { PageFooterNavigation } from './PageFooterNavigation';
|
||||
import { PageHeader } from './PageHeader';
|
||||
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,6 +28,7 @@ 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;
|
||||
@@ -103,11 +103,18 @@ export async function PageBody(props: {
|
||||
/>
|
||||
) : null}
|
||||
<main
|
||||
id={MAIN_CONTENT_ID}
|
||||
// Comments on the whole page target anywhere in it that isn't a block.
|
||||
{...(withCommentAnchors ? { 'data-comment-page': '' } : {})}
|
||||
className={cx(
|
||||
'page-main',
|
||||
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,
|
||||
pageHasToc ? 'page-has-toc' : 'page-no-toc',
|
||||
wideLayout ? 'layout-wide' : 'layout-default'
|
||||
)}
|
||||
@@ -164,9 +171,14 @@ export async function PageBody(props: {
|
||||
) : null}
|
||||
|
||||
{page.layout.metadata ? (
|
||||
<div className="page-meta">
|
||||
<div
|
||||
className={tcls(
|
||||
CONTENT_STYLE,
|
||||
'mt-6 flex flex-row flex-wrap items-center gap-4 text-tint contrast-more:text-tint-strong'
|
||||
)}
|
||||
>
|
||||
{updatedAt ? (
|
||||
<p className="page-meta-date">
|
||||
<p className="mr-auto text-sm">
|
||||
{t(
|
||||
language,
|
||||
'page_last_modified',
|
||||
|
||||
@@ -4,10 +4,12 @@ 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.
|
||||
@@ -27,7 +29,7 @@ export async function PageBodyBlankslate(props: {
|
||||
|
||||
const pageElements = await Promise.all(
|
||||
pages.map(async (child) => {
|
||||
const icon = <PageIcon page={child} style="page-blankslate-icon" />;
|
||||
const icon = <PageIcon page={child} style={['text-base', 'text-tint']} />;
|
||||
|
||||
if (child.type === RevisionPageType.Computed) {
|
||||
throw new Error(
|
||||
@@ -71,5 +73,18 @@ export async function PageBodyBlankslate(props: {
|
||||
})
|
||||
);
|
||||
|
||||
return <div className="page-blankslate">{pageElements}</div>;
|
||||
return (
|
||||
<div
|
||||
className={tcls(
|
||||
CONTENT_STYLE,
|
||||
'grid',
|
||||
'gap-4',
|
||||
'grid-cols-1',
|
||||
'sm:grid-cols-2',
|
||||
'md:layout-wide:grid-cols-3'
|
||||
)}
|
||||
>
|
||||
{pageElements}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
import type { StaticImageData } from 'next/image';
|
||||
import { assert } from 'ts-essentials';
|
||||
|
||||
import {
|
||||
CustomizationDefaultThemeMode,
|
||||
type RevisionPageDocument,
|
||||
type RevisionPageDocumentCover,
|
||||
} from '@gitbook/api';
|
||||
import type { RevisionPageDocument, 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;
|
||||
|
||||
@@ -89,7 +87,54 @@ export async function PageCover(props: {
|
||||
data-cover-text-color-dark={cover.textColorDark}
|
||||
data-cover-type={as}
|
||||
data-full={String(as === 'full')}
|
||||
className="page-cover"
|
||||
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
|
||||
)}
|
||||
>
|
||||
<PageCoverImage
|
||||
imgs={{
|
||||
@@ -99,11 +144,6 @@ export async function PageCover(props: {
|
||||
y={cover.yPos}
|
||||
height={height}
|
||||
mask={mask}
|
||||
priorityTheme={
|
||||
context.customization.themes.default === CustomizationDefaultThemeMode.Dark
|
||||
? 'dark'
|
||||
: 'light'
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client';
|
||||
import type { ImageSize } from '../utils';
|
||||
import { useCoverPosition } from './useCoverPosition';
|
||||
import { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
interface ImageAttributes {
|
||||
src: string;
|
||||
@@ -25,14 +25,10 @@ interface PageCoverImageProps {
|
||||
// Only if the `height` was customized by the user (and thus defined), we use it to set the cover's height and skip the default behaviour of fixed aspect-ratio.
|
||||
height: number | undefined;
|
||||
mask?: 'none' | 'radial';
|
||||
/** Theme most visitors see first, its cover is the LCP candidate. */
|
||||
priorityTheme?: 'light' | 'dark';
|
||||
}
|
||||
|
||||
export function PageCoverImage(props: PageCoverImageProps) {
|
||||
const { imgs, y, height, mask, priorityTheme = 'light' } = props;
|
||||
// The light cover is never demoted to low: a visitor can still have switched to the light theme.
|
||||
const darkFirst = priorityTheme === 'dark' && Boolean(imgs.dark);
|
||||
const { imgs, y, height, mask } = props;
|
||||
const { objectPositionY, isLoading } = useCoverPosition(imgs, y, {
|
||||
height,
|
||||
aspectRatio: PAGE_COVER_SIZE,
|
||||
@@ -40,21 +36,21 @@ export function PageCoverImage(props: PageCoverImageProps) {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="page-cover-loading">
|
||||
<div className="page-cover-skeleton" />
|
||||
<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>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page-cover-frame" style={{ height }}>
|
||||
<div className="h-full w-full overflow-hidden @container" style={{ height }}>
|
||||
<img
|
||||
src={imgs.light.src}
|
||||
srcSet={imgs.light.srcSet}
|
||||
sizes={imgs.light.sizes}
|
||||
fetchPriority={darkFirst ? 'auto' : 'high'}
|
||||
fetchPriority="high"
|
||||
alt="Page cover"
|
||||
className={cx('page-cover-img', imgs.dark && 'page-cover-img-light')}
|
||||
className={tcls('w-full', 'object-cover', imgs.dark ? 'dark:hidden' : '')}
|
||||
style={{
|
||||
aspectRatio: height
|
||||
? undefined
|
||||
@@ -73,9 +69,9 @@ export function PageCoverImage(props: PageCoverImageProps) {
|
||||
src={imgs.dark.src}
|
||||
srcSet={imgs.dark.srcSet}
|
||||
sizes={imgs.dark.sizes}
|
||||
fetchPriority={darkFirst ? 'high' : 'low'}
|
||||
fetchPriority="low"
|
||||
alt="Page cover"
|
||||
className="page-cover-img page-cover-img-dark"
|
||||
className={tcls('w-full', 'object-cover', 'dark:inline', 'hidden')}
|
||||
style={{
|
||||
aspectRatio: height
|
||||
? undefined
|
||||
|
||||
@@ -3,11 +3,12 @@ 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.
|
||||
@@ -26,7 +27,7 @@ export async function PageFooterNavigation(props: {
|
||||
const nextHref = next ? linker.toPathForPage({ pages: revision.pages, page: next }) : '';
|
||||
|
||||
return (
|
||||
<div className="page-nav">
|
||||
<div className={tcls(CONTENT_STYLE, 'mt-6 flex @xl:flex-row flex-col gap-3 text-tint')}>
|
||||
{previous ? (
|
||||
<NavigationCard
|
||||
icon="chevron-left"
|
||||
@@ -83,12 +84,24 @@ function NavigationCard(
|
||||
<Link
|
||||
href={href}
|
||||
insights={insights}
|
||||
className={cx('page-nav-card', reversed && 'page-nav-next')}
|
||||
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'
|
||||
)}
|
||||
>
|
||||
<Icon icon={icon} className="size-3" />
|
||||
<div className="page-nav-body">
|
||||
<span className="page-nav-label">{label}</span>
|
||||
<span className="page-nav-title">{title}</span>
|
||||
<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>
|
||||
</Link>
|
||||
);
|
||||
|
||||
@@ -11,6 +11,7 @@ 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,
|
||||
@@ -25,11 +26,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: {
|
||||
@@ -161,9 +162,9 @@ export async function PageHeader(props: {
|
||||
|
||||
const pageActions = (
|
||||
<div
|
||||
className={cx(
|
||||
'page-header-actions',
|
||||
!showBreadcrumbs && 'page-header-actions-solo',
|
||||
className={tcls(
|
||||
'float-right ml-4 flex gap-2',
|
||||
showBreadcrumbs ? '-mb-1 -mt-1.5' : '-mt-3 xs:mt-2',
|
||||
// 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.
|
||||
@@ -172,7 +173,12 @@ 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-header-actions-api'
|
||||
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',
|
||||
]
|
||||
)}
|
||||
>
|
||||
{hasPageActions ? (
|
||||
@@ -203,11 +209,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-breadcrumbs"
|
||||
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"
|
||||
>
|
||||
<ol>
|
||||
<ol className="inline">
|
||||
{contextCrumbs.map((crumb, index) => (
|
||||
<li key={crumb.key}>
|
||||
<li key={crumb.key} className="inline">
|
||||
<ContextCrumb crumb={crumb} />
|
||||
{(index !== contextCrumbs.length - 1 || hasAncestors) && (
|
||||
<BreadcrumbSeparator />
|
||||
@@ -226,7 +232,7 @@ export async function PageHeader(props: {
|
||||
page: target,
|
||||
});
|
||||
return (
|
||||
<li key={breadcrumb.id}>
|
||||
<li key={breadcrumb.id} className="inline">
|
||||
<BreadcrumbItemDropdown
|
||||
href={href}
|
||||
label={breadcrumb.title}
|
||||
@@ -253,21 +259,46 @@ export async function PageHeader(props: {
|
||||
{...(context.changeRequest ? { 'data-comment-page-title': '' } : {})}
|
||||
data-cover-aware-text
|
||||
data-over-cover
|
||||
className="page-title"
|
||||
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'
|
||||
)}
|
||||
>
|
||||
<PageIcon page={page} style="page-title-icon" />
|
||||
<PageIcon page={page} style={['text-tint-subtle', 'shrink-0']} />
|
||||
{page.title}
|
||||
</h1>
|
||||
) : null}
|
||||
{page.description && page.layout.description ? (
|
||||
<p data-cover-aware-text data-over-cover className="page-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'
|
||||
)}
|
||||
>
|
||||
{page.description}
|
||||
</p>
|
||||
) : null}
|
||||
</>
|
||||
);
|
||||
|
||||
const headerClassName = 'page-header';
|
||||
const headerClassName = tcls(CONTENT_STYLE, 'mb-6 space-y-3 after:clear-both after:block');
|
||||
|
||||
// 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
|
||||
@@ -290,7 +321,16 @@ 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 = 'page-breadcrumbs-link';
|
||||
const BREADCRUMB_LINK_CLASSES = [
|
||||
'inline',
|
||||
'no-underline',
|
||||
'hover:underline',
|
||||
'text-xs',
|
||||
'font-normal',
|
||||
'items-center',
|
||||
'contrast-more:underline',
|
||||
'contrast-more:decoration-current',
|
||||
];
|
||||
|
||||
/** A section-group, section or variant crumb shown at the start of the breadcrumbs. */
|
||||
type BreadcrumbContextCrumb = {
|
||||
@@ -472,7 +512,13 @@ function getPageSiblings(
|
||||
* Separator rendered between two breadcrumb items.
|
||||
*/
|
||||
function BreadcrumbSeparator() {
|
||||
return <Icon aria-hidden icon="chevron-right" className="page-breadcrumbs-sep" />;
|
||||
return (
|
||||
<Icon
|
||||
aria-hidden
|
||||
icon="chevron-right"
|
||||
className="mx-2 inline-flex size-2 text-tint-subtle"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 { cx } from '@/lib/classnames';
|
||||
import { tcls } from '@/lib/tailwind';
|
||||
|
||||
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={cx('page-feedback', className)}>
|
||||
<div className="page-feedback-row">
|
||||
<div className={tcls('flex flex-col gap-3 text-sm', className)}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<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="page-feedback-thanks">
|
||||
<div className="animate-blur-in-display-slow flex items-center gap-1 p-1.5 text-success-subtle">
|
||||
<Icon icon="check-circle" className="size-4" />
|
||||
{tString(languages, 'was_this_helpful_thank_you')}
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user