@overlastic/vanilla 0.5.0 → 0.5.1
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 +20 -91
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,100 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://overlastic.vercel.app/" target="blank">
|
|
3
|
+
<img src="https://github.com/hairyf/overlastic/raw/master/docs/public/circle.svg" width="120" alt="Nest Logo" />
|
|
4
|
+
</a>
|
|
5
|
+
</p>
|
|
2
6
|
|
|
3
|
-
|
|
7
|
+
<p align="center">
|
|
8
|
+
A create modal | dialog | popup promise deferred library
|
|
9
|
+
</p>
|
|
4
10
|
|
|
5
|
-
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://www.npmjs.com/@overlastic/core"><img src="https://img.shields.io/npm/v/@overlastic/core.svg" alt="NPM Version" /></a>
|
|
13
|
+
<a href="https://www.npmjs.com/@overlastic/core"><img src="https://img.shields.io/npm/l/@overlastic/core.svg" alt="Package License" /></a>
|
|
14
|
+
<a href="https://www.npmjs.com/@overlastic/core"><img src="https://img.shields.io/npm/dm/@overlastic/core.svg" alt="NPM Downloads" /></a>
|
|
15
|
+
</p>
|
|
6
16
|
|
|
7
|
-
|
|
8
|
-
```sh
|
|
9
|
-
pnpm add @overlastic/vanilla
|
|
10
|
-
```
|
|
11
|
-
|
|
12
|
-
With yarn:
|
|
13
|
-
```sh
|
|
14
|
-
yarn add @overlastic/vanilla
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
## Usage
|
|
18
|
-
|
|
19
|
-
### Step 1: Define Component
|
|
20
|
-
|
|
21
|
-
Create custom elements in the form of functions and return them.
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
// overlay.ts
|
|
25
|
-
function Component(props) {
|
|
26
|
-
const element = document.createElement('div')
|
|
27
|
-
element.innerHTML = props.title
|
|
28
|
-
|
|
29
|
-
const { resolve, reject, deferred } = useOverlayDefine({
|
|
30
|
-
// Duration of overlays duration to avoid premature destruction of the component
|
|
31
|
-
duration: 1000,
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
// Add events that cause the overlays to end
|
|
35
|
-
element.onclick = function () {
|
|
36
|
-
resolve('ok')
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// Use setTimeout to wait for the element to be appended, then add a class name with animation
|
|
40
|
-
setTimeout(() => element.classList.add('show'))
|
|
41
|
-
// When the deferred is triggered, remove the displayed class name
|
|
42
|
-
deferred.finally(() => element.classList.remove('show'))
|
|
43
|
-
|
|
44
|
-
return element
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export default Component
|
|
48
|
-
```
|
|
17
|
+
## Description
|
|
49
18
|
|
|
50
|
-
|
|
19
|
+
Create messages or dialog overlays using Overlastic in native HTML.
|
|
51
20
|
|
|
52
|
-
|
|
21
|
+
## Installation
|
|
53
22
|
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
import Component from './overlay'
|
|
57
|
-
|
|
58
|
-
// Convert to imperative callback
|
|
59
|
-
const callback = defineOverlay(Component)
|
|
60
|
-
// Call the component and get the value of the resolve callback
|
|
61
|
-
const value = await callback({ title: 'callbackOverlay' })
|
|
62
|
-
// value === "callbackOverlay:confirmed"
|
|
23
|
+
```bash
|
|
24
|
+
$ npm install --save @overlastic/vanilla
|
|
63
25
|
```
|
|
64
26
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
import { defineOverlay } from '@overlastic/vanilla'
|
|
69
|
-
import Component from './overlay'
|
|
70
|
-
|
|
71
|
-
const value = await renderOverlay(Component, {
|
|
72
|
-
title: 'useOverlayDefine'
|
|
73
|
-
})
|
|
74
|
-
// value === "useOverlayDefine:confirmed"
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Custom Element
|
|
78
|
-
|
|
79
|
-
After mounting a custom element, you can pass in the corresponding custom element or name through 'defineOverlay' to use the custom element.
|
|
80
|
-
|
|
81
|
-
> You can use [lit](https://lit.dev/) Quickly build custom elements.
|
|
27
|
+
## Quick Start
|
|
82
28
|
|
|
83
|
-
|
|
84
|
-
const callback1 = defineOverlay('my-custom-element')
|
|
85
|
-
|
|
86
|
-
callback1({/* props(attrs) */})
|
|
87
|
-
|
|
88
|
-
function CustomComponent(props) {
|
|
89
|
-
const customElement = document.createElement('my-custom-element')
|
|
90
|
-
|
|
91
|
-
const { resolve, reject } = useOverlayDefine({
|
|
92
|
-
duration: 1000,
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
// ...
|
|
96
|
-
return customElement
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const callback2 = defineOverlay(CustomComponent)
|
|
100
|
-
```
|
|
29
|
+
[Overview & Tutorial](https://overlastic.vercel.app/en/vanilla/)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@overlastic/vanilla",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/hairyf/overlastic#readme",
|
|
7
7
|
"repository": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@overlastic/core": "^0.5.
|
|
28
|
+
"@overlastic/core": "^0.5.1"
|
|
29
29
|
},
|
|
30
30
|
"scripts": {
|
|
31
31
|
"build": "tsup src/index.ts",
|