This commit is contained in:
2023-10-04 18:25:11 +08:00
parent 44cc5e2494
commit fa23b6cd7a
2 changed files with 31 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { List, ListItem, Avatar, Span, Dialog } from './weigets.js' import { List, ListItem, Avatar, Span, Dialog, Button, Input } from './weigets.js'
export default class ClientList { export default class ClientList {
constructor({ channels = {}, EventListeners = {}, name: username, onexit }) { constructor({ channels = {}, EventListeners = {}, name: username, onexit }) {
@ -229,8 +229,34 @@ export default class ClientList {
onclick: event => { onclick: event => {
event.stopPropagation() event.stopPropagation()
// 点击插入一个弹出层 // 点击插入一个弹出层
const dialog = Dialog({}) document.body.appendChild(Dialog({
document.body.appendChild(dialog) children: [
Avatar({
src: item.avatar ?? '/favicon.ico',
style: {
width: '100px',
height: '100px',
borderRadius: '50%',
margin: '0 auto',
display: 'block'
}
}),
Input({
value: item.name ?? item.id,
type: 'text',
onchange: event => {
console.log(event.target.value)
}
}),
Button({
textContent: '保存',
onclick: event => {
event.stopPropagation()
document.body.removeChild(event.target.parentNode.parentNode)
}
})
]
}))
} }
}), }),
Span({ Span({

View File

@ -40,8 +40,8 @@ export function Avatar(options) {
// 弹出窗口, 高斯模糊背景, 进入离开动画过渡 // 弹出窗口, 高斯模糊背景, 进入离开动画过渡
export function Dialog(options) { export function Dialog(options) {
const element = createElement(options, 'div') const element = createElement({}, 'div')
const content = createElement({ classList: ['content'] }) const content = createElement(options)
element.style.cssText = ` element.style.cssText = `
position: fixed; position: fixed;
top: 0; top: 0;