nanosplash 4.0.3 β†’ 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 (68) hide show
  1. package/.github/workflows/ci.prod.yml +43 -34
  2. package/.prettierrc +9 -10
  3. package/README.md +118 -52
  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 -90
  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 +16 -25
  42. package/vitest.config.ts +20 -0
  43. package/.env +0 -1
  44. package/.github/workflows/ci.test.yml +0 -48
  45. package/.github/workflows/vitepress.prod.yml +0 -69
  46. package/LICENSE +0 -21
  47. package/docs/.vitepress/config.ts +0 -78
  48. package/docs/.vitepress/theme/css/style.css +0 -258
  49. package/docs/.vitepress/theme/index.ts +0 -16
  50. package/docs/.vitepress/theme/vue/Card.vue +0 -31
  51. package/docs/.vitepress/theme/vue/CardGrid.vue +0 -17
  52. package/docs/.vitepress/theme/vue/PlayGround.vue +0 -36
  53. package/docs/api/doc/hide.md +0 -48
  54. package/docs/api/doc/show.md +0 -46
  55. package/docs/api/start/customize.md +0 -30
  56. package/docs/api/start/features.md +0 -17
  57. package/docs/api/start/install.md +0 -61
  58. package/docs/api/start/playground.md +0 -16
  59. package/docs/api/start/usage.md +0 -22
  60. package/docs/index.md +0 -33
  61. package/docs/public/macos.jpg +0 -0
  62. package/src/style/ns.sass +0 -120
  63. package/src/ts/Nanosplash.ts +0 -176
  64. package/src/ts/main.ts +0 -5
  65. package/src/ts/types/NanosplashInterface.ts +0 -29
  66. package/src/ts/types/Types.ts +0 -16
  67. package/src/ts/types/global.d.ts +0 -14
  68. package/tests/Nanosplash.spec.ts +0 -207
@@ -1,59 +1,68 @@
1
- name: CI Production - Build, Test, Publish
1
+ name: CI Production
2
2
 
3
3
  on:
4
4
  pull_request:
5
- branches:
6
- - production
5
+ branches: [ production ]
7
6
 
8
7
  jobs:
9
8
  build-and-test:
10
9
  runs-on: ubuntu-latest
11
10
 
12
11
  steps:
13
- - name: Install Node.js
14
- uses: actions/setup-node@v3
12
+ # Checking out the repository with the latest version
13
+ - uses: actions/checkout@v4
15
14
  with:
16
- node-version: 20
17
- registry-url: 'https://registry.npmjs.org'
15
+ ref: production
18
16
 
19
- - name: Install PNPM
20
- uses: pnpm/action-setup@v3
17
+ # Setting up the latest Node.js version
18
+ - name: Set up Node.js
19
+ uses: actions/setup-node@v4
21
20
  with:
22
- version: 8
21
+ node-version: 'latest'
23
22
 
24
- - name: Checkout
25
- uses: actions/checkout@v3
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'
26
28
 
27
- - name: Set up Git and update production branch
29
+ # Configuring git for GitHub Actions
30
+ - name: Configure Git
28
31
  run: |
29
32
  git config --global user.name "GitHub Actions"
30
33
  git config --global user.email "actions@github.com"
31
- git fetch
32
- git checkout production
33
- git pull --no-rebase
34
-
35
- - name: Setup GitHub Pages
36
- uses: actions/configure-pages@v3
37
-
38
- - name: Install dependencies
39
- run: pnpm install --no-frozen-lockfile
34
+ git config --global init.defaultBranch production
40
35
 
41
- - name: Build
42
- run: pnpm build
36
+ # Installing dependencies using Bun
37
+ - name: Install Dependencies
38
+ run: bun install
43
39
 
44
- - name: Test
45
- run: pnpm test
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 }}
46
52
 
47
- - name: Generate Code Coverage
48
- run: pnpm coverage
53
+ # Running Vitest with coverage using Bun
54
+ - name: Run Vitest with Coverage
55
+ run: bunx vitest run --coverage
49
56
 
50
- - name: Upload coverage reports to Codecov
51
- uses: codecov/codecov-action@v4.0.1
57
+ # Uploading coverage to Coveralls
58
+ - name: Upload Coverage to Coveralls
59
+ uses: coverallsapp/github-action@v2
52
60
  with:
53
- token: ${{ secrets.CODECOV_TOKEN }}
54
- slug: isakhauge/nanosplash
61
+ github-token: ${{ secrets.GITHUB_TOKEN }}
62
+ path-to-lcov: ./coverage/lcov.info
55
63
 
64
+ # Publishing to NPM
56
65
  - name: Publish to NPM
57
- run: npm publish
66
+ run: bunx npm publish
58
67
  env:
59
- NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
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,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.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
+ ---