Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d3048ea7be |
@@ -25,13 +25,13 @@ export const animSnowSway = keyframes({
|
||||
});
|
||||
|
||||
/**
|
||||
* String-light twinkle — each bulb set softly brightens and dims, like
|
||||
* incandescent bulbs warming and cooling. Opacity only.
|
||||
* String-light breathing — bokeh orbs softly pulse in brightness and scale,
|
||||
* like incandescent bulbs warming and cooling. Opacity + transform only.
|
||||
*/
|
||||
export const animBulbBreathe = keyframes({
|
||||
'0%': { opacity: '0.6' },
|
||||
'50%': { opacity: '1' },
|
||||
'100%': { opacity: '0.6' },
|
||||
'0%': { transform: 'scale(0.92)', opacity: '0.55' },
|
||||
'50%': { transform: 'scale(1.08)', opacity: '0.95' },
|
||||
'100%': { transform: 'scale(0.92)', opacity: '0.55' },
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -44,3 +44,13 @@ export const animAurora = keyframes({
|
||||
'50%': { transform: 'translate3d(6%, 0, 0) scaleY(1.08)', opacity: '0.8' },
|
||||
'100%': { transform: 'translate3d(-6%, 0, 0) scaleY(1)', opacity: '0.5' },
|
||||
});
|
||||
|
||||
/**
|
||||
* Vignette frost — a barely-there breathing of the cold frame so the static
|
||||
* tint feels alive without distracting motion.
|
||||
*/
|
||||
export const animFrostPulse = keyframes({
|
||||
'0%': { opacity: '0.85' },
|
||||
'50%': { opacity: '1' },
|
||||
'100%': { opacity: '0.85' },
|
||||
});
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import { SeasonalOverlayProps } from '../types';
|
||||
import { animSnowFall, animSnowSway, animBulbBreathe, animAurora } from './Christmas.css';
|
||||
import {
|
||||
animSnowFall,
|
||||
animSnowSway,
|
||||
animBulbBreathe,
|
||||
animAurora,
|
||||
animFrostPulse,
|
||||
} from './Christmas.css';
|
||||
|
||||
// Deterministic pseudo-random so the scene is identical every mount (no React
|
||||
// state per frame). Large primes keep the distribution well spread.
|
||||
@@ -9,71 +15,15 @@ const rand = (seed: number) => {
|
||||
return x - Math.floor(x);
|
||||
};
|
||||
|
||||
// [Gitea #240] The string lights are a real garland now: a thin wire in
|
||||
// shallow scallops with small bulbs hanging from it, all inside the top ~16px so
|
||||
// they sit above the header's icons and text instead of over them (phone
|
||||
// header icons start ~18px down; the bulbs end by ~15px). One 600px
|
||||
// SVG tile (five scallops, five colours) repeats across the width; bulbs are
|
||||
// split into two sets that twinkle alternately (opacity only).
|
||||
const TILE_W = 600;
|
||||
const TILE_H = 18;
|
||||
const SCALLOP = 120;
|
||||
const svgUrl = (body: string) =>
|
||||
`url("data:image/svg+xml,${encodeURIComponent(
|
||||
`<svg xmlns='http://www.w3.org/2000/svg' width='${TILE_W}' height='${TILE_H}' viewBox='0 0 ${TILE_W} ${TILE_H}'>${body}</svg>`,
|
||||
)}")`;
|
||||
const GARLAND_HUES = [
|
||||
'oklch(0.66 0.2 27)', // red
|
||||
'oklch(0.84 0.15 85)', // gold
|
||||
'oklch(0.66 0.16 150)', // green
|
||||
'oklch(0.66 0.14 245)', // blue
|
||||
'oklch(0.93 0.05 90)', // warm white
|
||||
// Warm incandescent string-light hues in oklch — gold, soft red, cool white,
|
||||
// pine green, icy blue. Kept luminous and gentle so they read as bokeh glow.
|
||||
const BULB_COLORS = [
|
||||
'oklch(0.85 0.12 85)', // warm gold
|
||||
'oklch(0.72 0.15 28)', // soft red
|
||||
'oklch(0.95 0.03 230)', // icy white
|
||||
'oklch(0.78 0.13 150)', // pine green
|
||||
'oklch(0.8 0.1 235)', // cool blue
|
||||
];
|
||||
const bulbsSvg = (which: 0 | 1, glow: boolean) =>
|
||||
GARLAND_HUES.map((hue, k) => {
|
||||
if (k % 2 !== which) return '';
|
||||
const x = SCALLOP / 2 + k * SCALLOP;
|
||||
if (glow) return `<ellipse cx='${x}' cy='11' rx='6' ry='6' fill='${hue}' opacity='0.55'/>`;
|
||||
return (
|
||||
`<rect x='${x - 1.5}' y='5.4' width='3' height='2.6' rx='0.7' fill='oklch(0.5 0.03 150)'/>` +
|
||||
`<ellipse cx='${x}' cy='11.4' rx='2.7' ry='3.6' fill='${hue}'/>` +
|
||||
`<ellipse cx='${x - 0.9}' cy='10' rx='0.8' ry='1.2' fill='white' opacity='0.7'/>`
|
||||
);
|
||||
}).join('');
|
||||
const GLOW_FILTER =
|
||||
"<filter id='g' x='-1' y='-1' width='3' height='3'><feGaussianBlur stdDeviation='2.6'/></filter>";
|
||||
const WIRE = svgUrl(
|
||||
`<path d='M0 1 Q${SCALLOP / 2} 10 ${SCALLOP} 1 ${Array.from(
|
||||
{ length: TILE_W / SCALLOP - 1 },
|
||||
(_, i) => `T${(i + 2) * SCALLOP} 1`,
|
||||
).join(
|
||||
' ',
|
||||
)}' fill='none' stroke='oklch(0.58 0.05 150)' stroke-width='1.2' stroke-opacity='0.8'/>`,
|
||||
);
|
||||
const BULBS_A = svgUrl(
|
||||
`${GLOW_FILTER}<g filter='url(#g)'>${bulbsSvg(0, true)}</g>${bulbsSvg(0, false)}`,
|
||||
);
|
||||
const BULBS_B = svgUrl(
|
||||
`${GLOW_FILTER}<g filter='url(#g)'>${bulbsSvg(1, true)}</g>${bulbsSvg(1, false)}`,
|
||||
);
|
||||
|
||||
// A six-armed snowflake for the near layer: a blue-grey halo stroke under a
|
||||
// white one, so it reads on light themes as well as dark (no CSS filter).
|
||||
const CRYSTAL_ARMS = Array.from({ length: 6 }, (_, i) => i * 60)
|
||||
.map(
|
||||
(a) =>
|
||||
`<g transform='rotate(${a} 12 12)'><path d='M12 12V2.5M12 6l-2.6-2.4M12 6l2.6-2.4M12 9.2l-1.8-1.6M12 9.2l1.8-1.6'/></g>`,
|
||||
)
|
||||
.join('');
|
||||
const crystalUrl = `url("data:image/svg+xml,${encodeURIComponent(
|
||||
`<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'><g fill='none' stroke-linecap='round'><g stroke='oklch(0.55 0.05 245)' stroke-opacity='0.55' stroke-width='2.6'>${CRYSTAL_ARMS}</g><g stroke='white' stroke-width='1.2'>${CRYSTAL_ARMS}</g></g></svg>`,
|
||||
)}")`;
|
||||
|
||||
// Snow dot: white core with a soft blue-grey rim and shadow — visible on white
|
||||
// (the rim) and on dark (the core).
|
||||
const FLAKE_BG =
|
||||
'radial-gradient(circle at 38% 35%, oklch(1 0 0) 0%, oklch(0.97 0.01 230) 55%, oklch(0.9 0.03 235) 100%)';
|
||||
const FLAKE_SHADOW = '0 0 0 0.6px oklch(0.6 0.04 240 / 0.55), 0 1px 2px oklch(0.35 0.05 245 / 0.3)';
|
||||
|
||||
type Flake = {
|
||||
left: number;
|
||||
@@ -85,13 +35,22 @@ type Flake = {
|
||||
blur: number;
|
||||
};
|
||||
|
||||
type Bulb = {
|
||||
left: number;
|
||||
top: number;
|
||||
size: number;
|
||||
color: string;
|
||||
duration: number;
|
||||
delay: number;
|
||||
};
|
||||
|
||||
export function ChristmasOverlay({ reduced }: SeasonalOverlayProps) {
|
||||
// Three parallax bands of snow: far (small/slow/dim) -> near (large/fast).
|
||||
const flakes = useMemo<Flake[]>(() => {
|
||||
const bands = [
|
||||
{ count: 16, size: [2, 3], dur: [16, 22], op: [0.5, 0.7], blur: 0.4 },
|
||||
{ count: 12, size: [3, 4.5], dur: [11, 15], op: [0.65, 0.85], blur: 0 },
|
||||
{ count: 8, size: [4.5, 6.5], dur: [8, 11], op: [0.8, 1], blur: 0 },
|
||||
{ count: 12, size: [1.5, 2.5], dur: [16, 22], op: [0.35, 0.55], blur: 0.6 },
|
||||
{ count: 10, size: [2.5, 4], dur: [11, 15], op: [0.55, 0.8], blur: 0.3 },
|
||||
{ count: 8, size: [4, 6.5], dur: [8, 11], op: [0.7, 0.95], blur: 0 },
|
||||
];
|
||||
const out: Flake[] = [];
|
||||
let s = 1;
|
||||
@@ -116,53 +75,62 @@ export function ChristmasOverlay({ reduced }: SeasonalOverlayProps) {
|
||||
return out;
|
||||
}, []);
|
||||
|
||||
// A few large six-armed crystals drifting in front.
|
||||
const crystals = useMemo<Flake[]>(
|
||||
() =>
|
||||
Array.from({ length: 6 }, (_, i) => ({
|
||||
left: 6 + rand(i + 40) * 88,
|
||||
size: 12 + rand(i + 41) * 5,
|
||||
duration: 13 + rand(i + 42) * 6,
|
||||
delay: -rand(i + 43) * 19,
|
||||
swayDuration: 6 + rand(i + 44) * 4,
|
||||
opacity: 0.55 + rand(i + 45) * 0.15,
|
||||
blur: 0,
|
||||
})),
|
||||
[],
|
||||
);
|
||||
|
||||
const garlandLayer = (image: string, delay: number): React.CSSProperties => ({
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: `${TILE_H}px`,
|
||||
backgroundImage: image,
|
||||
backgroundRepeat: 'repeat-x',
|
||||
backgroundSize: `${TILE_W}px ${TILE_H}px`,
|
||||
// Start mid-scallop so the wire doesn't begin at a bulb on the far left.
|
||||
backgroundPosition: '-30px 0',
|
||||
animation: reduced ? 'none' : `${animBulbBreathe} 3.2s ease-in-out ${delay}s infinite`,
|
||||
willChange: reduced ? undefined : 'opacity',
|
||||
});
|
||||
// Bokeh string lights strung along the very top edge, gently sagging.
|
||||
const bulbs = useMemo<Bulb[]>(() => {
|
||||
const count = 9;
|
||||
const out: Bulb[] = [];
|
||||
for (let i = 0; i < count; i += 1) {
|
||||
const t = i / (count - 1);
|
||||
// Two-segment garland sag so the lights drape rather than sit in a line.
|
||||
const sag = Math.sin(t * Math.PI * 2) * 3.2;
|
||||
out.push({
|
||||
left: 4 + t * 92,
|
||||
top: 2.5 + Math.abs(Math.sin(t * Math.PI)) * 2 + sag,
|
||||
size: 12 + rand(i + 5) * 8,
|
||||
color: BULB_COLORS[i % BULB_COLORS.length],
|
||||
duration: 3.4 + rand(i + 2) * 2.6,
|
||||
delay: -rand(i + 9) * 3,
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Soft night-blue wash at the top only; the bottom stays clear so the
|
||||
composer isn't greyed on light themes. */}
|
||||
{/* Deep night-blue ambient wash — layered radial + linear oklch gradients
|
||||
for depth. Kept low-opacity so chat text stays legible (WCAG-AA). */}
|
||||
<div
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
inset: 0,
|
||||
contain: 'layout paint style',
|
||||
backgroundImage: [
|
||||
'radial-gradient(120% 70% at 50% -12%, oklch(0.3 0.07 250 / 0.12) 0%, transparent 55%)',
|
||||
'radial-gradient(70% 40% at 50% 112%, oklch(0.9 0.03 230 / 0.06) 0%, transparent 70%)',
|
||||
'radial-gradient(120% 80% at 50% -10%, oklch(0.25 0.07 250 / 0.16) 0%, transparent 55%)',
|
||||
'radial-gradient(90% 60% at 85% 110%, oklch(0.3 0.06 255 / 0.1) 0%, transparent 60%)',
|
||||
'linear-gradient(180deg, oklch(0.95 0.03 230 / 0.05) 0%, transparent 22%, transparent 80%, oklch(0.22 0.07 255 / 0.08) 100%)',
|
||||
].join(','),
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Aurora shimmer high up — kept faint. */}
|
||||
{/* Frosted vignette frame — cold edges, clear center. backdrop-filter on a
|
||||
single cheap layer for a faint icy haze around the rim. */}
|
||||
<div
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
inset: 0,
|
||||
contain: 'layout paint style',
|
||||
backdropFilter: 'blur(0.4px) saturate(1.04)',
|
||||
WebkitBackdropFilter: 'blur(0.4px) saturate(1.04)',
|
||||
backgroundImage:
|
||||
'radial-gradient(135% 120% at 50% 42%, transparent 52%, oklch(0.9 0.04 225 / 0.07) 74%, oklch(0.28 0.07 250 / 0.16) 100%)',
|
||||
animation: reduced ? 'none' : `${animFrostPulse} 12s ease-in-out infinite`,
|
||||
willChange: reduced ? undefined : 'opacity',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Aurora shimmer band high up — soft conic-ish wash of icy blue/green. */}
|
||||
<div
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
@@ -170,59 +138,99 @@ export function ChristmasOverlay({ reduced }: SeasonalOverlayProps) {
|
||||
top: '-6%',
|
||||
left: '-10%',
|
||||
right: '-10%',
|
||||
height: '32%',
|
||||
height: '40%',
|
||||
contain: 'layout paint style',
|
||||
mixBlendMode: 'screen',
|
||||
filter: 'blur(26px)',
|
||||
opacity: reduced ? 0.45 : undefined,
|
||||
opacity: reduced ? 0.6 : undefined,
|
||||
backgroundImage: [
|
||||
'radial-gradient(60% 100% at 30% 0%, oklch(0.85 0.12 165 / 0.14) 0%, transparent 70%)',
|
||||
'radial-gradient(55% 100% at 68% 0%, oklch(0.8 0.1 235 / 0.12) 0%, transparent 72%)',
|
||||
'radial-gradient(60% 100% at 30% 0%, oklch(0.85 0.12 165 / 0.18) 0%, transparent 70%)',
|
||||
'radial-gradient(55% 100% at 68% 0%, oklch(0.8 0.1 235 / 0.16) 0%, transparent 72%)',
|
||||
'radial-gradient(50% 100% at 50% 0%, oklch(0.9 0.06 280 / 0.1) 0%, transparent 75%)',
|
||||
].join(','),
|
||||
animation: reduced ? 'none' : `${animAurora} 18s ease-in-out infinite`,
|
||||
willChange: reduced ? undefined : 'transform, opacity',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Snowfall (motion) — three parallax bands plus the crystals. */}
|
||||
{!reduced &&
|
||||
[...flakes, ...crystals].map((f, i) => {
|
||||
const crystal = i >= flakes.length;
|
||||
return (
|
||||
<div
|
||||
key={`snow-${i}`}
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: `${f.left}%`,
|
||||
width: `${f.size}px`,
|
||||
height: `${f.size}px`,
|
||||
animation: `${animSnowSway} ${f.swayDuration}s ease-in-out ${f.delay}s infinite`,
|
||||
willChange: 'transform',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
...(crystal
|
||||
? { backgroundImage: crystalUrl, backgroundSize: '100% 100%' }
|
||||
: { borderRadius: '50%', background: FLAKE_BG, boxShadow: FLAKE_SHADOW }),
|
||||
opacity: f.opacity,
|
||||
filter: f.blur ? `blur(${f.blur}px)` : undefined,
|
||||
animation: `${animSnowFall} ${f.duration}s linear ${f.delay}s infinite`,
|
||||
willChange: 'transform, opacity',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
{/* String-light wire — a faint catenary line the bulbs hang from. */}
|
||||
<div
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: 0,
|
||||
right: 0,
|
||||
height: '14%',
|
||||
contain: 'layout paint style',
|
||||
backgroundImage:
|
||||
'radial-gradient(140% 60% at 50% -30%, oklch(0.3 0.04 250 / 0.14) 0%, transparent 70%)',
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Static snow for reduced motion / the settings preview. */}
|
||||
{/* Bokeh string lights — soft blurred orbs that breathe. */}
|
||||
{bulbs.map((b, i) => (
|
||||
<div
|
||||
key={`bulb-${i}`}
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
left: `${b.left}%`,
|
||||
top: `${b.top}%`,
|
||||
width: `${b.size}px`,
|
||||
height: `${b.size}px`,
|
||||
marginLeft: `${-b.size / 2}px`,
|
||||
borderRadius: '50%',
|
||||
background: `radial-gradient(circle at 38% 34%, oklch(0.98 0.02 95 / 0.95) 0%, ${b.color} 38%, transparent 72%)`,
|
||||
boxShadow: `0 0 ${b.size}px ${b.size * 0.45}px ${b.color.replace(')', ' / 0.45)')}`,
|
||||
filter: 'blur(0.5px)',
|
||||
opacity: reduced ? 0.9 : undefined,
|
||||
animation: reduced
|
||||
? 'none'
|
||||
: `${animBulbBreathe} ${b.duration}s ease-in-out ${b.delay}s infinite`,
|
||||
willChange: reduced ? undefined : 'transform, opacity',
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* Snowfall (motion only) — three parallax bands. Static dusting below. */}
|
||||
{!reduced &&
|
||||
flakes.map((f, i) => (
|
||||
<div
|
||||
key={`snow-${i}`}
|
||||
aria-hidden="true"
|
||||
style={{
|
||||
position: 'absolute',
|
||||
top: 0,
|
||||
left: `${f.left}%`,
|
||||
width: `${f.size}px`,
|
||||
height: `${f.size}px`,
|
||||
animation: `${animSnowSway} ${f.swayDuration}s ease-in-out ${f.delay}s infinite`,
|
||||
willChange: 'transform',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
width: '100%',
|
||||
height: '100%',
|
||||
borderRadius: '50%',
|
||||
background:
|
||||
'radial-gradient(circle at 35% 35%, oklch(0.99 0.01 230 / 0.95) 0%, oklch(0.95 0.03 230 / 0.7) 60%, transparent 100%)',
|
||||
boxShadow: '0 0 4px oklch(0.9 0.05 235 / 0.55)',
|
||||
opacity: f.opacity,
|
||||
filter: f.blur ? `blur(${f.blur}px)` : undefined,
|
||||
animation: `${animSnowFall} ${f.duration}s linear ${f.delay}s infinite`,
|
||||
willChange: 'transform, opacity',
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{/* Static dusting of snow for the reduced-motion / preview scene — a
|
||||
sparse scatter so the thumbnail still reads as snowfall. */}
|
||||
{reduced &&
|
||||
[...flakes, ...crystals].map((f, i) => {
|
||||
const crystal = i >= flakes.length;
|
||||
const fy = rand(i + 0.5) * 88 + 8;
|
||||
flakes.map((f, i) => {
|
||||
const fy = rand(i + 0.5) * 96 + 2;
|
||||
return (
|
||||
<div
|
||||
key={`snow-static-${i}`}
|
||||
@@ -233,24 +241,16 @@ export function ChristmasOverlay({ reduced }: SeasonalOverlayProps) {
|
||||
top: `${fy}%`,
|
||||
width: `${f.size}px`,
|
||||
height: `${f.size}px`,
|
||||
...(crystal
|
||||
? {
|
||||
backgroundImage: crystalUrl,
|
||||
backgroundSize: '100% 100%',
|
||||
transform: `rotate(${rand(i + 3) * 60}deg)`,
|
||||
}
|
||||
: { borderRadius: '50%', background: FLAKE_BG, boxShadow: FLAKE_SHADOW }),
|
||||
borderRadius: '50%',
|
||||
background:
|
||||
'radial-gradient(circle at 35% 35%, oklch(0.99 0.01 230 / 0.95) 0%, oklch(0.95 0.03 230 / 0.7) 60%, transparent 100%)',
|
||||
boxShadow: '0 0 4px oklch(0.9 0.05 235 / 0.5)',
|
||||
opacity: f.opacity,
|
||||
filter: f.blur ? `blur(${f.blur}px)` : undefined,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
{/* The garland on top of everything: wire, then two twinkling bulb sets. */}
|
||||
<div aria-hidden="true" style={{ ...garlandLayer(WIRE, 0), animation: 'none' }} />
|
||||
<div aria-hidden="true" style={garlandLayer(BULBS_A, 0)} />
|
||||
<div aria-hidden="true" style={garlandLayer(BULBS_B, -1.6)} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,28 +9,16 @@ import { keyframes } from '@vanilla-extract/css';
|
||||
*/
|
||||
|
||||
/**
|
||||
* Firework burst — a thin spark ring expands from a pinpoint, brightens, then
|
||||
* fades as it grows. Scale + opacity only; the ring is a radial-gradient border
|
||||
* supplied inline. Long pauses between bursts come from a low keyframe-duty:
|
||||
* the ring spends most of the cycle collapsed and invisible.
|
||||
* Firework burst — the spark burst pops open from a point, drifts down a little
|
||||
* as it spreads (gravity) and fades fast. Scale + translate + opacity only. Long
|
||||
* gaps between bursts come from a low keyframe duty: invisible most of the cycle.
|
||||
*/
|
||||
export const animBurst = keyframes({
|
||||
'0%': { transform: 'scale(0.05)', opacity: '0' },
|
||||
'4%': { transform: 'scale(0.12)', opacity: '0.95' },
|
||||
'22%': { transform: 'scale(1)', opacity: '0.55' },
|
||||
'34%': { transform: 'scale(1.25)', opacity: '0' },
|
||||
'100%': { transform: 'scale(1.25)', opacity: '0' },
|
||||
});
|
||||
|
||||
/**
|
||||
* Burst core flash — the bright pinpoint at a firework's origin pops just before
|
||||
* the ring blooms, then quickly dims. Pairs with animBurst on the same cadence.
|
||||
*/
|
||||
export const animCoreFlash = keyframes({
|
||||
'0%': { transform: 'scale(0.2)', opacity: '0' },
|
||||
'3%': { transform: 'scale(1)', opacity: '1' },
|
||||
'14%': { transform: 'scale(0.6)', opacity: '0' },
|
||||
'100%': { transform: 'scale(0.6)', opacity: '0' },
|
||||
'0%': { transform: 'translate3d(0, 0, 0) scale(0.15)', opacity: '0' },
|
||||
'3%': { transform: 'translate3d(0, 0, 0) scale(0.4)', opacity: '1' },
|
||||
'14%': { transform: 'translate3d(0, 6px, 0) scale(1)', opacity: '0.75' },
|
||||
'24%': { transform: 'translate3d(0, 14px, 0) scale(1.1)', opacity: '0' },
|
||||
'100%': { transform: 'translate3d(0, 14px, 0) scale(1.1)', opacity: '0' },
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,6 @@ import React, { useMemo } from 'react';
|
||||
import { SeasonalOverlayProps } from '../types';
|
||||
import {
|
||||
animBurst,
|
||||
animCoreFlash,
|
||||
animShimmer,
|
||||
animConfettiFall,
|
||||
animConfettiSway,
|
||||
@@ -12,7 +11,7 @@ import {
|
||||
|
||||
/**
|
||||
* New Year overlay — a midnight celebration. Layered oklch gradients sink the
|
||||
* app into a deep navy night; fireworks bloom as expanding spark rings, a
|
||||
* app into a deep navy night; fireworks pop as spark bursts at the edges, a
|
||||
* champagne-gold shimmer sweeps across, confetti slivers tumble down, and
|
||||
* sparkle stars twinkle. All motion is transform/opacity only.
|
||||
*
|
||||
@@ -26,8 +25,8 @@ import {
|
||||
* position:fixed, or pointer-events here — kept well below opaque so chat text
|
||||
* stays WCAG-AA legible.
|
||||
*
|
||||
* REDUCED MOTION: when `reduced`, render a static but gorgeous scene (a frozen
|
||||
* firework bloom mid-burst, scattered gold confetti, a still shimmer band) with
|
||||
* REDUCED MOTION: when `reduced`, render a static but gorgeous scene (two still
|
||||
* bursts peeking in from the top corners, scattered confetti, a still shimmer) with
|
||||
* no `animation` at all. The settings preview always passes reduced=true.
|
||||
*/
|
||||
|
||||
@@ -89,16 +88,44 @@ const sparkleUri = (color: string) =>
|
||||
`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 0 L14 10 L24 12 L14 14 L12 24 L10 14 L0 12 L10 10 Z' fill='${color}'/></svg>`,
|
||||
)}")`;
|
||||
|
||||
// [Gitea #230] A firework is spark rays + ember dots radiating from a point
|
||||
// (not a solid ring), drawn once as an SVG and scaled/faded by the keyframes.
|
||||
const burstUri = (ring: string, core: string) => {
|
||||
const rays = Array.from({ length: 14 }, (_, k) => {
|
||||
const a = (k / 14) * Math.PI * 2 + (k % 2) * 0.12;
|
||||
const [c, si] = [Math.cos(a), Math.sin(a)];
|
||||
const r1 = k % 2 ? 18 : 14;
|
||||
const r2 = k % 2 ? 38 : 44;
|
||||
const p = (r: number) => `${(50 + c * r).toFixed(1)} ${(50 + si * r).toFixed(1)}`;
|
||||
return (
|
||||
`<path d='M${p(r1)} L${p(r2)}' stroke='${ring}' stroke-width='1.6' stroke-linecap='round' stroke-opacity='0.85'/>` +
|
||||
`<circle cx='${(50 + c * (r2 + 4)).toFixed(1)}' cy='${(50 + si * (r2 + 4)).toFixed(1)}' r='1.5' fill='${core}'/>`
|
||||
);
|
||||
}).join('');
|
||||
return `url("data:image/svg+xml,${encodeURIComponent(
|
||||
`<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='50' r='6' fill='${core}' opacity='0.5'/>${rays}</svg>`,
|
||||
)}")`;
|
||||
};
|
||||
|
||||
export function NewYearOverlay({ reduced }: SeasonalOverlayProps) {
|
||||
const bursts = useMemo<Burst[]>(
|
||||
() =>
|
||||
// Bursts cluster in the upper two-thirds of the sky, away from typical text.
|
||||
// [Gitea #230] Bursts go off in the top band or along the side edges,
|
||||
// away from the reading column (top ones centred at the very top edge so they
|
||||
// fan down through the header row and fade), and are kept small; the old ones were
|
||||
// large rings anywhere in the upper two-thirds, over message text.
|
||||
Array.from({ length: 7 }, (_, i) => {
|
||||
const hue = BURST_HUES[i % BURST_HUES.length];
|
||||
const edge = i % 3 === 2;
|
||||
const right = rand(i + 51) > 0.5;
|
||||
return {
|
||||
top: 8 + rand(i + 1) * 48,
|
||||
left: 8 + rand(i + 11) * 84,
|
||||
size: 130 + Math.floor(rand(i + 21) * 110),
|
||||
top: edge ? 22 + rand(i + 1) * 45 : -2 + rand(i + 1) * 5,
|
||||
left: edge
|
||||
? right
|
||||
? 92 + rand(i + 11) * 6
|
||||
: 2 + rand(i + 11) * 6
|
||||
: 6 + rand(i + 11) * 88,
|
||||
size: 90 + Math.floor(rand(i + 21) * 60),
|
||||
ring: hue[0],
|
||||
core: hue[1],
|
||||
duration: 6.5 + rand(i + 31) * 4,
|
||||
@@ -174,9 +201,16 @@ export function NewYearOverlay({ reduced }: SeasonalOverlayProps) {
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Fireworks — expanding spark rings + a core flash. In reduced mode we
|
||||
freeze the first burst mid-bloom and drop the rest. */}
|
||||
{(reduced ? bursts.slice(0, 1) : bursts).map((b, i) => (
|
||||
{/* Fireworks — spark bursts that pop, drift down a little and fade. In
|
||||
reduced mode, two still bursts peek in from the top corners instead
|
||||
of one frozen over the timeline. */}
|
||||
{(reduced
|
||||
? [
|
||||
{ ...bursts[0], top: -4, left: 1, size: 160 },
|
||||
{ ...bursts[1], top: -3, left: 99, size: 130 },
|
||||
]
|
||||
: bursts
|
||||
).map((b, i) => (
|
||||
<div
|
||||
key={`b${i}`}
|
||||
aria-hidden="true"
|
||||
@@ -188,57 +222,15 @@ export function NewYearOverlay({ reduced }: SeasonalOverlayProps) {
|
||||
height: `${b.size}px`,
|
||||
marginLeft: `${-b.size / 2}px`,
|
||||
marginTop: `${-b.size / 2}px`,
|
||||
backgroundImage: burstUri(b.ring, b.core),
|
||||
backgroundSize: '100% 100%',
|
||||
opacity: reduced ? 0.35 : undefined,
|
||||
animation: reduced
|
||||
? 'none'
|
||||
: `${animBurst} ${b.duration}s ease-out ${b.delay}s infinite`,
|
||||
willChange: reduced ? undefined : 'transform, opacity',
|
||||
}}
|
||||
>
|
||||
{/* Spark ring */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
inset: 0,
|
||||
borderRadius: '50%',
|
||||
willChange: reduced ? undefined : 'transform, opacity',
|
||||
background: `radial-gradient(circle, transparent 56%, ${b.ring} 64%, transparent 74%)`,
|
||||
transform: reduced ? 'scale(0.82)' : undefined,
|
||||
opacity: reduced ? 0.6 : undefined,
|
||||
animation: reduced
|
||||
? 'none'
|
||||
: `${animBurst} ${b.duration}s ease-out ${b.delay}s infinite`,
|
||||
}}
|
||||
/>
|
||||
{/* Inner secondary ring for a fuller bloom */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
inset: '18%',
|
||||
borderRadius: '50%',
|
||||
background: `radial-gradient(circle, transparent 50%, ${b.ring} 60%, transparent 72%)`,
|
||||
transform: reduced ? 'scale(0.7)' : undefined,
|
||||
opacity: reduced ? 0.4 : undefined,
|
||||
animation: reduced
|
||||
? 'none'
|
||||
: `${animBurst} ${b.duration}s ease-out ${b.delay + 0.12}s infinite`,
|
||||
}}
|
||||
/>
|
||||
{/* Core flash */}
|
||||
<div
|
||||
style={{
|
||||
position: 'absolute',
|
||||
left: '50%',
|
||||
top: '50%',
|
||||
width: '14%',
|
||||
height: '14%',
|
||||
marginLeft: '-7%',
|
||||
marginTop: '-7%',
|
||||
borderRadius: '50%',
|
||||
background: `radial-gradient(circle, ${b.core} 0%, transparent 70%)`,
|
||||
transform: reduced ? 'scale(0.9)' : undefined,
|
||||
opacity: reduced ? 0.85 : undefined,
|
||||
animation: reduced
|
||||
? 'none'
|
||||
: `${animCoreFlash} ${b.duration}s ease-out ${b.delay}s infinite`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
/>
|
||||
))}
|
||||
|
||||
{/* Twinkling sparkle stars. */}
|
||||
|
||||
Reference in New Issue
Block a user