From 4826626f64a39f4f8fabda968f84aca2d07eda06 Mon Sep 17 00:00:00 2001 From: Andrew Hosgood Date: Mon, 20 Nov 2023 15:16:58 +0000 Subject: [PATCH] Add missing cookie banner properties --- .../cookie-banner/cookie-banner.stories.js | 11 ++++++ .../components/cookie-banner/fixtures.json | 37 ++++++++++++++----- .../cookie-banner/macro-options.json | 12 ++++++ .../components/cookie-banner/template.njk | 2 +- src/nationalarchives/lib/cookies.mjs | 1 - 5 files changed, 52 insertions(+), 11 deletions(-) diff --git a/src/nationalarchives/components/cookie-banner/cookie-banner.stories.js b/src/nationalarchives/components/cookie-banner/cookie-banner.stories.js index 8fd6334a..4b290952 100644 --- a/src/nationalarchives/components/cookie-banner/cookie-banner.stories.js +++ b/src/nationalarchives/components/cookie-banner/cookie-banner.stories.js @@ -5,11 +5,13 @@ import { within, userEvent } from "@storybook/testing-library"; import Cookies from "../../lib/cookies.mjs"; const argTypes = { + serviceName: { control: "text" }, cookiesUrl: { control: "text" }, policies: { control: "text" }, policiesKey: { control: "text" }, preferencesSetKey: { control: "text" }, cookiesDomain: { control: "text" }, + cookiesPath: { control: "text" }, allowInsecure: { control: "boolean" }, classes: { control: "text" }, attributes: { control: "object" }, @@ -27,22 +29,26 @@ export default { }; const Template = ({ + serviceName, cookiesUrl, policies, policiesKey, preferencesSetKey, cookiesDomain, + cookiesPath, allowInsecure, classes, attributes, }) => CookieBanner({ params: { + serviceName, cookiesUrl, policies, policiesKey, preferencesSetKey, cookiesDomain, + cookiesPath, allowInsecure, classes, attributes, @@ -57,6 +63,7 @@ Standard.args = { export const Accept = Template.bind({}); Accept.args = { + serviceName: "My service", cookiesUrl: "#", allowInsecure: true, classes: "tna-cookie-banner--demo", @@ -97,6 +104,7 @@ Accept.play = async ({ canvasElement }) => { export const Reject = Template.bind({}); Reject.args = { + serviceName: "My service", cookiesUrl: "#", classes: "tna-cookie-banner--demo", }; @@ -132,6 +140,7 @@ Reject.play = async ({ canvasElement }) => { export const CustomPolicies = Template.bind({}); CustomPolicies.args = { + serviceName: "My service", cookiesUrl: "#", policies: "custom", classes: "tna-cookie-banner--demo", @@ -166,6 +175,7 @@ CustomPolicies.play = async ({ args, canvasElement }) => { export const Existing = Template.bind({}); Existing.args = { + serviceName: "My service", cookiesUrl: "#", allowInsecure: true, classes: "tna-cookie-banner--demo", @@ -200,6 +210,7 @@ Existing.play = async ({ canvasElement }) => { // export const EventHandling = Template.bind({}); // EventHandling.args = { +// serviceName: "My service", // cookiesUrl: "#", // policies: "custom", // classes: "tna-cookie-banner--demo", diff --git a/src/nationalarchives/components/cookie-banner/fixtures.json b/src/nationalarchives/components/cookie-banner/fixtures.json index 2223f02f..a49063d9 100644 --- a/src/nationalarchives/components/cookie-banner/fixtures.json +++ b/src/nationalarchives/components/cookie-banner/fixtures.json @@ -4,83 +4,102 @@ { "name": "minimal", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies" }, - "html": "", + "html": "", "hidden": false }, { "name": "custom preferences set key", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "cookiesPreferencesSetKey": "custom" }, - "html": "", + "html": "", "hidden": false }, { "name": "custom policies", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "policies": "custom" }, - "html": "", + "html": "", "hidden": false }, { "name": "custom policies key", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "policiesKey": "custom_key" }, - "html": "", + "html": "", "hidden": false }, { "name": "with domain", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "cookiesDomain": "nationalarchives.gov.uk" }, - "html": "", + "html": "", + "hidden": false + }, + { + "name": "with path", + "options": { + "serviceName": "My service", + "cookiesUrl": "/cookies", + "cookiesPath": "/my-service" + }, + "html": "", "hidden": false }, { "name": "with preferences set key", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "preferencesSetKey": "custom_preferences_set_key" }, - "html": "", + "html": "", "hidden": false }, { "name": "insecure", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "allowInsecure": true }, - "html": "", + "html": "", "hidden": false }, { "name": "with classes", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "classes": "tna-cookie-banner--fixture" }, - "html": "", + "html": "", "hidden": false }, { "name": "with attributes", "options": { + "serviceName": "My service", "cookiesUrl": "/cookies", "attributes": { "data-fixturetest": "pass" } }, - "html": "", + "html": "", "hidden": false } ] diff --git a/src/nationalarchives/components/cookie-banner/macro-options.json b/src/nationalarchives/components/cookie-banner/macro-options.json index 8ef747e9..2fdf153c 100644 --- a/src/nationalarchives/components/cookie-banner/macro-options.json +++ b/src/nationalarchives/components/cookie-banner/macro-options.json @@ -1,4 +1,10 @@ [ + { + "name": "serviceName", + "type": "string", + "required": true, + "description": "" + }, { "name": "cookiesUrl", "type": "string", @@ -23,6 +29,12 @@ "required": false, "description": "" }, + { + "name": "cookiesPath", + "type": "string", + "required": false, + "description": "" + }, { "name": "allowInsecure", "type": "boolean", diff --git a/src/nationalarchives/components/cookie-banner/template.njk b/src/nationalarchives/components/cookie-banner/template.njk index 89430c2e..fee2befb 100644 --- a/src/nationalarchives/components/cookie-banner/template.njk +++ b/src/nationalarchives/components/cookie-banner/template.njk @@ -1,7 +1,7 @@ {% from "nationalarchives/components/button/macro.njk" import tnaButton %} {%- set containerClasses = [params.classes] if params.classes else [] -%} -