Skip to content

Commit 94c6c59

Browse files
committed
feat(drawer): add support for drawer-item activated style
closes #247
1 parent b6bdac7 commit 94c6c59

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

components/drawer/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ By default the drawer component is responsive and will switch from temporary to
8080
|`exact`|Boolean| false | router-link property _(*)_ |
8181
|`active-class`|String| router-link-active | router-link property _(*)_ |
8282
|`exact-active-class`|String| router-link-exact-active | router-link property _(*)_ |
83+
|`activated`|Boolean| undefined | whether this item is selected (not needed if router-link mode is used) |
8384

8485
> _(*)_ Requires [vue-router](https://router.vuejs.org)
8586
> If the `to` property is defined, the item behaves as a

components/drawer/mdc-drawer-item.vue

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<custom-link :link="link"
33
class="mdc-drawer-item mdc-list-item"
4-
:class="classes" :style="styles"
4+
:class="[classes. itemClasses]" :style="styles"
55
@click="onClick">
66
<span class="mdc-list-item__graphic" v-if="hasStartDetail">
77
<slot name="start-detail">
@@ -21,8 +21,16 @@ export default {
2121
inject: ['mdcDrawer'],
2222
mixins: [DispatchEventMixin, CustomLinkMixin],
2323
props: {
24-
'start-icon': String,
25-
'temporary-close': {type: Boolean, default: true},
24+
startIcon: String,
25+
temporaryClose: {
26+
type: Boolean,
27+
default: true
28+
},
29+
activated: Boolean,
30+
exactActiveClass: {
31+
type: String,
32+
default: 'mdc-list-item--activated'
33+
}
2634
},
2735
data () {
2836
return {
@@ -31,6 +39,11 @@ export default {
3139
}
3240
},
3341
computed: {
42+
itemClasses () {
43+
return {
44+
'mdc-list-item--activated': this.activated
45+
}
46+
},
3447
hasStartDetail () {
3548
return this.startIcon || this.$slots['start-detail']
3649
}

demo/styles/demo.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ $mdc-theme-background: #fff;
2222
font-family: "Roboto Mono", Monaco, courier, monospace;
2323
font-weight: 400;
2424
font-size: .875rem;
25-
26-
&.router-link-exact-active {
27-
font-weight: 500;
28-
}
2925
}
3026
}
3127

0 commit comments

Comments
 (0)