Skip to content
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

Menu: add menu attribute - collapseTransition #8809

Merged
merged 2 commits into from Mar 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions examples/docs/en-US/menu.md
Expand Up @@ -282,6 +282,7 @@ Vertical NavMenu could be collapsed.
| unique-opened | whether only one sub-menu can be active | boolean | — | false |
| menu-trigger | how sub-menus are triggered, only works when `mode` is 'horizontal' | string | — | hover |
| router | whether `vue-router` mode is activated. If true, index will be used as 'path' to activate the route action | boolean | — | false |
| collapse-transition | whether the menu collapse transition is active | boolean | — | true |

### Menu Methods
| Event Name | Description | Parameters |
Expand Down
1 change: 1 addition & 0 deletions examples/docs/zh-CN/menu.md
Expand Up @@ -283,6 +283,7 @@
| unique-opened | 是否只保持一个子菜单的展开 | boolean | — | false |
| menu-trigger | 子菜单打开的触发方式(只在 mode 为 horizontal 时有效) | string | — | hover |
| router | 是否使用 vue-router 的模式,启用该模式会在激活导航时以 index 作为 path 进行路由跳转 | boolean | — | false |
| collapse-transition | 是否开启折叠动画 | boolean | — | true |

### Menu Methods
| 事件名称 | 说明 | 参数 |
Expand Down
50 changes: 33 additions & 17 deletions packages/menu/src/menu.vue
@@ -1,19 +1,4 @@
<template>
<el-menu-collapse-transition>
<ul class="el-menu"
:key="+collapse"
:style="{ backgroundColor: backgroundColor || '' }"
:class="{
'el-menu--horizontal': mode === 'horizontal',
'el-menu--collapse': collapse
}"
role="menubar"
>
<slot></slot>
</ul>
</el-menu-collapse-transition>
</template>
<script>
<script type="text/jsx">
import emitter from 'element-ui/src/mixins/emitter';
import Migrating from 'element-ui/src/mixins/migrating';
import Menubar from 'element-ui/src/utils/menu/aria-menubar';
Expand All @@ -22,6 +7,33 @@
export default {
name: 'ElMenu',

render (h) {
const component = (
<ul
role="menubar"
key={ +this.collapse }
style={{ backgroundColor: this.backgroundColor || '' }}
class={{
'el-menu--horizontal': this.mode === 'horizontal',
'el-menu--collapse': this.collapse,
"el-menu": true
}}
>
{ this.$slots.default }
</ul>
);

if (this.collapseTransition) {
return (
<el-menu-collapse-transition>
{ component }
</el-menu-collapse-transition>
);
} else {
return component;
}
},

componentName: 'ElMenu',

mixins: [emitter, Migrating],
Expand Down Expand Up @@ -114,7 +126,11 @@
collapse: Boolean,
backgroundColor: String,
textColor: String,
activeTextColor: String
activeTextColor: String,
collapseTransition: {
type: Boolean,
default: true
}
},
data() {
return {
Expand Down
3 changes: 3 additions & 0 deletions types/menu.d.ts
Expand Up @@ -34,4 +34,7 @@ export declare class ElMenu extends ElementUIComponent {

/** Whether vue-router mode is activated. If true, index will be used as 'path' to activate the route action */
router: boolean

/** Whether the menu collapse transition is active */
collapseTransition: boolean
}