You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/oaer/lib/components/slide.ts

88 lines
1.9 KiB
TypeScript

1 month ago
/*
* slide.ts
* Copyright (C) 2024 veypi <i@veypi.com>
* 2024-10-22 17:57
* Distributed under terms of the GPL license.
*/
4 weeks ago
import { v, proxy } from '../v2dom'
1 month ago
import account from './account'
import app from './app'
import logic from '../logic'
import bus from '../bus'
1 month ago
/*
mask
slide
header
body
main
footer
*
* */
export default class {
mask: HTMLElement
slide: HTMLElement
header: HTMLElement
1 month ago
body: HTMLElement
main: HTMLElement
footer: HTMLElement
constructor() {
this.header = v({
class: 'voa-slide-header voa-animate-slow',
1 month ago
})
this.footer = v({
class: 'voa-slide-footer',
4 weeks ago
children: ['logout'],
1 month ago
onclick: () => {
bus.emit('logout')
}
})
4 weeks ago
console.log(logic.user)
this.main = v({
class: 'voa-slide-main',
children: [
1 month ago
account,
v({ class: 'voa-sm-separate' }),
app(),
v({ class: 'voa-sm-separate' })
]
1 month ago
})
this.body = v({
class: 'voa-slide-body voa-animate-slow',
1 month ago
style: 'animation-delay: 300ms',
children: [this.main, this.footer]
})
this.slide = v({
1 month ago
id: 'voa-slide',
class: 'voa-slide',
1 month ago
children: [this.header, this.body]
})
this.mask = v({
class: 'voa-slide-mask',
1 month ago
style: 'visibility: hidden',
children: [this.slide],
onclick: (e: MouseEvent) => {
if (e.target === e.currentTarget) {
this.hide()
}
}
})
4 weeks ago
proxy.DomListen(this.mask, () => {
if (!logic.ready) {
this.hide()
}
})
1 month ago
document.body.appendChild(this.mask)
}
show() {
this.mask.style.visibility = 'visible'
this.header.classList.add('voa-slidein-right')
this.body.classList.add('voa-slidein-up')
1 month ago
}
hide() {
this.mask.style.visibility = 'hidden'
this.header.classList.remove('voa-slidein-right')
this.body.classList.remove('voa-slidein-up')
1 month ago
}
}