@clean-jsdoc-theme/rang

中文文档
5.2.1发布于 2026/10/24MITTypeScriptES Module构建来源已验证近 30 天下载 2.2万

Preact components, MDX component map, and island registry for clean-jsdoc-theme

原始使用文档
文档目录6 节
  1. What's inside
  2. Public API
  3. Styling contract
  4. FOUC + theme
  5. Contributors
  6. License

@clean-jsdoc-theme/rang

Preact component library + MDX element map + island registry for the v5 theme. dwar imports these directly to server-render pages and bundles each island as its own ESM chunk. rang owns every byte of page-shell HTML.

What's inside

  • Chrome — Layout, Header, Footer, Brand. SSR-only, no client JS of their own.
  • Islands — Sidebar, MobileNav, TOC, TocPopover, CtrlK, CodeTabs, CopyBtn, CopyPageButton, ThemeToggle, Settings, LanguageSwitcher, CodeViewer, Embed, PlaygroundMenu, Tabs. Each renders meaningful initial HTML and progressively enhances after hydration (keyboard handling, focus trap, scroll-spy, drawer state, clipboard, theme/setting persistence, locale navigation, a sandboxed iframe, a CDN-loaded Monaco source viewer, an "Open Code in" CodePen/JSFiddle/CodeSandbox dropdown).
  • SSR-only render helpers — Steps/Step (numbered stepper), PageNav (prev/next pager), Playground (a no-markup context carrier whose filename/highlight/providers the CodeBlock reads). These emit no island of their own.
  • Primitives — shadcn-style Button (buttonVariants), ButtonGroup (segmented/split buttons), DropdownMenu (compound root/trigger/content/item/…), Dialog (+ DialogHeader/DialogTitle/DialogBody/DialogFooter), CodeBlock (a code-block header — CODE/filename label, copy, and the playground dropdown), SimpleIcon (Simple-Icons CSS-mask glyph), and the cn class-merge helper.
  • defaultMdxComponents — element map for @mdx-js/mdx: headings with hover anchor links, external-link rel/target heuristics, <CopyBtn>-wrapped code blocks, table/list/quote primitives, and the <Callout> / <Steps> / <Tabs> / <Embed> / <Playground> elements.
  • ISLAND_REGISTRY — Record<IslandName, ComponentType> keyed by the IslandName union from @clean-jsdoc-theme/utils. The fifteen keys: sidebar, mobile-nav, toc, toc-mobile, cmdk, code-tabs, code-viewer, embed, playground, copy-btn, copy-page, theme-toggle, settings, language-switcher, tabs.
  • i18n seam — rang re-exports bhasha's LanguageProvider / useTranslation / createI18n so dwar can wrap each hydration root and seed it from the locale payload without a separate bhasha import. Every chrome/island string goes through t(key); LanguageSwitcher renders nothing for a single locale.

toc (the curved right rail) and toc-mobile (TocPopover, the < lg progress bar) are two presentations of the same headings; mobile-nav composes the theme toggle, settings, and sidebar into a < md drawer. embed and tabs are in-content islands (embed hydrates a sandboxed iframe; tabs is SSR-rendered and only DOM-enhanced).

Public API

import {
  // chrome
  Layout,
  Header,
  Footer,
  Brand,
  // islands
  Sidebar,
  MobileNav,
  TOC,
  TocPopover,
  CtrlK,
  CodeTabs,
  CopyBtn,
  CopyPageButton,
  ThemeToggle,
  useThemeMode,
  Settings,
  SettingsDialog,
  LanguageSwitcher,
  CodeViewer,
  // SSR render helpers + MDX containers
  Steps,
  Step,
  Tabs,
  Tab,
  PageNav,
  CodeBlock,
  // primitives
  Button,
  buttonVariants,
  ButtonGroup,
  DropdownMenu,
  Dialog,
  cn,
  // MDX map + registry
  defaultMdxComponents,
  ISLAND_REGISTRY,
  // i18n seam (re-exported from bhasha)
  LanguageProvider,
  useTranslation,
  createI18n,
} from '@clean-jsdoc-theme/rang';

Each component exports its own props type (SidebarProps, TOCProps, …). Island prop shapes match IslandPropsMap[K] from @clean-jsdoc-theme/utils exactly.

Styling contract

Components are styled with Tailwind utility classes that reference CSS custom properties. Consumers (dwar in the default pipeline; anyone else rendering rang directly) must define these on :root:

--clean-bg          --clean-bg-muted
--clean-fg          --clean-fg-muted
--clean-accent      --clean-accent-fg
--clean-border
--clean-font-heading   --clean-font-body   --clean-font-mono

The shadcn semantic aliases (background, foreground, primary, muted, accent, border, ring) are mapped onto these --clean-* vars via @theme, and a @custom-variant dark rebinds the dark: utility to [data-theme="dark"] (the theme toggle's signal) rather than the OS prefers-color-scheme. dwar's CSS pipeline plumbs ThemeTokens into these variables automatically; standalone consumers must define them.

FOUC + theme

useThemeMode (used by ThemeToggle) reads the stored localStorage preference inside an effect, so a pre-hydration inline script is required to set data-theme on <html> before first paint. dwar inlines this script automatically; standalone consumers should ship the equivalent.

Contributors

Thanks to everyone who has helped build clean-jsdoc-theme.

Contributors

License

MIT.

版本与发布记录

@clean-jsdoc-theme/rang 共发布 18 个版本,首次发布于 2026/06/10;过去 12 个月发布了 18 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
5.2.1latest2026/10/2416 天前
5.2.02026/08/282 个月前
5.1.12026/07/293 个月前
5.1.02026/07/243 个月前
5.0.82026/07/183 个月前
5.0.72026/07/074 个月前

其他发布通道:next → 5.0.0-alpha.0。

关于 @clean-jsdoc-theme/rang 的常见问题

@clean-jsdoc-theme/rang 是什么?

Preact components, MDX component map, and island registry for clean-jsdoc-theme

如何安装 @clean-jsdoc-theme/rang?

在项目目录运行 npm install @clean-jsdoc-theme/rang,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:preact(^10.22.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@clean-jsdoc-theme/rang 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@clean-jsdoc-theme/rang 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@clean-jsdoc-theme/rang 可以商用吗?

@clean-jsdoc-theme/rang 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@clean-jsdoc-theme/rang 的下载量有多少?

根据 npm 官方下载统计,@clean-jsdoc-theme/rang 在 2026/10/10 – 2026/11/08 这 30 天内被下载 21,826 次,日均约 728 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@clean-jsdoc-theme/rang 还在维护吗?

最新版本 5.2.1 发布于 2026/10/24(16 天前);至今共发布 18 个版本,其中过去 12 个月发布了 18 个;首次发布于 2026/06/10。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。