Skip to content

Commit

Permalink
fix(chips): refactor foundation as per MDCWeb 0.16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
stasson committed Jun 5, 2018
1 parent 0c8c3a8 commit d60fdb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
27 changes: 4 additions & 23 deletions components/chips/mdc-chip-set.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<template>
<div
:class="classes"
<div
:class="classes"
v-on="$listeners">
<slot/>
</div>
</template>

<script>
import MDCChipSetFoundation from '@material/chips/chip-set/foundation'
import MDCChipFoundation from '@material/chips/chip/foundation'
export default {
name: 'mdc-chip-set',
props: {
Expand Down Expand Up @@ -38,27 +37,9 @@ export default {
deregisterInteractionHandler: (evtType, handler) => {
this.$el.removeEventListener(evtType, handler)
},
appendChip: (text, leadingIcon, trailingIcon) => {
const chipTextEl = document.createElement('div')
chipTextEl.classList.add(MDCChipFoundation.cssClasses.TEXT)
chipTextEl.appendChild(document.createTextNode(text))
const chipEl = document.createElement('div')
chipEl.classList.add(MDCChipFoundation.cssClasses.CHIP)
if (leadingIcon) {
chipEl.appendChild(leadingIcon)
}
chipEl.appendChild(chipTextEl)
if (trailingIcon) {
chipEl.appendChild(trailingIcon)
}
this.root_.appendChild(chipEl)
return chipEl
},
removeChip: chip => {
const index = this.chips.indexOf(chip)
this.chips.splice(index, 1)
chip.remove()
// TODO: may need refactoring
this.$nextTick(() => chip.$destroy())
}
})
Expand Down
9 changes: 5 additions & 4 deletions components/chips/mdc-chip.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export default {
)
},
notifyTrailingIconInteraction: () => {
this.$emit('trailingIconClick')
emitCustomEvent(
this.$el,
MDCChipFoundation.strings.TRAILING_ICON_INTERACTION_EVENT,
Expand Down Expand Up @@ -150,12 +149,14 @@ export default {
)
}
},
notifyRemoval: () =>
this.emit(
notifyRemoval: () => {
emitCustomEvent(
this.$el,
MDCChipFoundation.strings.REMOVAL_EVENT,
{ chip: this },
true
),
)
},
getComputedStyleValue: propertyName =>
window.getComputedStyle(this.$el).getPropertyValue(propertyName),
setStyleProperty: (property, value) =>
Expand Down

0 comments on commit d60fdb2

Please sign in to comment.