Skip to content

Commit e40eb50

Browse files
fix: keep animated fact text readable
1 parent b6848a4 commit e40eb50

2 files changed

Lines changed: 36 additions & 4 deletions

File tree

demo-seydi-animee/motion.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,17 @@
184184
transform: scale(1.1) translate3d(0, var(--parallax-y, 0px), 0);
185185
}
186186
.motion-page .facts strong {
187-
background: linear-gradient(110deg, currentColor 25%, #bd9b5d 48%, currentColor 72%);
187+
color: var(--navy);
188+
background: linear-gradient(110deg, var(--navy) 25%, #8a6324 48%, var(--navy) 72%);
188189
background-size: 250% 100%;
189-
color: transparent;
190-
background-clip: text;
191-
-webkit-background-clip: text;
190+
}
191+
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
192+
.motion-page .facts strong {
193+
color: transparent;
194+
-webkit-text-fill-color: transparent;
195+
background-clip: text;
196+
-webkit-background-clip: text;
197+
}
192198
}
193199
.motion-page .facts.is-visible strong { animation: number-shine 1.6s .2s ease forwards; }
194200
.motion-page .gallery .photo-button::after {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import re
2+
from pathlib import Path
3+
4+
ROOT = Path(__file__).resolve().parents[1]
5+
MOTION_CSS = ROOT / "demo-seydi-animee" / "motion.css"
6+
7+
8+
def test_animated_fact_gradient_never_fades_to_transparent():
9+
css = MOTION_CSS.read_text(encoding="utf-8")
10+
match = re.search(
11+
r"\.motion-page \.facts strong\s*\{(?P<body>.*?)\}",
12+
css,
13+
flags=re.DOTALL,
14+
)
15+
assert match, "Règle animée des chiffres introuvable"
16+
rule = match.group("body")
17+
18+
# currentColor becomes transparent when the same rule sets color: transparent.
19+
assert "currentColor" not in rule
20+
assert "var(--navy)" in rule
21+
assert "#8a6324" in rule.lower()
22+
23+
# Text must remain readable when background-clip:text is unsupported.
24+
assert "@supports" in css
25+
assert ".motion-page .facts strong {\n color: var(--navy);" in css
26+
assert "-webkit-text-fill-color: transparent" in css

0 commit comments

Comments
 (0)