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

Commit

Permalink
feat(drawer): make header slot to be the content inside `<div class="… (
Browse files Browse the repository at this point in the history
#400)

* feat(drawer): make header slot to be the content inside `<div class="mdc-drawer__header">`

* test(drawer): update snapshots
  • Loading branch information
tychenjiajun committed Aug 26, 2019
1 parent e3b5b81 commit f8832dd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
10 changes: 2 additions & 8 deletions components/drawer/Drawer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
@MDCDrawer:opened="onOpened"
>
<div
v-if="!hasHeaderClass || title !== '' || subtitle !== ''"
v-if="$slots.header || title !== '' || subtitle !== ''"
class="mdc-drawer__header"
>
<h3
Expand All @@ -23,10 +23,6 @@
</h6>
<slot name="header" />
</div>
<slot
v-else
name="header"
/>
<slot />
</aside>
</template>
Expand Down Expand Up @@ -114,10 +110,8 @@ export default {
}
},
mounted () {
// the slots can only be accessible in nextTick
// to avoid error throw by focus trap
this.$nextTick(function () {
// judge whether the slots have the header class
this.hasHeaderClass = this.$slots.header[0].elm.classList.contains('mdc-drawer__header')
if (!this.mdcDrawer && (this.dismissible || this.modal)) { this.mdcDrawer = new MDCDrawer(this.$el) }
})
},
Expand Down
15 changes: 3 additions & 12 deletions components/drawer/__test__/__snapshots__/Drawer.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@

exports[`Drawer should render as dismissible 1`] = `
<aside class="mdc-drawer mdc-drawer--dismissible">
<div class="mdc-drawer__header">
<!---->
<!---->
</div>
<!---->
</aside>
`;

exports[`Drawer should render as modal 1`] = `
<aside class="mdc-drawer mdc-drawer--modal">
<div class="mdc-drawer__header">
<!---->
<!---->
</div>
<!---->
</aside>
`;

exports[`Drawer should render with no prop 1`] = `
<aside class="mdc-drawer">
<div class="mdc-drawer__header">
<!---->
<!---->
</div>
<!---->
</aside>
`;

Expand Down

0 comments on commit f8832dd

Please sign in to comment.