Add ULLI weather easter egg to falling background particles
This commit is contained in:
1 parent
955f47ccd6
commit
98182c179f
11 files changed
+399
-21
No files matched your search
+2
-8
@@ -10,15 +10,7 @@
|
||||
* { box-sizing: border-box; }
|
||||
body { margin: 0; background: #f5efe3; color: var(--ink); }
|
||||
body::before { content:""; position:fixed; inset:0; pointer-events:none; z-index:0; opacity:.42; background: radial-gradient(circle at 12% 8%, #fff8e7 0 0.7rem, transparent 13rem), radial-gradient(circle at 88% 24%, #ead8bd 0 0.45rem, transparent 15rem); }
|
||||
.leaf-field { position:fixed; inset:0; overflow:hidden; pointer-events:none; z-index:1; }
|
||||
.leaf { position:absolute; top:-3rem; width:1.1rem; height:1.65rem; border-radius:100% 0 100% 0; background:var(--accent); box-shadow:inset .18rem -.12rem 0 #8e431d; opacity:.62; transform:rotate(35deg); animation:leaf-fall 15s linear infinite; }
|
||||
.leaf:nth-child(2n) { background:var(--gold); width:.82rem; height:1.3rem; animation-duration:19s; }
|
||||
.leaf:nth-child(3n) { background:#a84e22; width:1.35rem; height:1.85rem; animation-duration:22s; }
|
||||
.leaf:nth-child(1) { left:7%; animation-delay:-4s; } .leaf:nth-child(2) { left:18%; animation-delay:-12s; } .leaf:nth-child(3) { left:32%; animation-delay:-7s; }
|
||||
.leaf:nth-child(4) { left:49%; animation-delay:-16s; } .leaf:nth-child(5) { left:64%; animation-delay:-2s; } .leaf:nth-child(6) { left:78%; animation-delay:-10s; } .leaf:nth-child(7) { left:91%; animation-delay:-18s; }
|
||||
@keyframes leaf-fall { 0% { transform:translate3d(0,-4rem,0) rotate(20deg); } 45% { transform:translate3d(3.5rem,48vh,0) rotate(170deg); } 100% { transform:translate3d(-4rem,112vh,0) rotate(330deg); } }
|
||||
main, dialog { position:relative; z-index:2; }
|
||||
@media (prefers-reduced-motion: reduce) { .leaf { animation: none; top: 8vh; opacity: .16; } }
|
||||
main { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 64px; }
|
||||
h1 { margin: 0; font: 500 clamp(2rem, 4vw, 3.25rem)/1 Georgia, "Times New Roman", serif; letter-spacing: -.035em; }
|
||||
h2 { margin: 0 0 8px; font: 500 2rem/1.1 Georgia, "Times New Roman", serif; }
|
||||
@@ -109,6 +101,8 @@
|
||||
.gallery-footer button { min-height: 34px; padding: 5px 10px; }
|
||||
@media (max-width: 720px) { main { width: calc(100% - 28px); padding-top: 28px; } .topbar { display: block; } .record-count { display: block; margin-top: 18px; } .controls { display: grid; grid-template-columns: 1fr 1fr; } .control-group:first-child, .controls > button, .controls > .export-link { grid-column: 1 / -1; } input { min-width: 0; width: 100%; } .auth-form { display: grid; } .application-layout { grid-template-columns:1fr; }.application-list { border-right:0; border-bottom:1px solid var(--line); }.application-detail dl { grid-template-columns:1fr; gap:4px; }.application-detail dd { margin-bottom:14px; } .weekday-field { grid-column: 1 / -1; min-width: 0; } .weekday-options { gap: 4px; } }
|
||||
</style>
|
||||
<link rel="stylesheet" href="/api/weather/effect.css">
|
||||
<script src="/api/weather/effect.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="leaf-field" aria-hidden="true"><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span></div>
|
||||
|
||||
+2
-13
@@ -9,18 +9,6 @@
|
||||
:root { color-scheme: light; font-family: "Trebuchet MS", ui-sans-serif, sans-serif; --ink:#2d2924; --muted:#675c50; --paper:#fffdf7; --ground:#f5efe3; --line:#ded3c2; --accent:#b56824; --gold:#d89a28; --leaf:#c96f25; --focus:#a9541d; --error:#8e3630; }
|
||||
* { box-sizing: border-box; } html, body { max-width: 100%; } body { margin: 0; background: var(--ground); color: var(--ink); }
|
||||
body::before { content:""; position:fixed; inset:0; pointer-events:none; z-index:-1; opacity:.42; background: radial-gradient(circle at 12% 8%, #fff8e7 0 0.7rem, transparent 13rem), radial-gradient(circle at 88% 24%, #ead8bd 0 0.45rem, transparent 15rem); }
|
||||
.leaf-field { position:fixed; inset:0; overflow:hidden; pointer-events:none; z-index:0; }
|
||||
.leaf { position:absolute; top:-3rem; width:1.1rem; height:1.65rem; border-radius:100% 0 100% 0; background:var(--leaf); box-shadow:inset .18rem -.12rem 0 #8e431d; opacity:.74; transform:rotate(35deg); animation:leaf-fall 15s linear infinite; }
|
||||
.leaf:nth-child(2n) { background:#e0a02f; width:.82rem; height:1.3rem; animation-duration:19s; }
|
||||
.leaf:nth-child(3n) { background:#a84e22; width:1.35rem; height:1.85rem; animation-duration:22s; }
|
||||
.leaf:nth-child(1) { left:7%; animation-delay:-4s; }
|
||||
.leaf:nth-child(2) { left:18%; animation-delay:-12s; }
|
||||
.leaf:nth-child(3) { left:32%; animation-delay:-7s; }
|
||||
.leaf:nth-child(4) { left:49%; animation-delay:-16s; }
|
||||
.leaf:nth-child(5) { left:64%; animation-delay:-2s; }
|
||||
.leaf:nth-child(6) { left:78%; animation-delay:-10s; }
|
||||
.leaf:nth-child(7) { left:91%; animation-delay:-18s; }
|
||||
@keyframes leaf-fall { 0% { transform:translate3d(0,-4rem,0) rotate(20deg); } 45% { transform:translate3d(3.5rem,48vh,0) rotate(170deg); } 100% { transform:translate3d(-4rem,112vh,0) rotate(330deg); } }
|
||||
main { position:relative; z-index:1; width: min(1060px, calc(100% - 32px)); margin: 48px auto 72px; }
|
||||
h1 { margin: 0 0 6px; font: 500 clamp(2.25rem, 5vw, 4rem)/1 Georgia, "Times New Roman", serif; letter-spacing: -.045em; }
|
||||
h2 { font: 500 1.55rem/1.15 Georgia, "Times New Roman", serif; } .muted { color: var(--muted); line-height: 1.55; }
|
||||
@@ -96,8 +84,9 @@
|
||||
input, select, textarea { font-size: 16px; }
|
||||
.site-footer { margin-top: 32px; }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) { .leaf { animation: none; top: 8vh; opacity: .18; } }
|
||||
</style>
|
||||
<link rel="stylesheet" href="/api/weather/effect.css">
|
||||
<script src="/api/weather/effect.js" defer></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="leaf-field" aria-hidden="true"><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span><span class="leaf"></span></div>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/* Shared by calculator and admin. Keep all particles below interactive content. */
|
||||
.leaf-field {
|
||||
--rain: #69849a;
|
||||
--snow: #fffefa;
|
||||
--snow-edge: #aab9c5;
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
}
|
||||
.leaf {
|
||||
position: absolute;
|
||||
top: -3rem;
|
||||
width: 1.1rem;
|
||||
height: 1.65rem;
|
||||
border-radius: 100% 0 100% 0;
|
||||
background: var(--leaf, var(--accent));
|
||||
box-shadow: inset .18rem -.12rem 0 #8e431d;
|
||||
opacity: .68;
|
||||
animation: leaf-fall var(--duration, 15s) linear infinite;
|
||||
}
|
||||
.leaf:nth-child(2n) { background: var(--gold); width: .82rem; height: 1.3rem; --duration: 19s; }
|
||||
.leaf:nth-child(3n) { background: #a84e22; width: 1.35rem; height: 1.85rem; --duration: 22s; }
|
||||
.leaf:nth-child(1) { left: 7%; animation-delay: -4s; }
|
||||
.leaf:nth-child(2) { left: 18%; animation-delay: -12s; }
|
||||
.leaf:nth-child(3) { left: 32%; animation-delay: -7s; }
|
||||
.leaf:nth-child(4) { left: 49%; animation-delay: -16s; }
|
||||
.leaf:nth-child(5) { left: 64%; animation-delay: -2s; }
|
||||
.leaf:nth-child(6) { left: 78%; animation-delay: -10s; }
|
||||
.leaf:nth-child(7) { left: 91%; animation-delay: -18s; }
|
||||
.leaf[data-kind="snow"] {
|
||||
width: calc(.45rem * var(--size));
|
||||
height: calc(.45rem * var(--size));
|
||||
border-radius: 50%;
|
||||
background: var(--snow);
|
||||
box-shadow: 0 0 2px var(--snow-edge);
|
||||
opacity: .85;
|
||||
animation-name: snow-fall;
|
||||
}
|
||||
.leaf[data-kind="rain"] {
|
||||
width: 1.5px;
|
||||
height: calc(1.6rem * var(--size));
|
||||
border-radius: 2px;
|
||||
background: var(--rain);
|
||||
box-shadow: none;
|
||||
opacity: .4;
|
||||
animation-name: rain-fall;
|
||||
}
|
||||
.weather-paused .leaf { animation-play-state: paused; }
|
||||
@keyframes leaf-fall {
|
||||
0% { transform: translate3d(0, -4rem, 0) rotate(20deg); }
|
||||
45% { transform: translate3d(calc(3.5rem + var(--drift, 0vw) * .45), 48vh, 0) rotate(170deg); }
|
||||
100% { transform: translate3d(calc(-4rem + var(--drift, 0vw)), 112vh, 0) rotate(330deg); }
|
||||
}
|
||||
@keyframes snow-fall {
|
||||
0% { transform: translate3d(0, -4rem, 0); }
|
||||
50% { transform: translate3d(calc(2rem + var(--drift, 0vw) * .5), 50vh, 0); }
|
||||
100% { transform: translate3d(var(--drift, 0vw), 112vh, 0); }
|
||||
}
|
||||
@keyframes rain-fall {
|
||||
from { transform: translate3d(0, -4rem, 0) rotate(calc(-1 * var(--rain-angle, 0deg))); }
|
||||
to { transform: translate3d(var(--drift, 0vw), 112vh, 0) rotate(calc(-1 * var(--rain-angle, 0deg))); }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.leaf-field .leaf { animation: none; top: 8vh; opacity: .16; }
|
||||
.leaf:nth-child(n+8) { display: none; }
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/* A little Pulkovo weather in the existing autumn background. */
|
||||
(() => {
|
||||
'use strict';
|
||||
const field = document.querySelector('.leaf-field');
|
||||
if (!field) return;
|
||||
const refreshMs = 5 * 60 * 1000;
|
||||
let timer;
|
||||
let controller;
|
||||
let nextRefresh = 0;
|
||||
let lastSignature = '';
|
||||
|
||||
function render(weather) {
|
||||
const mode = ['leaves', 'rain', 'snow', 'mixed'].includes(weather.mode) ? weather.mode : 'leaves';
|
||||
const intensity = Math.max(1, Math.min(3, Number(weather.intensity) || 1));
|
||||
const wind = Math.max(0, Math.min(60, Number(weather.wind_mps) || 0));
|
||||
const signature = `${mode}/${intensity}/${wind}`;
|
||||
if (signature === lastSignature) return;
|
||||
lastSignature = signature;
|
||||
const count = mode === 'leaves' ? 7 : [0, 18, 34, 54][Math.round(intensity)];
|
||||
const duration = (mode === 'rain' ? 1.7 : mode === 'leaves' ? 19 : 12) / (1 + Math.min(wind, 25) / 8);
|
||||
field.dataset.weather = mode;
|
||||
field.style.setProperty('--drift', `${Math.min(24, wind * 1.2)}vw`);
|
||||
field.style.setProperty('--rain-angle', `${Math.min(30, wind * 1.8)}deg`);
|
||||
const particles = document.createDocumentFragment();
|
||||
for (let index = 0; index < count; index++) {
|
||||
const particle = document.createElement('span');
|
||||
const kind = mode === 'mixed' ? (index % 2 ? 'rain' : 'snow') : mode;
|
||||
particle.className = 'leaf';
|
||||
particle.dataset.kind = kind;
|
||||
const seconds = (kind === 'rain' && mode === 'mixed' ? duration / 6 : duration) * (0.8 + Math.random() * 0.5);
|
||||
particle.style.left = `${(index + Math.random()) * 100 / count}%`;
|
||||
particle.style.setProperty('--duration', `${seconds.toFixed(2)}s`);
|
||||
particle.style.animationDelay = `${(-Math.random() * seconds).toFixed(2)}s`;
|
||||
particle.style.setProperty('--size', (0.65 + Math.random() * 0.65).toFixed(2));
|
||||
particles.append(particle);
|
||||
}
|
||||
field.replaceChildren(particles);
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
clearTimeout(timer);
|
||||
if (document.hidden || controller) return;
|
||||
if (Date.now() < nextRefresh) {
|
||||
timer = setTimeout(refresh, nextRefresh - Date.now());
|
||||
return;
|
||||
}
|
||||
controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller?.abort(), 5000);
|
||||
try {
|
||||
const response = await fetch('/api/weather/ulli', { signal: controller.signal, credentials: 'omit', cache: 'no-store' });
|
||||
if (!response.ok) throw new Error('weather unavailable');
|
||||
render(await response.json());
|
||||
} catch {
|
||||
render({ mode: 'leaves', intensity: 1, wind_mps: 0 });
|
||||
} finally {
|
||||
clearTimeout(timeout);
|
||||
controller = null;
|
||||
nextRefresh = Date.now() + refreshMs;
|
||||
if (!document.hidden) timer = setTimeout(refresh, refreshMs);
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
field.classList.toggle('weather-paused', document.hidden);
|
||||
if (document.hidden) {
|
||||
clearTimeout(timer);
|
||||
controller?.abort();
|
||||
} else {
|
||||
refresh();
|
||||
}
|
||||
});
|
||||
refresh();
|
||||
})();
|
||||
Reference in new issue
Block a user