@justeattakeaway/pie-avatar 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 +88 -0
- package/custom-elements.json +60 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +27 -0
- package/dist/react.d.ts +25 -0
- package/dist/react.js +13 -0
- package/package.json +51 -0
- package/src/avatar.scss +7 -0
- package/src/defs-react.ts +8 -0
- package/src/defs.ts +3 -0
- package/src/index.ts +30 -0
- package/src/react.ts +19 -0
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @justeattakeaway/pie-avatar
|
|
2
|
+
[Source Code](https://github.com/justeattakeaway/pie/tree/main/packages/components/pie-avatar) | [Design Documentation](https://pie.design/components/avatar) | [NPM](https://www.npmjs.com/package/@justeattakeaway/pie-avatar)
|
|
3
|
+
|
|
4
|
+
<p>
|
|
5
|
+
<a href="https://www.npmjs.com/@justeattakeaway/pie-avatar">
|
|
6
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-avatar.svg">
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
`@justeattakeaway/pie-avatar` is a Web Component built using the Lit library. It offers a simple and accessible button component for web applications.
|
|
11
|
+
|
|
12
|
+
## Table of Contents
|
|
13
|
+
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Documentation](#documentation)
|
|
16
|
+
- [Properties](#properties)
|
|
17
|
+
- [Slots](#slots)
|
|
18
|
+
- [CSS Variables](#css-variables)
|
|
19
|
+
- [Events](#events)
|
|
20
|
+
- [Usage Examples](#usage-examples)
|
|
21
|
+
- [Questions and Support](#questions-and-support)
|
|
22
|
+
- [Contributing](#contributing)
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
> To install any of our web components in your application, we would suggest following the [getting started guide](https://webc.pie.design/?path=/docs/introduction-getting-started--docs) to set up your project.
|
|
27
|
+
|
|
28
|
+
Ideally, you should install the component using the **`@justeattakeaway/pie-webc`** package, which includes all of the components. Or you can install the individual component package.
|
|
29
|
+
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
### Properties
|
|
33
|
+
| Prop | Options | Description | Default |
|
|
34
|
+
|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|
|
|
35
|
+
| | | | |
|
|
36
|
+
|
|
37
|
+
### Slots
|
|
38
|
+
| Slot | Description |
|
|
39
|
+
|----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
40
|
+
| | |
|
|
41
|
+
|
|
42
|
+
### CSS Variables
|
|
43
|
+
| Variable | Description | Default |
|
|
44
|
+
|----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
|
|
45
|
+
| | | |
|
|
46
|
+
|
|
47
|
+
### Events
|
|
48
|
+
| Event | Type | Description |
|
|
49
|
+
|------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------|
|
|
50
|
+
| | | |
|
|
51
|
+
|
|
52
|
+
## Usage Examples
|
|
53
|
+
|
|
54
|
+
**For HTML:**
|
|
55
|
+
|
|
56
|
+
```js
|
|
57
|
+
// import as module into a js file e.g. main.js
|
|
58
|
+
import '@justeattakeaway/pie-webc/components/avatar.js'
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<!-- pass js file into <script> tag -->
|
|
63
|
+
|
|
64
|
+
<script type="module" src="/main.js"></script>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**For Native JS Applications, Vue, Angular, Svelte etc.:**
|
|
68
|
+
|
|
69
|
+
```js
|
|
70
|
+
// Vue templates (using Nuxt 3)
|
|
71
|
+
import '@justeattakeaway/pie-webc/components/avatar.js'
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**For React Applications:**
|
|
76
|
+
|
|
77
|
+
```jsx
|
|
78
|
+
import { PieAvatar } from '@justeattakeaway/pie-webc/react/avatar.js';
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Questions and Support
|
|
83
|
+
|
|
84
|
+
If you work at Just Eat Takeaway.com, please contact us on **#help-designsystem**. Otherwise, please raise an issue on [Github](https://github.com/justeattakeaway/pie/issues).
|
|
85
|
+
|
|
86
|
+
## Contributing
|
|
87
|
+
|
|
88
|
+
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).
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"readme": "",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"kind": "javascript-module",
|
|
7
|
+
"path": "src/defs-react.js",
|
|
8
|
+
"declarations": [],
|
|
9
|
+
"exports": []
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"kind": "javascript-module",
|
|
13
|
+
"path": "src/defs.js",
|
|
14
|
+
"declarations": [],
|
|
15
|
+
"exports": []
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"kind": "javascript-module",
|
|
19
|
+
"path": "src/index.js",
|
|
20
|
+
"declarations": [
|
|
21
|
+
{
|
|
22
|
+
"kind": "class",
|
|
23
|
+
"description": "",
|
|
24
|
+
"name": "PieAvatar",
|
|
25
|
+
"members": [],
|
|
26
|
+
"mixins": [
|
|
27
|
+
{
|
|
28
|
+
"name": "RtlMixin",
|
|
29
|
+
"package": "@justeattakeaway/pie-webc-core"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"superclass": {
|
|
33
|
+
"name": "PieElement",
|
|
34
|
+
"package": "@justeattakeaway/pie-webc-core/src/internals/PieElement"
|
|
35
|
+
},
|
|
36
|
+
"tagName": "pie-avatar",
|
|
37
|
+
"customElement": true
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"exports": [
|
|
41
|
+
{
|
|
42
|
+
"kind": "js",
|
|
43
|
+
"name": "*",
|
|
44
|
+
"declaration": {
|
|
45
|
+
"name": "*",
|
|
46
|
+
"package": "./defs"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"kind": "js",
|
|
51
|
+
"name": "PieAvatar",
|
|
52
|
+
"declaration": {
|
|
53
|
+
"name": "PieAvatar",
|
|
54
|
+
"module": "src/index.js"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
4
|
+
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
5
|
+
import type { TemplateResult } from 'lit-html';
|
|
6
|
+
|
|
7
|
+
export declare interface AvatarProps {
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @tagname pie-avatar
|
|
12
|
+
*/
|
|
13
|
+
export declare class PieAvatar extends PieAvatar_base implements AvatarProps {
|
|
14
|
+
render(): TemplateResult<1>;
|
|
15
|
+
static styles: CSSResult;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare const PieAvatar_base: GenericConstructor<RTLInterface> & typeof PieElement;
|
|
19
|
+
|
|
20
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LitElement as p, html as f, unsafeCSS as h } from "lit";
|
|
2
|
+
import { RtlMixin as c, safeCustomElement as d } from "@justeattakeaway/pie-webc-core";
|
|
3
|
+
const e = class e extends p {
|
|
4
|
+
willUpdate() {
|
|
5
|
+
this.getAttribute("v") || this.setAttribute("v", e.v);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
e.v = "0.1.0";
|
|
9
|
+
let s = e;
|
|
10
|
+
const u = "*,*:after,*:before{box-sizing:inherit}:host{display:block}";
|
|
11
|
+
var b = Object.getOwnPropertyDescriptor, m = (i, l, v, o) => {
|
|
12
|
+
for (var t = o > 1 ? void 0 : o ? b(l, v) : l, r = i.length - 1, n; r >= 0; r--)
|
|
13
|
+
(n = i[r]) && (t = n(t) || t);
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
let a = class extends c(s) {
|
|
17
|
+
render() {
|
|
18
|
+
return f`<h1 data-test-id="pie-avatar">Hello world!</h1>`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
a.styles = h(u);
|
|
22
|
+
a = m([
|
|
23
|
+
d("pie-avatar")
|
|
24
|
+
], a);
|
|
25
|
+
export {
|
|
26
|
+
a as PieAvatar
|
|
27
|
+
};
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CSSResult } from 'lit';
|
|
2
|
+
import type { GenericConstructor } from '@justeattakeaway/pie-webc-core';
|
|
3
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
4
|
+
import * as React_2 from 'react';
|
|
5
|
+
import type { RTLInterface } from '@justeattakeaway/pie-webc-core';
|
|
6
|
+
import type { TemplateResult } from 'lit-html';
|
|
7
|
+
|
|
8
|
+
export declare interface AvatarProps {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export declare const PieAvatar: React_2.ForwardRefExoticComponent<AvatarProps & React_2.RefAttributes<PieAvatar_2> & ReactBaseType>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @tagname pie-avatar
|
|
15
|
+
*/
|
|
16
|
+
declare class PieAvatar_2 extends PieAvatar_base implements AvatarProps {
|
|
17
|
+
render(): TemplateResult<1>;
|
|
18
|
+
static styles: CSSResult;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare const PieAvatar_base: GenericConstructor<RTLInterface> & typeof PieElement;
|
|
22
|
+
|
|
23
|
+
declare type ReactBaseType = React_2.HTMLAttributes<HTMLElement>;
|
|
24
|
+
|
|
25
|
+
export { }
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as a from "react";
|
|
2
|
+
import { createComponent as e } from "@lit/react";
|
|
3
|
+
import { PieAvatar as t } from "./index.js";
|
|
4
|
+
const r = e({
|
|
5
|
+
displayName: "PieAvatar",
|
|
6
|
+
elementClass: t,
|
|
7
|
+
react: a,
|
|
8
|
+
tagName: "pie-avatar",
|
|
9
|
+
events: {}
|
|
10
|
+
}), m = r;
|
|
11
|
+
export {
|
|
12
|
+
m as PieAvatar
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justeattakeaway/pie-avatar",
|
|
3
|
+
"description": "PIE Design System Avatar 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
|
+
"custom-elements.json",
|
|
11
|
+
"src",
|
|
12
|
+
"dist",
|
|
13
|
+
"**/*.d.ts"
|
|
14
|
+
],
|
|
15
|
+
"pieMetadata": {
|
|
16
|
+
"componentStatus": "alpha"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "run -T vite build",
|
|
20
|
+
"build:react-wrapper": "npx build-react-wrapper",
|
|
21
|
+
"create:manifest": "yarn cem analyze --litelement",
|
|
22
|
+
"lint:scripts": "run -T eslint .",
|
|
23
|
+
"lint:scripts:fix": "yarn lint:scripts --fix",
|
|
24
|
+
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
|
|
25
|
+
"lint:style:fix": "yarn lint:style --fix",
|
|
26
|
+
"watch": "run -T vite build --watch",
|
|
27
|
+
"test:browsers": "npx playwright test -c ./playwright-lit.config.ts",
|
|
28
|
+
"test:browsers:ci": "yarn test:browsers",
|
|
29
|
+
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_AVATAR} percy exec --allowed-hostname cloudfront.net -- npx playwright test -c ./playwright-lit-visual.config.ts",
|
|
30
|
+
"test:visual:ci": "yarn test:visual"
|
|
31
|
+
},
|
|
32
|
+
"author": "Just Eat Takeaway.com - Design System Team",
|
|
33
|
+
"license": "Apache-2.0",
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@custom-elements-manifest/analyzer": "0.9.0",
|
|
36
|
+
"@justeattakeaway/pie-components-config": "0.20.1",
|
|
37
|
+
"@justeattakeaway/pie-css": "0.17.0",
|
|
38
|
+
"@justeattakeaway/pie-monorepo-utils": "0.5.1",
|
|
39
|
+
"cem-plugin-module-file-extensions": "0.0.5"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@justeattakeaway/pie-webc-core": "1.0.0"
|
|
43
|
+
},
|
|
44
|
+
"volta": {
|
|
45
|
+
"extends": "../../../package.json"
|
|
46
|
+
},
|
|
47
|
+
"customElements": "custom-elements.json",
|
|
48
|
+
"sideEffects": [
|
|
49
|
+
"dist/*.js"
|
|
50
|
+
]
|
|
51
|
+
}
|
package/src/avatar.scss
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* TODO: Verify if ReactBaseType can be set as a more specific React interface
|
|
4
|
+
* Use the React IntrinsicElements interface to find how to map standard HTML elements to existing React Interfaces
|
|
5
|
+
* Example: an HTML button maps to `React.ButtonHTMLAttributes<HTMLButtonElement>`
|
|
6
|
+
* https://github.com/DefinitelyTyped/DefinitelyTyped/blob/0bb210867d16170c4a08d9ce5d132817651a0f80/types/react/index.d.ts#L2829
|
|
7
|
+
*/
|
|
8
|
+
export type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
package/src/defs.ts
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { html, unsafeCSS } from 'lit';
|
|
2
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
3
|
+
import { RtlMixin, safeCustomElement } from '@justeattakeaway/pie-webc-core';
|
|
4
|
+
|
|
5
|
+
import styles from './avatar.scss?inline';
|
|
6
|
+
import { type AvatarProps } from './defs';
|
|
7
|
+
|
|
8
|
+
// Valid values available to consumers
|
|
9
|
+
export * from './defs';
|
|
10
|
+
|
|
11
|
+
const componentSelector = 'pie-avatar';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* @tagname pie-avatar
|
|
15
|
+
*/
|
|
16
|
+
@safeCustomElement('pie-avatar')
|
|
17
|
+
export class PieAvatar extends RtlMixin(PieElement) implements AvatarProps {
|
|
18
|
+
render () {
|
|
19
|
+
return html`<h1 data-test-id="pie-avatar">Hello world!</h1>`;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
23
|
+
static styles = unsafeCSS(styles);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
[componentSelector]: PieAvatar;
|
|
29
|
+
}
|
|
30
|
+
}
|
package/src/react.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import { PieAvatar as PieAvatarLit } from './index';
|
|
4
|
+
import { type AvatarProps } from './defs';
|
|
5
|
+
|
|
6
|
+
export * from './defs';
|
|
7
|
+
|
|
8
|
+
const PieAvatarReact = createComponent({
|
|
9
|
+
displayName: 'PieAvatar',
|
|
10
|
+
elementClass: PieAvatarLit,
|
|
11
|
+
react: React,
|
|
12
|
+
tagName: 'pie-avatar',
|
|
13
|
+
events: {},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
|
17
|
+
|
|
18
|
+
export const PieAvatar = PieAvatarReact as React.ForwardRefExoticComponent<React.PropsWithoutRef<AvatarProps>
|
|
19
|
+
& React.RefAttributes<PieAvatarLit> & ReactBaseType>;
|