Skip to content

Commit f5fc9c7

Browse files
refactor: update CSS for inner pages and enhance JavaScript canvas resizing logic for improved responsiveness and visual consistency
1 parent 0775d31 commit f5fc9c7

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

assets/css/style.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ main {
314314
z-index: 1;
315315
}
316316

317-
/* Inner pages: light content band over dark matrix */
317+
/* Inner pages: light content band */
318318
main > .section:not(.section-alt):not(.section-tint):not(.home-intro):not(.home-cta):not(.page-hero) {
319319
background: rgba(248, 250, 252, 0.96);
320320
backdrop-filter: blur(12px);
@@ -1142,6 +1142,7 @@ main > .section:not(.section-alt):not(.section-tint):not(.home-intro):not(.home-
11421142
content: "";
11431143
position: absolute;
11441144
inset: 0;
1145+
z-index: 1;
11451146
background:
11461147
radial-gradient(ellipse 80% 50% at 20% 40%, rgba(79, 70, 229, 0.38), transparent 58%),
11471148
radial-gradient(ellipse 60% 40% at 80% 60%, rgba(6, 182, 212, 0.3), transparent 52%),
@@ -1151,7 +1152,7 @@ main > .section:not(.section-alt):not(.section-tint):not(.home-intro):not(.home-
11511152

11521153
.page-hero--mesh .container {
11531154
position: relative;
1154-
z-index: 1;
1155+
z-index: 2;
11551156
}
11561157

11571158
.page-hero--mesh h1 {

assets/js/main.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -251,32 +251,25 @@
251251
var ctx = canvas.getContext("2d");
252252
if (!ctx) return;
253253

254-
var pageBg = canvas.classList.contains("matrix-canvas--page-bg");
254+
var inHero = canvas.classList.contains("matrix-canvas--hero");
255255
var cell = 16;
256256
var dpr = Math.max(1, Math.min(2.25, window.devicePixelRatio || 1));
257257
var cols = 0;
258258
var drops = [];
259259
var raf = 0;
260260

261-
function viewportSize() {
262-
return {
263-
w: window.innerWidth || document.documentElement.clientWidth || 800,
264-
h: window.innerHeight || document.documentElement.clientHeight || 600,
265-
};
266-
}
267-
268261
function resize() {
262+
var par = canvas.parentElement;
269263
var w;
270264
var h;
271-
if (pageBg) {
272-
var v = viewportSize();
273-
w = v.w;
274-
h = v.h;
265+
if (inHero && par) {
266+
w = par.clientWidth || 800;
267+
h = par.clientHeight || 400;
275268
canvas.style.width = w + "px";
276269
canvas.style.height = h + "px";
277270
} else {
278-
w = canvas.clientWidth || canvas.parentElement.clientWidth || window.innerWidth;
279-
h = canvas.clientHeight || canvas.parentElement.clientHeight || 420;
271+
w = canvas.clientWidth || (par && par.clientWidth) || window.innerWidth;
272+
h = canvas.clientHeight || (par && par.clientHeight) || 420;
280273
}
281274
canvas.width = Math.floor(w * dpr);
282275
canvas.height = Math.floor(h * dpr);
@@ -292,11 +285,10 @@
292285
}
293286

294287
function step() {
295-
var v = viewportSize();
296-
var w = pageBg ? v.w : canvas.clientWidth || v.w;
297-
var h = pageBg ? v.h : canvas.clientHeight || 420;
298-
/* Dark trail so white glyphs stay readable with screen blend on dark body */
299-
ctx.fillStyle = pageBg ? "rgba(2, 6, 14, 0.17)" : "rgba(3, 7, 18, 0.07)";
288+
var w = canvas.clientWidth || 800;
289+
var h = canvas.clientHeight || 400;
290+
/* Dark trail so white glyphs stay readable with screen blend on hero gradient */
291+
ctx.fillStyle = inHero ? "rgba(2, 6, 14, 0.17)" : "rgba(3, 7, 18, 0.07)";
300292
ctx.fillRect(0, 0, w, h);
301293

302294
ctx.font =
@@ -319,6 +311,12 @@
319311
step();
320312

321313
window.addEventListener("resize", resize, { passive: true });
314+
if (inHero && canvas.parentElement && typeof ResizeObserver !== "undefined") {
315+
var ro = new ResizeObserver(function () {
316+
resize();
317+
});
318+
ro.observe(canvas.parentElement);
319+
}
322320
return function stop() {
323321
window.cancelAnimationFrame(raf);
324322
};

0 commit comments

Comments
 (0)