nanosplash 4.0.3 β 4.0.5
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/.github/workflows/ci.all.yml +32 -0
- package/.github/workflows/ci.prod.pull_request.yml +54 -0
- package/.github/workflows/ci.prod.push.yml +68 -0
- package/.github/workflows/ci.test.yml +51 -43
- package/.github/workflows/reusable.build.yml +42 -0
- package/.github/workflows/reusable.format.yml +55 -0
- package/.github/workflows/reusable.lint.yml +30 -0
- package/.github/workflows/reusable.npm-publish.yml +55 -0
- package/.github/workflows/reusable.test.yml +50 -0
- package/.prettierrc +9 -10
- package/README.md +118 -52
- package/bun.lock +635 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/composables/index.html +116 -0
- package/coverage/lcov-report/src/composables/ns.ts.html +547 -0
- package/coverage/lcov-report/src/constants/index.html +116 -0
- package/coverage/lcov-report/src/constants/ns.ts.html +124 -0
- package/coverage/lcov-report/src/iife.ts.html +100 -0
- package/coverage/lcov-report/src/index.html +116 -0
- package/coverage/lcov-report/src/interfaces/INSElement.ts.html +100 -0
- package/coverage/lcov-report/src/interfaces/INanosplash.ts.html +304 -0
- package/coverage/lcov-report/src/interfaces/index.html +131 -0
- package/coverage/lcov-report/src/utils/dom-utils.ts.html +289 -0
- package/coverage/lcov-report/src/utils/index.html +116 -0
- package/coverage/lcov.info +271 -0
- package/dist/cjs/ns.cjs.js +135 -0
- package/dist/es/ns.es.js +197 -0
- package/dist/iife/ns.iife.js +135 -0
- package/eslint.config.js +7 -2
- package/package.json +72 -90
- package/src/composables/ns.ts +154 -0
- package/src/constants/ns.ts +13 -0
- package/src/iife.ts +5 -0
- package/src/interfaces/INSElement.ts +5 -0
- package/src/interfaces/INanosplash.ts +73 -0
- package/src/style/ns.css +134 -0
- package/src/types/dom.d.ts +3 -0
- package/src/types/generic/function.d.ts +1 -0
- package/src/types/global.d.ts +26 -0
- package/src/types/semantic/number.d.ts +1 -0
- package/src/types/semantic/string.d.ts +2 -0
- package/src/utils/dom-utils.ts +68 -0
- package/tests/ns.spec.ts +123 -0
- package/tsconfig.json +29 -21
- package/vite.config.ts +16 -25
- package/vitest.config.ts +20 -0
- package/.env +0 -1
- package/.github/workflows/ci.prod.yml +0 -59
- package/.github/workflows/vitepress.prod.yml +0 -69
- package/LICENSE +0 -21
- package/docs/.vitepress/config.ts +0 -78
- package/docs/.vitepress/theme/css/style.css +0 -258
- package/docs/.vitepress/theme/index.ts +0 -16
- package/docs/.vitepress/theme/vue/Card.vue +0 -31
- package/docs/.vitepress/theme/vue/CardGrid.vue +0 -17
- package/docs/.vitepress/theme/vue/PlayGround.vue +0 -36
- package/docs/api/doc/hide.md +0 -48
- package/docs/api/doc/show.md +0 -46
- package/docs/api/start/customize.md +0 -30
- package/docs/api/start/features.md +0 -17
- package/docs/api/start/install.md +0 -61
- package/docs/api/start/playground.md +0 -16
- package/docs/api/start/usage.md +0 -22
- package/docs/index.md +0 -33
- package/docs/public/macos.jpg +0 -0
- package/src/style/ns.sass +0 -120
- package/src/ts/Nanosplash.ts +0 -176
- package/src/ts/main.ts +0 -5
- package/src/ts/types/NanosplashInterface.ts +0 -29
- package/src/ts/types/Types.ts +0 -16
- package/src/ts/types/global.d.ts +0 -14
- package/tests/Nanosplash.spec.ts +0 -207
package/README.md
CHANGED
|
@@ -1,90 +1,156 @@
|
|
|
1
1
|
# Nanosplash
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**The tiny loading screen for web artisans**
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://github.com/isakhauge/nanosplash/actions/workflows/ci.prod.yml)
|
|
6
|
+
[](https://coveralls.io/github/isakhauge/nanosplash?branch=production)
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
[](https://codecov.io/gh/isakhauge/nanosplash)
|
|
8
|
+
---
|
|
9
9
|
|
|
10
|
-
##
|
|
10
|
+
## π Introduction
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Nanosplash provides a lightweight and customizable loading screen for your web applications. Whether you want a simple spinner or a fully branded loading experience, Nanosplash makes it easy to implement and customize.
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
---
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
## β¨ Features
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
- π¬ Tiny size: Only 3KB β ideal for lean, fast applications.
|
|
19
|
+
- β‘ High performance: Engineered for speed and responsiveness.
|
|
20
|
+
- β
Zero dependencies: No extra baggage β pure JavaScript!
|
|
21
|
+
- π¨ Minimalistic design: Easily integrates with other designs.
|
|
22
|
+
- π Exports in multiple formats: Supports ESM, CJS, and IIFE.
|
|
23
|
+
- π TypeScript support: Fully typed. Better DX.
|
|
24
|
+
- βοΈ 2 Function API: Small, simple β just what you need.
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
---
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
## π¦ Installation
|
|
29
|
+
|
|
30
|
+
Include Nanosplash in your project via your preferred method (e.g., CDN, module bundler). Example:
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
|
|
24
34
|
```
|
|
25
35
|
|
|
26
|
-
|
|
36
|
+
or
|
|
27
37
|
|
|
28
|
-
```
|
|
29
|
-
|
|
38
|
+
```bash
|
|
39
|
+
npm install nanosplash
|
|
30
40
|
```
|
|
31
41
|
|
|
32
|
-
|
|
42
|
+
---
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
## π― API Documentation
|
|
35
45
|
|
|
36
|
-
|
|
37
|
-
ns.show('Hi')
|
|
38
|
-
```
|
|
46
|
+
### `ns.show(text?, target?)`
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
Displays a Nanosplash.
|
|
41
49
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
| Parameter | Type | Description |
|
|
51
|
+
|-----------|----------------------------------|-------------------------------------------------------------|
|
|
52
|
+
| `text` | `string \| undefined` | Optional. Text to display alongside the spinner. |
|
|
53
|
+
| `target` | `string \| Element \| undefined` | Optional. CSS selector or an element to contain the splash. |
|
|
45
54
|
|
|
46
|
-
|
|
55
|
+
#### Examples:
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
- **Fullscreen spinner only:**
|
|
49
58
|
|
|
50
|
-
|
|
59
|
+
```js
|
|
60
|
+
ns.show()
|
|
61
|
+
```
|
|
51
62
|
|
|
52
|
-
|
|
53
|
-
ns.hide()
|
|
54
|
-
```
|
|
63
|
+
- **Fullscreen text and spinner:**
|
|
55
64
|
|
|
56
|
-
|
|
65
|
+
```js
|
|
66
|
+
ns.show('Loading...')
|
|
67
|
+
```
|
|
57
68
|
|
|
58
|
-
|
|
69
|
+
- **Spinner only within a specific element:**
|
|
59
70
|
|
|
60
|
-
```js
|
|
61
|
-
ns.
|
|
62
|
-
```
|
|
71
|
+
```js
|
|
72
|
+
ns.show(null, '#my-div')
|
|
73
|
+
```
|
|
63
74
|
|
|
64
|
-
|
|
75
|
+
- **Text and spinner within a specific element:**
|
|
65
76
|
|
|
66
|
-
|
|
77
|
+
```js
|
|
78
|
+
ns.show('Please wait', '#my-div')
|
|
79
|
+
```
|
|
67
80
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
### `ns.hide(id?)`
|
|
84
|
+
|
|
85
|
+
Hides or removes a Nanosplash.
|
|
86
|
+
|
|
87
|
+
| Parameter | Type | Description |
|
|
88
|
+
|-----------|-----------------------|------------------------------------------------------------|
|
|
89
|
+
| `id` | `number \| undefined` | Optional. The ID of the Nanosplash to remove. |
|
|
90
|
+
|
|
91
|
+
#### Examples:
|
|
92
|
+
|
|
93
|
+
- **Remove the oldest (FIFO) fullscreen Nanosplash:**
|
|
71
94
|
|
|
72
|
-
|
|
95
|
+
```js
|
|
96
|
+
ns.hide()
|
|
97
|
+
```
|
|
73
98
|
|
|
74
|
-
|
|
99
|
+
- **Remove a specific Nanosplash by ID:**
|
|
75
100
|
|
|
76
|
-
```
|
|
77
|
-
//
|
|
78
|
-
.
|
|
101
|
+
```js
|
|
102
|
+
const id = ns.show() // 1700000000000
|
|
103
|
+
ns.hide(id)
|
|
104
|
+
```
|
|
79
105
|
|
|
80
|
-
|
|
81
|
-
.ns
|
|
106
|
+
- **Remove all Nanosplashes:**
|
|
82
107
|
|
|
83
|
-
|
|
84
|
-
.
|
|
108
|
+
```js
|
|
109
|
+
ns.hide('*')
|
|
110
|
+
```
|
|
85
111
|
|
|
86
|
-
|
|
87
|
-
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## π¨ Customization
|
|
115
|
+
|
|
116
|
+
Nanosplash is designed to be fully customizable with CSS. You can style its key parts using these selectors:
|
|
117
|
+
|
|
118
|
+
| Selector | Description |
|
|
119
|
+
|------------------|------------------------------------------|
|
|
120
|
+
| `.nsh::before` | Backdrop |
|
|
121
|
+
| `.ns` | Main wrapper for the splash |
|
|
122
|
+
| `.nst` | Text element |
|
|
123
|
+
| `.nss` | Spinner element |
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## π οΈ Examples
|
|
128
|
+
|
|
129
|
+
Hereβs a quick snippet to show a loading indicator while fetching data:
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<div id="my-div"></div>
|
|
133
|
+
|
|
134
|
+
<script>
|
|
135
|
+
// Show a splash while loading
|
|
136
|
+
ns.show('Fetching data...', '#my-div')
|
|
137
|
+
|
|
138
|
+
fetch('/api/data')
|
|
139
|
+
.then(res => res.json())
|
|
140
|
+
.then(data => {
|
|
141
|
+
// Process data
|
|
142
|
+
})
|
|
143
|
+
.finally(() => {
|
|
144
|
+
// Hide splash
|
|
145
|
+
ns.hide()
|
|
146
|
+
})
|
|
147
|
+
</script>
|
|
88
148
|
```
|
|
89
149
|
|
|
90
|
-
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## π Contributing & Feedback
|
|
153
|
+
|
|
154
|
+
Found a bug or have a feature request? Visit the [GitHub repository](https://github.com/isakhauge/nanosplash) and open an issue or pull request!
|
|
155
|
+
|
|
156
|
+
---
|