Skip to content

docs: add layout component documentation and examples#371

Open
SonyLeo wants to merge 7 commits into
opentiny:developfrom
SonyLeo:feat/layout-docs
Open

docs: add layout component documentation and examples#371
SonyLeo wants to merge 7 commits into
opentiny:developfrom
SonyLeo:feat/layout-docs

Conversation

@SonyLeo

@SonyLeo SonyLeo commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

Layout 组件文档预览地址如下:

Layout 组件 →

Summary by CodeRabbit

  • New Features

    • Added a comprehensive set of layout demos covering basic usage, aside toggles, controlled and resizable sidebars, drawer modes, floating panels, and scroll-aware main content.
    • Added support for a cleaner floating layout experience when dragging is disabled.
  • Documentation

    • Expanded the layout component guide with usage patterns, configuration options, events, slots, and examples.
    • Updated the component navigation to include the Layout layout page.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds 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.

Changes

Layout Documentation and Demos

Layer / File(s) Summary
Sidebar navigation entry
docs/.vitepress/themeConfig.ts
Adds a "Layout 布局" link to the components sidebar.
Layout documentation page
docs/src/components/layout.md
New docs covering layout skeleton, mode, aside dock/drawer/collapse/resize, floating state, ProxyScrollbar, AsideToggle, props/slots/events/types tables, and CSS variables.
Basic layout and aside behavior demos
docs/demos/layout/basic.vue, docs/demos/layout/aside-collapse-effect.vue, docs/demos/layout/aside-resizable.vue, docs/demos/layout/aside-modes.vue, docs/demos/layout/aside-toggle.vue, docs/demos/layout/aside-controlled.vue
Demonstrates basic aside/header/footer slots, collapse effects, resizable width, dock/drawer modes, toggle-driven UI, and externally controlled aside state.
Floating mode demos
docs/demos/layout/floating-controlled.vue, docs/demos/layout/floating-panels.vue, docs/demos/layout/floating.vue, docs/demos/layout/mode.vue
Demonstrates controlled/uncontrolled floating state, draggable/resizable options, drawer-based floating panels, and normal-vs-floating mode switching.
Main scroll proxy scrollbar demos
docs/demos/layout/main-scroll-bubble.vue, docs/demos/layout/main-scroll-div.vue, docs/demos/layout/main-scroll.vue
Demonstrates TrLayout.ProxyScrollbar wired to a BubbleList and a plain div, with a switcher demo toggling between them.
Floating drag bar visibility
packages/components/src/layout/components/LayoutSurface.vue
Renders FloatingDragBar only when floating mode is active and the instance is draggable, instead of whenever floating.

Estimated code review effort: 2 (Simple) | ~15 minutes

Suggested reviewers: gene9831

Poem

Through docks and drawers I hop and glide,
Floating panels swaying side to side,
A scrollbar proxy, sleek and neat,
Drag bars now know when to greet. 🐇
Docs bloom bright, demos abound —
This bunny's burrow: solid ground! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the PR’s main change: adding Layout documentation and example demos.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@SonyLeo SonyLeo changed the title feat(docs): add layout component usage documentation docs: add layout component usage documentation Jun 30, 2026
@github-actions

github-actions Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

✅ Preview build completed successfully!

Click the image above to preview.
Preview will be automatically removed when this PR is closed.

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 79556a0 and d4346b6.

📒 Files selected for processing (12)
  • docs/.vitepress/themeConfig.ts
  • docs/demos/layout/aside-collapse-effect.vue
  • docs/demos/layout/aside-modes.vue
  • docs/demos/layout/aside-resizable.vue
  • docs/demos/layout/aside-slot-props.vue
  • docs/demos/layout/basic.vue
  • docs/demos/layout/floating-panels.vue
  • docs/demos/layout/floating.vue
  • docs/demos/layout/main-scroll-bubble.vue
  • docs/demos/layout/main-scroll-div.vue
  • docs/demos/layout/main-scroll.vue
  • docs/src/components/layout.md

Comment thread docs/demos/layout/aside-modes.vue Outdated
Comment thread docs/demos/layout/aside-resizable.vue Outdated
Comment thread docs/demos/layout/aside-slot-props.vue Outdated
Comment thread docs/demos/layout/aside-controlled.vue Outdated
Comment thread docs/demos/layout/floating-panels.vue Outdated
@SonyLeo SonyLeo changed the title docs: add layout component usage documentation docs: add layout component documentation and examples Jul 2, 2026
<demo vue="../../demos/layout/basic.vue" title="基础布局" description="最小布局示例。" />

## 侧栏

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我建议在 侧栏 这里说明下,影响侧栏的属性是 leftAsiderightAside,类型是 LayoutAsideProps。后面子章节,就不用再说明用 leftAside / rightAside 配置侧栏了

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已处理

image

<demo vue="../../demos/layout/aside-resizable.vue" title="宽度调整" description="拖动分隔线查看当前宽度和边界。" />

## 主区滚动

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里可以说明下,为什么提供这个组件

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已经补充说明

image

}
```

<demo

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个示例,我切换内容居中,会导致scrollTarget出现滚动条,应该是个bug

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已处理

如果文档页还是显示旧效果,建议清除缓存,或者开启无痕进行查看

【参考链接】
主区滚动 🔗

【效果截图】
layout-main-scrolling

Comment thread docs/src/components/layout.md Outdated
| `mode` | 布局模式;`normal` 参与普通布局,`floating` 会脱离普通布局,不占原来的位置空间 | `'normal' \| 'floating'` | `'normal'` |
| `leftAside` | 左侧栏配置 | [`LayoutAsideProps`](#layout-aside-props) | `-` |
| `rightAside` | 右侧栏配置 | [`LayoutAsideProps`](#layout-aside-props) | `-` |
| `floatingState` | 受控浮层状态,需配合 `update:floatingState` 回写 | [`LayoutFloatingState`](#layout-floating-state) | `-` |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

回写 换个描述,比如 双向绑定

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已处理,改写为 “同步外部状态”

Comment thread docs/src/components/layout.md Outdated

侧栏内容通过 `left-aside` / `right-aside` 提供。

受控用法下,状态变化后需要同步回写。侧栏内部切换可使用 `Layout.AsideToggle`,默认插槽提供 `{ isOpen }`。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

回写 换个描述

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已处理

Comment thread docs/src/components/layout.md Outdated

### 基本用法

`defaultFloatingState` 设置初始位置和大小,`floatingOptions` 设置拖动、缩放和尺寸范围。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 说明下 floatingState/defaultFloatingState 是受控/非受控下设置的值。
  2. 这里你只说明了 floatingState, floatingOptions 这一层,内部具体的属性,比如 placement, draggable 等其他都没说明。这里可以丰富下示例,比如加一个 draggable 开关,比如 placement 可以给个radio选择不同的placement,offsetX和offsetY设置0即可,这样能一眼看出 placement 的作用

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已处理

`Layout` 用于定义页面结构,区域中的具体内容可按需配置。

<demo vue="../../demos/layout/basic.vue" title="基础布局" description="最小布局示例。" />

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

基础布局之后,我建议按照 LayoutProps 的顺序来。先讲mode,然后是 leftAside/rightAside,接着 floating 相关的。
后面再接着讲 Layout.ProxyScrollbarLayout.AsideToggle

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已按照建议顺序调整

image

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/components/src/layout/components/LayoutSurface.vue (1)

84-85: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor duplication between canDragFloating and shouldShowFloatingDragBar.

Both share the isFloating.value && isFloatingDraggable.value sub-expression. Could derive shouldShowFloatingDragBar differently, 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6f9aac5 and 1aaee79.

📒 Files selected for processing (11)
  • docs/demos/layout/aside-collapse-effect.vue
  • docs/demos/layout/aside-modes.vue
  • docs/demos/layout/aside-slot-props.vue
  • docs/demos/layout/floating-controlled.vue
  • docs/demos/layout/floating-panels.vue
  • docs/demos/layout/floating.vue
  • docs/demos/layout/main-scroll-bubble.vue
  • docs/demos/layout/main-scroll-div.vue
  • docs/demos/layout/main-scroll.vue
  • docs/src/components/layout.md
  • packages/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`:占据页面空间

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没说明是LayoutAsideProps中的哪个属性

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已补充说明

image

Comment thread docs/src/components/layout.md Outdated
- `normal`:普通页面骨架,参与原始页面布局
- `floating`:悬浮工作区,脱离原始页面布局并挂载到 `body`

普通页面不需要显式传 `mode`。需要临时面板、悬浮工作台或可拖拽窗口时,再使用 `mode="floating"`。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

给个简单示例对比

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已补充案例说明

layout-mode

Comment thread docs/src/components/layout.md Outdated

`Layout.AsideToggle` 是内置侧栏开关按钮,只能在 `Layout` 内部使用,通常放在 `left-aside` / `right-aside` 插槽中。

它适合让侧栏内容自己控制展开和收起,默认插槽提供 `{ isOpen }`。自定义按钮内容时,应保留可读文本或补充 `aria-label`。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有代码示例

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已补充相关案例

layout-slot-mode

Comment thread docs/src/components/layout.md Outdated
description="内容区居中后,滚动条仍固定在主区右侧。"
/>

## Layout.AsideToggle

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以用中文描述

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已处理

标题由 Layout.AsideToggle 替换为 侧栏内控制

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 10e6b2b and 260ede9.

📒 Files selected for processing (5)
  • docs/demos/layout/aside-controlled.vue
  • docs/demos/layout/aside-modes.vue
  • docs/demos/layout/aside-toggle.vue
  • docs/demos/layout/mode.vue
  • docs/src/components/layout.md
✅ Files skipped from review due to trivial changes (2)
  • docs/demos/layout/aside-toggle.vue
  • docs/src/components/layout.md

Comment thread docs/demos/layout/mode.vue Outdated
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