docs: add layout component documentation and examples#371
Conversation
…ating panels, and scrollable main content
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds Layout component documentation and sidebar entry, along with numerous demo Vue files covering basic layout, aside dock/drawer/collapse/resize/toggle/controlled modes, floating mode variants, and main scroll proxy scrolling. Also fixes LayoutSurface to only render the floating drag bar when draggable. ChangesLayout Documentation and Demos
Estimated code review effort: 2 (Simple) | ~15 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
📦 Package Previewpnpm add https://pkg.pr.new/@opentiny/tiny-robot@d4346b6 pnpm add https://pkg.pr.new/@opentiny/tiny-robot-kit@d4346b6 pnpm add https://pkg.pr.new/@opentiny/tiny-robot-svgs@d4346b6 commit: d4346b6 |
There was a problem hiding this comment.
Actionable comments posted: 5
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/demos/layout/aside-modes.vue`:
- Around line 4-15: The left/right aside open-change handlers are using the
broader LayoutAsideOpenDetail type even though the emitted payload is
LayoutAsideOpenValue. Update the imports and the
updateLeftAside/updateRightAside parameter types to use LayoutAsideOpenValue,
keeping the handlers focused on the { open } payload so the template type-check
matches the emit signatures.
In `@docs/demos/layout/aside-resizable.vue`:
- Around line 4-5: The `left-aside-resize` event payload is typed incorrectly in
`aside-resizable.vue`; `updateLeftAsideWidth` should use
`LayoutAsideResizeValue` because the event emits `{ expandedWidth }`, not
`LayoutAsideResizeDetail`. Update the import from `@opentiny/tiny-robot` and
change the `updateLeftAsideWidth` handler signature to match the actual
`@left-aside-resize` payload so the demo type matches the event data.
In `@docs/demos/layout/aside-slot-props.vue`:
- Around line 12-19: The left aside in the demo is being collapsed to zero
width, which prevents the rail UI from having any visible space when the aside
is closed. Update the `leftAside` computed in `aside-slot-props.vue` to either
use a non-zero `collapsedWidth` or stop rendering the closed-state rail branch
and rely on the external control only; keep the behavior consistent anywhere the
same pattern is repeated.
- Around line 4-5: The aside event handlers in the demo are typed with the
generic payload interfaces, but the emitted payloads for the side-specific
events do not include a side field. Update the callback typings in
aside-slot-props.vue and the other aside event bindings in this demo to use the
side-specific payload shapes for left/right-aside-open-change and
left/right-aside-resize, and keep LayoutAsideProps only where the full aside
props are actually needed.
In `@docs/demos/layout/floating-panels.vue`:
- Line 4: The `left-aside-open-change` and `right-aside-open-change` handlers
are typed with `LayoutAsideOpenDetail`, but those events emit an `{ open }`
payload, so update the relevant type usage in `floating-panels.vue` to
`LayoutAsideOpenValue` instead. Locate the handler typings and any related
references to `LayoutAsideOpenDetail` in the floating panels demo, and replace
them so the event payload type matches the emitted shape.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: dc237448-4a35-4b26-8d3f-a3da5f984dcd
📒 Files selected for processing (12)
docs/.vitepress/themeConfig.tsdocs/demos/layout/aside-collapse-effect.vuedocs/demos/layout/aside-modes.vuedocs/demos/layout/aside-resizable.vuedocs/demos/layout/aside-slot-props.vuedocs/demos/layout/basic.vuedocs/demos/layout/floating-panels.vuedocs/demos/layout/floating.vuedocs/demos/layout/main-scroll-bubble.vuedocs/demos/layout/main-scroll-div.vuedocs/demos/layout/main-scroll.vuedocs/src/components/layout.md
| <demo vue="../../demos/layout/basic.vue" title="基础布局" description="最小布局示例。" /> | ||
|
|
||
| ## 侧栏 | ||
|
|
There was a problem hiding this comment.
我建议在 侧栏 这里说明下,影响侧栏的属性是 leftAside 和 rightAside,类型是 LayoutAsideProps。后面子章节,就不用再说明用 leftAside / rightAside 配置侧栏了
| <demo vue="../../demos/layout/aside-resizable.vue" title="宽度调整" description="拖动分隔线查看当前宽度和边界。" /> | ||
|
|
||
| ## 主区滚动 | ||
|
|
| } | ||
| ``` | ||
|
|
||
| <demo |
There was a problem hiding this comment.
这个示例,我切换内容居中,会导致scrollTarget出现滚动条,应该是个bug
There was a problem hiding this comment.
| | `mode` | 布局模式;`normal` 参与普通布局,`floating` 会脱离普通布局,不占原来的位置空间 | `'normal' \| 'floating'` | `'normal'` | | ||
| | `leftAside` | 左侧栏配置 | [`LayoutAsideProps`](#layout-aside-props) | `-` | | ||
| | `rightAside` | 右侧栏配置 | [`LayoutAsideProps`](#layout-aside-props) | `-` | | ||
| | `floatingState` | 受控浮层状态,需配合 `update:floatingState` 回写 | [`LayoutFloatingState`](#layout-floating-state) | `-` | |
|
|
||
| 侧栏内容通过 `left-aside` / `right-aside` 提供。 | ||
|
|
||
| 受控用法下,状态变化后需要同步回写。侧栏内部切换可使用 `Layout.AsideToggle`,默认插槽提供 `{ isOpen }`。 |
|
|
||
| ### 基本用法 | ||
|
|
||
| `defaultFloatingState` 设置初始位置和大小,`floatingOptions` 设置拖动、缩放和尺寸范围。 |
There was a problem hiding this comment.
- 说明下
floatingState/defaultFloatingState是受控/非受控下设置的值。 - 这里你只说明了
floatingState,floatingOptions这一层,内部具体的属性,比如placement,draggable等其他都没说明。这里可以丰富下示例,比如加一个draggable开关,比如placement可以给个radio选择不同的placement,offsetX和offsetY设置0即可,这样能一眼看出 placement 的作用
| `Layout` 用于定义页面结构,区域中的具体内容可按需配置。 | ||
|
|
||
| <demo vue="../../demos/layout/basic.vue" title="基础布局" description="最小布局示例。" /> | ||
|
|
There was a problem hiding this comment.
基础布局之后,我建议按照 LayoutProps 的顺序来。先讲mode,然后是 leftAside/rightAside,接着 floating 相关的。
后面再接着讲 Layout.ProxyScrollbar 和 Layout.AsideToggle
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/components/src/layout/components/LayoutSurface.vue (1)
84-85: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor duplication between
canDragFloatingandshouldShowFloatingDragBar.Both share the
isFloating.value && isFloatingDraggable.valuesub-expression. Could deriveshouldShowFloatingDragBardifferently, but not worth the churn given clarity is preserved.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/components/src/layout/components/LayoutSurface.vue` around lines 84 - 85, Remove the repeated predicate in LayoutSurface.vue by centralizing the shared isFloating.value && isFloatingDraggable.value check into a single computed or helper that both canDragFloating and shouldShowFloatingDragBar can use, while preserving the current behavior and keeping the readability of the two flags intact.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/components/src/layout/components/LayoutSurface.vue`:
- Around line 84-85: Remove the repeated predicate in LayoutSurface.vue by
centralizing the shared isFloating.value && isFloatingDraggable.value check into
a single computed or helper that both canDragFloating and
shouldShowFloatingDragBar can use, while preserving the current behavior and
keeping the readability of the two flags intact.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 031e19ea-9110-4282-acd0-8db82dcfc2b4
📒 Files selected for processing (11)
docs/demos/layout/aside-collapse-effect.vuedocs/demos/layout/aside-modes.vuedocs/demos/layout/aside-slot-props.vuedocs/demos/layout/floating-controlled.vuedocs/demos/layout/floating-panels.vuedocs/demos/layout/floating.vuedocs/demos/layout/main-scroll-bubble.vuedocs/demos/layout/main-scroll-div.vuedocs/demos/layout/main-scroll.vuedocs/src/components/layout.mdpackages/components/src/layout/components/LayoutSurface.vue
✅ Files skipped from review due to trivial changes (3)
- docs/demos/layout/floating-controlled.vue
- docs/demos/layout/aside-modes.vue
- docs/src/components/layout.md
🚧 Files skipped from review as they are similar to previous changes (7)
- docs/demos/layout/aside-collapse-effect.vue
- docs/demos/layout/main-scroll-bubble.vue
- docs/demos/layout/floating.vue
- docs/demos/layout/main-scroll.vue
- docs/demos/layout/floating-panels.vue
- docs/demos/layout/aside-slot-props.vue
- docs/demos/layout/main-scroll-div.vue
|
|
||
| ### 展示形态 | ||
|
|
||
| - `dock`:占据页面空间 |
There was a problem hiding this comment.
没说明是LayoutAsideProps中的哪个属性
| - `normal`:普通页面骨架,参与原始页面布局 | ||
| - `floating`:悬浮工作区,脱离原始页面布局并挂载到 `body` | ||
|
|
||
| 普通页面不需要显式传 `mode`。需要临时面板、悬浮工作台或可拖拽窗口时,再使用 `mode="floating"`。 |
|
|
||
| `Layout.AsideToggle` 是内置侧栏开关按钮,只能在 `Layout` 内部使用,通常放在 `left-aside` / `right-aside` 插槽中。 | ||
|
|
||
| 它适合让侧栏内容自己控制展开和收起,默认插槽提供 `{ isOpen }`。自定义按钮内容时,应保留可读文本或补充 `aria-label`。 |
| description="内容区居中后,滚动条仍固定在主区右侧。" | ||
| /> | ||
|
|
||
| ## Layout.AsideToggle |
There was a problem hiding this comment.
已处理
标题由 Layout.AsideToggle 替换为 侧栏内控制
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/demos/layout/mode.vue`:
- Around line 18-23: The TrLayout demo binds defaultFloatingState and
floatingOptions unconditionally, which breaks the LayoutNormalProps branch when
mode is normal. Update the mode.vue demo so those floating-only props are
applied only when mode === 'floating', ideally by moving them into a computed
v-bind object or equivalent conditional binding on TrLayout.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d1dd39f4-dd21-4e95-8eb3-18d91bbb6f01
📒 Files selected for processing (5)
docs/demos/layout/aside-controlled.vuedocs/demos/layout/aside-modes.vuedocs/demos/layout/aside-toggle.vuedocs/demos/layout/mode.vuedocs/src/components/layout.md
✅ Files skipped from review due to trivial changes (2)
- docs/demos/layout/aside-toggle.vue
- docs/src/components/layout.md








Layout 组件文档预览地址如下:
Layout 组件 →
Summary by CodeRabbit
New Features
Documentation