@justeattakeaway/pie-spinner 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/README.md +77 -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/spinner.scss +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
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-spinner">
|
|
7
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-spinner.svg">
|
|
8
|
+
</a>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
# Table of Contents
|
|
12
|
+
|
|
13
|
+
1. [Introduction](#pie-spinner)
|
|
14
|
+
2. [Installation](#installation)
|
|
15
|
+
3. [Importing the component](#importing-the-component)
|
|
16
|
+
4. [Peer Dependencies](#peer-dependencies)
|
|
17
|
+
5. [Props](#props)
|
|
18
|
+
6. [Contributing](#contributing)
|
|
19
|
+
|
|
20
|
+
## pie-spinner
|
|
21
|
+
|
|
22
|
+
`pie-spinner` is a Web Component built using the Lit library.
|
|
23
|
+
|
|
24
|
+
This component can be easily integrated into various frontend frameworks and customized through a set of properties.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
To install `pie-spinner` in your application, run the following on your command line:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# npm
|
|
33
|
+
$ npm i @justeattakeaway/pie-spinner
|
|
34
|
+
|
|
35
|
+
# yarn
|
|
36
|
+
$ yarn add @justeattakeaway/pie-spinner
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
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).
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Importing the component
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
// default
|
|
46
|
+
import { PieSpinner } from '@justeattakeaway/pie-spinner';
|
|
47
|
+
|
|
48
|
+
// react
|
|
49
|
+
import { PieSpinner } from '@justeattakeaway/pie-spinner/dist/react';
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Peer Dependencies
|
|
54
|
+
|
|
55
|
+
> [!IMPORTANT]
|
|
56
|
+
> When using `pie-spinner`, 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.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
## Props
|
|
60
|
+
|
|
61
|
+
| Property | Type | Default | Description |
|
|
62
|
+
|---|---|---|---|
|
|
63
|
+
| - | - | - | - |
|
|
64
|
+
|
|
65
|
+
In your markup or JSX, you can then use these to set the properties for the `pie-spinner` component:
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<!-- Native HTML -->
|
|
69
|
+
<pie-spinner></pie-spinner>
|
|
70
|
+
|
|
71
|
+
<!-- JSX -->
|
|
72
|
+
<PieSpinner></PieSpinner>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Contributing
|
|
76
|
+
|
|
77
|
+
Check out our [contributing guide](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide) for more information on [local development](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#local-development) and how to run specific [component tests](https://github.com/justeattakeaway/pie/wiki/Contributing-Guide#testing).
|
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
|
+
/**
|
|
6
|
+
* @tagname pie-spinner
|
|
7
|
+
*/
|
|
8
|
+
export declare class PieSpinner extends LitElement implements SpinnerProps {
|
|
9
|
+
render(): TemplateResult<1>;
|
|
10
|
+
static styles: CSSResult;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare interface SpinnerProps {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { unsafeCSS as t, LitElement as o, html as i } from "lit";
|
|
2
|
+
function l(e, s) {
|
|
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, s);
|
|
4
|
+
}
|
|
5
|
+
const r = "", d = "pie-spinner";
|
|
6
|
+
class n extends o {
|
|
7
|
+
render() {
|
|
8
|
+
return i`<h1 data-test-id="pie-spinner">Hello world!</h1>`;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
n.styles = t(r);
|
|
12
|
+
l(d, n);
|
|
13
|
+
export {
|
|
14
|
+
n as PieSpinner
|
|
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 const PieSpinner: ReactWebComponent<PieSpinner_2, {}>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @tagname pie-spinner
|
|
10
|
+
*/
|
|
11
|
+
declare class PieSpinner_2 extends LitElement implements SpinnerProps {
|
|
12
|
+
render(): TemplateResult<1>;
|
|
13
|
+
static styles: CSSResult;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare interface SpinnerProps {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { }
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import * as S from "react";
|
|
2
|
+
import { PieSpinner as g } from "./index.js";
|
|
3
|
+
import "lit";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2018 Google LLC
|
|
7
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
8
|
+
*/
|
|
9
|
+
const M = /* @__PURE__ */ new Set(["children", "localName", "ref", "style", "className"]), E = /* @__PURE__ */ new WeakMap(), P = (p, a, d, m, h) => {
|
|
10
|
+
const i = h == null ? void 0 : h[a];
|
|
11
|
+
i === void 0 || d === m ? d == null && a in HTMLElement.prototype ? p.removeAttribute(a) : p[a] = d : ((s, t, u) => {
|
|
12
|
+
let o = E.get(s);
|
|
13
|
+
o === void 0 && E.set(s, o = /* @__PURE__ */ new Map());
|
|
14
|
+
let r = o.get(t);
|
|
15
|
+
u !== void 0 ? r === void 0 ? (o.set(t, r = { handleEvent: u }), s.addEventListener(t, r)) : r.handleEvent = u : r !== void 0 && (o.delete(t), s.removeEventListener(t, r));
|
|
16
|
+
})(p, i, d);
|
|
17
|
+
};
|
|
18
|
+
function b(p = window.React, a, d, m, h) {
|
|
19
|
+
let i, s, t;
|
|
20
|
+
if (a === void 0) {
|
|
21
|
+
const l = p;
|
|
22
|
+
({ tagName: s, elementClass: t, events: m, displayName: h } = l), i = l.react;
|
|
23
|
+
} else
|
|
24
|
+
i = p, t = d, s = a;
|
|
25
|
+
const u = i.Component, o = i.createElement, r = new Set(Object.keys(m ?? {}));
|
|
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
|
+
P(this.o, v, this.props[v], e ? e[v] : void 0, m);
|
|
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, w) => {
|
|
45
|
+
typeof c == "function" ? c(w) : c.current = w;
|
|
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
|
+
M.has(n) ? y[n === "className" ? "class" : n] = c : r.has(n) || n in t.prototype ? this.i[n] = c : y[n] = c;
|
|
51
|
+
return o(s, y);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
f.displayName = h ?? t.name;
|
|
55
|
+
const N = i.forwardRef((l, e) => o(f, { ...l, _$Gl: e }, l == null ? void 0 : l.children));
|
|
56
|
+
return N.displayName = f.displayName, N;
|
|
57
|
+
}
|
|
58
|
+
const R = b({
|
|
59
|
+
displayName: "PieSpinner",
|
|
60
|
+
elementClass: g,
|
|
61
|
+
react: S,
|
|
62
|
+
tagName: "pie-spinner",
|
|
63
|
+
events: {}
|
|
64
|
+
});
|
|
65
|
+
export {
|
|
66
|
+
R as PieSpinner
|
|
67
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justeattakeaway/pie-spinner",
|
|
3
|
+
"description": "PIE Design System Spinner 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-spinner && 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_SPINNER} 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": "0.4.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@justeattakeaway/pie-webc-core": "0.11.0"
|
|
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 './spinner.scss?inline';
|
|
5
|
+
import { SpinnerProps } from './defs';
|
|
6
|
+
|
|
7
|
+
// Valid values available to consumers
|
|
8
|
+
export * from './defs';
|
|
9
|
+
|
|
10
|
+
const componentSelector = 'pie-spinner';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @tagname pie-spinner
|
|
14
|
+
*/
|
|
15
|
+
export class PieSpinner extends LitElement implements SpinnerProps {
|
|
16
|
+
render () {
|
|
17
|
+
return html`<h1 data-test-id="pie-spinner">Hello world!</h1>`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
21
|
+
static styles = unsafeCSS(styles);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
defineCustomElement(componentSelector, PieSpinner);
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
[componentSelector]: PieSpinner;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/spinner.scss
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use '@justeattakeaway/pie-css/scss' as p;
|