Skip to content

Commit d2b70e1

Browse files
Roméo MaignalRoméo Maignal
authored andcommitted
feat(viz2): current year is now a label over the cursor over the sliding bar
1 parent bd2a9b5 commit d2b70e1

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/components/Viz2.css

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
border-radius: 2px;
129129
background: var(--border);
130130
cursor: pointer;
131+
margin-top: 22px; /* room for the floating year label above */
131132
}
132133

133134
.viz2-track-fill {
@@ -148,14 +149,16 @@
148149
margin: 0;
149150
}
150151

151-
/* current year badge */
152-
.viz2-yr-current {
152+
/* floating year label above the thumb */
153+
.viz2-yr-thumb-label {
154+
position: absolute;
155+
top: -22px;
156+
transform: translateX(-50%);
153157
font-family: var(--mono);
154-
font-size: 12px;
158+
font-size: 11px;
155159
font-weight: 600;
156160
color: var(--accent);
157161
white-space: nowrap;
158-
min-width: 36px;
159-
text-align: right;
160-
flex-shrink: 0;
162+
pointer-events: none;
163+
user-select: none;
161164
}

src/components/Viz2.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ const Viz2: React.FC = () => {
321321

322322
<div className="viz2-track-wrap">
323323
<div className="viz2-track-fill" style={{ width: `${pct}%` }} />
324+
<span className="viz2-yr-thumb-label" style={{ left: `${pct}%` }}>{year}</span>
324325
<input
325326
type="range"
326327
className="viz2-slider"
@@ -329,8 +330,6 @@ const Viz2: React.FC = () => {
329330
onChange={e => { setPlaying(false); setYear(Number(e.target.value)) }}
330331
/>
331332
</div>
332-
333-
<span className="viz2-yr-current">{year}</span>
334333
</div>
335334

336335
<span className="viz2-yr-edge">{YEAR_MAX}</span>

0 commit comments

Comments
 (0)