Skip to content

Commit d3b9edb

Browse files
committed
feat(list): add support for interactive prop, default to non-interactive
closes #224
1 parent 44b8711 commit d3b9edb

File tree

4 files changed

+39
-9
lines changed

4 files changed

+39
-9
lines changed

components/list/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
|`bordered`|Boolean|| bordered style |
1919
|`two-line`|Boolean|| two-line style |
2020
|`avatar-list`|Boolean|| set avatar style list |
21-
21+
|`interactive`|Boolean|| set interactive style for hover, focus, and press states |
2222

2323
### Dense List
2424

components/list/demo.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
</mdc-layout-cell>
2323

2424
<mdc-layout-cell>
25-
<mdc-list dense bordered >
25+
<mdc-list dense bordered>
2626
<mdc-list-item>
2727
<i slot="start-detail" class="material-icons">favorite_border</i>
2828
start details

components/list/mdc-list-item.vue

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<template>
2-
<li class="mdc-list-item">
2+
<li class="mdc-list-item"
3+
:class="classes" :style="styles"
4+
:tabindex="isInteractive ? '0' : undefined">
35

46
<span class="mdc-list-item__graphic" v-if="hasStartDetail">
57
<slot name="start-detail"></slot>
@@ -21,9 +23,21 @@
2123
</template>
2224

2325
<script>
26+
import {RippleBase} from '../ripple'
27+
2428
export default {
2529
name: 'mdc-list-item',
30+
inject: ['mdcList'],
31+
data () {
32+
return {
33+
classes: {},
34+
styles: {}
35+
}
36+
},
2637
computed: {
38+
isInteractive () {
39+
return this.mdcList && this.mdcList.interactive
40+
},
2741
hasSecondary () {
2842
return !!this.$slots['secondary']
2943
},
@@ -33,6 +47,17 @@ export default {
3347
hasStartDetail () {
3448
return !!this.$slots['start-detail']
3549
}
50+
},
51+
mounted () {
52+
if (this.isInteractive) {
53+
this.ripple = new RippleBase(this)
54+
this.ripple.init()
55+
}
56+
},
57+
beforeDestroy () {
58+
this.ripple && this.ripple.destroy()
59+
this.ripple = null
3660
}
3761
}
3862
</script>
63+

components/list/mdc-list.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,24 @@
88
export default {
99
name: 'mdc-list',
1010
props: {
11-
'dense': Boolean,
12-
'avatar-list': Boolean,
13-
'two-line': Boolean,
14-
'bordered': Boolean
11+
dense: Boolean,
12+
avatarList: Boolean,
13+
twoLine: Boolean,
14+
bordered: Boolean,
15+
interactive: Boolean
16+
},
17+
provide () {
18+
return { mdcList: this }
1519
},
1620
data () {
1721
return {
1822
classes: {
1923
'mdc-list--dense': this.dense,
2024
'mdc-list--avatar-list': this.avatarList,
2125
'mdc-list--two-line': this.twoLine,
22-
'mdc-list--bordered': this.bordered
23-
}
26+
'mdc-list--bordered': this.bordered,
27+
'mdc-list--non-interactive': !this.interactive
28+
}
2429
}
2530
}
2631
}

0 commit comments

Comments
 (0)