2026-01-18 12:55:28 +00:00
|
|
|
|
/**
|
2026-02-08 21:51:11 +00:00
|
|
|
|
* Development diagnostics utility
|
|
|
|
|
|
*
|
|
|
|
|
|
* Provides opt-in debugging helpers for visual issues.
|
|
|
|
|
|
* No automatic DOM manipulation — CSS is the single source of truth.
|
|
|
|
|
|
*
|
|
|
|
|
|
* Available console commands (DEV only):
|
|
|
|
|
|
* __enableCleanMode() — disable all decorative pseudo-elements
|
|
|
|
|
|
* __disableCleanMode() — re-enable them
|
|
|
|
|
|
* __findVerticalLines() — highlight narrow full-height elements
|
2026-01-18 12:55:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
export function fixDisplayIssues(): void {
|
|
|
|
|
|
if (typeof window === 'undefined') return;
|
|
|
|
|
|
|
2026-02-08 21:51:11 +00:00
|
|
|
|
// Remove grid overlay if accidentally left on (e.g. from devtools)
|
|
|
|
|
|
const gridOverlay = document.getElementById('grid-overlay');
|
|
|
|
|
|
if (gridOverlay) {
|
|
|
|
|
|
gridOverlay.remove();
|
|
|
|
|
|
}
|
2026-01-18 15:28:22 +00:00
|
|
|
|
|
2026-02-08 21:51:11 +00:00
|
|
|
|
// Register opt-in diagnostic tools (DEV only, never auto-executed)
|
2026-01-18 12:55:28 +00:00
|
|
|
|
if (import.meta.env.DEV) {
|
2026-02-08 21:51:11 +00:00
|
|
|
|
/** Toggle "clean mode": hides body::before/after noise texture */
|
2026-01-18 12:55:28 +00:00
|
|
|
|
(window as any).__enableCleanMode = () => {
|
2026-02-08 21:51:11 +00:00
|
|
|
|
const id = 'fix-display-clean-mode';
|
|
|
|
|
|
if (document.getElementById(id)) return;
|
|
|
|
|
|
const style = document.createElement('style');
|
|
|
|
|
|
style.id = id;
|
|
|
|
|
|
style.textContent = `
|
|
|
|
|
|
body::before, body::after { display: none !important; }
|
2026-01-18 12:55:28 +00:00
|
|
|
|
`;
|
2026-02-08 21:51:11 +00:00
|
|
|
|
document.head.appendChild(style);
|
|
|
|
|
|
console.log('[Diagnostics] Clean mode ON — noise texture hidden.');
|
2026-01-18 12:55:28 +00:00
|
|
|
|
};
|
2026-01-18 15:28:22 +00:00
|
|
|
|
|
2026-01-18 12:55:28 +00:00
|
|
|
|
(window as any).__disableCleanMode = () => {
|
2026-02-08 21:51:11 +00:00
|
|
|
|
document.getElementById('fix-display-clean-mode')?.remove();
|
|
|
|
|
|
console.log('[Diagnostics] Clean mode OFF.');
|
2026-01-18 12:55:28 +00:00
|
|
|
|
};
|
2026-01-18 15:28:22 +00:00
|
|
|
|
|
2026-02-08 21:51:11 +00:00
|
|
|
|
/** Highlight narrow full-height elements that could be stray lines */
|
2026-01-18 12:55:28 +00:00
|
|
|
|
(window as any).__findVerticalLines = () => {
|
2026-02-08 21:51:11 +00:00
|
|
|
|
const results: Array<{ el: HTMLElement; w: number; h: number }> = [];
|
|
|
|
|
|
document.querySelectorAll('*').forEach((el) => {
|
|
|
|
|
|
const r = (el as HTMLElement).getBoundingClientRect();
|
|
|
|
|
|
if (r.width > 0 && r.width < 10 && r.height > window.innerHeight * 0.3) {
|
|
|
|
|
|
results.push({ el: el as HTMLElement, w: r.width, h: r.height });
|
2026-01-18 12:55:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-02-08 21:51:11 +00:00
|
|
|
|
results.forEach(({ el, w, h }, i) => {
|
|
|
|
|
|
el.style.outline = `3px solid ${i % 2 === 0 ? 'red' : 'yellow'}`;
|
|
|
|
|
|
el.style.outlineOffset = '2px';
|
|
|
|
|
|
console.log(`[Diagnostics] ${i + 1}. ${el.tagName}${el.id ? '#' + el.id : ''} — ${w.toFixed(1)}×${h.toFixed(0)}px`);
|
2026-01-18 12:55:28 +00:00
|
|
|
|
});
|
2026-02-08 21:51:11 +00:00
|
|
|
|
console.log(`[Diagnostics] Found ${results.length} narrow vertical elements.`);
|
|
|
|
|
|
return results;
|
2026-01-18 12:55:28 +00:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-08 21:51:11 +00:00
|
|
|
|
// Auto-run once on import (DEV only) — grid overlay cleanup only
|
|
|
|
|
|
if (import.meta.env.DEV && typeof window !== 'undefined') {
|
|
|
|
|
|
if (document.readyState === 'loading') {
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', fixDisplayIssues, { once: true });
|
|
|
|
|
|
} else {
|
|
|
|
|
|
fixDisplayIssues();
|
2026-01-18 12:55:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|