-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(scrollable): fix CSS shadow effect (#381)
The `.moj-scrollable-pane` class is supposed to add shadows to indicate that its contents are scrollable, but it is not suitably dynamic. This CSS uses [scroll shadows][scroll-shadows] to make the shadows dynamically appear on the left and right when there's overflow content there. If there's no overflow content, or the container is scrolled all the way to one side, the shadows are hidden. I removed the `.moj-scrollable-pane__wrapper` class because it's unnecessary. [scroll-shadows]: https://www.bram.us/2019/10/24/pure-css-scroll-shadows-vertical-horizontal/
- Loading branch information
Showing
2 changed files
with
159 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,43 @@ | ||
.moj-scrollable-pane { | ||
|
||
@include govuk-media-query($until: 1020px) { | ||
position: relative; | ||
overflow: hidden; // Hides the shadow | ||
clear: both; // Fixes render bug | ||
// width: 100% // Fixes render bug | ||
|
||
&:after { | ||
position: absolute; | ||
top: 0; | ||
left: 100%; | ||
width: 50px; | ||
height: 100%; | ||
border-radius: 10px 0 0 10px / 50% 0 0 50%; | ||
box-shadow: -5px 0 10px rgba(0, 0, 0, 0.25); | ||
content:""; | ||
} | ||
} | ||
|
||
$scrollableBgColor: white; | ||
$scrollableTransparentColor: rgba(255, 255, 255, 0); | ||
$scrollableShadowColor: rgba(0, 0, 0, 0.2); | ||
$scrollableShadowSize: 0.75em; | ||
|
||
overflow-x: scroll; | ||
background: linear-gradient( | ||
to right, | ||
$scrollableBgColor, | ||
$scrollableBgColor, | ||
$scrollableTransparentColor calc($scrollableShadowSize * 2) | ||
), | ||
radial-gradient( | ||
farthest-side at 0 50%, | ||
$scrollableShadowColor, | ||
$scrollableTransparentColor | ||
), | ||
linear-gradient( | ||
to left, | ||
$scrollableBgColor, | ||
$scrollableBgColor, | ||
$scrollableTransparentColor calc($scrollableShadowSize * 2) | ||
), | ||
radial-gradient( | ||
farthest-side at 100% 50%, | ||
$scrollableShadowColor, | ||
$scrollableTransparentColor | ||
) | ||
100%; | ||
background-color: $scrollableBgColor; | ||
background-repeat: no-repeat; | ||
background-attachment: local, scroll, local, scroll; | ||
background-size: 100% 100%, $scrollableShadowSize 100%, 100% 100%, | ||
$scrollableShadowSize 100%; | ||
} | ||
|
||
@include govuk-media-query($until: 1020px) { | ||
.moj-scrollable-pane__wrapper { | ||
overflow-x: auto; | ||
} | ||
|
||
.moj-scrollable-pane__wrapper .govuk-table__header, | ||
.moj-scrollable-pane__wrapper .govuk-table__cell { | ||
.moj-scrollable-pane .govuk-table__header, | ||
.moj-scrollable-pane .govuk-table__cell { | ||
white-space: nowrap; | ||
} | ||
|
||
.moj-scrollable-pane > div::-webkit-scrollbar { | ||
height: 10px; // Match GOVUK spacing units | ||
} | ||
|
||
.moj-scrollable-pane > div::-webkit-scrollbar-track { | ||
background: govuk-colour("light-grey"); | ||
box-shadow: 0 0 2px rgba(0,0,0,.15) inset; // Simulate scrollbar look and feel | ||
} | ||
|
||
.moj-scrollable-pane > div::-webkit-scrollbar-thumb { | ||
background: govuk-colour("dark-grey"); | ||
border-radius: govuk-spacing(1); | ||
} | ||
} | ||
} |