Summary
Code examples in the GlassyUI documentation site have no copy button. Users must manually select and copy code, which is friction-heavy especially for long snippets.
Proposed Solution
Add a floating copy button to every <pre> / code block on the docs site:
document.querySelectorAll('pre code').forEach(block => {
const btn = document.createElement('button');
btn.textContent = 'Copy';
btn.className = 'copy-btn';
btn.addEventListener('click', () => {
navigator.clipboard.writeText(block.innerText).then(() => {
btn.textContent = 'Copied!';
setTimeout(() => (btn.textContent = 'Copy'), 2000);
});
});
block.parentElement.style.position = 'relative';
block.parentElement.appendChild(btn);
});
Style the button with the Glassy aesthetic and position it at top: 8px; right: 8px inside the code block container.
Checklist
Additional Context
Level 2 feature. Include a fallback for document.execCommand('copy') for older browsers.
Summary
Code examples in the GlassyUI documentation site have no copy button. Users must manually select and copy code, which is friction-heavy especially for long snippets.
Proposed Solution
Add a floating copy button to every
<pre>/ code block on the docs site:Style the button with the Glassy aesthetic and position it at
top: 8px; right: 8pxinside the code block container.Checklist
Additional Context
Level 2 feature. Include a fallback for
document.execCommand('copy')for older browsers.