mirror of
https://github.com/kognise/water.css.git
synced 2026-01-23 05:27:05 +01:00
Globally set box-sizing to border-box (and improve code snippet copy button)
This commit is contained in:
parent
2ca1eee9cf
commit
9cf9e052ac
6 changed files with 40 additions and 24 deletions
|
|
@ -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')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue