nanosplash 3.0.8 → 3.1.0

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 (57) hide show
  1. package/.prettierrc +1 -1
  2. package/README.md +52 -4
  3. package/bun.lockb +0 -0
  4. package/dist/cjs/ns.cjs +1 -2
  5. package/dist/es/ns.js +42 -340
  6. package/dist/iife/ns.iife.js +1 -2
  7. package/docs/.vitepress/.temp/@localSearchIndexroot.Ba2B1gNE.js +4 -0
  8. package/docs/.vitepress/.temp/Card.Ce4dbGEn.js +30 -0
  9. package/docs/.vitepress/.temp/VPLocalSearchBox.DV6bivXX.js +382 -0
  10. package/docs/.vitepress/.temp/api_doc_hide.md.js +25 -0
  11. package/docs/.vitepress/.temp/api_doc_show.md.js +25 -0
  12. package/docs/.vitepress/.temp/api_start_customize.md.js +42 -0
  13. package/docs/.vitepress/.temp/api_start_features.md.js +19 -0
  14. package/docs/.vitepress/.temp/api_start_install.md.js +35 -0
  15. package/docs/.vitepress/.temp/api_start_playground.md.js +213 -0
  16. package/docs/.vitepress/.temp/api_start_usage.md.js +36 -0
  17. package/docs/.vitepress/.temp/app.js +5090 -0
  18. package/docs/.vitepress/.temp/assets/style.lcyfX_uc.css +5374 -0
  19. package/docs/.vitepress/.temp/index.md.js +19 -0
  20. package/docs/.vitepress/.temp/macos.jpg +0 -0
  21. package/docs/.vitepress/.temp/package.json +1 -0
  22. package/docs/.vitepress/.temp/plugin-vue_export-helper.1tPrXgE0.js +10 -0
  23. package/docs/.vitepress/{config.ts → config.mts} +46 -44
  24. package/docs/.vitepress/theme/css/style.css +107 -6
  25. package/docs/.vitepress/theme/vue/CardGrid.vue +1 -1
  26. package/docs/.vitepress/theme/vue/Exe.vue +58 -28
  27. package/docs/.vitepress/theme/vue/PlayGround.vue +5 -21
  28. package/docs/api/doc/hide.md +12 -33
  29. package/docs/api/doc/show.md +12 -13
  30. package/docs/api/start/customize.md +30 -0
  31. package/docs/api/start/features.md +3 -3
  32. package/docs/api/start/install.md +12 -8
  33. package/docs/api/start/playground.md +1 -1
  34. package/docs/api/start/usage.md +4 -7
  35. package/docs/index.md +25 -25
  36. package/docs/public/macos.jpg +0 -0
  37. package/eslint.config.js +9 -0
  38. package/package.json +54 -48
  39. package/src/style/ns.sass +98 -73
  40. package/src/ts/Nanosplash.ts +209 -0
  41. package/src/ts/main.ts +2 -8
  42. package/src/ts/types/NanosplashInterface.ts +26 -0
  43. package/src/ts/types/Types.ts +29 -3
  44. package/src/ts/types/global.d.ts +9 -9
  45. package/tests/Nanosplash.spec.ts +33 -0
  46. package/.prettierignore +0 -1
  47. package/src/ts/core/DomUtilities.ts +0 -161
  48. package/src/ts/core/Service.ts +0 -211
  49. package/src/ts/core/ServiceInterface.ts +0 -58
  50. package/src/ts/core/Splash.ts +0 -121
  51. package/src/ts/core/SplashInterface.ts +0 -46
  52. package/src/ts/core/SplashQueue.ts +0 -49
  53. package/tests/DomUtilities.spec.ts +0 -117
  54. package/tests/Guid.spec.ts +0 -21
  55. package/tests/Service.spec.ts +0 -198
  56. package/tests/Splash.spec.ts +0 -64
  57. package/tests/TestUtilities.ts +0 -48
@@ -0,0 +1,19 @@
1
+ import { ssrRenderAttrs } from "vue/server-renderer";
2
+ import { useSSRContext } from "vue";
3
+ import { _ as _export_sfc } from "./plugin-vue_export-helper.1tPrXgE0.js";
4
+ const __pageData = JSON.parse('{"title":"","description":"","frontmatter":{"layout":"home","hero":{"name":"Nanosplash","text":"","tagline":"The tiny loading screen for web artisans","actions":[{"theme":"brand","text":"Get started","link":"/api/start/install.md"},{"theme":"alt","text":"Playground","link":"/api/start/playground.md"},{"theme":"alt","text":"API Documentation","link":"/api/doc/show.md"}]},"features":[{"title":"✨ Tiny","details":"Less than 2KB minified and gzipped.","link":"/api/start/features#small-bundle-size"},{"title":"✌️ 2 Function API","details":"Start using Nanosplash in seconds.","link":"/api/start/features#simple-api"},{"title":"🪴 Spawning","details":"Spawn a splash element anywhere in your DOM.","link":"/api/start/features#spawning"},{"title":"🚀 Node recycling","details":"Nanosplash will recycle existing elements.","link":"/api/start/features#element-recycling"}]},"headers":[],"relativePath":"index.md","filePath":"index.md"}');
5
+ const _sfc_main = { name: "index.md" };
6
+ function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
7
+ _push(`<div${ssrRenderAttrs(_attrs)}></div>`);
8
+ }
9
+ const _sfc_setup = _sfc_main.setup;
10
+ _sfc_main.setup = (props, ctx) => {
11
+ const ssrContext = useSSRContext();
12
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("index.md");
13
+ return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
14
+ };
15
+ const index = /* @__PURE__ */ _export_sfc(_sfc_main, [["ssrRender", _sfc_ssrRender]]);
16
+ export {
17
+ __pageData,
18
+ index as default
19
+ };
Binary file
@@ -0,0 +1 @@
1
+ { "private": true, "type": "module" }
@@ -0,0 +1,10 @@
1
+ const _export_sfc = (sfc, props) => {
2
+ const target = sfc.__vccOpts || sfc;
3
+ for (const [key, val] of props) {
4
+ target[key] = val;
5
+ }
6
+ return target;
7
+ };
8
+ export {
9
+ _export_sfc as _
10
+ };
@@ -14,49 +14,51 @@ export default defineConfig({
14
14
  { text: 'API documentation', link: '/api/doc/show' },
15
15
  ],
16
16
 
17
- sidebar: {
18
- '/api/': [
19
- {
20
- text: 'Get started',
21
- items: [
22
- {
23
- text: 'Installation',
24
- link: '/api/start/install',
25
- },
26
- {
27
- text: 'Usage',
28
- link: '/api/start/usage',
29
- },
30
- {
31
- text: 'Playground',
32
- link: '/api/start/playground',
33
- },
34
- ],
35
- },
36
- {
37
- text: 'API Documentation',
38
- items: [
39
- {
40
- text: 'Methods',
41
- items: [
42
- {
43
- text: 'Show',
44
- link: '/api/doc/show',
45
- },
46
- {
47
- text: 'Hide',
48
- link: '/api/doc/hide',
49
- },
50
- ],
51
- },
52
- ],
53
- },
54
- {
55
- text: 'Features',
56
- link: '/api/start/features',
57
- },
58
- ],
59
- },
17
+ sidebar: [
18
+ {
19
+ text: 'Get started',
20
+ items: [
21
+ {
22
+ text: 'Installation',
23
+ link: '/api/start/install',
24
+ },
25
+ {
26
+ text: 'Usage',
27
+ link: '/api/start/usage',
28
+ },
29
+ {
30
+ text: 'Playground',
31
+ link: '/api/start/playground',
32
+ },
33
+ {
34
+ text: 'Customize',
35
+ link: '/api/start/customize',
36
+ },
37
+ ],
38
+ },
39
+ {
40
+ text: 'API Documentation',
41
+ items: [
42
+ {
43
+ text: 'Methods',
44
+ items: [
45
+ {
46
+ text: 'Show',
47
+ link: '/api/doc/show',
48
+ },
49
+ {
50
+ text: 'Hide',
51
+ link: '/api/doc/hide',
52
+ },
53
+ ],
54
+ },
55
+ ],
56
+ },
57
+ {
58
+ text: 'Features',
59
+ link: '/api/start/features',
60
+ },
61
+ ],
60
62
 
61
63
  socialLinks: [
62
64
  { icon: 'github', link: 'https://github.com/isakhauge/nanosplash' },
@@ -70,7 +72,7 @@ export default defineConfig({
70
72
 
71
73
  footer: {
72
74
  message:
73
- 'Made with 🤍 by <a href="https://twitter.com/isakhauge">Isak Hauge</a>',
75
+ 'Made with 💖 by <a href="https://twitter.com/isakhauge">Isak Hauge</a>',
74
76
  },
75
77
  },
76
78
  })
@@ -142,16 +142,117 @@
142
142
  }
143
143
 
144
144
  .vp-doc [class*='language-'] .has-highlighted-lines .line {
145
- transition: filter 0.35s, opacity 0.35s;
145
+ transition:
146
+ filter 0.35s,
147
+ opacity 0.35s;
146
148
  }
147
- .vp-doc [class*='language-'] .has-highlighted-lines .line:not(.highlighted) {
149
+ .vp-doc code:has(.highlighted) .line:not(.highlighted) {
148
150
  filter: blur(1px);
149
151
  opacity: 0.5;
152
+ transition: all 0.3s ease;
150
153
  }
151
- .vp-doc
152
- [class*='language-']
153
- .has-highlighted-lines:hover
154
- .line:not(.highlighted) {
154
+ .vp-doc code:has(.highlighted):hover .line:not(.highlighted) {
155
155
  filter: blur(0);
156
156
  opacity: 1;
157
+ transition: all 0.3s ease;
158
+ }
159
+
160
+ :root {
161
+ --ns-doc-glass-border: 1px solid rgba(130, 130, 130, 0.2);
162
+ }
163
+
164
+ header {
165
+ backdrop-filter: blur(10px) !important;
166
+ -webkit-backdrop-filter: blur(10px) !important;
167
+ border-top: var(--ns-doc-glass-border);
168
+ border-bottom: var(--ns-doc-glass-border);
169
+ }
170
+
171
+ .mac.dark header {
172
+ background-color: rgba(0, 0, 0, 0.1);
173
+ }
174
+
175
+ .mac:not(.dark) header {
176
+ background-color: rgba(255, 255, 255, 0.5);
177
+ }
178
+
179
+ .VPNavBar {
180
+ background-color: transparent !important;
181
+ border-bottom: 0 !important;
182
+ }
183
+
184
+ .VPNavBar .content-body {
185
+ background-color: transparent !important;
186
+ border-bottom: 0 !important;
187
+ }
188
+
189
+ /* Remove header divider */
190
+ .VPNavBar > .divider {
191
+ opacity: 0;
192
+ }
193
+
194
+ .VPNavBarTitle {
195
+ background: var(--vp-home-hero-name-background);
196
+ -webkit-background-clip: text;
197
+ background-clip: text;
198
+ -webkit-text-fill-color: var(--vp-home-hero-name-color);
199
+ }
200
+
201
+ .VPNavBarTitle .title {
202
+ border: 0 !important;
203
+ }
204
+
205
+ .DocSearch-Button {
206
+ background-color: rgba(255, 255, 255, 0.05);
207
+ border: var(--ns-doc-glass-border);
208
+ }
209
+
210
+ .VPButton {
211
+ border-radius: 8px !important;
212
+ }
213
+
214
+ .VPFeature {
215
+ background-color: transparent !important;
216
+ box-shadow:
217
+ 0 -8px 32px rgba(0, 81, 255, 0.1),
218
+ 0 8px 32px rgba(251, 0, 255, 0.1);
219
+ }
220
+
221
+ /* Remove footer border */
222
+ .VPFooter {
223
+ border-top: 0 !important;
224
+ }
225
+
226
+ /* Center footer credits */
227
+ .VPFooter .container {
228
+ justify-content: center;
229
+ }
230
+
231
+ .VPLocalSearchBox .backdrop {
232
+ background-color: transparent !important;
233
+ backdrop-filter: blur(10px) !important;
234
+ -webkit-backdrop-filter: blur(10px) !important;
235
+ }
236
+
237
+ .VPButton {
238
+ border: var(--ns-doc-glass-border) !important;
239
+ background-color: transparent !important;
240
+ /* box-shadow:
241
+ 0 2px 4px rgba(0, 0, 0, 0.025),
242
+ 0 4px 8px rgba(0, 0, 0, 0.025),
243
+ 0 8px 16px rgba(0, 0, 0, 0.025); */
244
+ }
245
+
246
+ .VPButton.brand {
247
+ background-color: #222 !important;
248
+ }
249
+
250
+ .VPLocalSearchBox .shell {
251
+ box-shadow:
252
+ 0 0 2px 1px #0000000d,
253
+ 0 4px 8px rgba(0, 0, 0, 0.05),
254
+ 0 8px 16px rgba(0, 0, 0, 0.05),
255
+ 0 16px 32px rgba(0, 0, 0, 0.05),
256
+ 0 32px 64px rgba(0, 0, 0, 0.05),
257
+ 0 64px 128px rgba(0, 0, 0, 0.05);
157
258
  }
@@ -9,7 +9,7 @@
9
9
  display: grid
10
10
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr))
11
11
  grid-gap: 25px
12
- background-image: url(https://9to5mac.com/wp-content/uploads/sites/6/2022/06/macOS-Ventura-wallpaper-1-1.jpg?quality=82&strip=all)
12
+ background-image: url('/macos.jpg')
13
13
  background-size: cover
14
14
  background-position-y: bottom
15
15
  padding: 25px
@@ -1,35 +1,69 @@
1
1
  <script setup>
2
- import { ref, defineProps } from 'vue'
3
- import { Service } from '../../../../dist/es/ns'
4
- Service.start()
2
+ import { ref } from 'vue'
3
+ import { useNs } from '../../../../dist/es/ns.js'
4
+ const ns = useNs()
5
5
 
6
- const props = defineProps({
7
- commands: Array,
8
- })
6
+ const Commands = {
7
+ ShowInsideA: 'ns.show("Loading A", "#a")',
8
+ ShowInsideB: 'ns.show("Loading B", "#b")',
9
+ ShowInsideC: 'ns.show("Loading C", "#c")',
10
+ ShowInsideD: 'ns.show("Loading D", "#d")',
11
+ ShowInsideWrapper: 'ns.show("Loading Wrapper", "#wrapper")',
12
+ ShowFullScreen: 'ns.show("Loading window")',
13
+ Progress: 'Progressive Demo',
14
+ Hide: 'ns.hide()',
15
+ HideAll: 'ns.hide("*")',
16
+ }
9
17
 
10
18
  const rCommandString = ref('')
11
19
 
12
20
  const wait = ms => new Promise(r => setTimeout(r, ms))
13
21
 
14
- function onClickExe() {
15
- const str = rCommandString.value
16
- let executable = null
17
- if (str.startsWith('ns.show(')) {
18
- const text = /ns\.show\(['"](.+)['"]\)/.exec(str)[1]
19
- executable = async () => {
20
- const id = eval(str)
21
- let ms = 4000
22
- while (ms > 0) {
23
- await wait(1000)
24
- ms -= 1000
25
- ns.show(`${text} (${ms / 1000})`)
22
+ async function onClickExe() {
23
+ const value = rCommandString.value
24
+ const phrases = [
25
+ 'Generating witty dialog',
26
+ 'Swapping time and space',
27
+ 'sudo rm -rf /**/*',
28
+ 'Tokenizing real life',
29
+ 'Pushing pixels',
30
+ "Don't think of purple hippos",
31
+ 'One mississippi, two mississippi...',
32
+ ]
33
+ switch (value) {
34
+ case Commands.ShowInsideA:
35
+ ns.show('Loading A', '#a')
36
+ break
37
+ case Commands.ShowInsideB:
38
+ ns.show('Loading B', '#b')
39
+ break
40
+ case Commands.ShowInsideC:
41
+ ns.show('Loading C', '#c')
42
+ break
43
+ case Commands.ShowInsideD:
44
+ ns.show('Loading D', '#d')
45
+ break
46
+ case Commands.ShowInsideWrapper:
47
+ ns.show('Loading Wrapper', '#wrapper')
48
+ break
49
+ case Commands.ShowFullScreen:
50
+ const id = ns.show('Loading window')
51
+ await wait(4000)
52
+ ns.hide(id)
53
+ break
54
+ case Commands.Hide:
55
+ ns.hide()
56
+ break
57
+ case Commands.HideAll:
58
+ ns.hide('*')
59
+ break
60
+ case Commands.Progress:
61
+ for (const phrase of phrases) {
62
+ ns.show(phrase)
63
+ await wait(1500)
26
64
  }
27
- ns.hideId(id)
28
- }
29
- } else {
30
- executable = new Function(rCommandString.value)
65
+ ns.hide('*')
31
66
  }
32
- executable()
33
67
  }
34
68
  </script>
35
69
 
@@ -37,11 +71,7 @@ function onClickExe() {
37
71
  <div class="container">
38
72
  <select class="select" v-model="rCommandString">
39
73
  <option value="" selected disabled>Click and select</option>
40
- <option
41
- v-for="(command, i) in props.commands"
42
- :key="i"
43
- :value="command"
44
- >
74
+ <option v-for="(command, i) in Commands" :key="i" :value="command">
45
75
  {{ command }}
46
76
  </option>
47
77
  </select>
@@ -2,41 +2,25 @@
2
2
  import CardGrid from './CardGrid.vue'
3
3
  import Card from './Card.vue'
4
4
  import Exe from './Exe.vue'
5
-
6
- const commands = [
7
- 'ns.showInside("#a", "Loading A")',
8
- 'ns.showInside("#b", "Loading B")',
9
- 'ns.showInside("#c", "Loading C")',
10
- 'ns.showInside("#d", "Loading D")',
11
- 'ns.showInside("#wrapper", "Loading Wrapper")',
12
- 'ns.show("Loading window")',
13
- 'ns.hide()',
14
- 'ns.hideInside("#b")',
15
- 'ns.hideAll()',
16
- ]
17
5
  </script>
18
6
 
19
7
  <template>
20
8
  <div class="playground">
21
9
  <CardGrid id="wrapper">
22
10
  <Card id="a">
23
- Lorem ipsum dolor sit amet consectetur adipiscing elit ut
24
- aliquam
11
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut aliquam
25
12
  </Card>
26
13
  <Card id="b">
27
- Lorem ipsum dolor sit amet consectetur adipiscing elit ut
28
- aliquam
14
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut aliquam
29
15
  </Card>
30
16
  <Card id="c">
31
- Lorem ipsum dolor sit amet consectetur adipiscing elit ut
32
- aliquam
17
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut aliquam
33
18
  </Card>
34
19
  <Card id="d">
35
- Lorem ipsum dolor sit amet consectetur adipiscing elit ut
36
- aliquam
20
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut aliquam
37
21
  </Card>
38
22
  </CardGrid>
39
- <Exe :commands="commands"></Exe>
23
+ <Exe />
40
24
  </div>
41
25
  </template>
42
26
 
@@ -2,10 +2,10 @@
2
2
 
3
3
  ## Hide
4
4
 
5
- Hides the oldest loading screen (FIFO) and returns the GUID of the loading screen that was removed, or `null` if no loading screen was found.
5
+ Hides the oldest Nanosplash (FIFO).
6
6
 
7
7
  ```ts
8
- ns.hide(): GUIDString | null
8
+ ns.hide(): void
9
9
  ```
10
10
 
11
11
  ```js
@@ -18,52 +18,31 @@ ns.hide() // Hides 'c'
18
18
  ```
19
19
 
20
20
  ::: tip
21
- 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`](#hide-by-id) and [`hideInside`](#hide-inside) for more information.
21
+ If you have multiple Nanosplashes open at the same time, I would recommend
22
+ that you hide specific elements based on their ID.
23
+ See [Hide by ID](#hide-by-id) for more information.
22
24
  :::
23
25
 
24
26
  ## Hide by ID
25
27
 
26
- Hides the Nanosplash loading screen with the given GUID. If a loading screen matching the GUID is found, it will be removed and the same GUID will be returned. If no loading screen is found, `null` will be returned.
28
+ Hides a Nanosplash by its ID.
27
29
 
28
30
  ```ts
29
- ns.hideId(guid: GUIDString): GUIDString | null
31
+ ns.hide(id: number): number | null
30
32
  ```
31
33
 
32
- The show methods always retrun a GUID. This identifier can be used to hide specific loading screens.
34
+ The show method returns the Nanosplash ID. This identifier can be
35
+ used to hide a specific Nanosplash at a later time.
33
36
 
34
37
  ```js
35
38
  const id = ns.show('Loading')
36
- ns.hideId(id)
37
- ```
38
-
39
- ## Hide inside
40
-
41
- 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.
42
-
43
- ```ts
44
- ns.hideInside(ref: Reference): GUIDString | null
45
- ```
46
-
47
- 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.
48
-
49
- ```js
50
- const selector = '#my-table'
51
- ns.showInside(selector, 'Loading')
52
- ns.hideInside(selector)
53
- ```
54
-
55
- You can also use the `Element` type as the reference.
56
-
57
- ```js
58
- const element = document.getElementById('my-table')
59
- ns.showInside(element, 'Loading')
60
- ns.hideInside(element)
39
+ ns.hide(id)
61
40
  ```
62
41
 
63
42
  ## Hide all
64
43
 
65
- Hides all Nanosplash loading screens.
44
+ Hides all Nanosplashes in the `window`.
66
45
 
67
46
  ```ts
68
- ns.hideAll(): void
47
+ ns.hide('*'): void
69
48
  ```
@@ -2,42 +2,41 @@
2
2
 
3
3
  ## Show
4
4
 
5
- This method displays a fullscreen loading screen and returns a GUID string.
5
+ This function display NS in fullscreen and returns the internal ID.
6
6
 
7
7
  ```ts
8
- ns.show(text?: string): GUIDString
8
+ ns.show(text?: string): number
9
9
  ```
10
10
 
11
11
  If you enter no text, it will display the spinning wheel only.
12
12
 
13
13
  ```js
14
- ns.show()
14
+ ns.show(): number
15
15
  ```
16
16
 
17
17
  If you enter text, it will display the spinning wheel adjacent to the text.
18
18
 
19
19
  ```js
20
- ns.show('Loading')
20
+ ns.show('Loading'): number
21
21
  ```
22
22
 
23
23
  ## Show inside
24
24
 
25
- This method displays a loading screen inside an element and returns a GUID
26
- string. The `Reference` type is a union type of `string | Element`. A reference
27
- can be both a CSS selector `string` or an `Element`.
25
+ This function display NS inside another element and returns the internal ID,
26
+ or `null` if the reference argument does not match any node inside the DOM.
28
27
 
29
28
  ```ts
30
- ns.showInside(ref: Reference, text?: string): GUIDString | null
29
+ ns.show(text?: string, ref?: Element | string): number | null
31
30
  ```
32
31
 
33
32
  ```js
34
- // CSS selector
35
- const selector = '#my-table'
36
- ns.showInside(selector, 'Loading')
33
+ // DOM selector
34
+ const selector: string = '#my-table'
35
+ ns.show('Loading', selector)
37
36
 
38
37
  // Element
39
- const element = document.getElementById('my-table')
40
- ns.showInside(element, 'Loading')
38
+ const element: HTMLElement = document.getElementById('my-table')
39
+ ns.show('Loading', element)
41
40
  ```
42
41
 
43
42
  ::: tip
@@ -0,0 +1,30 @@
1
+ # Customize
2
+
3
+ Stying Nanosplash to your needs is easy!
4
+
5
+ ```css
6
+ /* Backdrop */
7
+ .nsh::before {
8
+ background-color: var(--your-bg);
9
+ backdrop-filter: var(--your-filter);
10
+ }
11
+
12
+ /* Main */
13
+ .ns {
14
+ gap: var(--text-spinner-gap);
15
+ }
16
+
17
+ /* Text */
18
+ .nst {
19
+ color: var(--color);
20
+ font-size: var(--size);
21
+ font-family: var(--font);
22
+ font-weight: var(--weight);
23
+ }
24
+
25
+ /* Spinner */
26
+ .nss {
27
+ width: var(--spinner-width);
28
+ height: var(--spinner-height);
29
+ }
30
+ ```
@@ -2,9 +2,9 @@
2
2
 
3
3
  ## Small bundle size
4
4
 
5
- The Nanosplash bundle is less than 3KB minified and gzipped and will not add any significant weight to your application what so ever. Go to [Bundlephobia](https://bundlephobia.com/package/nanosplash) to see for yourself.
5
+ The Nanosplash bundle is less than 2KB minified and gzipped and will not add any significant weight to your application what so ever. Go to [Bundlephobia](https://bundlephobia.com/package/nanosplash) to see for yourself.
6
6
 
7
- ## Simple API
7
+ ## Simple, 2 Function API
8
8
 
9
9
  Nanosplash was written from the ground up with simplicity in mind. The API is very simple and easy to use, and you can easily get started in seconds. Just install the package and start using `ns.show` and `ns.hide`. Go to [Getting started](/api/start/install.md) to see how.
10
10
 
@@ -12,6 +12,6 @@ Nanosplash was written from the ground up with simplicity in mind. The API is ve
12
12
 
13
13
  With Nanosplash you can spawn a splash element anywhere in your DOM. You can even spawn multiple splash elements if you want to. Go to the [API Documentation](/api/doc/show#show-inside) to see how.
14
14
 
15
- ## Element recycling
15
+ ## Node recycling
16
16
 
17
17
  Instead of creating new elements all the time and exhausting DOM manipulations, we recycle and repurpose obsolete splash elements instead. For each time a splash element is created, we check for existing splash elements inside the parent element and use them instead of creating new ones.
@@ -12,20 +12,22 @@ CSS is included inside the JS bundle. 🎉
12
12
 
13
13
  ## Install via CDN
14
14
 
15
- Add the following script tag to the `<head>` of your HTML document:
15
+ Add the following script tag inside of the `<body>` tag:
16
16
 
17
17
  ```html
18
18
  <script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
19
19
  ```
20
20
 
21
- ```html{5}
21
+ ```html{7}
22
22
  <html>
23
23
  <head>
24
24
  <meta charset="UTF-8" />
25
25
  <title>My awesome application 🚀</title>
26
- <script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
27
26
  </head>
28
- ...
27
+ <body>
28
+ <script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
29
+ ...
30
+ </body>
29
31
  </html>
30
32
  ```
31
33
 
@@ -45,9 +47,11 @@ yarn add nanosplash
45
47
 
46
48
  To import and start the Nanosplash service in your application, you need to import the Service class and start it.
47
49
 
48
- ```js{2}
49
- import { Service } from 'nanosplash'
50
- Service.start()
50
+ ```js{2,3}
51
+ import { useNs } from 'nanosplash'
52
+ const ns = useNs()
53
+ ns.show('It works!')
51
54
  ```
52
55
 
53
- The service will inject an instance of itself inside the global `window` object. You can now start using Nanosplash by simply calling `ns.show`.
56
+ The hook will inject the Nanosplash API inside the global `window` object.
57
+ You can now start using Nanosplash by simply calling `ns.show`.
@@ -6,6 +6,6 @@ import PlayGround from '../../.vitepress/theme/vue/PlayGround.vue'
6
6
 
7
7
  Here you can play around with Nanosplash and see how it works.
8
8
 
9
- <PlayGround></PlayGround>
9
+ <PlayGround />
10
10
 
11
11
  Select a method from the dropdown menu above and click "Run" to see it in action.