Skip to content

Commit

Permalink
Merge pull request #2998 from alphagov/kg-back-link-text-zoom
Browse files Browse the repository at this point in the history
Refactor back link and breadcrumb chevrons to use ems
  • Loading branch information
querkmachine authored Nov 29, 2022
2 parents 45c5f2f + 33d69cb commit 394b181
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 29 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixes

- [#2998: Refactor back link and breadcrumb chevrons to use ems](https://github.com/alphagov/govuk-frontend/pull/2998)

## 4.4.0 (Feature release)

### New features
Expand Down
38 changes: 19 additions & 19 deletions src/govuk/components/back-link/_index.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
@include govuk-exports("govuk/component/back-link") {
// Component font-size on the Frontend (used for calculations)
$font-size: 16;

// Size of chevron (excluding border)
$chevron-size: 7px;
$chevron-size: govuk-em(7px, $font-size);

// Size of chevron border
$chevron-border-width: 1px;
$chevron-border-min-width: 1px;
$chevron-border-width: govuk-em($chevron-border-min-width, $font-size);

// Colour of chevron
$chevron-border-colour: $govuk-secondary-text-colour;

.govuk-back-link {
@include govuk-typography-responsive($size: 16);
@include govuk-typography-responsive($size: $font-size);
@include govuk-link-common;
@include govuk-link-style-text;

Expand All @@ -21,7 +24,7 @@
margin-bottom: govuk-spacing(3);

// Allow space for the arrow
padding-left: 14px;
padding-left: govuk-em(14px, $font-size);
}

// Prepend left pointing chevron
Expand All @@ -35,14 +38,15 @@
@if $govuk-use-legacy-font {
// Begin adjustments for font baseline offset
// These should be removed when legacy font support is dropped
top: -1px;
bottom: 1px;
$offset: govuk-em(1px, $font-size);
top: $offset * -1;
bottom: $offset;
} @else {
top: 0;
bottom: 0;
}

left: 3px;
left: govuk-em(3px, $font-size);

width: $chevron-size;
height: $chevron-size;
Expand All @@ -52,9 +56,16 @@
transform: rotate(225deg);

border: solid;
border-width: $chevron-border-width $chevron-border-width 0 0;
border-width: $chevron-border-min-width $chevron-border-min-width 0 0;
border-color: $chevron-border-colour;

@supports (border-width: unquote("max(0px)")) {
border-width: unquote("max(#{$chevron-border-min-width}, #{$chevron-border-width}) max(#{$chevron-border-min-width}, #{$chevron-border-width})") 0 0;

// Ensure that the chevron never gets smaller than 16px
font-size: unquote("max(#{$font-size * 1px}, 1em)");
}

// Fall back to a less than sign for IE8
@include govuk-if-ie8 {
content: "\003c"; // Less than sign (<)
Expand All @@ -81,15 +92,4 @@
bottom: -14px;
left: 0;
}

@if $govuk-use-legacy-font {
// Begin adjustments for font baseline offset
// These should be removed when legacy font support is dropped
.govuk-back-link:before {
$offset: 1px;

top: $offset * -1;
bottom: $offset;
}
}
}
31 changes: 21 additions & 10 deletions src/govuk/components/breadcrumbs/_index.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
@include govuk-exports("govuk/component/breadcrumbs") {
// Component font-size on the Frontend (used for calculations)
$font-size: 16;

// Size of chevron (excluding border)
$chevron-size: 7px;
$chevron-size: govuk-em(7px, $font-size);

// Size of chevron border
$chevron-border-width: 1px;
$chevron-border-min-width: 1px;
$chevron-border-width: govuk-em($chevron-border-min-width, $font-size);

// Colour of chevron
$chevron-border-colour: $govuk-secondary-text-colour;
Expand All @@ -13,10 +16,10 @@
// of length 8 (7px + 1px border):
//
// √(8² + 8²) * 0.5 ≅ 5.655
$chevron-altitude-calculated: 5.655px;
$chevron-altitude-calculated: govuk-em(5.655px, $font-size);

.govuk-breadcrumbs {
@include govuk-font($size: 16);
@include govuk-font($size: $font-size);
@include govuk-text-colour;

margin-top: govuk-spacing(3);
Expand All @@ -40,8 +43,8 @@

// Add both margin and padding such that the chevron appears centrally
// between each breadcrumb item
margin-left: govuk-spacing(2);
padding-left: govuk-spacing(2) + $chevron-altitude-calculated;
margin-left: govuk-em(govuk-spacing(2), $font-size);
padding-left: govuk-em(govuk-spacing(2), $font-size) + $chevron-altitude-calculated;

float: left;

Expand All @@ -55,8 +58,9 @@
@if $govuk-use-legacy-font {
// Begin adjustments for font baseline offset
// These should be removed when legacy font support is dropped
top: -1px;
bottom: 1px;
$offset: govuk-em(1px, $font-size);
top: $offset * -1;
bottom: $offset;
} @else {
top: 0;
bottom: 0;
Expand All @@ -74,9 +78,16 @@
transform: rotate(45deg);

border: solid;
border-width: $chevron-border-width $chevron-border-width 0 0;
border-width: $chevron-border-min-width $chevron-border-min-width 0 0;
border-color: $chevron-border-colour;

@supports (border-width: unquote("max(0px)")) {
border-width: unquote("max(#{$chevron-border-min-width}, #{$chevron-border-width}) max(#{$chevron-border-min-width}, #{$chevron-border-width})") 0 0;

// Ensure that the chevron never gets smaller than 16px
font-size: unquote("max(#{$font-size * 1px}, 1em)");
}

// Fall back to a greater than sign for IE8
@include govuk-if-ie8 {
content: "\003e"; // Greater than sign (>)
Expand Down Expand Up @@ -118,7 +129,7 @@
}

&:before {
top: 6px;
top: govuk-em(6px, $font-size);
margin: 0;
}
}
Expand Down

0 comments on commit 394b181

Please sign in to comment.