1
0
mirror of https://github.com/kognise/water.css.git synced 2025-10-24 01:46:09 +02:00

Globally set box-sizing to border-box (and improve code snippet copy button)

This commit is contained in:
Felix Mattick
2022-01-22 12:58:18 -06:00
parent 2ca1eee9cf
commit 9cf9e052ac
6 changed files with 40 additions and 24 deletions

View File

@@ -327,18 +327,12 @@ for (const category of categories) {
const pre = document.createElement('pre')
const code = document.createElement('code')
code.innerText = snippet.code.trim()
code.style.position = 'relative'
pre.style.position = 'relative'
pre.appendChild(code)
const button = document.createElement('button')
button.innerText = 'Copy'
Object.assign(button.style, {
position: 'absolute',
top: '0',
right: '0',
margin: '6px',
padding: '8px'
})
button.className = 'snippet-copy'
let timeout = null
button.addEventListener('click', () => {
navigator.clipboard.writeText(snippet.code.trim())
@@ -347,9 +341,7 @@ for (const category of categories) {
timeout = setTimeout(() => { button.innerText = 'Copy' }, 1000)
})
code.appendChild(button)
pre.appendChild(code)
pre.appendChild(button)
demosContainer.appendChild(pre)
const details = document.createElement('details')