Skip to content

Commit

Permalink
Merge pull request #75 from FriedRiceNoodles/docs/menu
Browse files Browse the repository at this point in the history
docs(menu): added html source code, and updated docs
  • Loading branch information
FriedRiceNoodles authored Mar 16, 2024
2 parents 53548f9 + e6699c6 commit 32874d8
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { Divider, Menu, MenuItem } from '@banana-ui/react';
import React from 'react';

export default function BasicUsage() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { Divider, Menu, MenuItem } from '@banana-ui/react';
import React from 'react';

export default function BasicUsage() {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
*/

import { Divider, Menu, MenuItem } from '@banana-ui/react';
import React from 'react';

export default function BasicUsage() {
const onSelect = (
Expand Down
21 changes: 7 additions & 14 deletions docs/example/Menu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,15 @@ demo:
<b-menu> | Menu
```

:::info
Menu 组件搭配 MenuItem 组件使用

```
<b-menu-item> | MenuItem
```

:::
## 介绍

菜单提供了一个选项/操作列表供用户选择。

## 代码演示

<code src="./demos/BasicUsage.tsx"></code>
<code src="./demos/Disabled.tsx"></code>
<code src="./demos/Event.tsx"></code>
<code src="./demos/basicUsage.tsx"></code>
<code src="./demos/disabled.tsx"></code>
<code src="./demos/event.tsx"></code>

## 属性 (MenuItem 菜单子项) - Attributes & Properties

Expand All @@ -36,9 +29,9 @@ Menu 组件搭配 MenuItem 组件使用

## 事件 - Events

| 事件 | 说明 | Event Detail |
| ------ | ---------- | ---------------- |
| select | 选中时触发 | `{item: string}` |
| 事件 | 说明 | Event Detail |
| ------ | ---------- | ------------------------- |
| select | 选中时触发 | `{item: {value: string}}` |

## 插槽 - Slots

Expand Down
11 changes: 11 additions & 0 deletions public/Menu/basicUsage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<b-menu style="max-width: 200px;">
<b-menu-item>Option 1</b-menu-item>
<b-menu-item>Option 2</b-menu-item>
<b-menu-item>Option 3</b-menu-item>
<b-menu-item>Option 4</b-menu-item>
<b-menu-item>Option 5</b-menu-item>
<b-divider></b-divider>
<b-menu-item>Option A</b-menu-item>
<b-menu-item>Option B</b-menu-item>
<b-menu-item>Option C</b-menu-item>
</b-menu>
7 changes: 7 additions & 0 deletions public/Menu/disabled.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<b-menu style="max-width: 200px;">
<b-menu-item>Option 1</b-menu-item>
<b-menu-item>Option 2</b-menu-item>
<b-menu-item>Option 3</b-menu-item>
<b-divider></b-divider>
<b-menu-item disabled>Disabled</b-menu-item>
</b-menu>
14 changes: 14 additions & 0 deletions public/Menu/event.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<b-menu style="max-width: 200px;">
<b-menu-item value="opt-1">Option 1</b-menu-item>
<b-menu-item value="opt-2">Option 2</b-menu-item>
<b-menu-item value="opt-3">Option 3</b-menu-item>
<b-divider></b-divider>
<b-menu-item value="disabled" disabled>Disabled</b-menu-item>
</b-menu>

<script>
const menu = document.querySelector('b-menu');
menu.addEventListener('select', (event) => {
console.log(event.detail.item.value);
});
</script>

0 comments on commit 32874d8

Please sign in to comment.