|
1 | 1 | @import '@/styles/variables.scss'; |
2 | 2 |
|
| 3 | +// Frozen columns (must match STICKY_COLUMN_IDS in searchDefinitions.ts). Their |
| 4 | +// left offsets are measured at runtime and exposed as --sticky-left-<id> vars. |
| 5 | +$stickyColumnIds: rec_resource_id, name; |
| 6 | +$scrollbarGap: 0.25rem; |
| 7 | +$edgeFadeWidth: 2.5rem; |
| 8 | +$scrollbarThickness: 0.85rem; |
| 9 | + |
3 | 10 | .search-results-table { |
4 | 11 | position: relative; |
5 | 12 | max-width: 100%; |
6 | | - overflow-x: auto; |
| 13 | + |
| 14 | + // Second (top) scrollbar — an always-visible scrollbar over an empty spacer |
| 15 | + // sized to the table width, kept in sync with the real bottom scroller in JS. |
| 16 | + &__top-scroll { |
| 17 | + height: $scrollbarThickness; |
| 18 | + margin-bottom: $scrollbarGap; |
| 19 | + } |
| 20 | + |
| 21 | + &__top-scroll-spacer { |
| 22 | + height: 1px; |
| 23 | + } |
| 24 | + |
| 25 | + // Wraps the scrolling viewport so the edge-fade overlays can be anchored to it |
| 26 | + // (and not to the whole component, which includes the top scrollbar). |
| 27 | + &__body { |
| 28 | + position: relative; |
| 29 | + } |
| 30 | + |
| 31 | + &__viewport { |
| 32 | + max-width: 100%; |
| 33 | + } |
| 34 | + |
| 35 | + // Both horizontal scrollbars: shared overflow + always-visible styling. |
| 36 | + // `appearance: none` opts the WebKit scrollbar out of macOS's auto-hiding |
| 37 | + // overlay behaviour, rendering the classic always-visible style instead — still |
| 38 | + // the browser's own scrollbar, not a custom DOM element. We deliberately do NOT |
| 39 | + // set the standard `scrollbar-width` / `scrollbar-color`: when either is present |
| 40 | + // Chromium ignores `::-webkit-scrollbar` and falls back to a thin overlay bar |
| 41 | + // that still auto-hides on macOS. |
| 42 | + &__top-scroll, |
| 43 | + &__viewport { |
| 44 | + overflow-x: auto; |
| 45 | + overflow-y: hidden; |
| 46 | + |
| 47 | + &::-webkit-scrollbar { |
| 48 | + appearance: none; |
| 49 | + -webkit-appearance: none; |
| 50 | + height: $scrollbarThickness; |
| 51 | + } |
| 52 | + |
| 53 | + &::-webkit-scrollbar-track { |
| 54 | + background: $colorBackgroundGrey; |
| 55 | + border-radius: 999px; |
| 56 | + } |
| 57 | + |
| 58 | + &::-webkit-scrollbar-thumb { |
| 59 | + background: rgba($colorGreyMed, 0.5); |
| 60 | + border: 3px solid $colorBackgroundGrey; |
| 61 | + border-radius: 999px; |
| 62 | + } |
| 63 | + |
| 64 | + &::-webkit-scrollbar-thumb:hover { |
| 65 | + background: rgba($colorGreyMed, 0.75); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + // Edge indicators — non-scrolling white edge fades anchored to the body. The |
| 70 | + // right fade covers the right edge on every screen size; the left fade is used |
| 71 | + // on mobile (no frozen columns). On desktop the frozen-column boundary is |
| 72 | + // marked by the freeze divider (below) instead. |
| 73 | + &__fade { |
| 74 | + position: absolute; |
| 75 | + top: 0; |
| 76 | + // Stop above the bottom scrollbar (which reserves $scrollbarThickness at the |
| 77 | + // foot of the viewport) so the fades never paint over it — otherwise the bar |
| 78 | + // looks broken where a fade crosses it. |
| 79 | + bottom: $scrollbarThickness; |
| 80 | + width: $edgeFadeWidth; |
| 81 | + pointer-events: none; |
| 82 | + opacity: 0; |
| 83 | + transition: opacity 0.15s ease; |
| 84 | + z-index: 4; |
| 85 | + |
| 86 | + &--right { |
| 87 | + right: 0; |
| 88 | + background: linear-gradient(to right, rgba($colorWhite, 0), $colorWhite); |
| 89 | + } |
| 90 | + |
| 91 | + &--left { |
| 92 | + left: 0; |
| 93 | + background: linear-gradient(to left, rgba($colorWhite, 0), $colorWhite); |
| 94 | + } |
| 95 | + } |
| 96 | + |
| 97 | + // Freeze-boundary divider (desktop): a stronger line at the right edge of the |
| 98 | + // frozen columns, positioned at their measured total width. Drawn as an overlay |
| 99 | + // rather than a cell border, which does not paint reliably on sticky cells in a |
| 100 | + // border-collapse table. |
| 101 | + &__freeze-divider { |
| 102 | + position: absolute; |
| 103 | + top: 0; |
| 104 | + bottom: $scrollbarThickness; |
| 105 | + left: calc(var(--sticky-total-width, 0) - 1px); |
| 106 | + width: 1px; |
| 107 | + background: rgba($colorGreyMed, 0.7); |
| 108 | + pointer-events: none; |
| 109 | + opacity: 0; |
| 110 | + transition: opacity 0.15s ease; |
| 111 | + z-index: 4; |
| 112 | + } |
7 | 113 |
|
8 | 114 | &__status { |
9 | 115 | min-width: 100%; |
|
14 | 120 | } |
15 | 121 | } |
16 | 122 |
|
| 123 | +// Reveal the edge indicators based on the scroll-state classes the hook sets on |
| 124 | +// the wrapper. Written as explicit class selectors (rather than nested `&…&…`) |
| 125 | +// so each selector carries its own scoping root. |
| 126 | +.search-results-table--scroll-right .search-results-table__fade--right { |
| 127 | + opacity: 1; |
| 128 | +} |
| 129 | + |
| 130 | +// Left fade only below the desktop breakpoint — matches where freezing is off. |
| 131 | +@media (max-width: ($mdBreakpoint - 0.02px)) { |
| 132 | + .search-results-table--scroll-left .search-results-table__fade--left { |
| 133 | + opacity: 1; |
| 134 | + } |
| 135 | +} |
| 136 | + |
| 137 | +// Freeze divider only at/above the desktop breakpoint (where columns freeze), |
| 138 | +// and only while the table can actually scroll horizontally. |
| 139 | +@media (min-width: $mdBreakpoint) { |
| 140 | + .search-results-table--scroll-left .search-results-table__freeze-divider, |
| 141 | + .search-results-table--scroll-right .search-results-table__freeze-divider { |
| 142 | + opacity: 1; |
| 143 | + } |
| 144 | +} |
| 145 | + |
17 | 146 | .results-table { |
18 | 147 | width: 100%; |
19 | 148 | min-width: 100%; |
|
110 | 239 | min-height: 100%; |
111 | 240 | } |
112 | 241 | } |
| 242 | + |
| 243 | +// Freeze the first columns from the desktop breakpoint up. On mobile only a |
| 244 | +// couple of columns fit at once, so freezing them is intentionally disabled. |
| 245 | +@media (min-width: $mdBreakpoint) { |
| 246 | + .results-table { |
| 247 | + @each $id in $stickyColumnIds { |
| 248 | + td.results-table__column--#{$id}, |
| 249 | + th.results-table__column--#{$id} { |
| 250 | + position: sticky; |
| 251 | + left: var(--sticky-left-#{$id}, 0); |
| 252 | + } |
| 253 | + |
| 254 | + // Lift frozen cells above the scrolling cells (headers above bodies). |
| 255 | + td.results-table__column--#{$id} { |
| 256 | + z-index: 1; |
| 257 | + } |
| 258 | + |
| 259 | + th.results-table__column--#{$id} { |
| 260 | + z-index: 3; |
| 261 | + } |
| 262 | + } |
| 263 | + } |
| 264 | +} |
0 commit comments