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

Cookie consent component #448

Open
wants to merge 26 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f64ad93
Initial setup of Cookie banner.
oisa Mar 27, 2024
5b29c41
Adds base styles of variations and base functionality
oisa Aug 13, 2024
51032eb
Updates to cookie banner functions
oisa Aug 15, 2024
22de85b
Updates to documentation setup
oisa Aug 26, 2024
31b66bf
Deploy test
oisa Sep 13, 2024
55118c0
Test github test-staging workflow
oisa Oct 13, 2024
2d43ad2
Removes malfunctioning pa11y ci automated testing.
oisa Oct 14, 2024
3f0ac24
Updates Cookie banner to Cookie consent
oisa Oct 14, 2024
5d74b83
Cookie consent dialog base element sans function
oisa Nov 15, 2024
c081cdd
Updates cookie consent API integration sans full config setup
oisa Nov 20, 2024
ed52fc0
Cookie consent script management
oisa Nov 22, 2024
0a250b2
Cookie consent merge multiple instances into single instance alongsid…
oisa Nov 27, 2024
2b8d62d
Update cookies consent preferences for testing
oisa Nov 27, 2024
dfb9fbb
Merge branch 'master' into feature/cookie-banner
oisa Nov 27, 2024
e5a0ee5
Cookie consent adjustments to test on staging
oisa Nov 28, 2024
468aecc
Fixes consent modal from api
oisa Nov 28, 2024
e7b8ab8
Cookie consent - adds dynamic preferences dialog, ability to add uned…
oisa Dec 3, 2024
54c2f8a
Cookie consent - adds fixed consent banner
oisa Dec 3, 2024
890fcad
Cookie consent updates event handling and clearer distinction of bann…
oisa Dec 4, 2024
b6be999
Cookie consent - updates to conditional confirmation message and rest…
oisa Dec 9, 2024
2089a91
Cookie consent - adds conditions for confirmation message, removes li…
oisa Dec 10, 2024
04687df
Merge branch 'master' into feature/cookie-banner
oisa Dec 10, 2024
166de60
Cookie consent - updates documentation config, cleans up js
oisa Dec 11, 2024
9232685
Cookie consent - updates docs-specific settings as well as function t…
oisa Dec 11, 2024
3531169
Cookie consent - initial documentation setup
oisa Dec 12, 2024
eed2fbc
Cookie consent - documentation updates
oisa Dec 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"linebreak-style": 0,
"max-len": [1, 130, 2],
"newline-per-chained-call": ["error", { "ignoreChainWithDepth": 2 }],
"semi": [2, "never"]
"semi": [2, "never"],
"no-new": "off"
},
"env": {
"browser": true,
Expand Down
Binary file modified HTMLstarterkit.zip
Binary file not shown.
25 changes: 21 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ function lintStyles() {
}))
}

function removeCookieConsentCSS() {
return src('dist/**/*.js')
.pipe(
inject.append(`
document.addEventListener('DOMContentLoaded', () => {
const unwantedStylesheet = Array.from(document.querySelectorAll('link')).find(
link => link.href.includes('cookieconsent.css')
);
if (unwantedStylesheet) {
unwantedStylesheet.remove();
}
});
`)
)
.pipe(dest('dist'));
}

function generateSitemap() {
return src(['./dist/**/*.html', '!**/blank.html'], { read: false })
.pipe(sitemap({ siteUrl: config.baseUrl.full }))
Expand Down Expand Up @@ -315,14 +332,14 @@ function renamePathForProd() {

function addAnalytics() {
return src(`${config.dir.build}/**/*.html`)
.pipe(inject.after('<head>', `<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
.pipe(inject.after('<head>', `<script data-category="analytics">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-P2NKBBJZ');</script>
`))
.pipe(inject.after('<head>', `<script async src="https://www.googletagmanager.com/gtag/js?id=G-49T9M12F86"></script>
<script>
.pipe(inject.after('<head>', `<script async data-category="analytics" src="https://www.googletagmanager.com/gtag/js?id=G-49T9M12F86"></script>
<script data-category="analytics">
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
Expand All @@ -343,7 +360,7 @@ function bumping() {
}

const styles = series(lintStyles, buildStyles, buildCoreStyles, buildDocStyles)
const javascript = series(lintJavascript, compileJS, compileTypes, compileDocsJS)
const javascript = series(lintJavascript, compileJS, compileTypes, compileDocsJS, removeCookieConsentCSS)

function watchFiles(done) {
watch(config.scss.watch, series(styles, reload))
Expand Down
9 changes: 9 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,9 @@
"gulp-better-rollup": {
"rollup": "^1||^2||^3"
}
},
"dependencies": {
"@floating-ui/dom": "^1.6.7",
"vanilla-cookieconsent": "^3.0.1"
}
}
1 change: 1 addition & 0 deletions src/components/_all.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@import 'card/card';
@import 'card-carousel/carousel';
@import 'content-block/content-block';
@import 'cookie-consent/cookie-consent';
@import 'date-input/date-input';
@import 'date-picker/date-picker';
@import 'dialog/dialog';
Expand Down
7 changes: 7 additions & 0 deletions src/components/cookie-consent/_cookie-consent.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{#if-equals type "banner"}}
<a href="#" class="js-open-banner-cookie-consent" aria-haspopup="dialog">Trigger consent banner</a>
{{/if-equals}}

{{#if-equals type "dialog"}}
<a href="#" class="js-open-dialog-cookie-consent-preferences" aria-haspopup="dialog">Trigger cookie preferences</a>
{{/if-equals}}
181 changes: 181 additions & 0 deletions src/components/cookie-consent/_cookie-consent.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
.nsw-cookie-banner {
padding: rem(24px) 0;
background-color: var(--nsw-brand-light);
position: fixed;
bottom: 0;
left: 0;
width: 100%;
z-index: 1000;

.nsw-icon-button {
position: absolute;
top: rem(-8px);
right: rem(4px);

&:hover {
@include nsw-hover;
background-color: var(--nsw-hover-light);
}

&:focus {
@include nsw-focus($color: var(--nsw-text-light));
}
}

&__wrapper {
@include container;
position: relative;
}

&__title {
@include font-size('md');
font-weight: var(--nsw-font-bold);
}

&__content {
margin: rem(16px) rem(36px) rem(24px) 0;
}

&__buttons-container {
display: flex;
flex-wrap: wrap;
gap: rem(16px);
margin-top: rem(16px);
}

&--light {
background-color: var(--nsw-status-info-bg);
color: var(--nsw-text-dark);

.nsw-cookie-banner__content a {
@include link-dark;
}

.nsw-icon-button {
color: var(--nsw-brand-dark);

&:hover {
background-color: var(--nsw-hover);
}

&:focus {
outline-color: var(--nsw-focus);
}
}
}
}

.nsw-cookie-dialog {
z-index: 1100;

.nsw-dialog__top {
position: sticky;
top: 0;
background: var(--nsw-white);
}

&__bottom {
border-top: 1px solid var(--nsw-grey-04);
position: absolute;
bottom: 0;
left: 0;
right: 0;
display: flex;
flex-direction: column;
padding: rem(16px);

@include breakpoint('md') {
flex-direction: row-reverse;
justify-content: space-between;
}

@include breakpoint('lg') {
padding: rem(32px);
}

button {
margin-bottom: rem(16px);

@include breakpoint('md') {
margin-bottom: 0;
}

&:last-child {
margin-bottom: 0;

@include breakpoint('md') {
margin-left: 0;
}
}
}
}

&__cta-group {
display: flex;
gap: rem(16px);

@include breakpoint('md') {
flex-direction: row;
}
}

.nsw-dialog__content {
padding-top: rem(16px);
padding-bottom: rem(16px);
}

.nsw-tabs__content {
border: 0;
-webkit-overflow-scrolling: auto;
max-height: 320px;
padding-left: 8px;
overflow: scroll;

&:focus-visible {
outline: 2px solid var(--nsw-brand-dark);
border: 0;
}

&:focus {
outline: none;
}

&::-webkit-scrollbar {
width: 8px;
}

&::-webkit-scrollbar-thumb {
border-radius: 4px;
background-color: var(--nsw-grey-03);
box-shadow: 0 0 1px var(--nsw-grey-03);
}
}

&__list {
display: flex;
flex-direction: column;
padding-left: 0;
gap: rem(8px);
}

&__list-item {
display: flex;
flex-direction: column;
gap: rem(8px);

label {
@include font-size('md');
font-weight: var(--nsw-font-bold);
cursor: pointer;
}

&:not(:nth-child(1)) {
border-top: 1px solid var(--nsw-grey-04);
padding-top: rem(28px);
}
}

&__cookie-details {
margin-left: 48px;
}
}
Loading
Loading