nanosplash 3.0.0 → 3.0.2

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 (77) 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/LICENSE +21 -0
  6. package/README.md +14 -41
  7. package/bun.lockb +0 -0
  8. package/coverage/DomUtilities.ts.html +568 -0
  9. package/coverage/Service.ts.html +718 -0
  10. package/coverage/Splash.ts.html +448 -0
  11. package/coverage/SplashQueue.ts.html +232 -0
  12. package/coverage/base.css +224 -0
  13. package/coverage/block-navigation.js +87 -0
  14. package/coverage/clover.xml +560 -0
  15. package/coverage/coverage-final.json +5 -0
  16. package/coverage/favicon.png +0 -0
  17. package/coverage/index.html +161 -0
  18. package/coverage/prettify.css +1 -0
  19. package/coverage/prettify.js +2 -0
  20. package/coverage/sort-arrow-sprite.png +0 -0
  21. package/coverage/sorter.js +196 -0
  22. package/dist/cjs/ns.cjs +2 -0
  23. package/dist/es/ns.js +342 -0
  24. package/dist/iife/ns.iife.js +2 -0
  25. package/docs/.vitepress/config.ts +75 -0
  26. package/docs/.vitepress/theme/css/style.css +157 -0
  27. package/docs/.vitepress/theme/index.ts +16 -0
  28. package/docs/.vitepress/theme/vue/Card.vue +31 -0
  29. package/docs/.vitepress/theme/vue/CardGrid.vue +17 -0
  30. package/docs/.vitepress/theme/vue/Exe.vue +86 -0
  31. package/docs/.vitepress/theme/vue/PlayGround.vue +50 -0
  32. package/docs/api/doc/hide.md +69 -0
  33. package/docs/api/doc/show.md +47 -0
  34. package/docs/api/start/features.md +17 -0
  35. package/docs/api/start/install.md +53 -0
  36. package/docs/api/start/playground.md +11 -0
  37. package/docs/api/start/usage.md +25 -0
  38. package/docs/index.md +30 -0
  39. package/package.json +86 -66
  40. package/src/style/ns.sass +95 -0
  41. package/src/ts/core/DomUtilities.ts +161 -0
  42. package/src/ts/core/Service.ts +211 -0
  43. package/src/ts/core/{Nanosplash/interfaces/NanosplashAPI.ts → ServiceInterface.ts} +18 -10
  44. package/src/ts/core/Splash.ts +121 -0
  45. package/src/ts/core/SplashInterface.ts +46 -0
  46. package/src/ts/core/SplashQueue.ts +49 -0
  47. package/src/ts/main.ts +9 -0
  48. package/src/ts/types/Types.ts +3 -0
  49. package/src/ts/types/global.d.ts +14 -0
  50. package/src/vite-env.d.ts +0 -8
  51. package/tests/DomUtilities.spec.ts +117 -0
  52. package/tests/Guid.spec.ts +5 -5
  53. package/tests/Service.spec.ts +198 -0
  54. package/tests/Splash.spec.ts +64 -0
  55. package/tests/TestUtilities.ts +48 -0
  56. package/tsconfig.json +21 -20
  57. package/vite.config.ts +14 -22
  58. package/dist/main.css +0 -1
  59. package/dist/ns.cjs.js +0 -1
  60. package/dist/ns.es.js +0 -330
  61. package/dist/ns.iife.js +0 -2
  62. package/index.html +0 -52
  63. package/src/main.ts +0 -8
  64. package/src/sass/ns.sass +0 -86
  65. package/src/ts/core/Nanosplash/Nanosplash.ts +0 -97
  66. package/src/ts/core/Nanosplash/interfaces/NanosplashInterface.ts +0 -42
  67. package/src/ts/core/Nanosplash/repositories/NanosplashRepository.ts +0 -178
  68. package/src/ts/core/Nanosplash/services/NanosplashService.ts +0 -222
  69. package/src/ts/types/Alias.d.ts +0 -1
  70. package/src/ts/types/Nanosplash.d.ts +0 -18
  71. package/src/ts/types/NanosplashService.d.ts +0 -1
  72. package/src/ts/util/Guid.ts +0 -13
  73. package/src/ts/util/Stack.ts +0 -73
  74. package/tests/Nanosplash.spec.ts +0 -64
  75. package/tests/NanosplashRepository.spec.ts +0 -91
  76. package/tests/NanosplashService.spec.ts +0 -119
  77. package/tests/Stack.spec.ts +0 -56
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Customize default theme styling by overriding CSS variables:
3
+ * https://github.com/vuejs/vitepress/blob/main/src/client/theme-default/styles/vars.css
4
+ */
5
+
6
+ /**
7
+ * Colors
8
+ *
9
+ * Each colors have exact same color scale system with 3 levels of solid
10
+ * colors with different brightness, and 1 soft color.
11
+ *
12
+ * - `XXX-1`: The most solid color used mainly for colored text. It must
13
+ * satisfy the contrast ratio against when used on top of `XXX-soft`.
14
+ *
15
+ * - `XXX-2`: The color used mainly for hover state of the button.
16
+ *
17
+ * - `XXX-3`: The color for solid background, such as bg color of the button.
18
+ * It must satisfy the contrast ratio with pure white (#ffffff) text on
19
+ * top of it.
20
+ *
21
+ * - `XXX-soft`: The color used for subtle background such as custom container
22
+ * or badges. It must satisfy the contrast ratio when putting `XXX-1` colors
23
+ * on top of it.
24
+ *
25
+ * The soft color must be semi transparent alpha channel. This is crucial
26
+ * because it allows adding multiple "soft" colors on top of each other
27
+ * to create a accent, such as when having inline code block inside
28
+ * custom containers.
29
+ *
30
+ * - `default`: The color used purely for subtle indication without any
31
+ * special meanings attched to it such as bg color for menu hover state.
32
+ *
33
+ * - `brand`: Used for primary brand colors, such as link text, button with
34
+ * brand theme, etc.
35
+ *
36
+ * - `tip`: Used to indicate useful information. The default theme uses the
37
+ * brand color for this by default.
38
+ *
39
+ * - `warning`: Used to indicate warning to the users. Used in custom
40
+ * container, badges, etc.
41
+ *
42
+ * - `danger`: Used to show error, or dangerous message to the users. Used
43
+ * in custom container, badges, etc.
44
+ * -------------------------------------------------------------------------- */
45
+
46
+ :root {
47
+ --vp-c-default-1: var(--vp-c-gray-1);
48
+ --vp-c-default-2: var(--vp-c-gray-2);
49
+ --vp-c-default-3: var(--vp-c-gray-3);
50
+ --vp-c-default-soft: var(--vp-c-gray-soft);
51
+
52
+ --vp-c-brand-1: var(--vp-c-indigo-1);
53
+ --vp-c-brand-2: var(--vp-c-indigo-2);
54
+ --vp-c-brand-3: var(--vp-c-indigo-3);
55
+ --vp-c-brand-soft: var(--vp-c-indigo-soft);
56
+
57
+ --vp-c-tip-1: var(--vp-c-brand-1);
58
+ --vp-c-tip-2: var(--vp-c-brand-2);
59
+ --vp-c-tip-3: var(--vp-c-brand-3);
60
+ --vp-c-tip-soft: var(--vp-c-brand-soft);
61
+
62
+ --vp-c-warning-1: var(--vp-c-yellow-1);
63
+ --vp-c-warning-2: var(--vp-c-yellow-2);
64
+ --vp-c-warning-3: var(--vp-c-yellow-3);
65
+ --vp-c-warning-soft: var(--vp-c-yellow-soft);
66
+
67
+ --vp-c-danger-1: var(--vp-c-red-1);
68
+ --vp-c-danger-2: var(--vp-c-red-2);
69
+ --vp-c-danger-3: var(--vp-c-red-3);
70
+ --vp-c-danger-soft: var(--vp-c-red-soft);
71
+ }
72
+
73
+ /**
74
+ * Component: Button
75
+ * -------------------------------------------------------------------------- */
76
+
77
+ :root {
78
+ --vp-button-brand-border: transparent;
79
+ --vp-button-brand-text: var(--vp-c-white);
80
+ --vp-button-brand-bg: var(--vp-c-brand-3);
81
+ --vp-button-brand-hover-border: transparent;
82
+ --vp-button-brand-hover-text: var(--vp-c-white);
83
+ --vp-button-brand-hover-bg: var(--vp-c-brand-2);
84
+ --vp-button-brand-active-border: transparent;
85
+ --vp-button-brand-active-text: var(--vp-c-white);
86
+ --vp-button-brand-active-bg: var(--vp-c-brand-1);
87
+ }
88
+
89
+ /**
90
+ * Component: Home
91
+ * -------------------------------------------------------------------------- */
92
+
93
+ :root {
94
+ --vp-home-hero-name-color: transparent;
95
+ --vp-home-hero-name-background: -webkit-linear-gradient(
96
+ 120deg,
97
+ #bd34fe 30%,
98
+ #41d1ff
99
+ );
100
+
101
+ --vp-home-hero-image-background-image: linear-gradient(
102
+ -45deg,
103
+ #bd34fe 50%,
104
+ #47caff 50%
105
+ );
106
+ --vp-home-hero-image-filter: blur(40px);
107
+ }
108
+
109
+ @media (min-width: 640px) {
110
+ :root {
111
+ --vp-home-hero-image-filter: blur(56px);
112
+ }
113
+ }
114
+
115
+ @media (min-width: 960px) {
116
+ :root {
117
+ --vp-home-hero-image-filter: blur(72px);
118
+ }
119
+ }
120
+
121
+ /**
122
+ * Component: Custom Block
123
+ * -------------------------------------------------------------------------- */
124
+
125
+ :root {
126
+ --vp-custom-block-tip-border: transparent;
127
+ --vp-custom-block-tip-text: var(--vp-c-text-1);
128
+ --vp-custom-block-tip-bg: var(--vp-c-brand-soft);
129
+ --vp-custom-block-tip-code-bg: var(--vp-c-brand-soft);
130
+ }
131
+
132
+ /**
133
+ * Component: Algolia
134
+ * -------------------------------------------------------------------------- */
135
+
136
+ .DocSearch {
137
+ --docsearch-primary-color: var(--vp-c-brand-1) !important;
138
+ }
139
+
140
+ .vp-doc [class*='language-'] code .highlighted {
141
+ background-color: transparent;
142
+ }
143
+
144
+ .vp-doc [class*='language-'] .has-highlighted-lines .line {
145
+ transition: filter 0.35s, opacity 0.35s;
146
+ }
147
+ .vp-doc [class*='language-'] .has-highlighted-lines .line:not(.highlighted) {
148
+ filter: blur(1px);
149
+ opacity: 0.5;
150
+ }
151
+ .vp-doc
152
+ [class*='language-']
153
+ .has-highlighted-lines:hover
154
+ .line:not(.highlighted) {
155
+ filter: blur(0);
156
+ opacity: 1;
157
+ }
@@ -0,0 +1,16 @@
1
+ // https://vitepress.dev/guide/custom-theme
2
+ import { h } from 'vue'
3
+ import Theme from 'vitepress/theme'
4
+ import './css/style.css'
5
+
6
+ export default {
7
+ extends: Theme,
8
+ Layout: () => {
9
+ return h(Theme.Layout, null, {
10
+ // https://vitepress.dev/guide/extending-default-theme#layout-slots
11
+ })
12
+ },
13
+ enhanceApp({ app, router, siteData }) {
14
+ // ...
15
+ },
16
+ }
@@ -0,0 +1,31 @@
1
+ <script setup>
2
+ import { useAttrs } from 'vue'
3
+ const attrs = useAttrs()
4
+ </script>
5
+
6
+ <template>
7
+ <div class="card">
8
+ <div v-if="attrs.id" class="id">#{{ attrs.id }}</div>
9
+ <slot></slot>
10
+ </div>
11
+ </template>
12
+
13
+ <style lang="sass" scoped>
14
+ .card
15
+ color: White
16
+ line-height: 1
17
+ position: relative
18
+ padding: 30px
19
+ border-radius: 5px
20
+ background-color: rgba(White, 0.2)
21
+ backdrop-filter: blur(5px)
22
+ -webkit-backdrop-filter: blur(5px)
23
+ border: 1px solid rgba(White, 0.2)
24
+ .id
25
+ position: absolute
26
+ top: 5px
27
+ left: 5px
28
+ font-size: 10px
29
+ color: rgba(White, 0.7)
30
+ letter-spacing: 0.1em
31
+ </style>
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <div class="card-grid">
3
+ <slot></slot>
4
+ </div>
5
+ </template>
6
+
7
+ <style lang="sass" scoped>
8
+ .card-grid
9
+ display: grid
10
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr))
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)
13
+ background-size: cover
14
+ background-position-y: bottom
15
+ padding: 25px
16
+ border-radius: 5px
17
+ </style>
@@ -0,0 +1,86 @@
1
+ <script setup>
2
+ import { ref, defineProps } from 'vue'
3
+ import { Service } from '../../../../dist/es/ns'
4
+ Service.start()
5
+
6
+ const props = defineProps({
7
+ commands: Array,
8
+ })
9
+
10
+ const rCommandString = ref('')
11
+
12
+ const wait = ms => new Promise(r => setTimeout(r, ms))
13
+
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})`)
26
+ }
27
+ ns.hideId(id)
28
+ }
29
+ } else {
30
+ executable = new Function(rCommandString.value)
31
+ }
32
+ executable()
33
+ }
34
+ </script>
35
+
36
+ <template>
37
+ <div class="container">
38
+ <select class="select" v-model="rCommandString">
39
+ <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
+ >
45
+ {{ command }}
46
+ </option>
47
+ </select>
48
+ <div class="exe" @click="onClickExe">Run</div>
49
+ </div>
50
+ </template>
51
+
52
+ <style lang="sass" scoped>
53
+ @use "sass:color"
54
+
55
+ $border-radius: 5px
56
+ .container
57
+ position: relative
58
+ display: flex
59
+ border-radius: $border-radius
60
+ z-index: 1
61
+ & > *
62
+ padding: 10px 20px
63
+
64
+ .select
65
+ position: relative
66
+ display: flex
67
+ flex-grow: 1
68
+ font-family: monospace
69
+ font-size: 14px
70
+ background-color: var(--vp-c-bg-alt)
71
+ border-radius: $border-radius 0 0 $border-radius
72
+ border: 1px solid rgba(Black, 0.1)
73
+ cursor: pointer
74
+
75
+ $btn-bg: RoyalBlue
76
+ .exe
77
+ position: relative
78
+ display: inline-flex
79
+ color: White
80
+ background-color: $btn-bg
81
+ cursor: pointer
82
+ border-radius: 0 $border-radius $border-radius 0
83
+ border: 1px solid rgba(Black, 0.1)
84
+ &:hover
85
+ background-color: darken($btn-bg, 10%)
86
+ </style>
@@ -0,0 +1,50 @@
1
+ <script setup>
2
+ import CardGrid from './CardGrid.vue'
3
+ import Card from './Card.vue'
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
+ </script>
18
+
19
+ <template>
20
+ <div class="playground">
21
+ <CardGrid id="wrapper">
22
+ <Card id="a">
23
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut
24
+ aliquam
25
+ </Card>
26
+ <Card id="b">
27
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut
28
+ aliquam
29
+ </Card>
30
+ <Card id="c">
31
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut
32
+ aliquam
33
+ </Card>
34
+ <Card id="d">
35
+ Lorem ipsum dolor sit amet consectetur adipiscing elit ut
36
+ aliquam
37
+ </Card>
38
+ </CardGrid>
39
+ <Exe :commands="commands"></Exe>
40
+ </div>
41
+ </template>
42
+
43
+ <style lang="sass" scoped>
44
+ .playground
45
+ display: flex
46
+ flex-direction: column
47
+ row-gap: 20px
48
+ & > *
49
+ box-shadow: 0 2px 10px rgba(Black, 0.1)
50
+ </style>
@@ -0,0 +1,69 @@
1
+ # Hide Nanosplash
2
+
3
+ ## Hide
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.
6
+
7
+ ```ts
8
+ ns.hide(): GUIDString | null
9
+ ```
10
+
11
+ ```js
12
+ ns.show('a')
13
+ ns.show('b')
14
+ ns.show('c')
15
+ ns.hide() // Hides 'a'
16
+ ns.hide() // Hides 'b'
17
+ ns.hide() // Hides 'c'
18
+ ```
19
+
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.
22
+ :::
23
+
24
+ ## Hide by ID
25
+
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.
27
+
28
+ ```ts
29
+ ns.hideId(guid: GUIDString): GUIDString | null
30
+ ```
31
+
32
+ The show methods always retrun a GUID. This identifier can be used to hide specific loading screens.
33
+
34
+ ```js
35
+ 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)
61
+ ```
62
+
63
+ ## Hide all
64
+
65
+ Hides all Nanosplash loading screens.
66
+
67
+ ```ts
68
+ ns.hideAll(): void
69
+ ```
@@ -0,0 +1,47 @@
1
+ # Show Nanosplash
2
+
3
+ ## Show
4
+
5
+ This method displays a fullscreen loading screen and returns a GUID string.
6
+
7
+ ```ts
8
+ ns.show(text?: string): GUIDString
9
+ ```
10
+
11
+ If you enter no text, it will display the spinning wheel only.
12
+
13
+ ```js
14
+ ns.show()
15
+ ```
16
+
17
+ If you enter text, it will display the spinning wheel adjacent to the text.
18
+
19
+ ```js
20
+ ns.show('Loading')
21
+ ```
22
+
23
+ ## Show inside
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`.
28
+
29
+ ```ts
30
+ ns.showInside(ref: Reference, text?: string): GUIDString | null
31
+ ```
32
+
33
+ ```js
34
+ // CSS selector
35
+ const selector = '#my-table'
36
+ ns.showInside(selector, 'Loading')
37
+
38
+ // Element
39
+ const element = document.getElementById('my-table')
40
+ ns.showInside(element, 'Loading')
41
+ ```
42
+
43
+ ::: tip
44
+ A host element can only contain one Nanosplash element at a time. If
45
+ you try to show a splash inside an element that already contains a splash,
46
+ the existing splash will be overwritten.
47
+ :::
@@ -0,0 +1,17 @@
1
+ # Features
2
+
3
+ ## Small bundle size
4
+
5
+ The Nanosplash bundle is merely 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.
6
+
7
+ ## Simple API
8
+
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
+
11
+ ## Spawning
12
+
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
+
15
+ ## Element recycling
16
+
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.
@@ -0,0 +1,53 @@
1
+ <script setup>
2
+ import Card from '../../.vitepress/theme/vue/Card.vue'
3
+ </script>
4
+
5
+ # Installation
6
+
7
+ Nanosplash can be installed either via CDN or NPM. Installing via CDN is easier and requires less configuration, but installing via NPM is more flexible and allows you to controll the imports and initialization of the Nanosplash service running in your application.
8
+
9
+ ## CSS
10
+
11
+ Since version 3.0.2, CSS is included inside the JS bundle. 🎉
12
+
13
+ ## Install via CDN
14
+
15
+ Add the following script tag to the `<head>` of your HTML document:
16
+
17
+ ```html
18
+ <script src="https://unpkg.com/nanosplash@3.0.2/dist/iife/ns.iife.js"></script>
19
+ ```
20
+
21
+ ```html{5}
22
+ <html>
23
+ <head>
24
+ <meta charset="UTF-8" />
25
+ <title>My awesome application 🚀</title>
26
+ <script src="https://unpkg.com/nanosplash@3.0.2/dist/iife/ns.iife.js"></script>
27
+ </head>
28
+ ...
29
+ </html>
30
+ ```
31
+
32
+ Now you can easily start using Nanosplash by simply calling `ns.show`.
33
+
34
+ ```ts
35
+ ns.show('It works!')
36
+ ```
37
+
38
+ ## Install via NPM
39
+
40
+ Install Nanosplash via NPM by running the following command:
41
+
42
+ ```bash
43
+ yarn add nanosplash
44
+ ```
45
+
46
+ To import and start the Nanosplash service in your application, you need to import the Service class and start it.
47
+
48
+ ```js{2}
49
+ import { Service } from 'nanosplash'
50
+ Service.start()
51
+ ```
52
+
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`.
@@ -0,0 +1,11 @@
1
+ <script setup>
2
+ import PlayGround from '../../.vitepress/theme/vue/PlayGround.vue'
3
+ </script>
4
+
5
+ # Playground
6
+
7
+ Here you can play around with Nanosplash and see how it works.
8
+
9
+ <PlayGround></PlayGround>
10
+
11
+ Select a method from the dropdown menu above and click "Run" to see it in action.
@@ -0,0 +1,25 @@
1
+ # Usage
2
+
3
+ ```js{2,5,8,11,14,18,21}
4
+ // Fullscreen spinning wheel
5
+ ns.show()
6
+
7
+ // Fullscreen spinning wheel with text
8
+ ns.show('Loading')
9
+
10
+ // Display inside an element
11
+ ns.showInside('#my-table', 'Fetching data')
12
+
13
+ // Hide the first created loading screen (FIFO)
14
+ ns.hide()
15
+
16
+ // Hide loading screen inside an element
17
+ ns.hideInside('#my-table')
18
+
19
+ // Hide specific loading screen
20
+ const id = ns.show('Loading')
21
+ ns.hideId(id)
22
+
23
+ // Hide all loading screens
24
+ ns.hideAll()
25
+ ```
package/docs/index.md ADDED
@@ -0,0 +1,30 @@
1
+ ---
2
+ # https://vitepress.dev/reference/default-theme-home-page
3
+ layout: home
4
+
5
+ hero:
6
+ name: 'Nanosplash'
7
+ text: ''
8
+ tagline: The tiny loading screen for web artisans
9
+ actions:
10
+ - theme: brand
11
+ text: Get started
12
+ link: /api/start/install.md
13
+ - theme: alt
14
+ text: API Documentation
15
+ link: /api/doc/show.md
16
+
17
+ features:
18
+ - title: 📦 Tiny
19
+ details: Only 3KB minified and gzipped.
20
+ link: /api/start/features#small-bundle-size
21
+ - title: 🍼 Simple API
22
+ details: Start using Nanosplash in seconds.
23
+ link: /api/start/features#simple-api
24
+ - title: 🧚 Spawning
25
+ details: Spawn a splash element anywhere in your DOM.
26
+ link: /api/start/features#spawning
27
+ - title: ♻️ Element recycling
28
+ details: Nanosplash will recycle existing elements.
29
+ link: /api/start/features#element-recycling
30
+ ---