Closed vanitabarrett closed 3 years ago
I think there's at least 3 different ways this component could be used, and they each probably need slightly different treatments…
When the 'accept all' / 'reject all' buttons are pressed, the browser POSTs to the server, and a full page navigation occurs.
When the 'accept all' / 'reject all' buttons are pressed, the client-side JavaScript provided by the service team sets any required cookies and fires any other events required, and the cookie banner is replaced by the 'accepted' / 'rejected' banner immediately.
This only works if cookies are only set from the client-side JS, and not from the server?
When the 'accept all' / 'reject all' buttons are pressed, an AJAX request is made to the server.
The 'accepted' / 'rejected' banner is either displayed immediately or after the request has completed (see below).
Originally posted by @36degrees in https://github.com/alphagov/design-system-team-internal/issues/402#issuecomment-739949168
There were 3 different options which we prototyped:
confirmationBanner
and a questionBanner
.banners
each with a number of actions
.The design of the banners means we should be able to make the options generic (apply to all), and this would also help to simplify the Nunjucks API. We've therefore decided to go with Option 2 for now, but to keep an open mind as we start building the component. If anything crops up, we may need to revisit this decision.
An example of what Option 2 might look like. A fuller example has been implemented in the prototype here
We still need to make decisions on the following:
{{ govukCookieBanner({
banners: [{
title: "Cookies on [service name]",
html: "<p>We use cookies to make this service work</p><p>We'd like to set some additional cookies so we can remember your settings, understand how you use the service and make improvements.</p>",
attributes: {
"data-module": "govuk-cookie-banner-question"
},
actions: [
{
text: "Accept cookies",
attributes: {
"data-accept-cookies": "accept"
}
},
{
text: "Reject cookies",
attributes: {
"data-reject-cookies": "reject"
}
},
{
text: "View cookies and set preferences",
href: "/cookie-preferences"
}
]
}, {
html: "<p>You've accepted additional cookies. You can <a href='/cookie-preferences'>change your cookie settings</a> at any time.</p>",
attributes: {
"data-module": "govuk-cookie-banner-accept",
"tabindex": "-1"
},
hidden: true
}, {
html: "<p>You've rejected additional cookies. You can <a href='/cookie-preferences'>change your cookie settings</a> at any time.</p>",
attributes: {
"data-module": "govuk-cookie-banner-reject",
"tabindex": "-1"
},
hidden: true
}]
}) }}
What
Decide if the cookie banner and the confirmation banner are the same component. Could be:
Why
Making a decision about this upfront will simplify the development process. We've done some prototyping of both options here: https://github.com/alphagov/govuk-frontend/pull/2081
Who needs to know about this
Developers Technical Writers / Content Design Designers
Done when