Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Commit

Permalink
feat(menu): Synchronise with mdc-web v0.30.0
Browse files Browse the repository at this point in the history
  • Loading branch information
matsp committed Feb 6, 2018
1 parent 1ef3026 commit 7a83af9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
25 changes: 12 additions & 13 deletions components/Menu/Menu.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<div
class="mdc-simple-menu"
class="mdc-menu"
:class="classes"
tabindex="-1"
@MDCSimpleMenu:selected="onSelect"
@MDCSimpleMenu:cancel="onCancel">
@MDCMenu:selected="onSelect"
@MDCMenu:cancel="onCancel">
<slot />
</div>
</template>

<script>
import { MDCSimpleMenu } from '@material/menu'
import { MDCMenu } from '@material/menu'
export default {
model: {
Expand All @@ -20,26 +20,25 @@ export default {
props: {
startOpen: {
type: Boolean,
required: false,
default: false
}
},
data () {
return {
mdcSimpleMenu: null
mdcMenu: null
}
},
computed: {
classes () {
return {
'mdc-simple-menu--open': this.startOpen
'mdc-menu--open': this.startOpen
}
}
},
mounted () {
if (this.$slots.default) {
this.$slots.default.map(n => {
n.elm.classList.add('mdc-simple-menu__items')
n.elm.classList.add('mdc-menu__items')
})
this.$slots.default[0].elm.setAttribute('role', 'menu')
Expand All @@ -50,18 +49,18 @@ export default {
})
}
this.mdcSimpleMenu = MDCSimpleMenu.attachTo(this.$el)
this.mdcSimpleMenu.open = this.open
this.mdcMenu = MDCMenu.attachTo(this.$el)
this.mdcMenu.open = this.open
},
beforeDestroy () {
this.mdcSimpleMenu.destroy()
this.mdcMenu.destroy()
},
methods: {
show () {
this.mdcSimpleMenu.show()
this.mdcMenu.show()
},
hide () {
this.mdcSimpleMenu.hide()
this.mdcMenu.hide()
},
onSelect (event) {
this.$emit('change', event.detail.index)
Expand Down
14 changes: 6 additions & 8 deletions components/Menu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ data() {

### Props & methods

| Prop | Type | Default | Required | Description |
|------|------|---------|----------|-------------|
| startOpen | Boolean | - | false | whether the menu should be open at start |
| dense | Boolean | - | false | whether the menu entries should be densed |
| twoline | Boolean | - | false | whether the menu entries should be twoline |
| Prop | Type | Default | Description |
|------|------|---------|-------------|
| startOpen | Boolean | false | whether the menu should be open at start |

| Method | Description |
|--------|-------------|
Expand All @@ -53,9 +51,9 @@ data() {

### Slots

| Slot | Prop dependencies | Description |
|------|-------------------|-------------|
| default | - | menu content (list) |
| Slot | Description |
|------|-------------|
| default | menu content (list) |

## MenuAnchor

Expand Down

0 comments on commit 7a83af9

Please sign in to comment.