forked from koshikraj/ottopus
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscroll.css
More file actions
69 lines (58 loc) · 2.63 KB
/
Copy pathscroll.css
File metadata and controls
69 lines (58 loc) · 2.63 KB
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
/* Ottopus — the scrollbar.
The platform default is a wide opaque bar, which is fine against a page and
wrong against water: it reads as a piece of chrome bolted to the side of the
token list. This replaces it with a slim floating thumb in the same slate the
quiet text uses, over no track at all.
Native, not a JavaScript reimplementation. A scripted thumb would have to
re-earn click-to-page, drag, keyboard scrolling, momentum and the OS's own
auto-hide behaviour, and would get at least one of them wrong on a surface
where people scroll a list of balances.
Two vocabularies, because there is no single one yet: scrollbar-color is the
standard and all Firefox understands, while Chrome only learned it in 121 and
still gives ::-webkit-scrollbar the finer control. Both are declared; a
browser applies whichever it knows. */
:root {
/* The reserved gutter. Anything aligning a header to a scrolled list below it
needs the same number, so it lives here rather than in one component. */
--ot-scroll-size: 10px;
--ot-scroll-thumb: color-mix(in srgb, var(--ot-text-3) 42%, transparent);
--ot-scroll-thumb-hover: color-mix(in srgb, var(--ot-text-3) 68%, transparent);
}
.ot-scroll {
/* Stable, so a list that grows past its container does not shift its own
columns sideways at the moment it becomes scrollable. */
scrollbar-gutter: stable;
scrollbar-width: thin;
scrollbar-color: var(--ot-scroll-thumb) transparent;
}
.ot-scroll::-webkit-scrollbar {
width: var(--ot-scroll-size);
height: var(--ot-scroll-size);
}
.ot-scroll::-webkit-scrollbar-track,
.ot-scroll::-webkit-scrollbar-corner {
background: transparent;
}
/* The border is transparent and clipped away from the fill, which is how a
4px thumb gets a 10px hit target: you grab the padding, you see the pill. */
.ot-scroll::-webkit-scrollbar-thumb {
background-color: var(--ot-scroll-thumb);
background-clip: content-box;
border: 3px solid transparent;
border-radius: var(--ot-radius-pill);
}
.ot-scroll::-webkit-scrollbar-thumb:hover {
background-color: var(--ot-scroll-thumb-hover);
}
/* A header outside a scroll container has no gutter of its own, so its right
edge lands a scrollbar's width past the rows below it. A margin, not padding:
it shrinks the header's box by exactly the gutter, whatever padding the
header already carries.
Only from 40rem up. Below that the platform is usually a phone, whose
scrollbars overlay the content rather than reserve space beside it, so there
is nothing to compensate for. */
@media (min-width: 40rem) {
.ot-scroll-gutter {
margin-inline-end: var(--ot-scroll-size);
}
}