nanosplash 3.0.1 → 3.0.3

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 (66) hide show
  1. package/.github/workflows/ci.yml +50 -44
  2. package/.github/workflows/vitepress.yml +69 -0
  3. package/.prettierignore +1 -0
  4. package/.prettierrc +10 -10
  5. package/README.md +11 -172
  6. package/bun.lockb +0 -0
  7. package/coverage/{core/Dom.ts.html → DomUtilities.ts.html} +141 -138
  8. package/coverage/{core/Service.ts.html → Service.ts.html} +250 -322
  9. package/coverage/{core/Splash.ts.html → Splash.ts.html} +145 -154
  10. package/coverage/SplashQueue.ts.html +232 -0
  11. package/coverage/clover.xml +557 -552
  12. package/coverage/coverage-final.json +5 -9043
  13. package/coverage/index.html +53 -23
  14. package/dist/cjs/ns.cjs +2 -0
  15. package/dist/es/ns.js +342 -0
  16. package/dist/iife/ns.iife.js +2 -0
  17. package/docs/.vitepress/config.ts +75 -0
  18. package/docs/.vitepress/theme/css/style.css +157 -0
  19. package/docs/.vitepress/theme/index.ts +16 -0
  20. package/docs/.vitepress/theme/vue/Card.vue +31 -0
  21. package/docs/.vitepress/theme/vue/CardGrid.vue +17 -0
  22. package/docs/.vitepress/theme/vue/Exe.vue +86 -0
  23. package/docs/.vitepress/theme/vue/PlayGround.vue +50 -0
  24. package/docs/api/doc/hide.md +69 -0
  25. package/docs/api/doc/show.md +47 -0
  26. package/docs/api/start/features.md +17 -0
  27. package/docs/api/start/install.md +53 -0
  28. package/docs/api/start/playground.md +11 -0
  29. package/docs/api/start/usage.md +25 -0
  30. package/docs/index.md +30 -0
  31. package/package.json +85 -87
  32. package/src/style/ns.sass +95 -0
  33. package/src/ts/core/{Dom.ts → DomUtilities.ts} +58 -57
  34. package/src/ts/core/Service.ts +66 -90
  35. package/src/ts/core/ServiceInterface.ts +5 -7
  36. package/src/ts/core/Splash.ts +23 -26
  37. package/src/ts/core/SplashInterface.ts +12 -20
  38. package/src/ts/core/SplashQueue.ts +49 -0
  39. package/src/ts/types/Types.ts +0 -9
  40. package/tests/{Dom.spec.ts → DomUtilities.spec.ts} +13 -23
  41. package/tests/Guid.spec.ts +3 -3
  42. package/tests/Service.spec.ts +146 -67
  43. package/tests/Splash.spec.ts +26 -26
  44. package/tests/TestUtilities.ts +48 -0
  45. package/tsconfig.json +1 -0
  46. package/vite.config.ts +1 -15
  47. package/coverage/core/index.html +0 -146
  48. package/coverage/types/Types.ts.html +0 -121
  49. package/coverage/types/index.html +0 -116
  50. package/dist/latest/cjs/ns.cjs +0 -1
  51. package/dist/latest/cjs/style.css +0 -1
  52. package/dist/latest/es/ns.js +0 -306
  53. package/dist/latest/es/style.css +0 -1
  54. package/dist/latest/iife/ns.iife.js +0 -4
  55. package/dist/versioned/3.0.1/cjs/ns.cjs +0 -1
  56. package/dist/versioned/3.0.1/cjs/style.css +0 -1
  57. package/dist/versioned/3.0.1/es/ns.js +0 -306
  58. package/dist/versioned/3.0.1/es/style.css +0 -1
  59. package/dist/versioned/3.0.1/iife/ns.iife.js +0 -2
  60. package/docs/index.6d66a821.js +0 -1
  61. package/docs/index.74dbd99e.css +0 -1
  62. package/docs/index.f34144dc.js +0 -1
  63. package/docs/index.html +0 -107
  64. package/index.html +0 -105
  65. package/src/sass/ns.sass +0 -95
  66. package/vite.demo.config.ts +0 -16
@@ -1,48 +1,54 @@
1
- name: Build and Test
1
+ name: Main Github Actions Workflow
2
2
 
3
3
  on:
4
- push:
5
- branches:
6
- - production
7
- pull_request:
8
- branches:
9
- - production
4
+ push:
5
+ branches:
6
+ - production
7
+ pull_request:
8
+ branches:
9
+ - production
10
10
 
11
11
  jobs:
12
- build-and-test:
13
- runs-on: ubuntu-latest
14
-
15
- steps:
16
- - name: Checkout code
17
- uses: actions/checkout@v2
18
-
19
- - name: Setup Node.js
20
- uses: actions/setup-node@v2
21
- with:
22
- node-version: '20'
23
-
24
- - name: Set up Git and update production branch
25
- run: |
26
- git config --global user.name "GitHub Actions"
27
- git config --global user.email "actions@github.com"
28
- git checkout production
29
- git fetch
30
- git pull --no-rebase
31
-
32
- - name: Install dependencies
33
- run: yarn install --frozen-lockfile
34
-
35
- - name: Build (Vite)
36
- run: yarn build
37
-
38
- - name: Test (Vitest)
39
- run: yarn test
40
-
41
- - name: Generate Code Coverage (Vitest)
42
- run: yarn coverage
43
-
44
- - name: Commit and push changes
45
- run: |
46
- git add .
47
- git commit --allow-empty -m "Build, test, and coverage report"
48
- git push
12
+ build-and-test:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v3
18
+
19
+ - name: Install Bun
20
+ uses: oven-sh/setup-bun@v1
21
+
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v3
24
+ with:
25
+ node-version: 20
26
+
27
+ - name: Set up Git and update production branch
28
+ run: |
29
+ git config --global user.name "GitHub Actions"
30
+ git config --global user.email "actions@github.com"
31
+ git checkout production
32
+ git fetch
33
+ git pull --no-rebase
34
+
35
+ - name: Setup Pages
36
+ uses: actions/configure-pages@v3
37
+
38
+ - name: Install dependencies
39
+ run: bun install
40
+
41
+ - name: Build (Vite)
42
+ run: bun run build
43
+
44
+ - name: Test (Vitest)
45
+ run: bun run test
46
+
47
+ - name: Generate Code Coverage (Vitest)
48
+ run: bun run coverage
49
+
50
+ - name: Commit and push changes
51
+ run: |
52
+ git add .
53
+ git commit --allow-empty -m "Build, test, and coverage report"
54
+ git push
@@ -0,0 +1,69 @@
1
+ # Sample workflow for building and deploying a VitePress site to GitHub Pages
2
+ #
3
+ name: Deploy VitePress site to Pages
4
+
5
+ on:
6
+ # Runs on pushes targeting the `main` branch. Change this to `master` if you're
7
+ # using the `master` branch as the default branch.
8
+ push:
9
+ branches: [production]
10
+ pull_request:
11
+ branches: [production]
12
+
13
+ # Allows you to run this workflow manually from the Actions tab
14
+ workflow_dispatch:
15
+
16
+ # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
17
+ permissions:
18
+ contents: read
19
+ pages: write
20
+ id-token: write
21
+
22
+ # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
23
+ # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
24
+ concurrency:
25
+ group: pages
26
+ cancel-in-progress: false
27
+
28
+ jobs:
29
+ # Build job
30
+ build:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - name: Checkout
34
+ uses: actions/checkout@v3
35
+ with:
36
+ fetch-depth: 0 # Not needed if lastUpdated is not enabled
37
+ # - uses: pnpm/action-setup@v2 # Uncomment this if you're using pnpm
38
+ - name: Install Bun
39
+ uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
40
+ - name: Setup Node
41
+ uses: actions/setup-node@v3
42
+ with:
43
+ node-version: 20
44
+ cache: yarn
45
+ - name: Setup Pages
46
+ uses: actions/configure-pages@v3
47
+ - name: Install dependencies
48
+ run: bun install
49
+ - name: Build with VitePress
50
+ run: |
51
+ bun run docs:build
52
+ touch docs/.vitepress/dist/.nojekyll
53
+ - name: Upload artifact
54
+ uses: actions/upload-pages-artifact@v2
55
+ with:
56
+ path: docs/.vitepress/dist
57
+
58
+ # Deployment job
59
+ deploy:
60
+ environment:
61
+ name: github-pages
62
+ url: ${{ steps.deployment.outputs.page_url }}
63
+ needs: build
64
+ runs-on: ubuntu-latest
65
+ name: Deploy
66
+ steps:
67
+ - name: Deploy to GitHub Pages
68
+ id: deployment
69
+ uses: actions/deploy-pages@v2
@@ -0,0 +1 @@
1
+ *.sass
package/.prettierrc CHANGED
@@ -1,12 +1,12 @@
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": 4,
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
12
12
  }
package/README.md CHANGED
@@ -8,184 +8,23 @@
8
8
 
9
9
  <br>
10
10
 
11
- ## Get started
11
+ > 📣 **New in 3.0.3**
12
+ >
13
+ > - CSS is included inside the ES and CJS bundles 🎉
14
+ > - The `ns.hide` method will now delete splash screens in a FIFO sequence.
12
15
 
13
- ### Install via CDN
14
-
15
- When installing via CDN, you will always get the latest version, and CSS is included inside the bundle.
16
-
17
- ```html
18
- <script src="https://unpkg.com/nanosplash/dist/latest/iife/ns.iife.js">
19
- ```
20
-
21
- Pros:
22
-
23
- - Easy to get started.
24
- - Always get the latest version.
25
- - CSS is included inside the bundle.
26
-
27
- Cons:
28
-
29
- - Always get the latest version.
30
-
31
- ### Install via NPM
32
-
33
- ```bash
34
- yarn add nanosplash
35
- ```
16
+ ## Usage
36
17
 
37
18
  ```js
38
- import { Service } from 'nanosplash'
39
- Service.start()
40
- ```
41
-
42
- The CSS file is located in the following path:
43
-
44
- ```text
45
- node_modules/nanosplash/dist/latest/es/style.css
46
- ```
47
-
48
- ### Example usage
49
-
50
- It's so simple to use.
51
-
52
- ```js
53
- // Display a fullscreen loading screen
19
+ // Fullscreen splash screen
54
20
  ns.show('Loading')
55
-
56
- axios.get('/api/users')
57
- .then((response) => /* Do something */ )
58
- .finally(() => {
59
- // Hide it when you're done
60
- ns.hide()
61
- })
62
- ```
63
-
64
- ### TLDR
65
-
66
- ```js
67
- // Fullscreen spinning wheel
68
- ns.show()
69
-
70
- // Fullscreen spinning wheel with text
71
- ns.show('Loading')
72
-
73
- // Display inside an element
74
- ns.showInside('#my-table', 'Fetching data')
75
-
76
- // Hide the last created loading screen (LIFO)
77
21
  ns.hide()
78
22
 
79
- // Hide loading screen inside an element
80
- ns.hideInside('#my-table')
81
-
82
- // Hide specific loading screen
83
- const id = ns.show('Loading')
84
- ns.hideId(id)
85
-
86
- // Hide all loading screens
87
- ns.hideAll()
88
- ```
89
-
90
- ## API Documentation
91
-
92
- ### Show
93
-
94
- This method displays a fullscreen loading screen and returns a GUID string.
95
-
96
- ```ts
97
- ns.show(text?: string): GUIDString
98
- ```
99
-
100
- If you enter no text, it will display the spinning wheel only.
101
-
102
- ```js
103
- ns.show() // Spinner only
104
- ns.show('Loading') // Spinner with text
105
- ```
106
-
107
- ### Show inside
108
-
109
- This method displays a fullscreen loading screen inside an element and returns a GUID string.
110
-
111
- ```ts
112
- ns.showInside(ref: Reference, text?: string): GUIDString | null
113
- ```
114
-
115
- The `Reference` type is a union type of `string | Element`. The `string` type is a CSS selector string. The `Element` type is a DOM element.
116
-
117
- ```js
118
- // Both works
119
- const selector = '#my-table'
120
- const element = document.getElementById('my-table')
121
- ns.showInside(selector, 'Loading')
122
- ns.showInside(element, 'Loading')
123
- ```
124
-
125
- ### Hide
126
-
127
- Hides the last created loading screen (LIFO).
128
-
129
- ```ts
130
- ns.hide(): GUIDString | null
131
- ```
132
-
133
- The reason why the hide function works in a LIFO (last in first out) manner is because you should always see the loading screen that you want to hide, which will always be the last one you created.
134
-
135
- ```js
136
- ns.show('a')
137
- ns.show('b')
138
- ns.show('c')
139
- ns.hide() // Hides 'c'
140
- ns.hide() // Hides 'b'
141
- ns.hide() // Hides 'a'
142
- ```
143
-
144
- > 💡 **PRO Tip:** If you have multiple loading screens open at the same time, I would recommend that you hide specific elements based on their GUID or host element. See `hideId` and `hideInside` for more information.
145
-
146
- ### Hide by ID
147
-
148
- Hides the Nanosplash loading screen with the given GUID string.
149
-
150
- ```ts
151
- ns.hideId(guid: GUIDString): GUIDString | null
152
- ```
153
-
154
- The show methods always retrun a GUID. This identifier can be used to hide specific loading screens.
155
-
156
- ```js
157
- const id = ns.show('Loading')
158
- ns.hideId(id)
159
- ```
160
-
161
- ### Hide inside
162
-
163
- Hides the Nanosplash loading screen inside another element — if any — that corresponds with the given element reference. Returns the GUID string of the loading screen that was hidden, or null if no loading screen was found inside.
164
-
165
- ```ts
166
- ns.hideInside(ref: Reference): GUIDString | null
167
- ```
168
-
169
- This method works almost the same way as `hideId`, but instead of using the GUID string as the identifier, it uses the host element as the identifier.
170
-
171
- ```js
172
- const selector = '#my-table'
173
- ns.showInside(selector, 'Loading')
174
- ns.hideInside(selector)
175
- ```
176
-
177
- You can also use the `Element` type as the reference.
178
-
179
- ```js
180
- const element = document.getElementById('my-table')
181
- ns.showInside(element, 'Loading')
182
- ns.hideInside(element)
23
+ // Splash screen inside a DOM element
24
+ ns.showInside('#my-div', 'Loading')
25
+ ns.hide()
183
26
  ```
184
27
 
185
- ### Hide all
28
+ ## Documentation
186
29
 
187
- Hide all Nanosplash loading screens.
188
-
189
- ```ts
190
- ns.hideAll(): void
191
- ```
30
+ [isakhauge.github.io/nanosplash/](https://isakhauge.github.io/nanosplash/)
package/bun.lockb ADDED
Binary file