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",
"description": "",
"files": [

View File

@ -4,18 +4,7 @@
* @date 2023/03/27 10:39:29
*/
import {
css,
html,
bind,
unbind,
Component,
outsideClick,
clearOutsideClick,
nextTick,
classMap,
styleMap
} from '@bd/core'
import { css, html, Component, nextTick, classMap } from '@bd/core'
const DIRECTION = {
left: 'l2r-in',
@ -25,16 +14,37 @@ const DIRECTION = {
}
class Drawer extends Component {
static animation = {}
static props = {
title: { type: String, default: '', attribute: false },
title: '',
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 = [
css`
:host {
display: none;
position: fixed;
left: 0;
top: 0;
@ -42,9 +52,8 @@ class Drawer extends Component {
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.3);
transition: opacity 0.3s linear;
opacity: 0;
}
.drawer {
display: flex;
flex-direction: column;
@ -60,6 +69,10 @@ class Drawer extends Component {
}
&.r2l-in {
animation: r2l-in 0.3s ease-in-out forwards;
&.out {
animation-direction: reverse;
}
}
&.t2b-in {
animation: t2b-in 0.3s ease-in-out forwards;
@ -90,11 +103,6 @@ class Drawer extends Component {
flex: 1;
padding: 16px;
}
:host([visible]) {
display: block;
opacity: 1;
}
`,
css`
:host([from='left']),
@ -173,13 +181,17 @@ class Drawer extends Component {
}
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() {
let classes = classMap({
drawer: true,
[DIRECTION[this.from]]: this.visible
drawer: true
// [DIRECTION[this.from]]: this.visible,
// out: !this.visible
})
return html`