diff --git a/components.json b/components.json index 6d271113..1bf6dc72 100644 --- a/components.json +++ b/components.json @@ -4,6 +4,7 @@ "dialog": "./packages/dialog/index.js", "autocomplete": "./packages/autocomplete/index.js", "dropdown": "./packages/dropdown/index.js", + "dropdown-menu": "./packages/dropdown-menu/index.js", "dropdown-item": "./packages/dropdown-item/index.js", "menu": "./packages/menu/index.js", "submenu": "./packages/submenu/index.js", diff --git a/examples/docs/zh-cn/dropdown.md b/examples/docs/zh-cn/dropdown.md index 313e0646..cd6d9cca 100644 --- a/examples/docs/zh-cn/dropdown.md +++ b/examples/docs/zh-cn/dropdown.md @@ -3,23 +3,31 @@ .el-dropdown { vertical-align: top; - & .el-button-group { - margin-bottom: 0; - } & + .el-dropdown { margin-left: 15px; } } + .el-dropdown-link { + cursor: pointer; + color: #20a0ff; + } + .el-icon-caret-bottom { + vertical-align: middle; + font-size: 12px; + } } - .demo-dropdown .block { - display: inline-block; - padding: 30px 0; - text-align: center; - border-right: solid 1px #EFF2F6; - flex: 1; - &:last-child { - border-right: none; + .block-col-2 { + margin: -24px; + + .el-col { + padding: 30px 0; + text-align: center; + border-right: 1px solid #eff2f6; + + &:last-child { + border-right: 0; + } } } @@ -34,17 +42,9 @@ @@ -59,12 +59,17 @@ :::demo 通过`text`属性来设置按钮文字。默认条件下,他由一个主要按钮和一个下拉按钮组成,`el-dropdown`中的主要按钮同样可以设置点击事件,只要使用`mainclick`事件即可。默认情况下,下拉按钮只要`hover`即可,无需点击也会显示下拉菜单。 ```html - - 黄金糕 - 狮子头 - 螺蛳粉 - 双皮奶 - 蚵仔煎 + + + 下拉菜单 + + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + ``` ::: @@ -76,19 +81,29 @@ :::demo 设置`icon-separate`属性来呈现不带独立按钮的下拉菜单,设置为`false`即可。在选项三和选项四中插入了一条分割线,只需要在选项四中设置`class`为`divider`。 ```html - - 选项一 - 选项二 - 选项三 - 选项四 + + + 更多菜单 + + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + 更多菜单 + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + - - 选项一 - 选项二 - 选项三 - 选项四 - ``` ::: @@ -98,33 +113,51 @@ :::demo 在`trigger`属性设置为`click`即可。 ```html -
- hover 激活 - - 选项一 - 选项二 - 选项三 - 选项四 - -
-
- click 激活 - - 选项一 - 选项二 - 选项三 - 选项四 - -
+ + + hover 激活 + + + 下拉菜单 + + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + + click 激活 + + + 下拉菜单 + + + 黄金糕 + 狮子头 + 螺蛳粉 + 双皮奶 + 蚵仔煎 + + + + ``` ::: + ### Attributes | 参数 | 说明 | 类型 | 可选值 | 默认值 | |------------- |---------------- |---------------- |---------------------- |-------- | -| text | 菜单按钮文本 | string | — | — | | type | 菜单按钮类型,同 Button 组件 | string | — | — | -| trigger | 触发下拉菜单的方式 | string | hover,click | hover | -| icon-separate | 独立的下拉菜单按钮 | boolean | — | true | -| size | 菜单按钮尺寸,同 Button 组件 | string | large, small, mini | — | +| split-button | 带下拉框的按钮 | boolean | — | false | | menu-align | 菜单水平对齐方向 | string | start, end | end | +| trigger | 触发下拉的行为 | string | hover, click | hover | + +### Events +| 事件名称 | 说明 | 回调参数 | +|---------- |-------- |---------- | +| click | `split-button` 为 true 时,点击左侧按钮的回调 | — | diff --git a/packages/dropdown-menu/index.js b/packages/dropdown-menu/index.js new file mode 100644 index 00000000..72ff1af8 --- /dev/null +++ b/packages/dropdown-menu/index.js @@ -0,0 +1,7 @@ +const ElDropdownMenu = require('../dropdown/src/dropdown-menu'); + +ElDropdownMenu.install = function(Vue) { + Vue.component(ElDropdownMenu.name, ElDropdownMenu); +}; + +module.exports = ElDropdownMenu; diff --git a/packages/dropdown/src/dropdown-menu.vue b/packages/dropdown/src/dropdown-menu.vue index 5fe2a998..329ac8b1 100644 --- a/packages/dropdown/src/dropdown-menu.vue +++ b/packages/dropdown/src/dropdown-menu.vue @@ -1,5 +1,5 @@ @@ -7,6 +7,11 @@ import Popper from 'main/utils/popper'; export default { + name: 'ElDropdownMenu', + + props: { + visible: Boolean + }, data() { return { popper: null @@ -17,13 +22,6 @@ return this.$parent.menuAlign; } }, - methods: { - updatePopper() { - if (this.popper) { - this.popper.update(); - } - } - }, mounted() { document.body.appendChild(this.$el); diff --git a/packages/dropdown/src/dropdown.vue b/packages/dropdown/src/dropdown.vue index 75b7d428..3fd35f34 100644 --- a/packages/dropdown/src/dropdown.vue +++ b/packages/dropdown/src/dropdown.vue @@ -1,78 +1,24 @@ - diff --git a/packages/theme-default/src/button.css b/packages/theme-default/src/button.css index 91a1acd6..dd9b98c9 100644 --- a/packages/theme-default/src/button.css +++ b/packages/theme-default/src/button.css @@ -35,16 +35,7 @@ border: 0; } - & .el-icon-right { - margin-left: 5px; - } - & .el-icon-left { - margin-right: 5px; - } - & [class*="el-icon-"] { - /*line-height: 0.9;*/ - & + span { margin-left: 5px; } diff --git a/packages/theme-default/src/dropdown.css b/packages/theme-default/src/dropdown.css index d4be874c..13d89bf7 100644 --- a/packages/theme-default/src/dropdown.css +++ b/packages/theme-default/src/dropdown.css @@ -53,8 +53,9 @@ } } @e icon { - padding-left: 5px; - transform: scale(.8, .8); + font-size: 12px; + vertical-align: middle; + margin: 0 3px; } @m text { .el-button-text { diff --git a/packages/theme-default/src/icon.css b/packages/theme-default/src/icon.css index deeba92b..f24d22b4 100644 --- a/packages/theme-default/src/icon.css +++ b/packages/theme-default/src/icon.css @@ -69,6 +69,13 @@ animation: rotating 1s linear infinite; } +.el-icon-right { + margin-left: 5px; +} +.el-icon-left { + margin-right: 5px; +} + @keyframes rotating { 0% { transform: rotateZ(0deg); diff --git a/src/index.js b/src/index.js index 19488fd9..f828f6d5 100644 --- a/src/index.js +++ b/src/index.js @@ -3,6 +3,7 @@ import Pagination from '../packages/pagination/index.js'; import Dialog from '../packages/dialog/index.js'; import Autocomplete from '../packages/autocomplete/index.js'; import Dropdown from '../packages/dropdown/index.js'; +import DropdownMenu from '../packages/dropdown-menu/index.js'; import DropdownItem from '../packages/dropdown-item/index.js'; import Menu from '../packages/menu/index.js'; import Submenu from '../packages/submenu/index.js'; @@ -62,6 +63,7 @@ const install = function(Vue) { Vue.component(Dialog.name, Dialog); Vue.component(Autocomplete.name, Autocomplete); Vue.component(Dropdown.name, Dropdown); + Vue.component(DropdownMenu.name, DropdownMenu); Vue.component(DropdownItem.name, DropdownItem); Vue.component(Menu.name, Menu); Vue.component(Submenu.name, Submenu); @@ -133,6 +135,7 @@ module.exports = { Dialog, Autocomplete, Dropdown, + DropdownMenu, DropdownItem, Menu, Submenu,