Skip to content

[refactor] upgrade Idea React v2 components & examples to Bootstrap 6 - #76

Merged
TechQuery merged 14 commits into
mainfrom
copilot/upgrade-bootstrap-v6-components
Nov 1, 2026
Merged

TechQuery merged 14 commits into
mainfrom
copilot/upgrade-bootstrap-v6-components

Conversation

Copilot AI commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

PR-76 PR-76 PR-76 Powered by Pull Request Badge

Summary

Migrate every Bootstrap-dependent wrapper in source/ to Bootstrap 6 (6.0.0-alpha.1), replace monolithic components with composable sub-components, and turn the ViNext workspace into a complete, statically exported documentation site. react-bootstrap and the legacy preview/ workspace are gone, and the library now runs on React 19 with explicit client boundaries so ViNext can prerender class components.

Component library

  • Reworked existing wrappers to Bootstrap 6 class names, markup, and color modes: Avatar, Badge, Button, Countdown, Menu, MonthCalendar, NativeDialog, Navbar, OverlayBox, PageNav, Select, ShareBox, SpinnerButton, TableSpinner, Time, Timeline, Toast, UserRank, ZodiacBar, and the marquees.
  • New wrappers: ButtonGroup/ButtonToolbar, Card (+ CardHeader, CardBody, CardFooter, CardTitle, CardText), Grid (Container/Row/Col), Image, Table, ListGroup/ListGroupItem, Spinner, CloseButton, ToggleButton, Drawer (+ DrawerHeader, DrawerTitle, DrawerBody, DrawerFooter), DialogHeader/DialogTitle/DialogBody/DialogFooter, Nav/NavItem/NavLink, Popover, and Tooltip.
  • Atomic APIs replace hand-written Bootstrap class strings:
    • Row accepts cols plus sm/md/lg/xl/2xl breakpoints; Col accepts span and the same breakpoints (true for equal-width columns).
    • ListGroup supports flush, numbered, and horizontal (boolean or breakpoint); ListGroupItem supports theme, action, active, and disabled.
    • Card, Drawer, and NativeDialog expose header/title/body/footer parts, so guides never inline structural class names.
  • Expanded Menu (MenuPanel, MenuHeader, MenuDivider, MenuSubmenu, MenuItemContent, MenuItemDescription, MenuText) and Navbar (NavbarBrand, NavbarNav, NavbarText, NavbarToggler).
  • Added ToastContainer, ToastItem, ToastHeader, and ToastBody; split TextTruncate/TypeEcho into folders and added ScrollNavScroller.
  • CodeBlock highlights JavaScript, JSX, TypeScript, and TSX with Shiki, using paired light/dark themes and inline colors for zero client-side highlighting; React element children are serialized to JSX source.
  • Overlay fixes: Popover/Tooltip arrows are absolutely positioned per placement, and OverlayBox derives its distance from the popover/tooltip type instead of a fixed offset.
  • React 19 prerender fix: every class component (UserRankView, NativeDialog, Countdown, Menu, MonthCalendar, OverlayBox, PageNav, ScrollNav.Scroller, TextTruncate/TypeEcho content, Editor, ShareBox, ClickBoundary) starts with 'use client'. ViNext prerenders through React's react-server export, which does not provide Component/PureComponent, so a missing directive failed the build with Class extends value undefined.

Behavior and API

  • Toast.open() messages use theme instead of the old variant field.
  • NativeDialog keeps its native open state in sync with the prop and supports theme, modal, keyboard, and backdrop.
  • OverlayBox gains overlayClassName for scoped popover/tooltip theming, opens on hover/focus/click, and closes on outside pointer interaction or Esc; Popover and Tooltip share OverlayTriggerProps from Overlay.ts.
  • Nav remains server-renderable: disabled links use disabled pe-none with aria-disabled="true" and tabindex="-1" instead of a click interceptor; PageNav reuses Nav/NavLink through NavProps.
  • Navbar supports theme="dark" and responsive expand breakpoints with drawer-based mobile navigation; Drawer supports all placements plus optional footer content.
  • Menu exposes autoClose (true | 'inside' | 'outside' | false), logical align, submenus, and keyboard navigation with focus restoration.
  • Select props follow the Bootstrap 6 attribute names, and MonthCalendar/ShareBox compose Badge/Image instead of duplicating markup.
  • MobX usage follows the documented conventions: instance arrow actions are wrapped with action(() => …) rather than @action field decorators, and state updates after await go through their own actions.

Documentation site

  • 43 component guides: 17 Bootstrap 6 wrapper guides (Avatar, Badge, Button, Button group, Card, Close button, Dialog, Drawer, Grid, Image, Menu, Nav, Navbar, Popover & tooltip, Spinner, Table, Toasts) and 26 extension guides, plus the Bootstrap and extension catalogs.
  • Guides are MDX pages that adapt the upstream Bootstrap 6 documentation to Idea React wrappers and keep the required CC BY 3.0 attribution with links to each upstream source.
  • Shared documentation layout with sticky header, grouped sidebar, in-page table of contents, and footer; inner pages use one consistent content column.
  • Live examples use LiveExample, CodeExample, CodeCard, and LiveRunner (built on LiveTSX), plus docs-only interactive demos (DialogDemo, DialogModelDemo, DrawerDemo, LoadingDemo, NavbarDemo, SelectDemo, ToastDemo).
  • Every JSX/TSX code fence renders through the Shiki-backed CodeBlock, imported directly in the MDX page. The build keeps two small helpers: remarkInlineButtonChildren unwraps auto-generated paragraphs inside inline wrappers, and rehypeBootstrapTable adds the table class and a table-responsive wrapper to Markdown tables. No code-fence AST rewriting.
  • Site-wide features: search index generated from the exported HTML (Ctrl/⌘+K), persisted light/dark color mode, copy-command buttons, and a root error handler that reports unhandled rejections.
  • ViNext stays pure SSG: Bootstrap 6 CSS and Icons load from unpkg, output deploys as static files from document/dist/client/, and no Tailwind is used.

Tooling and tests

  • Version bumped to 3.0.0-alpha.1; react-bootstrap is no longer a runtime dependency and the preview/ workspace with its Parcel build is removed.
  • 24 test files / 54 tests use the Node.js native test runner with node:assert/strict and native mocks, covering the new and refactored wrappers (including ListGroup, ButtonGroup, Grid, Drawer, Card, Popover, Tooltip).
  • AGENTS.md now documents the Bootstrap upgrade workflow, client-component directives and displayName, MobX action conventions, render-method structure, component composition and prop reuse, docs styling rules, testing stages, deployment, and Git workflow.

Breaking changes

  • react-bootstrap is no longer a runtime dependency; Bootstrap 6 CSS is required.
  • Toast options use theme instead of variant.
  • Bootstrap 5 component markup and class names are replaced by their Bootstrap 6 equivalents.
  • Structural wrappers are now composed from parts (Card, Drawer, NativeDialog); the old single-element title/dialog layout props are replaced by sub-components.

Validation

  • Root tsc --noEmit
  • document workspace tsc --noEmit (fixed the index signature in TimeDistance and the RefCallback return types in TypeEcho/animate)
  • Node native test suite: 54/54 passing
  • Docs workspace build: 46 routes prerendered (45 pages + 404), 0 skipped, 45 pages indexed
  • All 43 guides render their JSX/TSX snippets as Shiki-highlighted blocks in both light and dark themes
  • Browser verification (Edge/CDP, desktop and 500 px): sticky header, mobile navbar drawer, menu, custom popover/tooltip placement, live toast, button toolbars, card list groups and grid columns, row-column/breakpoint grids, dialog and drawer parts, UserRank leaderboard (podium + table, hydrated), TimeDistance output, and TypeEcho typing animation — no console or hydration errors
  • ESLint and Prettier on changed source, config, and stylesheet files

Fixes #75

Copilot AI linked an issue Oct 30, 2026 that may be closed by this pull request
@TechQuery TechQuery added enhancement Some improvements feature New feature or request labels Oct 30, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Deploying idea-react with  Cloudflare Pages  Cloudflare Pages

Latest commit: b15c5ab
Status: ✅  Deploy successful!
Preview URL: https://8fa20b69.idea-react.pages.dev
Branch Preview URL: https://copilot-upgrade-bootstrap-v6.idea-react.pages.dev

View logs

Copilot AI changed the title [WIP] Upgrade Idea React v2 components to Bootstrap v6 Upgrade Idea React components and docs to Bootstrap 6 Oct 30, 2026
Copilot AI requested a review from TechQuery October 30, 2026 16:09
完成组件库向 Bootstrap 6 的全面迁移,并引入了一系列新的基础与增强组件。

主要变更包括:
- 核心组件升级:将现有组件(如 `OverlayBox`, `UserRank`, `Timeline` 等)重构以适配 Bootstrap 6 的类名和结构。
- 新增组件:
    - 布局相关:`Card`, `Grid` (Container, Row, Col), `Nav`
    - 媒体相关:`Image`
    - 交互相关:`Popover`, `Tooltip`
    - 数据展示:`Table`
- 代码重构:
    - 将部分 MobX 驱动的类组件转换为更简洁的函数式组件(如 `Time`, `TextTruncate` 等)。
    - 优化了 `ScrollNav` 的实现,将其拆分为 `Scroller` 逻辑组件。
    - 统一了 `Overlay` 相关的类型定义与方向处理。
- 文档与测试:
    - 更新 `ReadMe.md` 中的组件列表与示例代码。
    - 为新增组件编写了完整的单元测试,并更新了现有组件的测试用例以匹配 Bootstrap 6 的 DOM 结构。
- 版本更新:将 `package.json` 中的版本号提升至 `3.0.0-alpha.1`。
@TechQuery
TechQuery marked this pull request as ready for review October 30, 2026 22:18
同步更新文档内容以匹配 Bootstrap 6 的最新规范,并扩展了组件库的组件范围与功能细节。

主要变更包括:
- **组件实现扩展**:
    - 新增 `ButtonGroup`, `CloseButton`, `Drawer`, `ToggleButton` 等基础组件。
    - 增强 `Menu` 组件,引入 `MenuPanel`, `MenuHeader`, `MenuDivider`, `MenuSubmenu` 等子组件以支持复杂菜单结构。
    - 完善 `Navbar` 组件,新增 `NavbarBrand`, `NavbarNav`, `NavbarToggler` 等子组件。
    - 完善 `Nav` 组件,新增 `NavItem` 和 `NavLink`。
    - 增强 `Button` 组件,支持 `link` 变体及 `xs` 尺寸。
- **文档同步更新**:
    - 重写了 `Avatar`, `Badge`, `Button`, `Dialog`, `Menu`, `Navbar`, `OverlayBox`, `Spinner`, `Toast` 等核心组件的 MDX 文档,使其符合 Bootstrap 6 的设计指南与示例。
    - 更新了 `AGENTS.md` 中的 Bootstrap 源码获取路径。
    - 在文档页面中引入了新的交互式 Demo 组件(如 `DialogDemo`, `NavbarDemo`, `ToastDemo`)。
- **功能增强与优化**:
    - 为 `NativeDialog` 和 `Navbar` 增加了主题(`theme`)支持。
    - 为 `OverlayBox` 增加了自定义类名(`overlayClassName`)支持,便于实现自定义主题。
    - 优化了文档页面的布局,引入了 `DocumentationFooter`。
- **测试覆盖**:
    - 为新增组件(`ButtonGroup`, `CloseButton`, `Drawer`, `ToggleButton`)编写了单元测试。
    - 扩展了现有组件(`Button`, `Menu`, `Nav`, `Navbar`, `OverlayBox`)的测试用例,以验证 Bootstrap 6 的类名与交互逻辑。
通过新增多个核心组件、增强现有组件功能以及升级文档构建流程,进一步完善了基于 Bootstrap 6 的组件库。

主要变更包括:
- **新增组件实现**:
    - `ButtonGroup`: 支持水平与垂直布局。
    - `Card`: 提供灵活的内容容器。
    - `CloseButton`: 用于关闭对话框或抽屉的通用按钮。
    - `Drawer`: 基于原生 `<dialog>` 实现的侧边抽屉组件。
    - `Grid`: 实现响应式容器、行与列系统,支持断点布尔值配置。
    - `Image`: 支持响应式图片与缩略图样式。
    - `Nav`: 支持 Tabs、Pills、Underline 等多种导航样式。
    - `Table`: 支持条纹、悬停、边框等多种样式变体。
- **文档系统升级**:
    - 引入 `remark-gfm` 以支持 Markdown 中的 GitHub 风格表格。
    - 配置 Vite 插件,自动为文档中的 `table` 元素添加 `.table` 类名并包裹在 `.table-responsive` 容器中。
    - 新增多个组件的 MDX 交互式文档页面。
    - 更新侧边栏导航以包含新组件。
- **代码优化与测试**:
    - 优化 `Col` 组件的类型定义,支持 `true` 作为响应式断点的简写。
    - 为 `ButtonGroup` 和 `Grid` 增加了针对新特性的单元测试。
通过引入全新的交互式文档组件,提升了组件示例的可读性与演示效果。同时清理了不再使用的 `preview` 目录及相关依赖,优化了项目结构。

主要变更包括:
- **文档交互升级**:
    - 新增 `LiveRunner` 组件,利用 `LiveTSX` 实现文档页面的实时代码运行。
    - 新增 `CodeExample` 与 `LiveExample` 封装组件,支持在文档中同时展示代码块与实时交互演示。
    - 新增 `CodeCard` 用于美化代码展示样式。
    - 为 `Dialog`、`Loading`、`Select` 等多个组件新增了复杂的交互式 Demo 演示。
- **项目结构清理**:
    - 彻底移除 `preview/` 目录及其相关的配置文件(`package.json`, `tsconfig.json` 等)。
    - 从 `package.json` 中移除 `react-bootstrap` 依赖及相关的 `preview` 构建脚本。
    - 更新 `.npmignore` 以移除对已删除 `preview` 目录的忽略。
- **配置与文档更新**:
    - 更新 `document/app/site.ts`,移除已失效的预览站点链接及导航项。
    - 更新 `ReadMe.md`,同步移除预览站点的入口说明。
    - 优化了各组件 MDX 文档中的示例代码展示方式。
通过改进组件的布局逻辑、样式变量以及文档中的代码展示方式,提升了组件库的视觉一致性与文档的可读性。

主要变更包括:
- **组件样式与逻辑优化**:
    - **Overlay 系统**:为 `Popover` 和 `Tooltip` 的箭头(arrow)引入了基于位置的绝对定位类,并为 `OverlayBox` 增加了根据类型(popover/tooltip)自动计算间距(gap)的逻辑。
    - **组件细节调整**:优化了 `Menu` 的内联块布局、`Select` 的宽度控制、`VerticalMarquee` 的高度填充以及 `Card` 图片的填充模式。
    - **主题变量更新**:将 `OverlayBox` 的自定义样式从旧版 Bootstrap 变量迁移至 Bootstrap 6 的新版变量(如 `var(--bs-primary-bg)`)。
- **文档系统增强**:
    - **代码块升级**:在 MDX 文档中全面引入 `CodeBlock` 组件,统一了代码示例的展示风格,并支持了暗色主题(github-dark)。
    - **MDX 解析优化**:在 `vite.config.ts` 中新增了 `remarkInlineButtonChildren` 插件,解决了 MDX 解析中内联组件(如 `Button`, `Span` 等)可能导致的段落嵌套问题。
- **测试与配置**:
    - 更新了 `OverlayBox`、`Popover` 和 `Tooltip` 的单元测试,以匹配新的类名和布局结构。
    - 优化了文档布局的 CSS 样式,确保在暗色模式下代码高亮显示正常。
通过将大型组件拆分为更细粒度的子组件,并优化核心组件的 Props 定义,提升了组件库的可组合性与开发体验。

主要变更包括:
- **组件原子化重构**:
    - **Card**:新增 `CardHeader`、`CardBody`、`CardFooter` 和 `CardTitle` 子组件,取代原有的纯 div 布局。
    - **Drawer**:新增 `DrawerHeader`、`DrawerTitle`、`DrawerBody` 和 `DrawerFooter` 子组件。
    - **NativeDialog**:新增 `DialogHeader`、`DialogTitle`、`DialogBody` 和 `DialogFooter` 子组件。
    - **ButtonGroup**:新增 `ButtonToolbar` 组件,用于处理工具栏角色。
    - **ListGroup**:新增 `ListGroup` 及 `ListGroupItem` 组件,支持水平、编号及紧凑(flush)模式。
- **API 与逻辑优化**:
    - **Grid**:重构 `Row` 组件,支持通过 `cols` 和响应式断点 props(`sm`, `md` 等)直接控制列数,简化了 `row-cols-*` 类名的手动编写。
    - **Overlay**:统一了 `Popover` 和 `Tooltip` 的 Props 接口,通过 `OverlayTriggerProps` 实现逻辑复用。
    - **Select**:优化了 `SelectProps` 的类型定义,使其更符合 Bootstrap 6 的属性规范。
    - **MobX 实践**:将部分类组件中的 `@action` 装饰器改为 `action()` 函数式包装,并优化了异步方法后的状态更新逻辑。
- **文档与测试同步**:
    - 更新了所有受影响组件的 MDX 文档示例,使用新的原子化组件进行演示。
    - 增加了 `ListGroup` 的单元测试,并同步更新了 `Card`、`Drawer`、`Grid`、`NativeDialog` 等组件的测试用例以匹配新的子组件结构。
新增 ListGroup 组件及其子组件 ListGroupItem,支持多种交互模式与样式。同时更新文档系统以展示新组件。

主要变更:
- **组件实现**:
    - 实现 `ListGroup` 容器组件。
    - 实现 `ListGroupItem` 组件,支持根据 `href` 或 `type` 属性自动切换渲染为 `<a>`、`<button>` 或 `<li>` 标签。
    - 支持 `action`、`active`、`disabled`、`flush` 及 `numbered` 等 Bootstrap 6 风格的属性。
    - 为禁用状态的交互元素添加了 `pe-none` 类名及相应的无障碍属性处理。
- **文档更新**:
    - 新增 `ListGroup` 的 MDX 示例文档,涵盖基础用法、激活状态、链接与按钮模式、紧凑模式及编号模式。
    - 在组件概览页及侧边栏导航中同步添加了 ListGroup 链接。
- **测试增强**:
    - 编写 `ListGroup` 的单元测试,验证不同标签渲染逻辑、类名组合以及无障碍属性(aria-current, aria-disabled)的正确性。
@TechQuery TechQuery changed the title Upgrade Idea React components and docs to Bootstrap 6 [refactor] upgrade Idea React v2 components & examples to Bootstrap 6 Nov 1, 2026
@TechQuery
TechQuery merged commit 4c030d5 into main Nov 1, 2026
4 checks passed
@TechQuery
TechQuery deleted the copilot/upgrade-bootstrap-v6-components branch November 1, 2026 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Some improvements feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

升级 Idea React v2 组件到 Bootstrap v6

2 participants