Skip to content

Commit

Permalink
Move summary list border from cells to rows
Browse files Browse the repository at this point in the history
Simplify the code by moving the bottom border to the row itself. This requires us to set `border-collapse: collapse` in order to use the collapsing border model [1] as in the separated borders model (the initial border model) – 'rows, columns, row groups, and column groups cannot have borders' [2].

Unfortunately some browsers, including IE11 and Safari, still omit the border where a row is missing cells – so we do still need to provide the empty pseudo-element 'cell' for rows without actions.

[1]: https://drafts.csswg.org/css2/#collapsing-borders
[2]: https://drafts.csswg.org/css2/#:~:text=Rows%2C%20columns%2C%20row%20groups%2C%20and%20column%20groups%20cannot%20have%20borders%20(i.e.%2C%20user%20agents%20must%20ignore%20the%20border%20properties%20for%20those%20elements).
  • Loading branch information
36degrees committed Oct 14, 2021
1 parent 6ad9b59 commit c3759f7
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/govuk/components/summary-list/_index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
display: table;
width: 100%;
table-layout: fixed; // Required to allow us to wrap words that overflow.
border-collapse: collapse;
}
margin: 0; // Reset default user agent styles
@include govuk-responsive-margin(6, "bottom");
}

.govuk-summary-list__row {
border-bottom: 1px solid $govuk-border-colour;

@include govuk-media-query($until: tablet) {
margin-bottom: govuk-spacing(3);
border-bottom: 1px solid $govuk-border-colour;
}
@include govuk-media-query($from: tablet) {
display: table-row;
}
}

// Provide an empty 'cell' for rows that don't have actions – otherwise the
// bottom border is not drawn for that part of the row.
// bottom border is not drawn for that part of the row in some browsers.
.govuk-summary-list__row--no-actions:after {
content: "";
display: table-cell;
border-bottom: 1px solid $govuk-border-colour;
}

.govuk-summary-list__key,
Expand All @@ -39,7 +40,6 @@
padding-top: govuk-spacing(2);
padding-right: govuk-spacing(4);
padding-bottom: govuk-spacing(2);
border-bottom: 1px solid $govuk-border-colour;
}
}

Expand Down Expand Up @@ -117,36 +117,30 @@

// No border on entire summary list
.govuk-summary-list--no-border {
@include govuk-media-query($until: tablet) {
.govuk-summary-list__row {
border: 0;
}
.govuk-summary-list__row {
border: 0;
}

// Increase padding by 1px to compensate for 'missing' border
@include govuk-media-query($from: tablet) {
.govuk-summary-list__key,
.govuk-summary-list__value,
.govuk-summary-list__actions {
// Remove 1px border, add 1px height back on
padding-bottom: govuk-spacing(2) + 1px;
border: 0;
}
}
}

// No border on specific rows
.govuk-summary-list__row--no-border {
@include govuk-media-query($until: tablet) {
border: 0;
}
border: 0;

// Increase padding by 1px to compensate for 'missing' border
@include govuk-media-query($from: tablet) {
.govuk-summary-list__key,
.govuk-summary-list__value,
.govuk-summary-list__actions {
// Remove 1px border, add 1px height back on
padding-bottom: govuk-spacing(2) + 1px;
border: 0;
}
}
}
Expand Down

0 comments on commit c3759f7

Please sign in to comment.