Skip to content

Commit

Permalink
feat(navigation): enhance hover styles fo 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 Dec 15, 2023
1 parent ef965ef commit cbccda7
Show file tree
Hide file tree
Showing 3 changed files with 27 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
11 changes: 5 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,14 @@
font-weight: bold;
}

a:hover {
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 +117,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 @@ -66,7 +66,7 @@
}

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

&:focus {
Expand All @@ -79,9 +79,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 @@ -107,6 +112,10 @@

}

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

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

0 comments on commit cbccda7

Please sign in to comment.