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.
Files changed (67) hide show
  1. package/.github/workflows/ci.prod.yml +68 -0
  2. package/.prettierrc +9 -10
  3. package/README.md +118 -51
  4. package/bun.lock +635 -0
  5. package/coverage/lcov-report/base.css +224 -0
  6. package/coverage/lcov-report/block-navigation.js +87 -0
  7. package/coverage/lcov-report/favicon.png +0 -0
  8. package/coverage/lcov-report/index.html +176 -0
  9. package/coverage/lcov-report/prettify.css +1 -0
  10. package/coverage/lcov-report/prettify.js +2 -0
  11. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  12. package/coverage/lcov-report/sorter.js +196 -0
  13. package/coverage/lcov-report/src/composables/index.html +116 -0
  14. package/coverage/lcov-report/src/composables/ns.ts.html +547 -0
  15. package/coverage/lcov-report/src/constants/index.html +116 -0
  16. package/coverage/lcov-report/src/constants/ns.ts.html +124 -0
  17. package/coverage/lcov-report/src/iife.ts.html +100 -0
  18. package/coverage/lcov-report/src/index.html +116 -0
  19. package/coverage/lcov-report/src/interfaces/INSElement.ts.html +100 -0
  20. package/coverage/lcov-report/src/interfaces/INanosplash.ts.html +304 -0
  21. package/coverage/lcov-report/src/interfaces/index.html +131 -0
  22. package/coverage/lcov-report/src/utils/dom-utils.ts.html +289 -0
  23. package/coverage/lcov-report/src/utils/index.html +116 -0
  24. package/coverage/lcov.info +271 -0
  25. package/eslint.config.js +7 -2
  26. package/package.json +74 -88
  27. package/src/composables/ns.ts +154 -0
  28. package/src/constants/ns.ts +13 -0
  29. package/src/iife.ts +5 -0
  30. package/src/interfaces/INSElement.ts +5 -0
  31. package/src/interfaces/INanosplash.ts +73 -0
  32. package/src/style/ns.css +134 -0
  33. package/src/types/dom.d.ts +3 -0
  34. package/src/types/generic/function.d.ts +1 -0
  35. package/src/types/global.d.ts +26 -0
  36. package/src/types/semantic/number.d.ts +1 -0
  37. package/src/types/semantic/string.d.ts +2 -0
  38. package/src/utils/dom-utils.ts +68 -0
  39. package/tests/ns.spec.ts +124 -0
  40. package/tsconfig.json +29 -21
  41. package/vite.config.ts +18 -10
  42. package/vitest.config.ts +20 -0
  43. package/.github/workflows/ci.yml +0 -62
  44. package/.github/workflows/vitepress.yml +0 -68
  45. package/LICENSE +0 -21
  46. package/docs/.vitepress/config.ts +0 -78
  47. package/docs/.vitepress/theme/css/style.css +0 -258
  48. package/docs/.vitepress/theme/index.ts +0 -16
  49. package/docs/.vitepress/theme/vue/Card.vue +0 -31
  50. package/docs/.vitepress/theme/vue/CardGrid.vue +0 -17
  51. package/docs/.vitepress/theme/vue/PlayGround.vue +0 -36
  52. package/docs/api/doc/hide.md +0 -48
  53. package/docs/api/doc/show.md +0 -46
  54. package/docs/api/start/customize.md +0 -30
  55. package/docs/api/start/features.md +0 -17
  56. package/docs/api/start/install.md +0 -61
  57. package/docs/api/start/playground.md +0 -16
  58. package/docs/api/start/usage.md +0 -22
  59. package/docs/index.md +0 -33
  60. package/docs/public/macos.jpg +0 -0
  61. package/src/style/ns.sass +0 -120
  62. package/src/ts/Nanosplash.ts +0 -177
  63. package/src/ts/main.ts +0 -5
  64. package/src/ts/types/NanosplashInterface.ts +0 -26
  65. package/src/ts/types/Types.ts +0 -16
  66. package/src/ts/types/global.d.ts +0 -14
  67. 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
- "tabWidth": 2,
3
- "useTabs": true,
4
- "singleQuote": true,
5
- "bracketSpacing": true,
6
- "jsxSingleQuote": true,
7
- "endOfLine": "lf",
8
- "trailingComma": "es5",
9
- "arrowParens": "avoid",
10
- "semi": false,
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
- ### The tiny loading screen for web artisans
3
+ **The tiny loading screen for web artisans**
4
4
 
5
- <br>
5
+ [![CI Production: Build, Test, Publish](https://github.com/isakhauge/nanosplash/actions/workflows/ci.prod.yml/badge.svg)](https://github.com/isakhauge/nanosplash/actions/workflows/ci.prod.yml)
6
+ [![Coverage Status](https://coveralls.io/repos/github/isakhauge/nanosplash/badge.svg?branch=production)](https://coveralls.io/github/isakhauge/nanosplash?branch=production)
6
7
 
7
- [![Build](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml/badge.svg?branch=production)](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml)
8
+ ---
8
9
 
9
- ## πŸ’– Documentation
10
+ ## πŸš€ Introduction
10
11
 
11
- [isakhauge.github.io/nanosplash/](https://isakhauge.github.io/nanosplash/)
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
- ## πŸš€ Usage
14
+ ---
14
15
 
15
- ### Show
16
+ ## ✨ Features
16
17
 
17
- #### Spinner only
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
- Fullscreen Nanosplash with spinner only.
26
+ ---
20
27
 
21
- ```js
22
- ns.show()
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
- Nanosplash inside the given element with spinner only.
36
+ or
26
37
 
27
- ```js
28
- ns.show(null, '#my-div')
38
+ ```bash
39
+ npm install nanosplash
29
40
  ```
30
41
 
31
- #### Text and spinner
42
+ ---
32
43
 
33
- Fullscreen Nanosplash with text and spinner.
44
+ ## 🎯 API Documentation
34
45
 
35
- ```js
36
- ns.show('Hi')
37
- ```
46
+ ### `ns.show(text?, target?)`
38
47
 
39
- Nanosplash inside the given element with text and spinner.
48
+ Displays a Nanosplash.
40
49
 
41
- ```js
42
- ns.show('Hi', '#my-div')
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
- ### Hide
55
+ #### Examples:
46
56
 
47
- #### Agnostic (FIFO)
57
+ - **Fullscreen spinner only:**
48
58
 
49
- Remove the oldest Nanosplash residing inside the window body.
59
+ ```js
60
+ ns.show()
61
+ ```
50
62
 
51
- ```js
52
- ns.hide()
53
- ```
63
+ - **Fullscreen text and spinner:**
54
64
 
55
- #### Specific
65
+ ```js
66
+ ns.show('Loading...')
67
+ ```
56
68
 
57
- Remove a specific Nanosplash by its ID.
69
+ - **Spinner only within a specific element:**
58
70
 
59
- ```js
60
- ns.hide(id)
61
- ```
71
+ ```js
72
+ ns.show(null, '#my-div')
73
+ ```
62
74
 
63
- #### All
75
+ - **Text and spinner within a specific element:**
64
76
 
65
- Remove all Nanosplashes.
77
+ ```js
78
+ ns.show('Please wait', '#my-div')
79
+ ```
66
80
 
67
- ```js
68
- ns.hide('*')
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
- ## πŸ¦„ Customization
95
+ ```js
96
+ ns.hide()
97
+ ```
72
98
 
73
- You can easily make Nanosplash look the way you want.
99
+ - **Remove a specific Nanosplash by ID:**
74
100
 
75
- ```scss
76
- // Backdrop selector
77
- .nsh::before
101
+ ```js
102
+ const id = ns.show() // 1700000000000
103
+ ns.hide(id)
104
+ ```
78
105
 
79
- // Main wrapper selector
80
- .ns
106
+ - **Remove all Nanosplashes:**
81
107
 
82
- // Text selector
83
- .nst
108
+ ```js
109
+ ns.hide('*')
110
+ ```
84
111
 
85
- // Spinner selector
86
- .nss
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
- Read more here: [Customization](https://isakhauge.github.io/nanosplash/api/start/customize.html)
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
+ ---