Impeccable redesign: flat surfaces, no emoji, no eyebrows, system fonts, restrained palette
This commit is contained in:
+2
-27
@@ -10,8 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
links.classList.contains('nav__links--open') ? 'true' : 'false'
|
||||
);
|
||||
});
|
||||
// Close on link click
|
||||
links.querySelectorAll('.nav__link, .nav__cta').forEach(link => {
|
||||
links.querySelectorAll('.nav__link').forEach(link => {
|
||||
link.addEventListener('click', () => {
|
||||
links.classList.remove('nav__links--open');
|
||||
toggle.setAttribute('aria-expanded', 'false');
|
||||
@@ -41,42 +40,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
});
|
||||
|
||||
/* === Lazy load images === */
|
||||
if ('loading' in HTMLImageElement.prototype) {
|
||||
document.querySelectorAll('img[loading="lazy"]').forEach(img => {
|
||||
img.src = img.dataset.src || img.src;
|
||||
});
|
||||
}
|
||||
|
||||
/* === Copy code blocks === */
|
||||
document.querySelectorAll('pre').forEach(block => {
|
||||
const btn = document.createElement('button');
|
||||
btn.className = 'copy-btn';
|
||||
btn.textContent = 'Copiar';
|
||||
btn.setAttribute('aria-label', 'Copiar código');
|
||||
Object.assign(btn.style, {
|
||||
position: 'absolute',
|
||||
top: '8px',
|
||||
right: '8px',
|
||||
padding: '4px 10px',
|
||||
fontSize: '0.75rem',
|
||||
background: 'var(--color-bg-card)',
|
||||
border: '1px solid var(--color-border)',
|
||||
borderRadius: '4px',
|
||||
color: 'var(--color-text-muted)',
|
||||
cursor: 'pointer',
|
||||
opacity: '0',
|
||||
transition: 'opacity 150ms ease'
|
||||
});
|
||||
block.style.position = 'relative';
|
||||
block.appendChild(btn);
|
||||
block.addEventListener('mouseenter', () => btn.style.opacity = '1');
|
||||
block.addEventListener('mouseleave', () => btn.style.opacity = '0');
|
||||
btn.addEventListener('click', async () => {
|
||||
const code = block.querySelector('code');
|
||||
if (code) {
|
||||
await navigator.clipboard.writeText(code.textContent);
|
||||
btn.textContent = '✓ Copiado';
|
||||
btn.textContent = 'Copiado';
|
||||
setTimeout(() => { btn.textContent = 'Copiar'; }, 2000);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user