@justeattakeaway/pie-cookie-banner 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +17 -0
- package/README.md +106 -0
- package/declaration.d.ts +9 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +36 -0
- package/dist/react.d.ts +16 -0
- package/dist/react.js +67 -0
- package/package.json +41 -0
- package/src/cookie-banner.scss +120 -0
- package/src/defs.ts +3 -0
- package/src/index.ts +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright (c) Just Eat Takeaway.com
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img align="center" src="../../../readme_image.png" height="200" alt="">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/@justeattakeaway/pie-cookie-banner">
|
|
7
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-cookie-banner.svg">
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
# Table of Contents
|
|
12
|
+
|
|
13
|
+
1. [Introduction](#pie-cookie-banner)
|
|
14
|
+
2. [Local Development](#local-development)
|
|
15
|
+
3. [Importing the component](#importing-the-component)
|
|
16
|
+
4. [Props](#props)
|
|
17
|
+
5. [Testing](#testing)
|
|
18
|
+
|
|
19
|
+
# pie-cookie-banner
|
|
20
|
+
|
|
21
|
+
`pie-cookie-banner` is a Web Component built using the Lit library.
|
|
22
|
+
|
|
23
|
+
This component can be easily integrated into various frontend frameworks and customized through a set of properties.
|
|
24
|
+
|
|
25
|
+
## Local development
|
|
26
|
+
|
|
27
|
+
Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
To build the `pie-cookie-banner` package, run the following command:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yarn build --filter=pie-cookie-banner
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
If you'd like to develop using the component storybook, then you should build the component in `watch` mode, and run storybook in a separate terminal tab:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
yarn watch --filter=pie-cookie-banner
|
|
43
|
+
|
|
44
|
+
# in a separate terminal tab, run
|
|
45
|
+
yarn dev --filter=pie-storybook
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Importing the component
|
|
49
|
+
|
|
50
|
+
```js
|
|
51
|
+
// default
|
|
52
|
+
import { PieCookieBanner } from '@justeattakeaway/pie-cookie-banner';
|
|
53
|
+
|
|
54
|
+
// react
|
|
55
|
+
import { PieCookieBanner } from '@justeattakeaway/pie-cookie-banner/dist/react';
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Props
|
|
59
|
+
|
|
60
|
+
| Property | Type | Default | Description |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| - | - | - | - |
|
|
63
|
+
|
|
64
|
+
In your markup or JSX, you can then use these to set the properties for the `pie-cookie-banner` component:
|
|
65
|
+
|
|
66
|
+
```html
|
|
67
|
+
<!-- Native HTML -->
|
|
68
|
+
<pie-cookie-banner></pie-cookie-banner>
|
|
69
|
+
|
|
70
|
+
<!-- JSX -->
|
|
71
|
+
<PieCookieBanner></PieCookieBanner>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Testing
|
|
75
|
+
|
|
76
|
+
### Browser tests
|
|
77
|
+
|
|
78
|
+
To run the browser tests, run the following command from the root of the monorepo:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
yarn test:browsers --filter=pie-cookie-banner
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Visual tests
|
|
85
|
+
|
|
86
|
+
To run the visual regression tests, run the following command from the root of the monorepo:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
yarn test:visual --filter=pie-cookie-banner
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Note: To run these locally, you will need to ensure that any environment variables required are set up on your machine to mirror those on CI (such as Percy tokens). How you achieve this will differ between operating systems.
|
|
93
|
+
|
|
94
|
+
#### Setup via bash
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
export PERCY_TOKEN_PIE_COOKIE_BANNER=abcde
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Setup via package.json
|
|
101
|
+
|
|
102
|
+
Under scripts `test:visual` replace the environment variable with the below:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
PERCY_TOKEN_PIE_COOKIE_BANNER=abcde
|
|
106
|
+
```
|
package/declaration.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { LitElement } from 'lit';
|
|
3
|
+
import type { TemplateResult } from 'lit-html';
|
|
4
|
+
|
|
5
|
+
export declare interface CookieBannerProps {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export declare class PieCookieBanner extends LitElement implements CookieBannerProps {
|
|
9
|
+
render(): TemplateResult<1>;
|
|
10
|
+
static styles: CSSResult;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { unsafeCSS as i, LitElement as n, html as t } from "lit";
|
|
2
|
+
const a = `*{margin:0}.c-cookieBanner{--cb-font-family: var(--dt-font-interactive-m-family);--cb-font-size: calc(var(--dt-font-body-l-size) * 1px);--cb-line-height: calc(var(--dt-font-body-l-line-height) * 1px);--cb-font-weight: var(--dt-font-body-l-weight);--cb-padding-inline: var(--dt-spacing-d);--cb-padding-block: var(--dt-spacing-d);--cb-offset: 0;color-scheme:only dark;background-color:var(--dt-color-background-dark);color:var(--dt-color-content-inverse);font-family:var(--cb-font-family);font-size:var(--cb-font-size);line-height:var(--cb-line-height);font-weight:var(--cb-font-weight);padding-block-start:var(--cb-padding-block);padding-block-end:var(--cb-padding-block);max-height:432px;position:fixed;bottom:var(--cb-offset);left:var(--cb-offset);right:var(--cb-offset);border-top-left-radius:var(--dt-radius-rounded-c);border-top-right-radius:var(--dt-radius-rounded-c)}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner{--cb-padding-inline: var(--dt-spacing-f);--cb-offset: var(--dt-spacing-d);max-height:90%;border-bottom-left-radius:var(--dt-radius-rounded-c);border-bottom-right-radius:var(--dt-radius-rounded-c)}}.c-cookieBanner-title,.c-cookieBanner-body,.c-cookieBanner-actions{padding-inline-start:var(--cb-padding-inline);padding-inline-end:var(--cb-padding-inline)}.c-cookieBanner-title{--cb-title-font-size: var(--dt-font-heading-s-size--narrow);--cb-title-line-height: var(--dt-font-heading-s-line-height--narrow);font-size:calc(var(--cb-title-font-size) * 1px);font-weight:var(--dt-font-heading-s-weight);line-height:calc(var(--cb-title-line-height) * 1px)}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner-title{--cb-title-font-size: var(--dt-font-heading-s-size--wide);--cb-title-line-height: var(--dt-font-heading-s-line-height--wide)}}.c-cookieBanner-body{--cb-scroll-shadow-color: var(--dt-color-black);margin-block-start:var(--dt-spacing-a);max-height:200px;overflow-y:auto;background:linear-gradient(to bottom,transparent,var(--dt-color-background-dark) 75%) center bottom,linear-gradient(transparent,var(--cb-scroll-shadow-color)) center bottom;background-repeat:no-repeat;background-size:100% 48px,100% 8px;background-attachment:local,scroll}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner-body{max-height:150px}}.c-cookieBanner-actions{--cb-actions-flex-dir: column;margin-block-start:var(--dt-spacing-d);display:flex;gap:var(--dt-spacing-d);flex-direction:var(--cb-actions-flex-dir)}.c-cookieBanner-actions>pie-link{width:max-content;margin-inline-start:auto;margin-inline-end:auto}@media (min-width: 700px) and (orientation: landscape){.c-cookieBanner-actions{--cb-actions-flex-dir: row-reverse;justify-content:flex-start;align-items:center}.c-cookieBanner-actions>pie-link{margin-inline-start:0;margin-inline-end:0}}
|
|
3
|
+
`, o = "pie-cookie-banner";
|
|
4
|
+
class e extends n {
|
|
5
|
+
render() {
|
|
6
|
+
return t`
|
|
7
|
+
<aside data-test-id="pie-cookie-banner" class="c-cookieBanner">
|
|
8
|
+
<h2 class="c-cookieBanner-title">Cookies</h2>
|
|
9
|
+
<div class="c-cookieBanner-body">
|
|
10
|
+
<p>We use our own and third party cookies and other tech to enhance and personalise your user experience,
|
|
11
|
+
optimize analytics, and show ads with third parties
|
|
12
|
+
(read our <pie-link variant="inverse">Statement</pie-link>).
|
|
13
|
+
Necessary cookies are always set. Click <pie-link variant="inverse">Necessary only</pie-link>
|
|
14
|
+
to continue without accepting more. Click <pie-link variant="inverse">Manage preferences</pie-link>
|
|
15
|
+
to share your preferences or <pie-link variant="inverse">Accept all</pie-link>.</p>
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
<div class="c-cookieBanner-actions">
|
|
19
|
+
<pie-button variant="primary" isFullWidth="true" size="small-expressive">
|
|
20
|
+
Accept all
|
|
21
|
+
</pie-button>
|
|
22
|
+
<pie-button variant="outline" isFullWidth="true" size="small-expressive">
|
|
23
|
+
Necessary only
|
|
24
|
+
</pie-button>
|
|
25
|
+
<pie-link variant="inverse" size="medium" isBold="true">
|
|
26
|
+
Manage preferences
|
|
27
|
+
</pie-link>
|
|
28
|
+
</div>
|
|
29
|
+
</aside>`;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
e.styles = i(a);
|
|
33
|
+
customElements.define(o, e);
|
|
34
|
+
export {
|
|
35
|
+
e as PieCookieBanner
|
|
36
|
+
};
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { LitElement } from 'lit';
|
|
3
|
+
import type { ReactWebComponent } from '@lit-labs/react';
|
|
4
|
+
import type { TemplateResult } from 'lit-html';
|
|
5
|
+
|
|
6
|
+
export declare interface CookieBannerProps {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare const PieCookieBanner: ReactWebComponent<PieCookieBanner_2, {}>;
|
|
10
|
+
|
|
11
|
+
declare class PieCookieBanner_2 extends LitElement implements CookieBannerProps {
|
|
12
|
+
render(): TemplateResult<1>;
|
|
13
|
+
static styles: CSSResult;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { }
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as C from "react";
|
|
2
|
+
import { PieCookieBanner as E } from "./index.js";
|
|
3
|
+
import "lit";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2018 Google LLC
|
|
7
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
8
|
+
*/
|
|
9
|
+
const g = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), w = /* @__PURE__ */ new WeakMap(), b = (d, r, m, p, h) => {
|
|
10
|
+
const i = h == null ? void 0 : h[r];
|
|
11
|
+
i === void 0 || m === p ? m == null && r in HTMLElement.prototype ? d.removeAttribute(r) : d[r] = m : ((o, t, u) => {
|
|
12
|
+
let s = w.get(o);
|
|
13
|
+
s === void 0 && w.set(o, s = /* @__PURE__ */ new Map());
|
|
14
|
+
let a = s.get(t);
|
|
15
|
+
u !== void 0 ? a === void 0 ? (s.set(t, a = { handleEvent: u }), o.addEventListener(t, a)) : a.handleEvent = u : a !== void 0 && (s.delete(t), o.removeEventListener(t, a));
|
|
16
|
+
})(d, i, m);
|
|
17
|
+
};
|
|
18
|
+
function B(d = window.React, r, m, p, h) {
|
|
19
|
+
let i, o, t;
|
|
20
|
+
if (r === void 0) {
|
|
21
|
+
const l = d;
|
|
22
|
+
({ tagName: o, elementClass: t, events: p, displayName: h } = l), i = l.react;
|
|
23
|
+
} else
|
|
24
|
+
i = d, t = m, o = r;
|
|
25
|
+
const u = i.Component, s = i.createElement, a = new Set(Object.keys(p ?? {}));
|
|
26
|
+
class f extends u {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments), this.o = null;
|
|
29
|
+
}
|
|
30
|
+
t(e) {
|
|
31
|
+
if (this.o !== null)
|
|
32
|
+
for (const v in this.i)
|
|
33
|
+
b(this.o, v, this.props[v], e ? e[v] : void 0, p);
|
|
34
|
+
}
|
|
35
|
+
componentDidMount() {
|
|
36
|
+
this.t();
|
|
37
|
+
}
|
|
38
|
+
componentDidUpdate(e) {
|
|
39
|
+
this.t(e);
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const { _$Gl: e, ...v } = this.props;
|
|
43
|
+
this.h !== e && (this.u = (n) => {
|
|
44
|
+
e !== null && ((c, k) => {
|
|
45
|
+
typeof c == "function" ? c(k) : c.current = k;
|
|
46
|
+
})(e, n), this.o = n, this.h = e;
|
|
47
|
+
}), this.i = {};
|
|
48
|
+
const y = { ref: this.u };
|
|
49
|
+
for (const [n, c] of Object.entries(v))
|
|
50
|
+
g.has(n) ? y[n === "className" ? "class" : n] = c : a.has(n) || n in t.prototype ? this.i[n] = c : y[n] = c;
|
|
51
|
+
return s(o, y);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
f.displayName = h ?? t.name;
|
|
55
|
+
const N = i.forwardRef((l, e) => s(f, { ...l, _$Gl: e }, l == null ? void 0 : l.children));
|
|
56
|
+
return N.displayName = f.displayName, N;
|
|
57
|
+
}
|
|
58
|
+
const L = B({
|
|
59
|
+
displayName: "PieCookieBanner",
|
|
60
|
+
elementClass: E,
|
|
61
|
+
react: C,
|
|
62
|
+
tagName: "pie-cookie-banner",
|
|
63
|
+
events: {}
|
|
64
|
+
});
|
|
65
|
+
export {
|
|
66
|
+
L as PieCookieBanner
|
|
67
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justeattakeaway/pie-cookie-banner",
|
|
3
|
+
"description": "PIE Design System Cookie Banner built using Web Components",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"src",
|
|
11
|
+
"dist",
|
|
12
|
+
"**/*.d.ts"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "yarn build:wrapper pie-cookie-banner && run -T vite build",
|
|
16
|
+
"lint:scripts": "run -T eslint .",
|
|
17
|
+
"lint:scripts:fix": "yarn lint:scripts --fix",
|
|
18
|
+
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
|
|
19
|
+
"lint:style:fix": "yarn lint:style --fix",
|
|
20
|
+
"watch": "run -T vite build --watch",
|
|
21
|
+
"test": "echo \"Error: no test specified\" && exit 0",
|
|
22
|
+
"test:ci": "yarn test",
|
|
23
|
+
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
|
|
24
|
+
"test:browsers:ci": "yarn test:browsers",
|
|
25
|
+
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_COOKIE_BANNER} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
|
|
26
|
+
"test:visual:ci": "yarn test:visual"
|
|
27
|
+
},
|
|
28
|
+
"author": "JustEatTakeaway.com - Design System Web Team",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@justeattakeaway/pie-button": "0.26.0",
|
|
32
|
+
"@justeattakeaway/pie-components-config": "0.4.0",
|
|
33
|
+
"@justeattakeaway/pie-link": "0.3.0"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@justeattakeaway/pie-webc-core": "0.8.0"
|
|
37
|
+
},
|
|
38
|
+
"volta": {
|
|
39
|
+
"extends": "../../../package.json"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
@use '@justeattakeaway/pie-css/scss' as p;
|
|
2
|
+
|
|
3
|
+
* {
|
|
4
|
+
margin: 0;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
$breakpoint-wide: 700px;
|
|
8
|
+
|
|
9
|
+
.c-cookieBanner {
|
|
10
|
+
--cb-font-family: var(--dt-font-interactive-m-family);
|
|
11
|
+
--cb-font-size: #{p.font-size('--dt-font-body-l-size')};
|
|
12
|
+
--cb-line-height: calc(var(--dt-font-body-l-line-height) * 1px);
|
|
13
|
+
--cb-font-weight: var(--dt-font-body-l-weight);
|
|
14
|
+
--cb-padding-inline: var(--dt-spacing-d);
|
|
15
|
+
--cb-padding-block: var(--dt-spacing-d);
|
|
16
|
+
--cb-offset: 0;
|
|
17
|
+
|
|
18
|
+
color-scheme: only dark; // For Dark mode we will need to switch this to only light
|
|
19
|
+
background-color: var(--dt-color-background-dark);
|
|
20
|
+
color: var(--dt-color-content-inverse);
|
|
21
|
+
font-family: var(--cb-font-family);
|
|
22
|
+
font-size: var(--cb-font-size);
|
|
23
|
+
line-height: var(--cb-line-height);
|
|
24
|
+
font-weight: var(--cb-font-weight);
|
|
25
|
+
padding-block-start: var(--cb-padding-block);
|
|
26
|
+
padding-block-end: var(--cb-padding-block);
|
|
27
|
+
max-height: 432px;
|
|
28
|
+
position: fixed;
|
|
29
|
+
bottom: var(--cb-offset);
|
|
30
|
+
left: var(--cb-offset);
|
|
31
|
+
right: var(--cb-offset);
|
|
32
|
+
border-top-left-radius: var(--dt-radius-rounded-c);
|
|
33
|
+
border-top-right-radius: var(--dt-radius-rounded-c);
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
@media (min-width: $breakpoint-wide) and (orientation: landscape) {
|
|
37
|
+
--cb-padding-inline: var(--dt-spacing-f);
|
|
38
|
+
--cb-offset: var(--dt-spacing-d);
|
|
39
|
+
|
|
40
|
+
max-height: 90%;
|
|
41
|
+
border-bottom-left-radius: var(--dt-radius-rounded-c);
|
|
42
|
+
border-bottom-right-radius: var(--dt-radius-rounded-c);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.c-cookieBanner-title,
|
|
47
|
+
.c-cookieBanner-body,
|
|
48
|
+
.c-cookieBanner-actions {
|
|
49
|
+
padding-inline-start: var(--cb-padding-inline);
|
|
50
|
+
padding-inline-end: var(--cb-padding-inline);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.c-cookieBanner-title {
|
|
54
|
+
--cb-title-font-size: var(--dt-font-heading-s-size--narrow);
|
|
55
|
+
--cb-title-line-height: var(--dt-font-heading-s-line-height--narrow);
|
|
56
|
+
|
|
57
|
+
@include p.font-size(--cb-title-font-size);
|
|
58
|
+
font-weight: var(--dt-font-heading-s-weight);
|
|
59
|
+
line-height: calc(var(--cb-title-line-height) * 1px);
|
|
60
|
+
|
|
61
|
+
@media (min-width: $breakpoint-wide) and (orientation: landscape) {
|
|
62
|
+
--cb-title-font-size: var(--dt-font-heading-s-size--wide);
|
|
63
|
+
--cb-title-line-height: var(--dt-font-heading-s-line-height--wide);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.c-cookieBanner-body {
|
|
68
|
+
// We have to use a color darker than --dt-color-background-dark.
|
|
69
|
+
// Current the only option is this global token
|
|
70
|
+
--cb-scroll-shadow-color: var(--dt-color-black);
|
|
71
|
+
|
|
72
|
+
margin-block-start: var(--dt-spacing-a);
|
|
73
|
+
max-height: 200px;
|
|
74
|
+
overflow-y: auto;
|
|
75
|
+
background:
|
|
76
|
+
// Scroll shadow cover
|
|
77
|
+
// A top-to-bottom opacity gradient from transparent to the component background colour
|
|
78
|
+
linear-gradient(to bottom, transparent, var(--dt-color-background-dark) 75%) center bottom,
|
|
79
|
+
// Scroll shadow
|
|
80
|
+
linear-gradient(transparent, var(--cb-scroll-shadow-color)) center bottom;
|
|
81
|
+
background-repeat: no-repeat;
|
|
82
|
+
background-size: 100% 48px, 100% 8px;
|
|
83
|
+
|
|
84
|
+
// The shadow cover is an opacity gradient which is attached to the bottom of the scrollable element
|
|
85
|
+
// and scrolls with it, so as you reach the bottom of the content the more opaque portion covers
|
|
86
|
+
// (and therefore hides) the shadow. This gives the effect of the shadow fading away.
|
|
87
|
+
// The shadow itself does not move as you scroll.
|
|
88
|
+
background-attachment: local, scroll;
|
|
89
|
+
|
|
90
|
+
@media (min-width: $breakpoint-wide) and (orientation: landscape) {
|
|
91
|
+
max-height: 150px;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.c-cookieBanner-actions {
|
|
96
|
+
--cb-actions-flex-dir: column;
|
|
97
|
+
|
|
98
|
+
margin-block-start: var(--dt-spacing-d);
|
|
99
|
+
display: flex;
|
|
100
|
+
gap: var(--dt-spacing-d);
|
|
101
|
+
flex-direction: var(--cb-actions-flex-dir);
|
|
102
|
+
|
|
103
|
+
> pie-link {
|
|
104
|
+
width: max-content;
|
|
105
|
+
margin-inline-start: auto;
|
|
106
|
+
margin-inline-end: auto;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@media (min-width: $breakpoint-wide) and (orientation: landscape) {
|
|
110
|
+
--cb-actions-flex-dir: row-reverse;
|
|
111
|
+
|
|
112
|
+
justify-content: flex-start;
|
|
113
|
+
align-items: center;
|
|
114
|
+
|
|
115
|
+
> pie-link {
|
|
116
|
+
margin-inline-start: 0;
|
|
117
|
+
margin-inline-end: 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
package/src/defs.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { LitElement, html, unsafeCSS } from 'lit';
|
|
2
|
+
|
|
3
|
+
import styles from './cookie-banner.scss?inline';
|
|
4
|
+
import { CookieBannerProps } from './defs';
|
|
5
|
+
|
|
6
|
+
// Valid values available to consumers
|
|
7
|
+
export * from './defs';
|
|
8
|
+
|
|
9
|
+
const componentSelector = 'pie-cookie-banner';
|
|
10
|
+
|
|
11
|
+
export class PieCookieBanner extends LitElement implements CookieBannerProps {
|
|
12
|
+
render () {
|
|
13
|
+
return html`
|
|
14
|
+
<aside data-test-id="pie-cookie-banner" class="c-cookieBanner">
|
|
15
|
+
<h2 class="c-cookieBanner-title">Cookies</h2>
|
|
16
|
+
<div class="c-cookieBanner-body">
|
|
17
|
+
<p>We use our own and third party cookies and other tech to enhance and personalise your user experience,
|
|
18
|
+
optimize analytics, and show ads with third parties
|
|
19
|
+
(read our <pie-link variant="inverse">Statement</pie-link>).
|
|
20
|
+
Necessary cookies are always set. Click <pie-link variant="inverse">Necessary only</pie-link>
|
|
21
|
+
to continue without accepting more. Click <pie-link variant="inverse">Manage preferences</pie-link>
|
|
22
|
+
to share your preferences or <pie-link variant="inverse">Accept all</pie-link>.</p>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
<div class="c-cookieBanner-actions">
|
|
26
|
+
<pie-button variant="primary" isFullWidth="true" size="small-expressive">
|
|
27
|
+
Accept all
|
|
28
|
+
</pie-button>
|
|
29
|
+
<pie-button variant="outline" isFullWidth="true" size="small-expressive">
|
|
30
|
+
Necessary only
|
|
31
|
+
</pie-button>
|
|
32
|
+
<pie-link variant="inverse" size="medium" isBold="true">
|
|
33
|
+
Manage preferences
|
|
34
|
+
</pie-link>
|
|
35
|
+
</div>
|
|
36
|
+
</aside>`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
40
|
+
static styles = unsafeCSS(styles);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
customElements.define(componentSelector, PieCookieBanner);
|
|
44
|
+
|
|
45
|
+
declare global {
|
|
46
|
+
interface HTMLElementTagNameMap {
|
|
47
|
+
[componentSelector]: PieCookieBanner;
|
|
48
|
+
}
|
|
49
|
+
}
|