Skip to content

chore: replace mermaid with beautiful-mermaid#42

Merged
rsbh merged 30 commits intomainfrom
feat_use_beautiful_mermaid
Apr 28, 2026
Merged

chore: replace mermaid with beautiful-mermaid#42
rsbh merged 30 commits intomainfrom
feat_use_beautiful_mermaid

Conversation

@rsbh
Copy link
Copy Markdown
Member

@rsbh rsbh commented Apr 28, 2026

Library: https://github.com/lukilabs/beautiful-mermaid

Summary

  • Swap mermaid@^11.13.0 for beautiful-mermaid@^1.1.3
  • Render synchronously via useMemo (no dynamic import, no flash, no async state)
  • Map all renderer color tokens to Apsara CSS vars so diagrams pick up theme
    • bg: --rs-color-background-base-primary
    • fg: --rs-color-foreground-base-primary
    • line: --rs-color-border-base-focus
    • accent: --rs-color-foreground-accent-primary
    • muted: --rs-color-foreground-base-secondary
    • surface: --rs-color-background-neutral-secondary
    • border: --rs-color-border-base-tertiary
  • Surface render errors as a <pre> instead of crashing the page

Test plan

  • bun run dev:examples:frontier — diagrams render with current theme
  • Toggle dark mode — colors flip per Apsara tokens
  • Trigger an invalid diagram — page shows error text, no crash

🤖 Generated with Claude Code

rsbh and others added 29 commits April 23, 2026 10:15
Prepare Page type for backend-provided prev/next links used by the
docs sub-navbar. Adds PageNavLink/PageNav types, extends Page via
extends PageNav, unifies PageData with Page in page context, and
threads null placeholders through SSR + hydration until backend
computes real values.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nitro@3.0.260311-beta lists std-env in devDependencies but its
runtime imports it. Node ESM resolution from nitro's isolated
cache path fails without std-env at top-level node_modules.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the top Navbar; move navigation into a per-section tab bar
alongside the sidebar. Resize sidebar to 262px, swap button-based
nav links for pill-style tabs using mini typography tokens.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add getPageNav helper that flattens the page tree and returns the
adjacent PageNavLinks for a slug. Both the /api/page handler and SSR
pageData now populate prev/next so the client can render navigation
without re-flattening the tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Default theme now renders the main content inside a rounded, bordered
card with a sub-navbar at the top containing prev/next IconButtons
driven by the server-provided page nav, followed by breadcrumbs.
Breadcrumbs move out of Page.tsx since the Layout owns the chrome.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Add sidebar top navbar with placeholder logo, icon-only search, and
  IconButton-based theme switcher using resolvedTheme so system mode
  lands on the correct icon.
- Simplify Search component to IconButton only, drop cmdk kbd trigger.
- Wrap content in a bordered card, remove TOC from Page, align heading
  + paragraph typography with Aurora tokens.
- Secondary bg on sidebar + card wrapper, primary bg on content area.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
TOC renders as short horizontal markers floating right-center, each
width scaled from the heading text length (base + per char, clamped).
Hovering the aside fades the markers out and reveals a panel with the
full heading list, active state highlighted. Shadows switch to the
Apsara --rs-shadow-soft token.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- page-context: coerce prev/next from API response to null so the
  state always matches the Page type instead of carrying undefined.
- source.getPageNav: guard PageNavLink.title to string-only page names
  so ReactNode names don't stringify to "[object Object]".
- Layout tabs: compute per-entry active state from api.basePath instead
  of the shared isApiRoute boolean, so only the matching API tab
  highlights when multiple APIs are configured.
- Layout: skip breadcrumbs on API routes since the docs tree doesn't
  include API paths.
- Search: add title="Search (⌘K)" so the keyboard shortcut stays
  discoverable after the kbd hint was removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- search shortcut tooltip: platform-neutral "Ctrl/⌘K"
- TOC: mirror :hover with :focus-within for keyboard users
- getPageNav: derive PageNavLink.title from URL when page name is non-string

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- getPageNav: accept pre-loaded tree to avoid redundant tree rebuild
- entry-server: skip getPageNav when page is null; share tree with nav
- entry-client: nullable frontmatter/relativePath/originalPath in EmbeddedData; narrow at usage

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- SidebarNode recurses to depth 1 with data-depth attr on section
- Depth 0: non-collapsible section header
- Depth 1: collapsible sub-group with right-aligned chevron
- Grandchildren folders (depth > 1) ignored
- Hide sidebar scrollbar
- Style navGroup header/trigger/label/chevron via apsara classNames slots

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Drop tabBar (ContentDirButtons + API tabs) and subNav card-chrome
- Sidebar header: logo + search + theme only (version switcher moved out)
- Sidebar footer: holds VersionSwitcher, hidden when no versions
- Sidebar bg uses --rs-color-background-base-secondary
- Card: border-left only, no border-radius
- cardWrapper: drop horizontal padding
- TOC: drop extra right offset

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Render content-dir entries and API entries as Sidebar.Item cells
  at the top of Sidebar.Main, above the page tree
- Hidden when total (content + API) count is ≤ 1
- Drop Apsara's default header margin-bottom

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Top content links: tertiary text by default, primary when active, transparent bg
- Nav group label uses secondary for section headers, primary for sub-groups
- Nav group: zero out default margin-top, apply space-7 only to top-level (data-depth=0)
- Zero out gap on Sidebar.Main and nav-group-items
- Breadcrumbs: use render={<RouterLink>} so SPA navigation works (not-current items)
- Wrap top content/API links in .topLinks div with bottom margin

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- New SidebarLogo component reads config.logo.light/dark
- Falls back to BookOpenIcon when no logo is configured
- Picks src based on resolvedTheme from Apsara useTheme()

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Schema accepts icon string on content entries and api entries
- Icon can be a URL or an inline SVG string (uses currentColor)
- renderConfigIcon helper picks <img> for URL or inlines SVG
- Fallback to DocumentTextIcon / CodeBracketSquareIcon when absent

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Drop llms config section; routes serve unconditionally
- Remove llms.enabled gating from .md slug route and llms.txt routes
- Clean up llms: enabled: true from docs and versioned example yamls

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Remove footerSchema + FooterConfig from config schema
- Delete Footer component and CSS
- Remove Footer usage from paper theme Layout
- Clean footer: sections from docs and basic example yamls

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Head accepts optional markdownHref; DocsPage passes `/${slug}.md` so
crawlers and AI assistants can discover the raw markdown source.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds OpenInAI menu in the subNav with four actions:
- Copy as MD (fetches the page's .md and writes to clipboard)
- View MD (opens the raw .md in a new tab)
- Open in ChatGPT (chatgpt.com/?q=Read <mdUrl>)
- Open in Claude (claude.ai/new?q=Read <mdUrl>)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Bump @raystack/apsara to 1.0.0-rc.4
- Drop manual Dialog wrapper; use Command.Dialog + Command.DialogContent
- Command.List -> Command.Content
- Command.Group heading -> <Command.Label>
- Item onSelect -> onClick; Input leadingIcon replaces external icon
- Style dialogContent (width/radius/top) to position at 20% from top

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace four 48px usages (sidebar header, sidebar footer, subNav, etc)
with var(--navbar-height) defined on .layout.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Inline SVG icons using currentColor so they inherit the text color.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Layout: tighten isApiRoute match (exact /apis or /apis/ prefix) so
  breadcrumb suppression doesn't catch unrelated paths
- Sidebar: flex: 0 0 262px + flex-column so it doesn't shrink; Main
  gets overflow-y: auto + min-height: 0 for long trees
- Card: overflow visible so floating TOC + focus rings aren't clipped
- Toc markers: aria-hidden + tabIndex=-1 so the panel nav is the
  single accessible entry
- Toc: hide below 900px viewport via media query

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
beautiful-mermaid renders SVG synchronously with zero DOM deps,
removing the need for a dynamic import and the mermaid runtime.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Sync renderMermaidSVG inside useMemo (no flash, no async state)
- Map bg/fg/line/accent/muted/surface/border to apsara color tokens
- Surface render errors as a <pre> message instead of crashing

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 28, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
chronicle Ready Ready Preview, Comment Apr 28, 2026 9:24am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 28, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • New Features

    • Diagram rendering now displays explicit error messages when rendering fails, improving troubleshooting.
  • Refactor

    • Optimized diagram rendering with improved performance.

Walkthrough

Package dependency replaced from mermaid to beautiful-mermaid. Corresponding component refactored to use synchronous SVG generation with try/catch error handling instead of async client-side rendering, removing hooks and dynamic imports.

Changes

Cohort / File(s) Summary
Dependency Update
packages/chronicle/package.json
Replaced mermaid (^11.13.0) with beautiful-mermaid (^1.1.3) as runtime dependency.
Component Refactor
packages/chronicle/src/components/mdx/mermaid.tsx
Shifted from async dynamic imports and hooks to synchronous renderMermaidSVG computation in useMemo. Added try/catch error handling that renders errors in a <pre> block. CSS variables now passed as strings. Removed useEffect, useState, and ID generation logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately describes the main change: replacing the mermaid library with beautiful-mermaid.
Description check ✅ Passed The description is highly detailed and directly related to the changeset, covering library replacement, rendering approach, theme integration, and error handling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat_use_beautiful_mermaid

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@rsbh rsbh changed the base branch from main to feat_default_theme_changes April 28, 2026 03:55
@rsbh rsbh changed the base branch from feat_default_theme_changes to main April 28, 2026 09:12
@rsbh rsbh merged commit 6fce8f2 into main Apr 28, 2026
3 of 4 checks passed
rsbh added a commit that referenced this pull request Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants