threepipe
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

simple-bottom-buttons.ts 562B

12345678910111213
  1. export function createSimpleButtons(buttons: Record<string, (btn: HTMLButtonElement) => void>, container = document.body) {
  2. const entries = Object.entries(buttons)
  3. entries.forEach(([text, onclick], i) => {
  4. const btn = document.createElement('button')
  5. btn.innerText = text
  6. btn.style.position = 'absolute'
  7. btn.style.bottom = `${3 + (entries.length - i - 1) * 2}rem`
  8. btn.style.right = '3rem'
  9. btn.style.zIndex = '10000'
  10. btn.onclick = async() => onclick(btn)
  11. container.appendChild(btn)
  12. })
  13. }