@justeattakeaway/pie-tooltip 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 +54 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +27 -0
- package/dist/react.d.ts +21 -0
- package/dist/react.js +13 -0
- package/package.json +49 -0
- package/src/defs-react.ts +8 -0
- package/src/defs.ts +3 -0
- package/src/index.ts +32 -0
- package/src/react.ts +19 -0
- package/src/tooltip.scss +7 -0
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @justeattakeaway/pie-tooltip
|
|
2
|
+
[Source Code](https://github.com/justeattakeaway/pie/tree/main/packages/components/pie-tooltip) | [Design Documentation](https://pie.design/components/tooltip) | [NPM](https://www.npmjs.com/package/@justeattakeaway/pie-tooltip)
|
|
3
|
+
|
|
4
|
+
<p>
|
|
5
|
+
<a href="https://www.npmjs.com/@justeattakeaway/pie-tooltip">
|
|
6
|
+
<img alt="GitHub Workflow Status" src="https://img.shields.io/npm/v/@justeattakeaway/pie-tooltip.svg">
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
`@justeattakeaway/pie-tooltip` is a Web Component built using the Lit library. It offers a simple and accessible `tooltip` 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/tooltip.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/tooltip.js'
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**For React Applications:**
|
|
76
|
+
|
|
77
|
+
```jsx
|
|
78
|
+
import { PieTooltip } from '@justeattakeaway/pie-webc/react/tooltip.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,54 @@
|
|
|
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": "PieTooltip",
|
|
25
|
+
"members": [],
|
|
26
|
+
"superclass": {
|
|
27
|
+
"name": "PieElement",
|
|
28
|
+
"package": "@justeattakeaway/pie-webc-core/src/internals/PieElement"
|
|
29
|
+
},
|
|
30
|
+
"tagName": "pie-tooltip",
|
|
31
|
+
"customElement": true
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"exports": [
|
|
35
|
+
{
|
|
36
|
+
"kind": "js",
|
|
37
|
+
"name": "*",
|
|
38
|
+
"declaration": {
|
|
39
|
+
"name": "*",
|
|
40
|
+
"module": "src/defs"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"kind": "js",
|
|
45
|
+
"name": "PieTooltip",
|
|
46
|
+
"declaration": {
|
|
47
|
+
"name": "PieTooltip",
|
|
48
|
+
"module": "src/index.js"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
3
|
+
import { TemplateResult } from 'lit-html';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @tagname pie-tooltip
|
|
7
|
+
*/
|
|
8
|
+
export declare class PieTooltip extends PieElement implements TooltipProps {
|
|
9
|
+
render(): TemplateResult<1>;
|
|
10
|
+
static styles: CSSResult;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export declare interface TooltipProps {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LitElement as f, unsafeCSS as h, html as v } from "lit";
|
|
2
|
+
import { safeCustomElement as c } from "@justeattakeaway/pie-webc-core";
|
|
3
|
+
const e = class e extends f {
|
|
4
|
+
willUpdate() {
|
|
5
|
+
this.getAttribute("v") || this.setAttribute("v", e.v);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
e.v = "0.1.0";
|
|
9
|
+
let r = e;
|
|
10
|
+
const d = "*,*:after,*:before{box-sizing:inherit}:host{display:block}";
|
|
11
|
+
var u = Object.getOwnPropertyDescriptor, b = (o, l, n, a) => {
|
|
12
|
+
for (var t = a > 1 ? void 0 : a ? u(l, n) : l, s = o.length - 1, p; s >= 0; s--)
|
|
13
|
+
(p = o[s]) && (t = p(t) || t);
|
|
14
|
+
return t;
|
|
15
|
+
};
|
|
16
|
+
let i = class extends r {
|
|
17
|
+
render() {
|
|
18
|
+
return v`<h1 data-test-id="pie-tooltip">Hello world!</h1>`;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
i.styles = h(d);
|
|
22
|
+
i = b([
|
|
23
|
+
c("pie-tooltip")
|
|
24
|
+
], i);
|
|
25
|
+
export {
|
|
26
|
+
i as PieTooltip
|
|
27
|
+
};
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CSSResult } from 'lit';
|
|
2
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
3
|
+
import * as React_2 from 'react';
|
|
4
|
+
import { TemplateResult } from 'lit-html';
|
|
5
|
+
|
|
6
|
+
export declare const PieTooltip: React_2.ForwardRefExoticComponent<React_2.PropsWithChildren<Omit<React_2.PropsWithoutRef<TooltipProps>, "children">> & React_2.RefAttributes<PieTooltip_2> & ReactBaseType>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @tagname pie-tooltip
|
|
10
|
+
*/
|
|
11
|
+
declare class PieTooltip_2 extends PieElement implements TooltipProps {
|
|
12
|
+
render(): TemplateResult<1>;
|
|
13
|
+
static styles: CSSResult;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare type ReactBaseType = React_2.HTMLAttributes<HTMLElement>;
|
|
17
|
+
|
|
18
|
+
export declare interface TooltipProps {
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { }
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as o from "react";
|
|
2
|
+
import { createComponent as t } from "@lit/react";
|
|
3
|
+
import { PieTooltip as e } from "./index.js";
|
|
4
|
+
const i = t({
|
|
5
|
+
displayName: "PieTooltip",
|
|
6
|
+
elementClass: e,
|
|
7
|
+
react: o,
|
|
8
|
+
tagName: "pie-tooltip",
|
|
9
|
+
events: {}
|
|
10
|
+
}), m = i;
|
|
11
|
+
export {
|
|
12
|
+
m as PieTooltip
|
|
13
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justeattakeaway/pie-tooltip",
|
|
3
|
+
"description": "PIE Design System Tooltip 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
|
+
"replaces": {
|
|
18
|
+
"snacks": []
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "run -T vite build",
|
|
23
|
+
"build:react-wrapper": "run -T build-react-wrapper",
|
|
24
|
+
"create:manifest": "run -T cem analyze --litelement",
|
|
25
|
+
"lint:scripts": "run -T eslint .",
|
|
26
|
+
"lint:scripts:fix": "yarn lint:scripts --fix",
|
|
27
|
+
"lint:style": "run -T stylelint ./src/**/*.{css,scss}",
|
|
28
|
+
"lint:style:fix": "yarn lint:style --fix",
|
|
29
|
+
"watch": "run -T vite build --watch",
|
|
30
|
+
"test:browsers": "run -T playwright test -c ./playwright-lit.config.ts",
|
|
31
|
+
"test:browsers:ci": "yarn test:browsers",
|
|
32
|
+
"test:visual": "run -T cross-env-shell PERCY_TOKEN=${PERCY_TOKEN_PIE_TOOLTIP} percy exec --allowed-hostname cloudfront.net -- run -T playwright test -c ./playwright-lit-visual.config.ts",
|
|
33
|
+
"test:visual:ci": "yarn test:visual"
|
|
34
|
+
},
|
|
35
|
+
"author": "Just Eat Takeaway.com - Design System Team",
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@justeattakeaway/pie-components-config": "0.21.4",
|
|
39
|
+
"@justeattakeaway/pie-css": "1.7.0",
|
|
40
|
+
"@justeattakeaway/pie-monorepo-utils": "0.9.9"
|
|
41
|
+
},
|
|
42
|
+
"dependencies": {
|
|
43
|
+
"@justeattakeaway/pie-webc-core": "20.0.0"
|
|
44
|
+
},
|
|
45
|
+
"customElements": "custom-elements.json",
|
|
46
|
+
"sideEffects": [
|
|
47
|
+
"dist/*.js"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
@@ -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,32 @@
|
|
|
1
|
+
|
|
2
|
+
import { html, unsafeCSS } from 'lit';
|
|
3
|
+
import { PieElement } from '@justeattakeaway/pie-webc-core/src/internals/PieElement';
|
|
4
|
+
import {
|
|
5
|
+
safeCustomElement,
|
|
6
|
+
} from '@justeattakeaway/pie-webc-core';
|
|
7
|
+
import styles from './tooltip.scss?inline';
|
|
8
|
+
import { type TooltipProps } from './defs';
|
|
9
|
+
|
|
10
|
+
// Valid values available to consumers
|
|
11
|
+
export * from './defs';
|
|
12
|
+
|
|
13
|
+
const componentSelector = 'pie-tooltip';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @tagname pie-tooltip
|
|
17
|
+
*/
|
|
18
|
+
@safeCustomElement('pie-tooltip')
|
|
19
|
+
export class PieTooltip extends PieElement implements TooltipProps {
|
|
20
|
+
render () {
|
|
21
|
+
return html`<h1 data-test-id="pie-tooltip">Hello world!</h1>`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Renders a `CSSResult` generated from SCSS by Vite
|
|
25
|
+
static styles = unsafeCSS(styles);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
[componentSelector]: PieTooltip;
|
|
31
|
+
}
|
|
32
|
+
}
|
package/src/react.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { createComponent } from '@lit/react';
|
|
3
|
+
import { PieTooltip as PieTooltipLit } from './index';
|
|
4
|
+
import { type TooltipProps } from './defs';
|
|
5
|
+
|
|
6
|
+
export * from './defs';
|
|
7
|
+
|
|
8
|
+
const PieTooltipReact = createComponent({
|
|
9
|
+
displayName: 'PieTooltip',
|
|
10
|
+
elementClass: PieTooltipLit,
|
|
11
|
+
react: React,
|
|
12
|
+
tagName: 'pie-tooltip',
|
|
13
|
+
events: {},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
type ReactBaseType = React.HTMLAttributes<HTMLElement>
|
|
17
|
+
|
|
18
|
+
export const PieTooltip = PieTooltipReact as React.ForwardRefExoticComponent<React.PropsWithChildren<Omit<React.PropsWithoutRef<TooltipProps>, 'children'>>
|
|
19
|
+
& React.RefAttributes<PieTooltipLit> & ReactBaseType>;
|