Web: wykres tla slownika widoczny - pelna wysokosc sekcji, punkty i wyrazistsza linia
This commit is contained in:
@@ -13,8 +13,9 @@ import { StreakDots } from '../components/StreakDots';
|
||||
import { cn } from '../lib/utils';
|
||||
import { Section, SectionHeading } from './shared';
|
||||
|
||||
// Wykres w tle sekcji — rysowany od lewej do prawej w rytm scrolla.
|
||||
const CHART_PATH = 'M0,150 L130,118 L250,134 L380,86 L510,112 L650,58 L780,92 L900,44 L1000,66';
|
||||
// Wykres w tle sekcji — opada od lewej do prawej przez całą wysokość;
|
||||
// rysowany od lewej krawędzi okna w rytm scrolla (dashoffset + clip).
|
||||
const CHART_PATH = 'M0,40 L140,110 L300,220 L470,340 L640,470 L810,560 L1000,620';
|
||||
|
||||
function ChartBackdrop() {
|
||||
const wrapRef = useRef<HTMLDivElement>(null);
|
||||
@@ -40,7 +41,8 @@ function ChartBackdrop() {
|
||||
const update = () => {
|
||||
const r = wrap.getBoundingClientRect();
|
||||
const vh = window.innerHeight;
|
||||
const p = reduce ? 1 : Math.min(Math.max((vh - r.top) / (r.height + vh * 0.75), 0), 1);
|
||||
// p=0 gdy nagłówek sekcji wjeżdża, p=1 gdy jej dół opuszcza widok
|
||||
const p = reduce ? 1 : Math.min(Math.max((vh * 0.9 - r.top) / (r.height * 0.9), 0), 1);
|
||||
line.style.strokeDashoffset = String(len * (1 - p));
|
||||
clip.setAttribute('width', String(p * 1000));
|
||||
};
|
||||
@@ -61,33 +63,53 @@ function ChartBackdrop() {
|
||||
|
||||
return (
|
||||
<div ref={wrapRef} aria-hidden="true" className="pointer-events-none absolute inset-0 z-0">
|
||||
<svg
|
||||
viewBox="0 0 1000 190"
|
||||
preserveAspectRatio="none"
|
||||
className="h-[58%] w-full translate-y-14 opacity-35"
|
||||
>
|
||||
<svg viewBox="0 0 1000 700" preserveAspectRatio="none" className="h-full w-full">
|
||||
<defs>
|
||||
<linearGradient id="chart-fill" x1="0" y1="0" x2="0" y2="1">
|
||||
<stop offset="0%" stopColor="var(--accent)" stopOpacity="0.35" />
|
||||
<stop offset="0%" stopColor="var(--accent)" stopOpacity="0.5" />
|
||||
<stop offset="100%" stopColor="var(--accent)" stopOpacity="0" />
|
||||
</linearGradient>
|
||||
<clipPath id="chart-reveal">
|
||||
<rect ref={clipRef} x="0" y="0" width="0" height="190" />
|
||||
<rect ref={clipRef} x="0" y="0" width="0" height="700" />
|
||||
</clipPath>
|
||||
</defs>
|
||||
<g clipPath="url(#chart-reveal)">
|
||||
<path d={`${CHART_PATH} L1000,190 L0,190 Z`} fill="url(#chart-fill)" stroke="none" />
|
||||
<path
|
||||
d={`${CHART_PATH} L1000,700 L0,700 Z`}
|
||||
fill="url(#chart-fill)"
|
||||
fillOpacity="0.3"
|
||||
stroke="none"
|
||||
/>
|
||||
<path
|
||||
d={CHART_PATH}
|
||||
fill="none"
|
||||
stroke="var(--accent)"
|
||||
strokeOpacity="0.55"
|
||||
strokeWidth="3"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
</g>
|
||||
<path
|
||||
ref={lineRef}
|
||||
d={CHART_PATH}
|
||||
fill="none"
|
||||
stroke="var(--accent)"
|
||||
strokeOpacity="0.85"
|
||||
strokeWidth="2"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
vectorEffect="non-scaling-stroke"
|
||||
/>
|
||||
<g clipPath="url(#chart-reveal)">
|
||||
<circle cx="0" cy="40" r="4" fill="var(--accent)" />
|
||||
<circle cx="140" cy="110" r="4" fill="var(--accent)" opacity="0.9" />
|
||||
<circle cx="300" cy="220" r="4" fill="var(--accent)" opacity="0.9" />
|
||||
<circle cx="470" cy="340" r="4" fill="var(--accent)" opacity="0.9" />
|
||||
<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>
|
||||
</svg>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user