nanosplash 4.0.2 β 4.0.4
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.prod.yml +68 -0
- package/.prettierrc +9 -10
- package/README.md +118 -51
- 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/eslint.config.js +7 -2
- package/package.json +74 -88
- 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 +124 -0
- package/tsconfig.json +29 -21
- package/vite.config.ts +18 -10
- package/vitest.config.ts +20 -0
- package/.github/workflows/ci.yml +0 -62
- package/.github/workflows/vitepress.yml +0 -68
- 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 -177
- package/src/ts/main.ts +0 -5
- package/src/ts/types/NanosplashInterface.ts +0 -26
- package/src/ts/types/Types.ts +0 -16
- package/src/ts/types/global.d.ts +0 -14
- package/tests/Nanosplash.spec.ts +0 -25
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
name: CI Production
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ production ]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build-and-test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
|
|
11
|
+
steps:
|
|
12
|
+
# Checking out the repository with the latest version
|
|
13
|
+
- uses: actions/checkout@v4
|
|
14
|
+
with:
|
|
15
|
+
ref: production
|
|
16
|
+
|
|
17
|
+
# Setting up the latest Node.js version
|
|
18
|
+
- name: Set up Node.js
|
|
19
|
+
uses: actions/setup-node@v4
|
|
20
|
+
with:
|
|
21
|
+
node-version: 'latest'
|
|
22
|
+
|
|
23
|
+
# Setting up the latest Bun.js version
|
|
24
|
+
- name: Set up Bun.js
|
|
25
|
+
uses: oven-sh/setup-bun@v2
|
|
26
|
+
with:
|
|
27
|
+
bun-version: 'latest'
|
|
28
|
+
|
|
29
|
+
# Configuring git for GitHub Actions
|
|
30
|
+
- name: Configure Git
|
|
31
|
+
run: |
|
|
32
|
+
git config --global user.name "GitHub Actions"
|
|
33
|
+
git config --global user.email "actions@github.com"
|
|
34
|
+
git config --global init.defaultBranch production
|
|
35
|
+
|
|
36
|
+
# Installing dependencies using Bun
|
|
37
|
+
- name: Install Dependencies
|
|
38
|
+
run: bun install
|
|
39
|
+
|
|
40
|
+
# Running build using Bun
|
|
41
|
+
- name: Run Build
|
|
42
|
+
run: bun run build
|
|
43
|
+
|
|
44
|
+
# Committing build artifacts to the production branch
|
|
45
|
+
- name: Commit Build
|
|
46
|
+
run: |
|
|
47
|
+
git add .
|
|
48
|
+
git commit -m "GitHub Actions: Persist build artifacts[ci skip]" || echo "No changes to commit"
|
|
49
|
+
git push origin production
|
|
50
|
+
env:
|
|
51
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
52
|
+
|
|
53
|
+
# Running Vitest with coverage using Bun
|
|
54
|
+
- name: Run Vitest with Coverage
|
|
55
|
+
run: bunx vitest run --coverage
|
|
56
|
+
|
|
57
|
+
# Uploading coverage to Coveralls
|
|
58
|
+
- name: Upload Coverage to Coveralls
|
|
59
|
+
uses: coverallsapp/github-action@v2
|
|
60
|
+
with:
|
|
61
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
62
|
+
path-to-lcov: ./coverage/lcov.info
|
|
63
|
+
|
|
64
|
+
# Publishing to NPM
|
|
65
|
+
- name: Publish to NPM
|
|
66
|
+
run: bunx npm publish
|
|
67
|
+
env:
|
|
68
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
package/.prettierrc
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"printWidth": 80
|
|
2
|
+
"tabWidth": 2,
|
|
3
|
+
"singleQuote": true,
|
|
4
|
+
"bracketSpacing": true,
|
|
5
|
+
"jsxSingleQuote": true,
|
|
6
|
+
"endOfLine": "lf",
|
|
7
|
+
"trailingComma": "es5",
|
|
8
|
+
"arrowParens": "avoid",
|
|
9
|
+
"semi": false,
|
|
10
|
+
"printWidth": 80
|
|
12
11
|
}
|
package/README.md
CHANGED
|
@@ -1,89 +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
|
+
---
|
|
8
9
|
|
|
9
|
-
##
|
|
10
|
+
## π Introduction
|
|
10
11
|
|
|
11
|
-
|
|
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.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
---
|
|
14
15
|
|
|
15
|
-
|
|
16
|
+
## β¨ Features
|
|
16
17
|
|
|
17
|
-
|
|
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.
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
---
|
|
20
27
|
|
|
21
|
-
|
|
22
|
-
|
|
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>
|
|
23
34
|
```
|
|
24
35
|
|
|
25
|
-
|
|
36
|
+
or
|
|
26
37
|
|
|
27
|
-
```
|
|
28
|
-
|
|
38
|
+
```bash
|
|
39
|
+
npm install nanosplash
|
|
29
40
|
```
|
|
30
41
|
|
|
31
|
-
|
|
42
|
+
---
|
|
32
43
|
|
|
33
|
-
|
|
44
|
+
## π― API Documentation
|
|
34
45
|
|
|
35
|
-
|
|
36
|
-
ns.show('Hi')
|
|
37
|
-
```
|
|
46
|
+
### `ns.show(text?, target?)`
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
Displays a Nanosplash.
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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. |
|
|
44
54
|
|
|
45
|
-
|
|
55
|
+
#### Examples:
|
|
46
56
|
|
|
47
|
-
|
|
57
|
+
- **Fullscreen spinner only:**
|
|
48
58
|
|
|
49
|
-
|
|
59
|
+
```js
|
|
60
|
+
ns.show()
|
|
61
|
+
```
|
|
50
62
|
|
|
51
|
-
|
|
52
|
-
ns.hide()
|
|
53
|
-
```
|
|
63
|
+
- **Fullscreen text and spinner:**
|
|
54
64
|
|
|
55
|
-
|
|
65
|
+
```js
|
|
66
|
+
ns.show('Loading...')
|
|
67
|
+
```
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
- **Spinner only within a specific element:**
|
|
58
70
|
|
|
59
|
-
```js
|
|
60
|
-
ns.
|
|
61
|
-
```
|
|
71
|
+
```js
|
|
72
|
+
ns.show(null, '#my-div')
|
|
73
|
+
```
|
|
62
74
|
|
|
63
|
-
|
|
75
|
+
- **Text and spinner within a specific element:**
|
|
64
76
|
|
|
65
|
-
|
|
77
|
+
```js
|
|
78
|
+
ns.show('Please wait', '#my-div')
|
|
79
|
+
```
|
|
66
80
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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:**
|
|
70
94
|
|
|
71
|
-
|
|
95
|
+
```js
|
|
96
|
+
ns.hide()
|
|
97
|
+
```
|
|
72
98
|
|
|
73
|
-
|
|
99
|
+
- **Remove a specific Nanosplash by ID:**
|
|
74
100
|
|
|
75
|
-
```
|
|
76
|
-
//
|
|
77
|
-
.
|
|
101
|
+
```js
|
|
102
|
+
const id = ns.show() // 1700000000000
|
|
103
|
+
ns.hide(id)
|
|
104
|
+
```
|
|
78
105
|
|
|
79
|
-
|
|
80
|
-
.ns
|
|
106
|
+
- **Remove all Nanosplashes:**
|
|
81
107
|
|
|
82
|
-
|
|
83
|
-
.
|
|
108
|
+
```js
|
|
109
|
+
ns.hide('*')
|
|
110
|
+
```
|
|
84
111
|
|
|
85
|
-
|
|
86
|
-
|
|
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>
|
|
87
148
|
```
|
|
88
149
|
|
|
89
|
-
|
|
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
|
+
---
|