2023-09-28 15:20:02 +08:00
|
|
|
export function Button({ innerText, onclick }) {
|
|
|
|
const button = document.createElement('button')
|
|
|
|
button.innerText = innerText
|
|
|
|
button.onclick = onclick
|
|
|
|
return button
|
|
|
|
}
|
|
|
|
|
|
|
|
export function List({ children = [] }) {
|
|
|
|
const ul = document.createElement('ul')
|
|
|
|
children.forEach(child => ul.appendChild(child))
|
|
|
|
return ul
|
|
|
|
}
|
|
|
|
|
2023-10-01 03:20:16 +08:00
|
|
|
export function ListItem({ innerText, onclick, id, children = [], dataset }) {
|
2023-09-28 15:20:02 +08:00
|
|
|
const li = document.createElement('li')
|
|
|
|
li.innerText = innerText
|
|
|
|
li.onclick = onclick
|
|
|
|
li.id = id
|
2023-10-01 03:20:16 +08:00
|
|
|
dataset && Object.keys(dataset).forEach(key => li.dataset[key] = dataset[key])
|
2023-09-28 15:20:02 +08:00
|
|
|
children.forEach(child => li.appendChild(child))
|
|
|
|
return li
|
|
|
|
}
|