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