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

Add styling for the cookie banner component #2126

Merged
merged 3 commits into from
Feb 2, 2021

Conversation

hannalaakso
Copy link
Member

@hannalaakso hannalaakso commented Jan 28, 2021

What

Following on from #2114 and #2114, add the styling for the cookie banner component.

The designs are shown here: #2107 (comment) Additionally, the heading and content should be constrained to 2/3 grid column, whilst the button group should be full width on desktop.

Spacing

The component does not set bottom spacing. The bottom spacing should be created by the items inside the component.

Hiding sections

We're going to use the hidden attribute to hide sections as this will hide the content even if CSS fails to load.

display: none; will act as a fallback for legacy browsers (IE 8-10) that don't support the hidden attribute. Unfortunately it looks like Lynx doesn't support hidden but that's a vendor implementation issue. It also appears that Lynx hasn't been in active development for some time. Using the hidden attribute seems like the semantically correct thing to do here and it makes the component usable when CSS fails to load.

(The alternative would be to insert text into the DOM at relevant points which could also be a suitable solution in some contexts. We decided against it as the Design System components need to be really flexible so we're trying to avoid patterns where HTML markup needs to be maintained inside JavaScript which will also simplify localisation etc. where relevant.)

Border

Visually separate the cookie banner from content underneath with a transparent bottom border when user changes colours in their browser.

Remove visible focus indicator from cookie banner

when the element is programmatically focused.

The focused cookie banner is the first element on the page and the last thing the user interacted with prior to it gaining focus. We therefore assume that moving focus to it is not going to surprise users, and that giving it a visible focus indicator could be more confusing than helpful, especially as the element is not normally keyboard operable.

We will flag this in the research section of the guidance as something to monitor.

A related discussion: w3c/wcag#1001

(It's also worth noting that this is different to what we do with the notification banner which does have a visible focus indicator. However, the notification banner is further down the page and the user might not have interacted with it prior to it gaining focus. It is therefore helpful to indicate to users that the focus has moved to it, even though the element, like the cookie banner, isn’t normally keyboard operable.)

Fixes #2098 and #2112

Tested on

✅ Chrome 88 (Mac)
✅ Firefox 84 (Mac)
✅ Safari 14 (Mac)

✅ Chrome 85 (Windows)
✅ Firefox 85 (Windows)
✅ Edge 88 (Windows)

✅ Chrome (Android 10)
✅ Firefox (Android 9)
✅ Samsung Internet (Android 10)

✅ Safari (iPhone 12 , iOS 14)
✅ Chrome (iPhone 8, iOS 13)

✅ IE11 (Windows 10)
✅ IE10 (Windows 7)
✅ IE9 (Windows 7)
✅ IE8 (Windows 7)

When users change colours in their browser (Firefox 84)

Screenshot 2021-02-02 at 14 55 18

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 28, 2021 09:13 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 28, 2021 09:20 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 28, 2021 11:02 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 28, 2021 12:07 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 28, 2021 15:31 Inactive
@hannalaakso hannalaakso changed the title WIP cookie banner styles Add styling for the cookie banner component Jan 28, 2021
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 28, 2021 17:14 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 28, 2021 17:34 Inactive
Copy link
Member

@christopherthomasdesign christopherthomasdesign left a comment

Choose a reason for hiding this comment

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

At smaller sizes the link text isn't quite vertically centred in the space below the buttons:

Screenshot 2021-01-28 at 17 08 20

I think taking 5px off the bottom of the banner should fix it.

@36degrees 36degrees linked an issue Jan 29, 2021 that may be closed by this pull request
2 tasks
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 29, 2021 12:03 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 29, 2021 15:24 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 29, 2021 15:34 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 29, 2021 16:11 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 January 29, 2021 16:17 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 1, 2021 09:52 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 1, 2021 15:55 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 1, 2021 17:03 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 1, 2021 17:09 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 1, 2021 18:14 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 1, 2021 19:12 Inactive
@hannalaakso hannalaakso marked this pull request as draft February 1, 2021 19:14
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 2, 2021 14:49 Inactive
@hannalaakso hannalaakso marked this pull request as ready for review February 2, 2021 15:25
The component does not set bottom spacing. The bottom spacing should be created by the
items inside the component.

 We're going to use the `hidden` attribute to hide sections as this will hide the content even if CSS fails to load.

`display: none;` will act as a fallback for legacy browsers (IE 8-10) that don't support the `hidden` attribute.
Unfortunately it looks like Lynx doesn't support `hidden` but that's a vendor implementation issue. It also appears that
Lynx hasn't been in active development for some time. Using the `hidden` attribute seems like the semantically correct
thing to do here and it makes the component usable when CSS fails to load.

(The alternative would be to insert text into the DOM at relevant points which could also be a suitable solution in some
contexts. We decided against it as the Design System components need to be really flexible so we're trying to avoid
patterns where HTML markup needs to be maintained inside JavaScript which will also simplify localisation etc. where
relevant.)

Visually separate the cookie banner from content underneath with a transparent bottom border
when user changes colours in their browser.
when the element is programmatically focused.

The focused cookie banner is the first element on the page and the last thing the user
interacted with prior to it gaining focus.
We therefore assume that moving focus to it is not going to surprise users, and that giving
it a visible focus indicator could be more confusing than helpful, especially as the
element is not normally keyboard operable.

We have flagged this in the research section of the guidance as something to monitor.

A related discussion: w3c/wcag#1001

It's also worth noting that this is different to what we do with the notification banner which does have
a visible focus indicator. However, the notification banner is further down the page and the user might not have interacted with it prior to it gaining focus so it is helpful to indicate to users that the focus has moved to it (even though the element, like the cookie banner, isn’t normally keyboard operable).
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2126 February 2, 2021 16:05 Inactive
@vanitabarrett
Copy link
Contributor

Great work, looks awesome! 🎉

Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

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

🎉

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.

Add styling for cookie banner
5 participants