|
1 | 1 | <script>
|
| 2 | + import Vue from 'vue' |
2 | 3 | import MdAppSideDrawer from './MdAppSideDrawer'
|
3 | 4 | import MdAppInternalDrawer from './MdAppInternalDrawer'
|
| 5 | + import MdDrawerRightPrevious from '../MdDrawer/MdDrawerRightPrevious'; |
4 | 6 |
|
5 | 7 | const componentTypes = [
|
6 | 8 | 'md-app-toolbar',
|
|
12 | 14 | return componentOptions && componentTypes.includes(componentOptions.tag)
|
13 | 15 | }
|
14 | 16 |
|
15 |
| - function buildSlots (children, context, functionalContext, options) { |
| 17 | + function buildSlots (children, context, functionalContext, options, createElement) { |
16 | 18 | let slots = []
|
17 | 19 |
|
| 20 | + let hasDrawer = false |
| 21 | +
|
18 | 22 | if (children) {
|
19 | 23 | children.forEach(child => {
|
20 | 24 | const data = child.data
|
21 | 25 | const componentOptions = child.componentOptions
|
22 | 26 |
|
23 | 27 | if ((data && componentTypes.includes(data.slot)) || isValidChild(componentOptions)) {
|
24 | 28 | child.data.slot = data.slot || componentOptions.tag
|
| 29 | +
|
| 30 | + if (componentOptions.tag === 'md-app-drawer') { |
| 31 | + if (hasDrawer) { |
| 32 | + Vue.util.warn(`There shouldn't be more than one drawer in a MdApp at one time.`) |
| 33 | + return |
| 34 | + } |
| 35 | +
|
| 36 | + hasDrawer = true |
| 37 | + let nativeMdRight = componentOptions.propsData.mdRight |
| 38 | + let mdRight = nativeMdRight === '' || !!nativeMdRight |
| 39 | + child.data.slot += `-${mdRight ? 'right' : 'left'}` |
| 40 | + child.key = JSON.stringify({ |
| 41 | + 'persistent': child.data.attrs['md-persistent'], |
| 42 | + 'permanent': child.data.attrs['md-permanent'] |
| 43 | + }) |
| 44 | +
|
| 45 | + if (mdRight) { |
| 46 | + const drawerRightPrevious = createElement(MdDrawerRightPrevious, { props: {...child.data.attrs}}) |
| 47 | + drawerRightPrevious.data.slot = 'md-app-drawer-right-previous' |
| 48 | + slots.push(drawerRightPrevious) |
| 49 | + } |
| 50 | + } |
| 51 | +
|
25 | 52 | child.data.provide = options.Ctor.options.provide
|
26 | 53 | child.context = context
|
27 | 54 | child.functionalContext = functionalContext
|
|
54 | 81 | render (createElement, { children, props, data }) {
|
55 | 82 | let appComponent = MdAppSideDrawer
|
56 | 83 | const { context, functionalContext, componentOptions } = createElement(appComponent)
|
57 |
| - const slots = buildSlots(children, context, functionalContext, componentOptions) |
| 84 | + const slots = buildSlots(children, context, functionalContext, componentOptions, createElement) |
58 | 85 | const drawers = getDrawers(slots)
|
59 | 86 |
|
60 | 87 | drawers.forEach(drawer => {
|
|
157 | 184 | &.md-permanent-card + .md-app-scroller .md-content {
|
158 | 185 | @include md-layout-small-and-up {
|
159 | 186 | padding-left: 0;
|
| 187 | + padding-right: 0; |
160 | 188 | border-left: none;
|
| 189 | + border-right: none; |
161 | 190 | }
|
162 | 191 | }
|
163 | 192 | }
|
|
167 | 196 |
|
168 | 197 | @include md-layout-small-and-up {
|
169 | 198 | border-left: 1px solid transparent;
|
| 199 | + border-right: 1px solid transparent; |
170 | 200 | }
|
171 | 201 |
|
172 | 202 | > p {
|
|
185 | 215 | display: flex;
|
186 | 216 | overflow: auto;
|
187 | 217 | transform: translate3D(0, 0, 0);
|
188 |
| - transition: padding-left .4s $md-transition-default-timing; |
189 |
| - will-change: padding-left; |
| 218 | + transition: padding-left .4s $md-transition-default-timing, |
| 219 | + padding-right .4s $md-transition-default-timing; |
| 220 | + will-change: padding-left, padding-right; |
190 | 221 | }
|
191 | 222 |
|
192 | 223 | .md-app-scroller {
|
|
0 commit comments