Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(scrollable): fix CSS shadow effect #381

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
249 changes: 122 additions & 127 deletions docs/examples/patterns/filter-a-list/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -144,134 +144,129 @@ title: Filter a list pattern (example)
</div>

<div class="moj-scrollable-pane">

<div class="moj-scrollable-pane__wrapper">

{{ govukTable({
firstCellIsHeader: true,
head: [
{text: 'Reference'},
{text: 'Person'},
{text: 'Colour'},
{text: 'Status'},
{text: 'Date of last event'}
{{ govukTable({
firstCellIsHeader: true,
head: [
{text: 'Reference'},
{text: 'Person'},
{text: 'Colour'},
{text: 'Status'},
{text: 'Date of last event'}
],
rows: [
[
{html: '<a href="#" class="govuk-link">44455453</a>'},
{html: 'John Smith'},
{text: 'Blue'},
{html: 'Complete'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">12323212</a>'},
{html: 'Warren Sutton'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">45678765</a>'},
{html: 'Alan Jones'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">12345678</a>'},
{html: 'Jennifer Langley'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">89009800</a>'},
{html: 'Susan Francis'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">44455453</a>'},
{html: 'John Smith'},
{text: 'Blue'},
{html: 'Complete'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">12323212</a>'},
{html: 'Warren Sutton'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">45678765</a>'},
{html: 'Alan Jones'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">12345678</a>'},
{html: 'Jennifer Langley'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
rows: [
[
{html: '<a href="#" class="govuk-link">44455453</a>'},
{html: 'John Smith'},
{text: 'Blue'},
{html: 'Complete'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">12323212</a>'},
{html: 'Warren Sutton'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">45678765</a>'},
{html: 'Alan Jones'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">12345678</a>'},
{html: 'Jennifer Langley'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">89009800</a>'},
{html: 'Susan Francis'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">44455453</a>'},
{html: 'John Smith'},
{text: 'Blue'},
{html: 'Complete'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">12323212</a>'},
{html: 'Warren Sutton'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">45678765</a>'},
{html: 'Alan Jones'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">12345678</a>'},
{html: 'Jennifer Langley'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">89009800</a>'},
{html: 'Susan Francis'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">45456765</a>'},
{html: 'John Smith'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">88675411</a>'},
{html: 'Margaret Blake'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">44455453</a>'},
{html: 'John Smith'},
{text: 'Blue'},
{html: 'Complete'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">12323212</a>'},
{html: 'Warren Sutton'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">45678765</a>'},
{html: 'Alan Jones'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">12345678</a>'},
{html: 'Jennifer Langley'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
]
[
{html: '<a href="#" class="govuk-link">89009800</a>'},
{html: 'Susan Francis'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">45456765</a>'},
{html: 'John Smith'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">88675411</a>'},
{html: 'Margaret Blake'},
{text: 'Red'},
{html: 'Incomplete'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">44455453</a>'},
{html: 'John Smith'},
{text: 'Blue'},
{html: 'Complete'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">12323212</a>'},
{html: 'Warren Sutton'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '25 Jan 2018'}
],
[
{html: '<a href="#" class="govuk-link">45678765</a>'},
{html: 'Alan Jones'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
],
[
{html: '<a href="#" class="govuk-link">12345678</a>'},
{html: 'Jennifer Langley'},
{text: 'Yellow'},
{html: 'In progress'},
{text: '9 May 2018'}
]
}) }}
</div>

]
}) }}
</div>
</div>
77 changes: 37 additions & 40 deletions src/moj/objects/_scrollable-pane.scss
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);
}
}
}