Skip to content

feat(tabs): add header-only #3638

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

liangguanhui0117
Copy link

@liangguanhui0117 liangguanhui0117 commented Aug 10, 2025

PR

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • [x ] Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Tabs很多时候会作为状态控件使用。

Tabs are often used as status controls.

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added a new header-only boolean option for Tabs (default: false). In PC mode it displays only tab headers, omits rendering tab content, and forces position to top when enabled.
    • Added a demo component demonstrating the header-only behavior.
  • Documentation

    • Demo listings and descriptions updated to include the new header-only example.

Copy link

coderabbitai bot commented Aug 10, 2025

Walkthrough

Added a boolean headerOnly prop to Tabs, threaded through props, state, and types; render logic now suppresses tab content and forces position to top when enabled. Demo component and docs were added to showcase the header-only mode.

Changes

Cohort / File(s) Change Summary
Tabs props & PC render
packages/vue/src/tabs/src/index.ts, packages/vue/src/tabs/src/pc.vue
Added headerOnly: Boolean prop; when true, position is set to 'top' and slot content is rendered differently (no wrapping content container when header-only).
Renderless state & types
packages/renderless/src/tabs/vue.ts, packages/renderless/types/tabs.type.ts
Added headerOnly to reactive state (initialized from props) and declared optional headerOnly?: boolean on ITabsState.
Tab-item PC render
packages/vue/src/tab-item/src/pc.vue
Modified pane root render condition to avoid rendering tab pane content when root tabs are in header-only mode (!state.rootTabs.headerOnly).
Demos & docs
examples/sites/demos/apis/tabs.js, examples/sites/demos/pc/app/tabs/header-only.vue, .../webdoc/tabs.js
Added header-only API entry, new header-only.vue demo component, and registered the header-only demo in PC demos array.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Tabs
    participant TabItem

    User->>Tabs: enable headerOnly (prop)
    Tabs->>Tabs: state.headerOnly = true
    Tabs->>TabItem: set rootTabs.headerOnly = true
    TabItem->>TabItem: skip rendering pane content
    User->>Tabs: disable headerOnly
    Tabs->>TabItem: render pane content as normal
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Poem

I nibble keys and toss a clue,
Headers shimmer, panes say adieu.
One little flag, the top stays bright,
Tabs trimmed tidy in morning light.
— a rabbit, hopping through the view 🐇✨

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between edd4788 and cd3ed63.

📒 Files selected for processing (2)
  • examples/sites/demos/apis/tabs.js (1 hunks)
  • examples/sites/demos/pc/app/tabs/webdoc/tabs.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • examples/sites/demos/apis/tabs.js
  • examples/sites/demos/pc/app/tabs/webdoc/tabs.js
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the enhancement New feature or request (功能增强) label Aug 10, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (9)
packages/renderless/types/tabs.type.ts (1)

36-36: Add brief JSDoc and platform note

Document what headerOnly controls and that it’s intended for PC mode to aid discoverability in editors.

packages/vue/src/tabs/src/index.ts (1)

73-75: Prop looks fine; add a short comment and/or explicit default for clarity

Boolean props default to false implicitly. Adding a small comment (PC-only) and/or default: false can make intent obvious to readers.

   // 只渲染头部
-  headerOnly: Boolean
+  // PC only: when true, only render tab headers; content panels are omitted
+  headerOnly: {
+    type: Boolean,
+    default: false
+  }
examples/sites/demos/apis/tabs.js (1)

297-309: Consider adding “since version” metadata

If your docs pattern supports it, noting the version this prop was introduced in helps consumers track availability.

packages/vue/src/tab-item/src/pc.vue (2)

14-14: Optional: extract condition into a computed for readability

The in-template boolean is getting long. A computed like shouldRenderPanel improves readability and reuse.

In script:

const shouldRenderPanel = computed(
  () => !state.rootTabs.headerOnly && (!props.lazy || state.loaded || state.active)
)

In template:

<div v-if="shouldRenderPanel" v-show="state.active" ...>

14-14: Tests missing for new mode

Add unit tests to assert no tabpanel elements render when header-only is true, and that tab header interactions still emit click/change events as expected.

I can scaffold @vue/test-utils + vitest tests if helpful.

examples/sites/demos/pc/app/tabs/webdoc/tabs.js (1)

279-281: Fix typo and improve en-US phrasing/capitalization

  • Extra ">" inside the code tag.
  • Improve phrasing; capitalize "Only" in the demo name for consistency.

Apply:

-        'en-US': 'Use <code>>header-only</code> header only.'
+        'en-US': 'Use <code>header-only</code> to display only the header.'

And optionally:

-        'en-US': 'Header only'
+        'en-US': 'Header Only'

Also applies to: 276-276

examples/sites/demos/pc/app/tabs/header-only.vue (3)

2-2: Avoid passing a position that will be ignored in header-only mode

Since the component currently forces position to 'top' when header-only is set, remove the :position binding (or change the component to respect it).

Apply:

-  <tiny-tabs tab-style="card" style="width: 500px" :position="position" header-only>
+  <tiny-tabs tab-style="card" style="width: 500px" header-only>

And drop the unused position from data:

-      position: 'left',

Also applies to: 19-20


9-9: Use plain JS for the script block

No JSX is used; prefer lang="js" for clarity.

-<script lang="jsx">
+<script lang="js">

32-33: Remove unused data property

tabIndex is defined but unused.

-      ],
-      tabIndex: 2
+      ]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3e0d35 and 66ba41e.

📒 Files selected for processing (8)
  • examples/sites/demos/apis/tabs.js (1 hunks)
  • examples/sites/demos/pc/app/tabs/header-only.vue (1 hunks)
  • examples/sites/demos/pc/app/tabs/webdoc/tabs.js (1 hunks)
  • packages/renderless/src/tabs/vue.ts (1 hunks)
  • packages/renderless/types/tabs.type.ts (1 hunks)
  • packages/vue/src/tab-item/src/pc.vue (1 hunks)
  • packages/vue/src/tabs/src/index.ts (1 hunks)
  • packages/vue/src/tabs/src/pc.vue (3 hunks)
🔇 Additional comments (7)
packages/renderless/types/tabs.type.ts (1)

36-36: Type addition for headerOnly is reasonable

Optional boolean on ITabsState aligns with the new prop and existing optional fields (e.g., separator). No correctness concerns.

packages/vue/src/tabs/src/index.ts (1)

72-72: Scope check: panelWidth included in this PR

panelWidth appears alongside headerOnly here. If it’s unrelated to “header-only tabs,” consider splitting to keep PR scope focused and ease tracing changes. If intentional, ensure API docs and demos cover it (they seem to).

examples/sites/demos/apis/tabs.js (1)

297-309: API surface addition LGTM

The header-only prop is documented with clear zh-CN/en-US descriptions, pc-only mode, and demo reference.

packages/vue/src/tab-item/src/pc.vue (1)

14-14: Conditional omit of tab panels aligns with header-only behavior

v-if gate prevents content mount in header-only mode. This matches the feature goal.

examples/sites/demos/pc/app/tabs/webdoc/tabs.js (1)

273-283: Demo entry linkage LGTM

demoId, description, and codeFiles correctly point to header-only.vue; matches the new feature intent.

packages/vue/src/tabs/src/pc.vue (2)

55-57: Prop addition LGTM

New boolean prop headerOnly is correctly exposed in the component’s props list.


96-96: Confirm headerOnly orientation UX
The PC implementation currently hard‐codes the tab header to the top when headerOnly is true—ignoring any consumer‐provided position (e.g. your demo uses left). We need to decide whether:

  • Header‐only must always render at top. In that case, update demos/docs to remove or call out position when headerOnly is applied.
  • Headers should respect the position prop even in header‐only mode. Then remove the override so user orientation is honored.

Locations to review:

  • packages/vue/src/tabs/src/pc.vue:
    • Line ~96:
      -    const position = headerOnly ? 'top' : this.position
      +    const position = this.position
    Changing this is sufficient because TabNav PC reads state.rootTabs.position (from this local position)—no extra prop forwarding is required.

Please confirm the intended UX and update code/docs accordingly.

Copy link
Collaborator

@chenxi-20 chenxi-20 left a comment

Choose a reason for hiding this comment

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

请按照建议更改 @liangguanhui0117

type: 'boolean',
defaultValue: 'false',
desc: {
'zh-CN': '当 header-only 为 true 时,页签内容不再渲染,并且 position 将被设置为固定值 top',
Copy link
Collaborator

@chenxi-20 chenxi-20 Aug 18, 2025

Choose a reason for hiding this comment

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

建议描述更改为:当 header-only 为 true 时,页签内容不再渲染;此时position 值只能为 top

但更好的方式应该是支持所有的position值,只有top不太合理

@liangguanhui0117

Copy link
Author

Choose a reason for hiding this comment

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

那我把所有position模式,都支持下

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request (功能增强)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants