master
yutent 2023-03-28 19:40:39 +08:00
parent 461254d7af
commit f116d3a998
2 changed files with 38 additions and 26 deletions

View File

@ -1,5 +1,5 @@
{ {
"name": "@bd/wcui", "name": "@bd/ui",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"files": [ "files": [

View File

@ -4,18 +4,7 @@
* @date 2023/03/27 10:39:29 * @date 2023/03/27 10:39:29
*/ */
import { import { css, html, Component, nextTick, classMap } from '@bd/core'
css,
html,
bind,
unbind,
Component,
outsideClick,
clearOutsideClick,
nextTick,
classMap,
styleMap
} from '@bd/core'
const DIRECTION = { const DIRECTION = {
left: 'l2r-in', left: 'l2r-in',
@ -25,16 +14,37 @@ const DIRECTION = {
} }
class Drawer extends Component { class Drawer extends Component {
static animation = {}
static props = { static props = {
title: { type: String, default: '', attribute: false }, title: '',
from: 'right', from: 'right',
visible: false // visible: false,
visible: {
type: Boolean,
default: false,
observer(v) {
if (v) {
this.anim.start()
// this.setAttribute('fade-in', '')
// setTimeout(() => {
// // this.removeAttribute('fade-in')
// }, 300)
} else {
this.anim.end()
// this.style.display = 'block'
// this.setAttribute('fade-out', '')
// setTimeout(() => {
// this.removeAttribute('fade-out')
// }, 300)
}
}
},
'mask-close': true
} }
static styles = [ static styles = [
css` css`
:host { :host {
display: none;
position: fixed; position: fixed;
left: 0; left: 0;
top: 0; top: 0;
@ -42,9 +52,8 @@ class Drawer extends Component {
width: 100%; width: 100%;
height: 100%; height: 100%;
background: rgba(0, 0, 0, 0.3); background: rgba(0, 0, 0, 0.3);
transition: opacity 0.3s linear;
opacity: 0;
} }
.drawer { .drawer {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -60,6 +69,10 @@ class Drawer extends Component {
} }
&.r2l-in { &.r2l-in {
animation: r2l-in 0.3s ease-in-out forwards; animation: r2l-in 0.3s ease-in-out forwards;
&.out {
animation-direction: reverse;
}
} }
&.t2b-in { &.t2b-in {
animation: t2b-in 0.3s ease-in-out forwards; animation: t2b-in 0.3s ease-in-out forwards;
@ -90,11 +103,6 @@ class Drawer extends Component {
flex: 1; flex: 1;
padding: 16px; padding: 16px;
} }
:host([visible]) {
display: block;
opacity: 1;
}
`, `,
css` css`
:host([from='left']), :host([from='left']),
@ -173,13 +181,17 @@ class Drawer extends Component {
} }
mounted() { mounted() {
console.log('mounted title: ', this.title) console.log('mounted title: ', this['mask-close'])
this.$on('click', ev => {
console.log(ev.target, ev.currentTarget, ev.target === ev.currentTarget)
})
} }
render() { render() {
let classes = classMap({ let classes = classMap({
drawer: true, drawer: true
[DIRECTION[this.from]]: this.visible // [DIRECTION[this.from]]: this.visible,
// out: !this.visible
}) })
return html` return html`