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

Only underline logo on hover (with custom colours) #926

Merged
merged 2 commits into from
Jul 24, 2018

Conversation

36degrees
Copy link
Contributor

Because all borders will become text colour when a user overrides colour in their browser, the transparent border will become always visible.

By only applying the border on hover we avoid this which means we get the correct behaviour even when colours are customised. The layout is not affected because we offset the additional border with a negative margin.

We do however have to add an additional rule for IE8 which does not support customColor and so ignores the rule entirely - which meant it had no border before. This would be fine, except the negative margin does kicks in on hover, which means without a border the header would shrink by 1px on hover in IE8.

Before

screen shot 2018-07-23 at 16 55 05-fullpage

After

jul-23-2018 16-57-16

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-926 July 23, 2018 15:57 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-926 July 23, 2018 15:59 Inactive
border-bottom-color: currentColor;
margin-bottom: -1px; // Negate transparent bottom border
border-bottom: 1px solid currentColor;
@include govuk-if-ie8 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you include a comment that explains why the ie8 code is needed? the info in the PR is very good

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-926 July 23, 2018 16:12 Inactive
@@ -108,6 +108,8 @@
&:active {
margin-bottom: -1px; // Negate transparent bottom border
border-bottom: 1px solid currentColor;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, I think that border's default colour is currentColor which could mean changing this statement to border-bottom: 1px solid may remove the need for the conditional IE8 logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great suggestion – that seems to work well.

Copy link
Contributor

@NickColley NickColley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice attention to detail. 👍

I have a comment on a potential simpler approach, that is non-blocking.

Because all borders will become text colour when a user overrides colour in their browser, the transparent border will become always visible.

By only applying the border on hover we avoid this which means we get the correct behaviour even when colours are customised. The layout is not affected because we offset the additional border with a negative margin.

Removing any border-color attribute means that we'll use the currentColor for the border - making this explicit results in IE8 ignoring the rule because it doesn't understand the currentColor variable.
@36degrees
Copy link
Contributor Author

@NickColley would you mind taking another look?

@NickColley
Copy link
Contributor

👍

@36degrees 36degrees merged commit 8d3f5c1 into master Jul 24, 2018
@NickColley NickColley deleted the header-logo-underline-on-hover branch July 24, 2018 09:02
@36degrees 36degrees added this to the 1.2.0 milestone Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants