tiny-vue icon indicating copy to clipboard operation
tiny-vue copied to clipboard

✨ [Feature]: tree-menu支持分割线进行分组

Open kagol opened this issue 1 year ago • 2 comments

What problem does this feature solve

希望支持类似以下效果:

image

本来尝试使用 default 插槽实现,但是 default 插槽包裹了很多外层dom节点,导致效果不好。

const menus = [
  { id: 'inbox', label: 'Inbox' },
  { id: 'drafts', label: 'Drafts' },
  { id: 'sent', label: 'Sent' },
  { id: 'junk', label: 'Junk' },
  { id: 'trash', label: 'Trash' },
  { id: 'archive', label: 'Archive' },
  { type: 'split' },
  { id: 'social', label: 'Social' },
  { id: 'updates', label: 'Updates' },
  { id: 'forums', label: 'Forums' },
  { id: 'shopping', label: 'Shopping' },
  { id: 'promotions', label: 'Promotions' },
]

<tiny-tree-menu :data="menus" :show-filter="false" style="width: 100%; padding: 0 0.5rem;">
  <template #default="{ node, data }">
    <tiny-divider v-if="data.type === 'split'" style="width: 100%;"></tiny-divider>
    <span v-else>{{ data.label }}</span>
  </template>
</tiny-tree-menu>

实现出来的效果如下:

image

这不是我希望的效果。

What does the proposed API look like

可以设置一个特殊的 option: { type: 'split' },用来实现分组。

大致用法如下:

const menus = [
  { id: 'inbox', label: 'Inbox' },
  { id: 'drafts', label: 'Drafts' },
  { id: 'sent', label: 'Sent' },
  { id: 'junk', label: 'Junk' },
  { id: 'trash', label: 'Trash' },
  { id: 'archive', label: 'Archive' },
  { type: 'split' },
  { id: 'social', label: 'Social' },
  { id: 'updates', label: 'Updates' },
  { id: 'forums', label: 'Forums' },
  { id: 'shopping', label: 'Shopping' },
  { id: 'promotions', label: 'Promotions' },
]

<tiny-tree-menu :data="menus" :show-filter="false">
</tiny-tree-menu>

What is your project name

邮箱应用

kagol avatar Aug 10 '24 03:08 kagol

Bot detected the issue body's language is not English, translate it automatically.


Title: ✨ [Feature]: tree-menu supports dividing lines for grouping

Issues-translate-bot avatar Aug 10 '24 03:08 Issues-translate-bot

这样的 api 会不会好一点

const menus = [
  { id: 'inbox', label: 'Inbox' },
  { id: 'drafts', label: 'Drafts' },
  { id: 'sent', label: 'Sent' },
  { id: 'junk', label: 'Junk' },
  { id: 'trash', label: 'Trash' },
  { id: 'archive', label: 'Archive', split: true },
  { id: 'social', label: 'Social' },
  { id: 'updates', label: 'Updates' },
  { id: 'forums', label: 'Forums' },
  { id: 'shopping', label: 'Shopping' },
  { id: 'promotions', label: 'Promotions' },
]

<tiny-tree-menu :data="menus" :show-filter="false">
</tiny-tree-menu>

gweesin avatar Aug 10 '24 07:08 gweesin