@justeattakeaway/pie-notification 0.0.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/README.md +132 -0
- package/declaration.d.ts +9 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +15 -0
- package/dist/react.d.ts +19 -0
- package/dist/react.js +67 -0
- package/package.json +42 -0
- package/src/defs.ts +3 -0
- package/src/index.ts +30 -0
- package/src/notification.scss +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
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-notification">
|
|
7
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-notification.svg">
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
# Table of Contents
|
|
12
|
+
|
|
13
|
+
1. [Introduction](#pie-notification)
|
|
14
|
+
2. [Installation](#installation)
|
|
15
|
+
3. [Importing the component](#importing-the-component)
|
|
16
|
+
4. [Peer Dependencies](#peer-dependencies)
|
|
17
|
+
5. [Local Development](#local-development)
|
|
18
|
+
6. [Props](#props)
|
|
19
|
+
7. [Testing](#testing)
|
|
20
|
+
|
|
21
|
+
## pie-notification
|
|
22
|
+
|
|
23
|
+
`pie-notification` is a Web Component built using the Lit library.
|
|
24
|
+
|
|
25
|
+
This component can be easily integrated into various frontend frameworks and customized through a set of properties.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
To install `pie-notification` in your application, run the following on your command line:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
# npm
|
|
34
|
+
$ npm i @justeattakeaway/pie-notification
|
|
35
|
+
|
|
36
|
+
# yarn
|
|
37
|
+
$ yarn add @justeattakeaway/pie-notification
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
For full information on using PIE components as part of an application, check out the [Getting Started Guide](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components).
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Importing the component
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
// default
|
|
47
|
+
import { PieNotification } from '@justeattakeaway/pie-notification';
|
|
48
|
+
|
|
49
|
+
// react
|
|
50
|
+
import { PieNotification } from '@justeattakeaway/pie-notification/dist/react';
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
## Peer Dependencies
|
|
55
|
+
|
|
56
|
+
> [!IMPORTANT]
|
|
57
|
+
> When using `pie-notification`, you will also need to include a couple of dependencies to ensure the component renders as expected. See [the PIE Wiki](https://github.com/justeattakeaway/pie/wiki/Getting-started-with-PIE-Web-Components#expected-dependencies) for more information and how to include these in your application.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Local development
|
|
61
|
+
|
|
62
|
+
Install the dependencies. Note that this, and the following commands below, should be run from the **root of the monorepo**:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
yarn
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
To build the `pie-notification` package, run the following command:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
yarn build --filter=pie-notification
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
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:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
yarn watch --filter=pie-notification
|
|
78
|
+
|
|
79
|
+
# in a separate terminal tab, run
|
|
80
|
+
yarn dev --filter=pie-storybook
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## Props
|
|
85
|
+
|
|
86
|
+
| Property | Type | Default | Description |
|
|
87
|
+
|---|---|---|---|
|
|
88
|
+
| - | - | - | - |
|
|
89
|
+
|
|
90
|
+
In your markup or JSX, you can then use these to set the properties for the `pie-notification` component:
|
|
91
|
+
|
|
92
|
+
```html
|
|
93
|
+
<!-- Native HTML -->
|
|
94
|
+
<pie-notification></pie-notification>
|
|
95
|
+
|
|
96
|
+
<!-- JSX -->
|
|
97
|
+
<PieNotification></PieNotification>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Testing
|
|
101
|
+
|
|
102
|
+
### Browser tests
|
|
103
|
+
|
|
104
|
+
To run the browser tests, run the following command from the root of the monorepo:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
yarn test:browsers --filter=pie-notification
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### Visual tests
|
|
111
|
+
|
|
112
|
+
To run the visual regression tests, run the following command from the root of the monorepo:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
yarn test:visual --filter=pie-notification
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
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.
|
|
119
|
+
|
|
120
|
+
#### Setup via bash
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
export PERCY_TOKEN_PIE_NOTIFICATION=abcde
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Setup via package.json
|
|
127
|
+
|
|
128
|
+
Under scripts `test:visual` replace the environment variable with the below:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
PERCY_TOKEN_PIE_NOTIFICATION=abcde
|
|
132
|
+
```
|
package/declaration.d.ts
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { LitElement } from 'lit';
|
|
3
|
+
import type { TemplateResult } from 'lit-html';
|
|
4
|
+
|
|
5
|
+
export declare interface NotificationProps {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @tagname pie-notification
|
|
10
|
+
*/
|
|
11
|
+
export declare class PieNotification extends LitElement implements NotificationProps {
|
|
12
|
+
render(): TemplateResult<1>;
|
|
13
|
+
static styles: CSSResult;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { unsafeCSS as o, LitElement as i, html as s } from "lit";
|
|
2
|
+
function a(e, t) {
|
|
3
|
+
customElements.get(e) ? console.warn(`PIE Web Component: "${e}" has already been defined. Please ensure the component is only being defined once in your application.`) : customElements.define(e, t);
|
|
4
|
+
}
|
|
5
|
+
const l = "", c = "pie-notification";
|
|
6
|
+
class n extends i {
|
|
7
|
+
render() {
|
|
8
|
+
return s`<h1 data-test-id="pie-notification">Hello world!</h1>`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
n.styles = o(l);
|
|
12
|
+
a(c, n);
|
|
13
|
+
export {
|
|
14
|
+
n as PieNotification
|
|
15
|
+
};
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
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 NotificationProps {
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare const PieNotification: ReactWebComponent<PieNotification_2, {}>;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @tagname pie-notification
|
|
13
|
+
*/
|
|
14
|
+
declare class PieNotification_2 extends LitElement implements NotificationProps {
|
|
15
|
+
render(): TemplateResult<1>;
|
|
16
|
+
static styles: CSSResult;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { }
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as g from "react";
|
|
2
|
+
import { PieNotification as M } from "./index.js";
|
|
3
|
+
import "lit";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2018 Google LLC
|
|
7
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
8
|
+
*/
|
|
9
|
+
const P = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), E = /* @__PURE__ */ new WeakMap(), b = (d, l, m, p, h) => {
|
|
10
|
+
const n = h == null ? void 0 : h[l];
|
|
11
|
+
n === void 0 || m === p ? m == null && l in HTMLElement.prototype ? d.removeAttribute(l) : d[l] = m : ((o, t, u) => {
|
|
12
|
+
let s = E.get(o);
|
|
13
|
+
s === void 0 && E.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, n, m);
|
|
17
|
+
};
|
|
18
|
+
function C(d = window.React, l, m, p, h) {
|
|
19
|
+
let n, o, t;
|
|
20
|
+
if (l === void 0) {
|
|
21
|
+
const r = d;
|
|
22
|
+
({ tagName: o, elementClass: t, events: p, displayName: h } = r), n = r.react;
|
|
23
|
+
} else
|
|
24
|
+
n = d, t = m, o = l;
|
|
25
|
+
const u = n.Component, s = n.createElement, a = new Set(Object.keys(p ?? {}));
|
|
26
|
+
class v extends u {
|
|
27
|
+
constructor() {
|
|
28
|
+
super(...arguments), this.o = null;
|
|
29
|
+
}
|
|
30
|
+
t(e) {
|
|
31
|
+
if (this.o !== null)
|
|
32
|
+
for (const f in this.i)
|
|
33
|
+
b(this.o, f, this.props[f], e ? e[f] : void 0, p);
|
|
34
|
+
}
|
|
35
|
+
componentDidMount() {
|
|
36
|
+
this.t();
|
|
37
|
+
}
|
|
38
|
+
componentDidUpdate(e) {
|
|
39
|
+
this.t(e);
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const { _$Gl: e, ...f } = this.props;
|
|
43
|
+
this.h !== e && (this.u = (i) => {
|
|
44
|
+
e !== null && ((c, w) => {
|
|
45
|
+
typeof c == "function" ? c(w) : c.current = w;
|
|
46
|
+
})(e, i), this.o = i, this.h = e;
|
|
47
|
+
}), this.i = {};
|
|
48
|
+
const N = { ref: this.u };
|
|
49
|
+
for (const [i, c] of Object.entries(f))
|
|
50
|
+
P.has(i) ? N[i === "className" ? "class" : i] = c : a.has(i) || i in t.prototype ? this.i[i] = c : N[i] = c;
|
|
51
|
+
return s(o, N);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
v.displayName = h ?? t.name;
|
|
55
|
+
const y = n.forwardRef((r, e) => s(v, { ...r, _$Gl: e }, r == null ? void 0 : r.children));
|
|
56
|
+
return y.displayName = v.displayName, y;
|
|
57
|
+
}
|
|
58
|
+
const $ = C({
|
|
59
|
+
displayName: "PieNotification",
|
|
60
|
+
elementClass: M,
|
|
61
|
+
react: g,
|
|
62
|
+
tagName: "pie-notification",
|
|
63
|
+
events: {}
|
|
64
|
+
});
|
|
65
|
+
export {
|
|
66
|
+
$ as PieNotification
|
|
67
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justeattakeaway/pie-notification",
|
|
3
|
+
"description": "PIE Design System Notification built using Web Components",
|
|
4
|
+
"version": "0.0.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-notification && 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_NOTIFICATION} 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": "Just Eat Takeaway.com - Design System Team",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"@justeattakeaway/pie-components-config": "workspace:*"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@justeattakeaway/pie-webc-core": "workspace:*"
|
|
35
|
+
},
|
|
36
|
+
"volta": {
|
|
37
|
+
"extends": "../../../package.json"
|
|
38
|
+
},
|
|
39
|
+
"sideEffects": [
|
|
40
|
+
"dist/*.js"
|
|
41
|
+
]
|
|
42
|
+
}
|
package/src/defs.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { LitElement, html, unsafeCSS } from 'lit';
|
|
2
|
+
|
|
3
|
+
import { defineCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
4
|
+
import styles from './notification.scss?inline';
|
|
5
|
+
import { NotificationProps } from './defs';
|
|
6
|
+
|
|
7
|
+
// Valid values available to consumers
|
|
8
|
+
export * from './defs';
|
|
9
|
+
|
|
10
|
+
const componentSelector = 'pie-notification';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @tagname pie-notification
|
|
14
|
+
*/
|
|
15
|
+
export class PieNotification extends LitElement implements NotificationProps {
|
|
16
|
+
render () {
|
|
17
|
+
return html`<h1 data-test-id="pie-notification">Hello world!</h1>`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
21
|
+
static styles = unsafeCSS(styles);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
defineCustomElement(componentSelector, PieNotification);
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
[componentSelector]: PieNotification;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use '@justeattakeaway/pie-css/scss' as p;
|