1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
/*
* TextReveal — mask-position wipe animation
*
* Instead of sliding text through a fixed mask (odometer style),
* the mask itself sweeps across each span to reveal/hide text.
*
* Direction: bottom-to-top. New text rises in from below, old text exits upward.
*
* Entering: gradient reveals bottom-to-top (bottom of text appears first).
* gradient(to bottom, white 33%, transparent 33%+edge)
* pos 0 100% = transparent covers element = hidden
* pos 0 0% = white covers element = visible
*
* Leaving: gradient hides bottom-to-top (bottom of text disappears first).
* gradient(to top, white 33%, transparent 33%+edge)
* pos 0 100% = white covers element = visible
* pos 0 0% = transparent covers element = hidden
*
* Both transition from 0 100% (swap) → 0 0% (settled).
*/
[data-component="text-reveal"] {
--_edge: var(--text-reveal-edge, 17%);
--_dur: var(--text-reveal-duration, 450ms);
--_spring: var(--text-reveal-spring, cubic-bezier(0.34, 1.08, 0.64, 1));
--_spring-soft: var(--text-reveal-spring-soft, cubic-bezier(0.34, 1, 0.64, 1));
--_travel: var(--text-reveal-travel, 0px);
display: inline-flex;
align-items: center;
min-width: 0;
overflow: visible;
[data-slot="text-reveal-track"] {
display: grid;
min-height: 20px;
line-height: 20px;
justify-items: start;
align-items: center;
overflow: visible;
transition: width var(--_dur) var(--_spring-soft);
}
[data-slot="text-reveal-entering"],
[data-slot="text-reveal-leaving"] {
grid-area: 1 / 1;
line-height: 20px;
white-space: nowrap;
justify-self: start;
text-align: start;
mask-size: 100% 300%;
-webkit-mask-size: 100% 300%;
mask-repeat: no-repeat;
-webkit-mask-repeat: no-repeat;
transition-duration: var(--_dur);
transition-timing-function: var(--_spring);
}
/* ── entering: reveal bottom-to-top ──
* Gradient(to bottom): white at top, transparent at bottom of mask.
* Settled pos 0 0% = white covers element = visible
* Swap pos 0 100% = transparent covers = hidden
* Rises from below: translateY(travel) → translateY(0)
*/
[data-slot="text-reveal-entering"] {
mask-image: linear-gradient(to bottom, white 33%, transparent calc(33% + var(--_edge)));
-webkit-mask-image: linear-gradient(to bottom, white 33%, transparent calc(33% + var(--_edge)));
mask-position: 0 0%;
-webkit-mask-position: 0 0%;
transition-property:
mask-position,
-webkit-mask-position,
transform;
transform: translateY(0);
}
/* ── leaving: hide bottom-to-top + slide upward ──
* Gradient(to top): white at bottom, transparent at top of mask.
* Swap pos 0 100% = white covers element = visible
* Settled pos 0 0% = transparent covers = hidden
* Slides up: translateY(0) → translateY(-travel)
*/
[data-slot="text-reveal-leaving"] {
mask-image: linear-gradient(to top, white 33%, transparent calc(33% + var(--_edge)));
-webkit-mask-image: linear-gradient(to top, white 33%, transparent calc(33% + var(--_edge)));
mask-position: 0 0%;
-webkit-mask-position: 0 0%;
transition-property:
mask-position,
-webkit-mask-position,
transform;
transform: translateY(calc(var(--_travel) * -1));
}
/* ── swapping: instant reset ──
* Snap entering to hidden (below), leaving to visible (center).
*/
&[data-swapping="true"] [data-slot="text-reveal-entering"] {
mask-position: 0 100%;
-webkit-mask-position: 0 100%;
transform: translateY(var(--_travel));
transition-duration: 0ms !important;
}
&[data-swapping="true"] [data-slot="text-reveal-leaving"] {
mask-position: 0 100%;
-webkit-mask-position: 0 100%;
transform: translateY(0);
transition-duration: 0ms !important;
}
/* ── not ready: kill all transitions ── */
&[data-ready="false"] [data-slot="text-reveal-track"] {
transition-duration: 0ms !important;
}
&[data-ready="false"] [data-slot="text-reveal-entering"],
&[data-ready="false"] [data-slot="text-reveal-leaving"] {
transition-duration: 0ms !important;
}
&[data-truncate="true"] {
width: 100%;
}
&[data-truncate="true"] [data-slot="text-reveal-track"] {
width: 100%;
min-width: 0;
overflow: clip;
}
&[data-truncate="true"] [data-slot="text-reveal-entering"],
&[data-truncate="true"] [data-slot="text-reveal-leaving"] {
min-width: 0;
width: 100%;
overflow: clip;
}
}
@media (prefers-reduced-motion: reduce) {
[data-component="text-reveal"] [data-slot="text-reveal-track"] {
transition-duration: 0ms !important;
}
[data-component="text-reveal"] [data-slot="text-reveal-entering"],
[data-component="text-reveal"] [data-slot="text-reveal-leaving"] {
transition-duration: 0ms !important;
}
}
|