Skip to content

Commit

Permalink
feat(navigation): enhance hover styles of navigation links
Browse files Browse the repository at this point in the history
Applies to Primary navigation, Sub navigation and Side navigation.

Use the standard GDS link hover colour to ensure links colour contrast is sufficient for
readability.

Ensure borders follow suit, and ensure they're always on the same side of the element.

Fixes #447
  • Loading branch information
gregtyler committed Jan 25, 2024
1 parent 372d70b commit cd0f9df
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
10 changes: 9 additions & 1 deletion src/moj/components/primary-navigation/_primary-navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
}

&:hover {
color: govuk-tint($govuk-link-colour, 25);
color: $govuk-link-hover-colour;
}

&:focus {
Expand Down Expand Up @@ -95,6 +95,14 @@
width: 100%;
}

&:hover {
color: $govuk-link-hover-colour;

&:before {
background-color: $govuk-link-hover-colour;
}
}

&:focus {
color: govuk-colour("black"); // Focus colour on yellow should really be black.
position: relative; // Ensure focus sits above everything else.
Expand Down
12 changes: 6 additions & 6 deletions src/moj/components/side-navigation/_side-navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,13 @@
}

a:hover {
border-color: govuk-tint($govuk-link-colour, 25);
color: $govuk-link-hover-colour;
}

a:focus {
color: $govuk-focus-text-colour;
background-color: $govuk-focus-colour;
box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour;
border-color: $govuk-focus-text-colour;
border-left-color: transparent;
position: relative;
}

Expand All @@ -100,12 +98,15 @@
font-weight: bold;
}

a:hover {
color: $govuk-link-hover-colour;
border-color: $govuk-link-hover-colour;
}

a:focus {
color: $govuk-focus-text-colour;
background-color: $govuk-focus-colour;
box-shadow: 0 -2px $govuk-focus-colour, 0 4px $govuk-focus-text-colour;
border-color: $govuk-focus-text-colour;
border-left-color: transparent;
}

@include govuk-media-query($from: tablet) {
Expand All @@ -117,7 +118,6 @@
a:focus {
color: $govuk-focus-text-colour;
background-color: $govuk-focus-colour;
border-color: transparent;
}
}

Expand Down
17 changes: 13 additions & 4 deletions src/moj/components/sub-navigation/_sub-navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
}

&:hover {
color: govuk-tint($govuk-link-colour, 25);
color: $govuk-link-hover-colour;
}

&:focus {
Expand All @@ -73,9 +73,14 @@
background-color: govuk-colour("black");
content: "";
display: block;
width: 100%;
position: absolute; bottom: 0; left: 0; right: 0;
height: 5px;
height: 100%;
position: absolute; bottom: 0; left: 0;
width: 5px;

@include govuk-media-query($from: tablet) {
height: 5px;
width: 100%;
}
}

}
Expand All @@ -101,6 +106,10 @@

}

&:hover {
color: $govuk-link-hover-colour;
}

&:focus:before {
background-color: govuk-colour("black");
}
Expand Down

0 comments on commit cd0f9df

Please sign in to comment.