Simplify layout to column-based masonry
This commit is contained in:
parent
54c6fef694
commit
cafed99725
@ -445,23 +445,6 @@ function handleAmbientDrift() {
|
||||
}
|
||||
handleAmbientDrift();
|
||||
|
||||
function applyMasonry() {
|
||||
const grid = document.querySelector('.projects-grid');
|
||||
if (!grid) return;
|
||||
const rowHeight = 12; // matches grid-auto-rows
|
||||
const gap = 20; // matches grid gap
|
||||
grid.querySelectorAll('.project-container').forEach(card => {
|
||||
const height = card.getBoundingClientRect().height;
|
||||
const span = Math.ceil((height + gap) / (rowHeight + gap));
|
||||
card.style.gridRowEnd = `span ${span}`;
|
||||
});
|
||||
}
|
||||
|
||||
let resizeTimer = null;
|
||||
window.addEventListener('resize', () => {
|
||||
clearTimeout(resizeTimer);
|
||||
resizeTimer = setTimeout(applyMasonry, 150);
|
||||
});
|
||||
|
||||
const logoIcon = document.querySelector('.brand-icon');
|
||||
if (logoIcon) {
|
||||
@ -857,7 +840,6 @@ function render() {
|
||||
lastCountPulse = null;
|
||||
lastFinishedId = null;
|
||||
app.appendChild(grid);
|
||||
applyMasonry();
|
||||
}
|
||||
|
||||
render();
|
||||
|
||||
@ -244,17 +244,28 @@ h1 {
|
||||
}
|
||||
|
||||
.projects-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
|
||||
gap: 20px;
|
||||
align-items: start;
|
||||
grid-auto-rows: 12px; /* Base row height for masonry calc */
|
||||
grid-auto-flow: dense;
|
||||
display: block;
|
||||
column-width: 340px;
|
||||
column-gap: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.projects-grid {
|
||||
grid-template-columns: 1fr;
|
||||
column-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
.projects-grid {
|
||||
display: block;
|
||||
column-width: 340px;
|
||||
column-gap: 20px;
|
||||
}
|
||||
.project-container {
|
||||
break-inside: avoid;
|
||||
margin: 0 0 20px;
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,10 +274,13 @@ h1 {
|
||||
background: var(--card-bg);
|
||||
border-radius: 18px;
|
||||
padding: 5px 15px 15px 15px;
|
||||
margin: 0;
|
||||
margin: 0 0 20px;
|
||||
box-shadow: var(--shadow);
|
||||
transition: background-color 0.3s;
|
||||
border: 1px solid var(--border);
|
||||
break-inside: avoid;
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.project-header {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user