-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix(MdApp): right drawer, fully reactive #1493
Conversation
BREAKING CHANGE: Replace useless props `mdLeft` with `!this.mdRight` fix #1204
@VdustR Any news on that? |
I've fixed that two problem mentioned before. But it's broken with other |
@VdustR No problem at all! Just to know if we could integrate on the new release. Let's postpone it to beta-10 |
BREAKING CHANGE: no more than one drawer in a MdApp
Update:
Not Completed:
My test case: <script>
import Vue from 'vue'
import MdAppSideDrawer from './MdAppSideDrawer'
import MdAppInternalDrawer from './MdAppInternalDrawer'
const componentTypes = [
'md-app-toolbar',
'md-app-drawer',
'md-app-content'
]
function isValidChild (componentOptions) {
return componentOptions && componentTypes.includes(componentOptions.tag)
}
function buildSlots (children, context, functionalContext, options) {
let slots = []
let hasDrawer = false
if (children) {
children.forEach(child => {
const data = child.data
const componentOptions = child.componentOptions
if ((data && componentTypes.includes(data.slot)) || isValidChild(componentOptions)) {
child.data.slot = data.slot || componentOptions.tag
if (componentOptions.tag === 'md-app-drawer') {
if (hasDrawer) {
Vue.util.warn(`There shouldn't be more than one drawer in a MdApp at one time.`)
return
}
hasDrawer = true
let nativeMdRight = componentOptions.propsData.mdRight
let mdRight = nativeMdRight === '' || !!nativeMdRight
child.data.slot += `-${mdRight ? 'right' : 'left'}`
}
child.data.provide = options.Ctor.options.provide
child.context = context
child.functionalContext = functionalContext
slots.push(child)
}
})
}
return slots
}
function getDrawers (children) {
const drawerVnodes = children.filter(child => {
return child.componentOptions.tag === 'md-app-drawer'
})
return drawerVnodes.length ? drawerVnodes : []
}
function hasInternalDrawer (attrs) {
const mdPermanent = attrs && attrs['md-permanent']
return mdPermanent && (mdPermanent === 'clipped' || mdPermanent === 'card')
}
export default {
name: 'MdApp',
functional: true,
render (createElement, { children, props, data }) {
let appComponent = MdAppSideDrawer
const { context, functionalContext, componentOptions } = createElement(appComponent)
const slots = buildSlots(children, context, functionalContext, componentOptions)
const drawers = getDrawers(slots)
drawers.forEach(drawer => {
if (drawer && hasInternalDrawer(drawer.data.attrs)) {
appComponent = MdAppInternalDrawer
}
})
const staticClass = {}
if (data.staticClass) {
data.staticClass.split(/\s+/).forEach(name => {
if (name.length === 0) return
staticClass[name] = true
})
}
return createElement(appComponent, {
attrs: props,
class: {...staticClass, ...data.class},
style: {...data.staticStyle, ...data.style},
}, slots)
}
}
</script>
<style lang="scss">
@import "~components/MdAnimation/variables";
@import "~components/MdLayout/mixins";
.md-app {
display: flex;
overflow: hidden;
position: relative;
&.md-fixed {
.md-app-scroller {
overflow: auto;
}
}
&.md-reveal,
&.md-fixed-last,
&.md-overlap,
&.md-flexible {
transform: translate3d(0, 0, 0);
.md-app-toolbar {
position: absolute;
top: 0;
}
}
&.md-flexible,
&.md-overlap {
.md-app-toolbar {
min-height: 0;
}
}
&.md-flexible {
.md-toolbar-row {
&:first-child {
z-index: 2;
}
&:last-child {
position: fixed;
bottom: 0;
z-index: 1;
}
}
.md-display-1 {
position: fixed;
}
}
&.md-overlap {
.md-app-toolbar {
z-index: 1;
}
.md-app-content {
margin: -64px 24px 24px;
position: relative;
z-index: 2;
@include md-layout-small {
margin: -64px 16px 16px;
}
@include md-layout-xsmall {
margin: -64px 8px 8px;
}
}
}
}
.md-app-drawer {
&.md-permanent-card + .md-app-scroller .md-content {
@include md-layout-small-and-up {
padding-left: 0;
padding-right: 0;
border-left: none;
border-right: none;
}
}
}
.md-app-content {
padding: 16px;
@include md-layout-small-and-up {
border-left: 1px solid transparent;
border-right: 1px solid transparent;
}
> p {
&:first-child {
margin-top: 0;
}
&:last-child {
margin-bottom: 0;
}
}
}
.md-app-container {
flex: 1;
display: flex;
overflow: auto;
transform: translate3D(0, 0, 0);
transition: padding-left .4s $md-transition-default-timing,
padding-right .4s $md-transition-default-timing;
will-change: padding-left, padding-right;
}
.md-app-scroller {
flex: 1;
}
</style>
|
@marcosmoura would you review for current changes now? The codes and the breaking changes. |
use an previous element for styling container with right drawer with similar css codes
fully reactive drawer
Updated:
|
Changes:
MdApp
.v-if
mdLeft
with!this.mdRight
.My test case:
Other bug not fixed yet:
style is wrong when screen width < 600px because of padding which should be
0
.It's transition while toggle drawer
v-if
after:md-active
BREAKING CHANGE: Replace useless props
mdLeft
with!this.mdRight
fix #1204