From 3ac16c7b1b841027b2307a5817672c5b73861f52 Mon Sep 17 00:00:00 2001 From: Vi Pro Date: Mon, 14 May 2018 00:55:30 +0800 Subject: [PATCH] fix(MdApp): right drawer, fully reactive (#1493) * fix(MdApp): right drawer BREAKING CHANGE: Replace useless props `mdLeft` with `!this.mdRight` fix #1204 * fix(MdAppDrawer): right drawer supporting BREAKING CHANGE: no more than one drawer in a MdApp * fix(MdDrawerRightPrevious): right drawer styles use an previous element for styling container with right drawer with similar css codes * fix(MdDrawer): Temporary style * fix(MdAppSideDrawer): correct component name * fix(MdApp): reactive persistent drawer fully reactive drawer --- src/components/MdApp/MdApp.vue | 39 +++++++++++-- src/components/MdApp/MdAppDrawer.vue | 48 +++++++++++++--- src/components/MdApp/MdAppInternalDrawer.vue | 4 +- src/components/MdApp/MdAppMixin.js | 25 ++++++--- src/components/MdApp/MdAppSideDrawer.vue | 8 ++- src/components/MdApp/MdAppToolbar.vue | 4 ++ src/components/MdContent/theme.scss | 1 + src/components/MdDrawer/MdDrawer.vue | 48 +++++++++++++--- .../MdDrawer/MdDrawerRightPrevious.vue | 55 +++++++++++++++++++ src/components/MdDrawer/theme.scss | 8 ++- 10 files changed, 205 insertions(+), 35 deletions(-) create mode 100644 src/components/MdDrawer/MdDrawerRightPrevious.vue diff --git a/src/components/MdApp/MdApp.vue b/src/components/MdApp/MdApp.vue index 15e0986f6..5fbfacfa6 100644 --- a/src/components/MdApp/MdApp.vue +++ b/src/components/MdApp/MdApp.vue @@ -1,6 +1,8 @@ diff --git a/src/components/MdApp/MdAppInternalDrawer.vue b/src/components/MdApp/MdAppInternalDrawer.vue index 652fcd4f0..d96a07d85 100644 --- a/src/components/MdApp/MdAppInternalDrawer.vue +++ b/src/components/MdApp/MdAppInternalDrawer.vue @@ -3,10 +3,12 @@
- + +
+
diff --git a/src/components/MdApp/MdAppMixin.js b/src/components/MdApp/MdAppMixin.js index aff933b5a..0b9a085d9 100644 --- a/src/components/MdApp/MdAppMixin.js +++ b/src/components/MdApp/MdAppMixin.js @@ -48,7 +48,9 @@ export default { initialWidth: 0, active: false, mode: 'temporary', - width: 0 + submode: null, + width: 0, + right: false } } }), @@ -61,16 +63,21 @@ export default { isFixed () { return this.mdMode && this.mdMode !== 'fixed' }, - isMini () { + isDrawerMini () { return this.MdApp.drawer.mode === 'persistent' && this.MdApp.drawer.submode === 'mini' }, - contentStyles () { + contentPadding () { const drawer = this.MdApp.drawer - if (drawer.active && drawer.mode === 'persistent' && drawer.submode === 'full') { - return { - 'padding-left': drawer.width - } + if (this.MdApp.drawer.active && this.MdApp.drawer.mode === 'persistent' && this.MdApp.drawer.submode === 'full') { + return this.MdApp.drawer.width + } + + return 0 + }, + contentStyles () { + return { + [`padding-${this.MdApp.drawer.right ? 'right' : 'left'}`]: this.contentPadding } }, containerStyles () { @@ -80,8 +87,8 @@ export default { styles['margin-top'] = this.MdApp.toolbar.initialHeight + 'px' } - if (this.isMini) { - styles['padding-left'] = !this.MdApp.drawer.active ? this.MdApp.drawer.initialWidth + 'px' : 0 + if (this.isDrawerMini) { + styles[`padding-${this.MdApp.drawer.right ? 'right' : 'left'}`] = !this.MdApp.drawer.active ? this.MdApp.drawer.initialWidth + 'px' : 0 } return styles diff --git a/src/components/MdApp/MdAppSideDrawer.vue b/src/components/MdApp/MdAppSideDrawer.vue index 161fead7f..209675988 100644 --- a/src/components/MdApp/MdAppSideDrawer.vue +++ b/src/components/MdApp/MdAppSideDrawer.vue @@ -1,13 +1,15 @@ @@ -16,7 +18,7 @@ import MdAppMixin from './MdAppMixin' export default new MdComponent({ - name: 'MdAppInternalSideDrawer', + name: 'MdAppSideDrawer', mixins: [MdAppMixin] }) diff --git a/src/components/MdApp/MdAppToolbar.vue b/src/components/MdApp/MdAppToolbar.vue index 7ee41f99f..213a889ee 100644 --- a/src/components/MdApp/MdAppToolbar.vue +++ b/src/components/MdApp/MdAppToolbar.vue @@ -61,6 +61,10 @@ } } + .md-app-toolbar { + min-height: 64px; + } + .md-overlap { .md-app-toolbar { height: 196px; diff --git a/src/components/MdContent/theme.scss b/src/components/MdContent/theme.scss index f09a7f65d..3531260e4 100644 --- a/src/components/MdContent/theme.scss +++ b/src/components/MdContent/theme.scss @@ -15,6 +15,7 @@ .md-app & { @include md-theme-property(border-left-color, divider, background); + @include md-theme-property(border-right-color, divider, background); } } } diff --git a/src/components/MdDrawer/MdDrawer.vue b/src/components/MdDrawer/MdDrawer.vue index 4a7862806..93d30b1ed 100644 --- a/src/components/MdDrawer/MdDrawer.vue +++ b/src/components/MdDrawer/MdDrawer.vue @@ -17,7 +17,6 @@ MdOverlay }, props: { - mdLeft: Boolean, mdRight: Boolean, mdPermanent: { type: String, @@ -49,7 +48,7 @@ computed: { drawerClasses () { let classes = { - 'md-left': this.mdLeft, + 'md-left': !this.mdRight, 'md-right': this.mdRight, 'md-temporary': this.isTemporary, 'md-persistent': this.mdPersistent, @@ -165,8 +164,16 @@ } &.md-temporary { - + .md-app-container .md-content { - border-left: none; + &.md-left { + + .md-app-container .md-content { + border-left: none; + } + } + + &.md-right-previous { + + .md-app-container .md-content { + border-right: none; + } } &.md-active { @@ -216,22 +223,45 @@ &.md-persistent { &:not(.md-active) { - + .md-app-container .md-content { - border-left: none; + &.md-left { + + .md-app-container .md-content { + border-left: none; + } + } + + &.md-right-previous { + + .md-app-container .md-content { + border-right: none; + } } } } &.md-persistent-mini { - border-right: 1px solid; transform: translate3D(0, 64px, 0); transition: .3s $md-transition-stand-timing; transition-property: transform, width; will-change: transform, box-shadow; + &.md-left { + border-right: 1px solid; + } + + &.md-right { + border-left: 1px solid; + } + &.md-active { - + .md-app-container .md-content { - border-left: none; + &.md-left { + + .md-app-container .md-content { + border-left: none; + } + } + + &.md-right-previous { + + .md-app-container .md-content { + border-right: none; + } } } diff --git a/src/components/MdDrawer/MdDrawerRightPrevious.vue b/src/components/MdDrawer/MdDrawerRightPrevious.vue new file mode 100644 index 000000000..863c4d990 --- /dev/null +++ b/src/components/MdDrawer/MdDrawerRightPrevious.vue @@ -0,0 +1,55 @@ + + + diff --git a/src/components/MdDrawer/theme.scss b/src/components/MdDrawer/theme.scss index 570b6e06f..437c026c0 100644 --- a/src/components/MdDrawer/theme.scss +++ b/src/components/MdDrawer/theme.scss @@ -4,7 +4,13 @@ @include md-theme-property(color, text-primary, background); &.md-persistent-mini { - @include md-theme-property(border-right-color, divider, background); + &.md-left { + @include md-theme-property(border-right-color, divider, background); + } + + &.md-right { + @include md-theme-property(border-left-color, divider, background); + } } } }