Web: niebieska linia narastajaca od dolu w tle slownika - krzyzuje sie z pomaranczowa

This commit is contained in:
tisachi
2026-10-20 02:37:13 +02:00
parent 723e88dcbd
commit 2b5fc1a5be
2 changed files with 47 additions and 3 deletions

View File

@@ -13,25 +13,32 @@ import { StreakDots } from '../components/StreakDots';
import { cn } from '../lib/utils';
import { Section, SectionHeading } from './shared';
// Wykres w tle sekcji — opada od lewej do prawej przez całą wysokość;
// rysowany od lewej krawędzi okna w rytm scrolla (dashoffset + clip).
// Wykres w tle sekcji — pomarańczowa opada od lewej do prawej, niebieska
// wznosi się od dołu ku górze i nakłada na nią; obie rysowane w rytm scrolla.
const CHART_PATH = 'M0,40 L140,110 L300,220 L470,340 L640,470 L810,560 L1000,620';
const CHART_PATH2 = 'M0,660 L160,585 L330,455 L500,330 L670,215 L840,120 L1000,60';
function ChartBackdrop() {
const wrapRef = useRef<HTMLDivElement>(null);
const lineRef = useRef<SVGPathElement>(null);
const line2Ref = useRef<SVGPathElement>(null);
const clipRef = useRef<SVGRectElement>(null);
const clip2Ref = useRef<SVGRectElement>(null);
useEffect(() => {
const wrap = wrapRef.current;
const line = lineRef.current;
const line2 = line2Ref.current;
const clip = clipRef.current;
if (!wrap || !line || !clip) return;
const clip2 = clip2Ref.current;
if (!wrap || !line || !line2 || !clip || !clip2) return;
// jsdom nie implementuje getTotalLength — bez scrubbingu w testach
if (typeof line.getTotalLength !== 'function') return;
const len = line.getTotalLength();
line.style.strokeDasharray = String(len);
const len2 = line2.getTotalLength();
line2.style.strokeDasharray = String(len2);
const reduce =
typeof window.matchMedia === 'function' &&
@@ -44,7 +51,9 @@ function ChartBackdrop() {
// p=0 gdy nagłówek mija środek widoku, p=1 przy końcu sekcji
const p = reduce ? 1 : Math.min(Math.max((vh * 0.4 - r.top) / (r.height * 0.85), 0), 1);
line.style.strokeDashoffset = String(len * (1 - p));
line2.style.strokeDashoffset = String(len2 * (1 - p));
clip.setAttribute('width', String(p * 1000));
clip2.setAttribute('width', String(p * 1000));
};
const onScroll = () => {
cancelAnimationFrame(raf);
@@ -76,6 +85,9 @@ function ChartBackdrop() {
<clipPath id="chart-reveal">
<rect ref={clipRef} x="0" y="0" width="0" height="700" />
</clipPath>
<clipPath id="chart-reveal-2">
<rect ref={clip2Ref} x="0" y="0" width="0" height="700" />
</clipPath>
</defs>
<g clipPath="url(#chart-reveal)">
<path
@@ -114,6 +126,37 @@ function ChartBackdrop() {
<circle cx="640" cy="470" r="4" fill="var(--accent)" opacity="0.9" />
<circle cx="810" cy="560" r="4" fill="var(--accent)" opacity="0.9" />
</g>
<g clipPath="url(#chart-reveal-2)">
<path
d={CHART_PATH2}
fill="none"
stroke="var(--chart-blue)"
strokeOpacity="0.5"
strokeWidth="3"
strokeLinecap="round"
strokeLinejoin="round"
vectorEffect="non-scaling-stroke"
/>
</g>
<path
ref={line2Ref}
d={CHART_PATH2}
fill="none"
stroke="var(--chart-blue)"
strokeOpacity="0.8"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
vectorEffect="non-scaling-stroke"
/>
<g clipPath="url(#chart-reveal-2)">
<circle cx="0" cy="660" r="4" fill="var(--chart-blue)" />
<circle cx="160" cy="585" r="4" fill="var(--chart-blue)" opacity="0.9" />
<circle cx="330" cy="455" r="4" fill="var(--chart-blue)" opacity="0.9" />
<circle cx="500" cy="330" r="4" fill="var(--chart-blue)" opacity="0.9" />
<circle cx="670" cy="215" r="4" fill="var(--chart-blue)" opacity="0.9" />
<circle cx="840" cy="120" r="4" fill="var(--chart-blue)" opacity="0.9" />
</g>
</svg>
</div>
);

View File

@@ -14,6 +14,7 @@
--accent-dark: #f0542f;
--accent-ink: #1c0d06;
--accent-text: #ff7e61;
--chart-blue: #5b9dff;
--shadow: 0 1px 0 color-mix(in srgb, var(--text) 4%, transparent) inset;
--card-grad: linear-gradient(