nanosplash 3.1.0 → 4.0.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 (33) hide show
  1. package/.github/workflows/ci.yml +56 -49
  2. package/.github/workflows/vitepress.yml +52 -52
  3. package/README.md +22 -2
  4. package/dist/cjs/ns.cjs +1 -1
  5. package/dist/es/ns.js +40 -40
  6. package/dist/iife/ns.iife.js +1 -1
  7. package/docs/.vitepress/{config.mts → config.ts} +3 -0
  8. package/docs/.vitepress/theme/vue/PlayGround.vue +0 -2
  9. package/docs/api/start/customize.md +1 -1
  10. package/docs/api/start/install.md +9 -5
  11. package/docs/api/start/playground.md +6 -1
  12. package/package.json +12 -13
  13. package/src/ts/Nanosplash.ts +59 -59
  14. package/src/ts/main.ts +1 -1
  15. package/tests/Nanosplash.spec.ts +7 -5
  16. package/bun.lockb +0 -0
  17. package/docs/.vitepress/.temp/@localSearchIndexroot.Ba2B1gNE.js +0 -4
  18. package/docs/.vitepress/.temp/Card.Ce4dbGEn.js +0 -30
  19. package/docs/.vitepress/.temp/VPLocalSearchBox.DV6bivXX.js +0 -382
  20. package/docs/.vitepress/.temp/api_doc_hide.md.js +0 -25
  21. package/docs/.vitepress/.temp/api_doc_show.md.js +0 -25
  22. package/docs/.vitepress/.temp/api_start_customize.md.js +0 -42
  23. package/docs/.vitepress/.temp/api_start_features.md.js +0 -19
  24. package/docs/.vitepress/.temp/api_start_install.md.js +0 -35
  25. package/docs/.vitepress/.temp/api_start_playground.md.js +0 -213
  26. package/docs/.vitepress/.temp/api_start_usage.md.js +0 -36
  27. package/docs/.vitepress/.temp/app.js +0 -5090
  28. package/docs/.vitepress/.temp/assets/style.lcyfX_uc.css +0 -5374
  29. package/docs/.vitepress/.temp/index.md.js +0 -19
  30. package/docs/.vitepress/.temp/macos.jpg +0 -0
  31. package/docs/.vitepress/.temp/package.json +0 -1
  32. package/docs/.vitepress/.temp/plugin-vue_export-helper.1tPrXgE0.js +0 -10
  33. package/docs/.vitepress/theme/vue/Exe.vue +0 -117
@@ -1,54 +1,61 @@
1
1
  name: Build and Test
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
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
12
+ build-and-test:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Checkout
17
+ uses: actions/checkout@v3
18
+
19
+ - name: Install PNPM
20
+ uses: pnpm/action-setup@v3
21
+ with:
22
+ version: 8
23
+
24
+ - name: Setup Node.js
25
+ uses: actions/setup-node@v3
26
+ with:
27
+ node-version: 20
28
+ registry-url: 'https://registry.npmjs.org'
29
+ - name: Set up Git and update production branch
30
+ run: |
31
+ git config --global user.name "GitHub Actions"
32
+ git config --global user.email "actions@github.com"
33
+ git fetch
34
+ git checkout production
35
+ git pull --no-rebase
36
+
37
+ - name: Setup Pages
38
+ uses: actions/configure-pages@v3
39
+
40
+ - name: Install dependencies
41
+ run: pnpm install --no-frozen-lockfile
42
+
43
+ - name: Build (Vite)
44
+ run: pnpm build
45
+
46
+ - name: Test (Vitest)
47
+ run: pnpm test
48
+
49
+ - name: Generate Code Coverage (Vitest)
50
+ run: pnpm coverage
51
+
52
+ - name: Commit and push changes
53
+ run: |
54
+ git add .
55
+ git commit --allow-empty -m "Build, test, and coverage report"
56
+ git push
57
+
58
+ - name: Publish to NPM
59
+ run: npm publish
60
+ env:
61
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
@@ -3,66 +3,66 @@
3
3
  name: Deploy VitePress site to Pages
4
4
 
5
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]
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
12
 
13
- # Allows you to run this workflow manually from the Actions tab
14
- workflow_dispatch:
13
+ # Allows you to run this workflow manually from the Actions tab
14
+ workflow_dispatch:
15
15
 
16
16
  # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
17
17
  permissions:
18
- contents: read
19
- pages: write
20
- id-token: write
18
+ contents: read
19
+ pages: write
20
+ id-token: write
21
21
 
22
22
  # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
23
23
  # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
24
24
  concurrency:
25
- group: pages
26
- cancel-in-progress: false
25
+ group: pages
26
+ cancel-in-progress: false
27
27
 
28
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
- - name: Setup Pages
45
- uses: actions/configure-pages@v3
46
- - name: Install dependencies
47
- run: yarn install
48
- - name: Build with VitePress
49
- run: |
50
- bun run docs:build
51
- touch docs/.vitepress/dist/.nojekyll
52
- - name: Upload artifact
53
- uses: actions/upload-pages-artifact@v2
54
- with:
55
- path: docs/.vitepress/dist
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@v3
38
+ with:
39
+ version: 8
40
+ - name: Setup Node
41
+ uses: actions/setup-node@v3
42
+ with:
43
+ node-version: 20
44
+ - name: Setup Pages
45
+ uses: actions/configure-pages@v3
46
+ - name: Install dependencies
47
+ run: pnpm install --no-frozen-lockfile
48
+ - name: Build with VitePress
49
+ run: |
50
+ pnpm docs:build
51
+ touch docs/.vitepress/dist/.nojekyll
52
+ - name: Upload artifact
53
+ uses: actions/upload-pages-artifact@v2
54
+ with:
55
+ path: docs/.vitepress/dist
56
56
 
57
- # Deployment job
58
- deploy:
59
- environment:
60
- name: github-pages
61
- url: ${{ steps.deployment.outputs.page_url }}
62
- needs: build
63
- runs-on: ubuntu-latest
64
- name: Deploy
65
- steps:
66
- - name: Deploy to GitHub Pages
67
- id: deployment
68
- uses: actions/deploy-pages@v2
57
+ # Deployment job
58
+ deploy:
59
+ environment:
60
+ name: github-pages
61
+ url: ${{ steps.deployment.outputs.page_url }}
62
+ needs: build
63
+ runs-on: ubuntu-latest
64
+ name: Deploy
65
+ steps:
66
+ - name: Deploy to GitHub Pages
67
+ id: deployment
68
+ uses: actions/deploy-pages@v2
package/README.md CHANGED
@@ -6,11 +6,11 @@
6
6
 
7
7
  [![Build](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml/badge.svg?branch=production)](https://github.com/isakhauge/nanosplash/actions/workflows/ci.yml)
8
8
 
9
- ## Documentation
9
+ ## 💖 Documentation
10
10
 
11
11
  [isakhauge.github.io/nanosplash/](https://isakhauge.github.io/nanosplash/)
12
12
 
13
- ## Usage
13
+ ## 🚀 Usage
14
14
 
15
15
  ### Show
16
16
 
@@ -67,3 +67,23 @@ Remove all Nanosplashes.
67
67
  ```js
68
68
  ns.hide('*')
69
69
  ```
70
+
71
+ ## 🦄 Customization
72
+
73
+ You can easily make Nanosplash look the way you want.
74
+
75
+ ```scss
76
+ // Backdrop selector
77
+ .nsh::before
78
+
79
+ // Main wrapper selector
80
+ .ns
81
+
82
+ // Text selector
83
+ .nst
84
+
85
+ // Spinner selector
86
+ .nss
87
+ ```
88
+
89
+ Read more here: [Customization](https://isakhauge.github.io/nanosplash/api/start/customize.html)
package/dist/cjs/ns.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',y="3.1.0",m="nscss",i=()=>document.body,a=e=>(t=>({all:t,first:s=>t(s)[0]??null}))(t=>Array.from(e.querySelectorAll(t))),l=e=>a(document).all(e),d=e=>a(document).first(e),f=()=>l(".ns"),b=e=>e instanceof Element?e:d(e),r=(e,...t)=>{const s=document.createElement("div");return e&&s.classList.add(e),s.append(...t),s},h=e=>{const t=r();return t.innerHTML=e,t.firstChild},u=()=>{const t=h('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),s=r("ns",r("nst"),r("nss",t));return s.nsId=Date.now(),s},g=()=>f().sort((e,t)=>e.nsId-t.nsId)[0]??null,w=(e,t)=>{const n=a(e).first(".nst");if(!t)return n==null?void 0:n.remove();const o=r("nst",t);n?n.replaceWith(o):e.insertBefore(o,e.firstChild)},k=(e,t)=>{const s=t.firstElementChild;s&&t.insertBefore(e,s),t.append(e),t.classList.add("nsh")},x=(e,t)=>{const s=t?b(t):i;let n;const o=a(s??i()).first("& > .ns");o?n=o:(n=u(),k(n,s)),w(n,e??"");const p=window.scrollY+"px";return i().style.setProperty("--ns-top",p),n.nsId},c=e=>{var t;(t=e==null?void 0:e.parentElement)==null||t.classList.remove("nsh"),e==null||e.remove()},S=e=>f().find(t=>t.nsId===e)??null,z=e=>{e==="*"?l(".ns").forEach(c):c(typeof e=="number"?S(e):g())},I=()=>{var e;(e=d("#nscss"))==null||e.remove(),i().append(h(`<style id=${m}>${v}</style>`))},A=()=>!!new Promise(I)&&(window.ns={show:x,hide:z,version:y});exports.useNs=A;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',m="4.0.0",l="ns",i=document,r=i.body,a=e=>(s=>({all:s,first:t=>s(t)[0]??null}))(s=>Array.from(e.querySelectorAll(s))),f=e=>a(i).all(e),h=e=>a(i).first(e),p=()=>f(".ns"),u=e=>e instanceof Element?e:h(e),n=(e,...s)=>{const t=i.createElement("div");return e&&t.classList.add(e),t.append(...s),t},v=e=>{const s=n();return s.innerHTML=e,s.firstChild},g=()=>{const s=v('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),t=n("ns",n("nst"),n("nss",s));return t.nsId=Date.now(),t},k=()=>p().sort((e,s)=>e.nsId-s.nsId)[0]??null,w=(e,s)=>{const t=a(e).first(".nst");if(!s)return t==null?void 0:t.remove();const o=n("nst",s);t?t.replaceWith(o):e.insertBefore(o,e.firstChild)},x=(e,s)=>{const t=s.firstElementChild;t&&s.insertBefore(e,t),s.append(e),s.classList.add("nsh")},z=(e,s)=>{const t=s?u(s):r;let o;const c=a(t??r).first("& > .ns");c?o=c:(o=g(),x(o,t)),w(o,e??"");const y=scrollY+"px";return r.style.setProperty("--ns-top",y),o.nsId},d=e=>{var s;(s=e==null?void 0:e.parentElement)==null||s.classList.remove("nsh"),e==null||e.remove()},I=e=>p().find(s=>s.nsId===e)??null,N=e=>{e==="*"?f(".ns").forEach(d):d(typeof e=="number"?I(e):k())},A=()=>{var e;(e=h("#"+l))==null||e.remove(),r.append(v(`<style id=${l}>${b}</style>`))},S=()=>(A(),{show:z,hide:N,version:m});exports.useNs=S;
package/dist/es/ns.js CHANGED
@@ -1,44 +1,44 @@
1
- const v = '@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}', y = "3.1.0", m = "nscss", i = () => document.body, a = (e) => /* @__PURE__ */ ((t) => ({
2
- all: t,
3
- first: (s) => t(s)[0] ?? null
4
- }))((t) => Array.from(e.querySelectorAll(t))), l = (e) => a(document).all(e), d = (e) => a(document).first(e), f = () => l(".ns"), b = (e) => e instanceof Element ? e : d(e), r = (e, ...t) => {
5
- const s = document.createElement("div");
6
- return e && s.classList.add(e), s.append(...t), s;
7
- }, h = (e) => {
8
- const t = r();
9
- return t.innerHTML = e, t.firstChild;
10
- }, u = () => {
11
- const t = h('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'), s = r("ns", r("nst"), r("nss", t));
12
- return s.nsId = Date.now(), s;
13
- }, w = () => f().sort((e, t) => e.nsId - t.nsId)[0] ?? null, g = (e, t) => {
14
- const n = a(e).first(".nst");
15
- if (!t)
16
- return n == null ? void 0 : n.remove();
17
- const o = r("nst", t);
18
- n ? n.replaceWith(o) : e.insertBefore(o, e.firstChild);
19
- }, k = (e, t) => {
20
- const s = t.firstElementChild;
21
- s && t.insertBefore(e, s), t.append(e), t.classList.add("nsh");
22
- }, x = (e, t) => {
23
- const s = t ? b(t) : i;
24
- let n;
25
- const o = a(s ?? i()).first("& > .ns");
26
- o ? n = o : (n = u(), k(n, s)), g(n, e ?? "");
27
- const p = window.scrollY + "px";
28
- return i().style.setProperty("--ns-top", p), n.nsId;
29
- }, c = (e) => {
30
- var t;
31
- (t = e == null ? void 0 : e.parentElement) == null || t.classList.remove("nsh"), e == null || e.remove();
32
- }, S = (e) => f().find((t) => t.nsId === e) ?? null, z = (e) => {
33
- e === "*" ? l(".ns").forEach(c) : c(typeof e == "number" ? S(e) : w());
34
- }, I = () => {
1
+ const b = '@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}', m = "4.0.0", l = "ns", i = document, r = i.body, a = (e) => /* @__PURE__ */ ((s) => ({
2
+ all: s,
3
+ first: (t) => s(t)[0] ?? null
4
+ }))((s) => Array.from(e.querySelectorAll(s))), f = (e) => a(i).all(e), h = (e) => a(i).first(e), p = () => f(".ns"), u = (e) => e instanceof Element ? e : h(e), n = (e, ...s) => {
5
+ const t = i.createElement("div");
6
+ return e && t.classList.add(e), t.append(...s), t;
7
+ }, v = (e) => {
8
+ const s = n();
9
+ return s.innerHTML = e, s.firstChild;
10
+ }, g = () => {
11
+ const s = v('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'), t = n("ns", n("nst"), n("nss", s));
12
+ return t.nsId = Date.now(), t;
13
+ }, k = () => p().sort((e, s) => e.nsId - s.nsId)[0] ?? null, w = (e, s) => {
14
+ const t = a(e).first(".nst");
15
+ if (!s)
16
+ return t == null ? void 0 : t.remove();
17
+ const o = n("nst", s);
18
+ t ? t.replaceWith(o) : e.insertBefore(o, e.firstChild);
19
+ }, x = (e, s) => {
20
+ const t = s.firstElementChild;
21
+ t && s.insertBefore(e, t), s.append(e), s.classList.add("nsh");
22
+ }, z = (e, s) => {
23
+ const t = s ? u(s) : r;
24
+ let o;
25
+ const c = a(t ?? r).first("& > .ns");
26
+ c ? o = c : (o = g(), x(o, t)), w(o, e ?? "");
27
+ const y = scrollY + "px";
28
+ return r.style.setProperty("--ns-top", y), o.nsId;
29
+ }, d = (e) => {
30
+ var s;
31
+ (s = e == null ? void 0 : e.parentElement) == null || s.classList.remove("nsh"), e == null || e.remove();
32
+ }, I = (e) => p().find((s) => s.nsId === e) ?? null, A = (e) => {
33
+ e === "*" ? f(".ns").forEach(d) : d(typeof e == "number" ? I(e) : k());
34
+ }, N = () => {
35
35
  var e;
36
- (e = d("#nscss")) == null || e.remove(), i().append(h(`<style id=${m}>${v}</style>`));
37
- }, A = () => !!new Promise(I) && (window.ns = {
38
- show: x,
39
- hide: z,
40
- version: y
36
+ (e = h("#" + l)) == null || e.remove(), r.append(v(`<style id=${l}>${b}</style>`));
37
+ }, S = () => (N(), {
38
+ show: z,
39
+ hide: A,
40
+ version: m
41
41
  });
42
42
  export {
43
- A as useNs
43
+ S as useNs
44
44
  };
@@ -1 +1 @@
1
- (function(){"use strict";const p='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',v="3.1.0",y="nscss",i=()=>document.body,a=e=>(s=>({all:s,first:t=>s(t)[0]??null}))(s=>Array.from(e.querySelectorAll(s))),c=e=>a(document).all(e),l=e=>a(document).first(e),d=()=>c(".ns"),m=e=>e instanceof Element?e:l(e),o=(e,...s)=>{const t=document.createElement("div");return e&&t.classList.add(e),t.append(...s),t},f=e=>{const s=o();return s.innerHTML=e,s.firstChild},b=()=>{const s=f('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),t=o("ns",o("nst"),o("nss",s));return t.nsId=Date.now(),t},u=()=>d().sort((e,s)=>e.nsId-s.nsId)[0]??null,w=(e,s)=>{const n=a(e).first(".nst");if(!s)return n==null?void 0:n.remove();const r=o("nst",s);n?n.replaceWith(r):e.insertBefore(r,e.firstChild)},g=(e,s)=>{const t=s.firstElementChild;t&&s.insertBefore(e,t),s.append(e),s.classList.add("nsh")},k=(e,s)=>{const t=s?m(s):i;let n;const r=a(t??i()).first("& > .ns");r?n=r:(n=b(),g(n,t)),w(n,e??"");const I=window.scrollY+"px";return i().style.setProperty("--ns-top",I),n.nsId},h=e=>{var s;(s=e==null?void 0:e.parentElement)==null||s.classList.remove("nsh"),e==null||e.remove()},x=e=>d().find(s=>s.nsId===e)??null,S=e=>{e==="*"?c(".ns").forEach(h):h(typeof e=="number"?x(e):u())},z=()=>{var e;(e=l("#nscss"))==null||e.remove(),i().append(f(`<style id=${y}>${p}</style>`))};!!new Promise(z)&&(window.ns={show:k,hide:S,version:v})})();
1
+ (function(){"use strict";const y='@keyframes nsRotate{to{transform:rotate(360deg)}}@keyframes nsDash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}to{stroke-dasharray:90,150;stroke-dashoffset:-124}}@keyframes nsFade{0%{opacity:0}to{opacity:1}}@keyframes nsAscend{0%{opacity:0;transform:translateY(13px)}to{opacity:1;transform:translateY(0)}}:root{--ns-top: 0px}.ns,body.nsh,body.nsh:before,.nsh:before{width:100%;height:100%}.ns,.nsh:before{bottom:0;right:0}.ns{display:flex;justify-content:center;align-items:center}.nsh{--color: DarkSlateGray;--size: 20px;--relSize: calc(var(--size) * .9);--font: "Helvetica", "Arial", sans-serif;--weight: 400;--bg: rgba(255, 255, 255, .9);--zIdx: 999999999;--blur: blur(5px)}.nsh{position:relative;z-index:var(--zIdx)}.nsh:before{position:absolute;background-color:var(--bg);content:"";backdrop-filter:var(--blur);-webkit-backdrop-filter:var(--blur);z-index:calc(var(--zIdx) + 1);border-radius:inherit}body.nsh,body.nsh:before{position:fixed;top:var(--ns-top);left:0}.ns{position:absolute;z-index:calc(var(--zIdx) + 2);animation:nsFade 2s;gap:var(--relSize)}.nst{color:var(--color);font-size:var(--size);font-family:var(--font);font-weight:var(--weight);max-width:80dvw;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-shadow:0 0 .06rem rgba(47,79,79,.25);filter:drop-shadow(0 0 .07rem rgba(0,0,0,.25));animation:nsAscend .5s}.nss{display:block;width:var(--relSize);height:var(--relSize);animation:nsAscend .5s}.nss>svg{animation:nsRotate 2s linear infinite;position:relative;width:inherit;height:inherit;stroke-width:8}.nss .path{stroke:var(--color);stroke-linecap:round;animation:nsDash 1.5s ease-in-out infinite}',b="4.0.0",c="ns",r=document,i=r.body,a=e=>(s=>({all:s,first:t=>s(t)[0]??null}))(s=>Array.from(e.querySelectorAll(s))),l=e=>a(r).all(e),d=e=>a(r).first(e),f=()=>l(".ns"),m=e=>e instanceof Element?e:d(e),o=(e,...s)=>{const t=r.createElement("div");return e&&t.classList.add(e),t.append(...s),t},h=e=>{const s=o();return s.innerHTML=e,s.firstChild},u=()=>{const s=h('<svg viewBox="0 0 50 50"><circle class=path cx=25 cy=25 r=20 fill=none /></svg>'),t=o("ns",o("nst"),o("nss",s));return t.nsId=Date.now(),t},g=()=>f().sort((e,s)=>e.nsId-s.nsId)[0]??null,w=(e,s)=>{const t=a(e).first(".nst");if(!s)return t==null?void 0:t.remove();const n=o("nst",s);t?t.replaceWith(n):e.insertBefore(n,e.firstChild)},k=(e,s)=>{const t=s.firstElementChild;t&&s.insertBefore(e,t),s.append(e),s.classList.add("nsh")},x=(e,s)=>{const t=s?m(s):i;let n;const v=a(t??i).first("& > .ns");v?n=v:(n=u(),k(n,t)),w(n,e??"");const S=scrollY+"px";return i.style.setProperty("--ns-top",S),n.nsId},p=e=>{var s;(s=e==null?void 0:e.parentElement)==null||s.classList.remove("nsh"),e==null||e.remove()},z=e=>f().find(s=>s.nsId===e)??null,I=e=>{e==="*"?l(".ns").forEach(p):p(typeof e=="number"?z(e):g())},A=()=>{var e;(e=d("#"+c))==null||e.remove(),i.append(h(`<style id=${c}>${y}</style>`))},N=()=>(A(),{show:x,hide:I,version:b});window.ns=N()})();
@@ -6,6 +6,9 @@ export default defineConfig({
6
6
  description: 'The tiny loading screen for web artisans',
7
7
  base: '/nanosplash/',
8
8
  appearance: 'dark',
9
+ head: [
10
+ ['script', { src: 'https://unpkg.com/nanosplash/dist/iife/ns.iife.js' }],
11
+ ],
9
12
  themeConfig: {
10
13
  nav: [
11
14
  { text: 'Home', link: '/' },
@@ -1,7 +1,6 @@
1
1
  <script setup>
2
2
  import CardGrid from './CardGrid.vue'
3
3
  import Card from './Card.vue'
4
- import Exe from './Exe.vue'
5
4
  </script>
6
5
 
7
6
  <template>
@@ -20,7 +19,6 @@ import Exe from './Exe.vue'
20
19
  Lorem ipsum dolor sit amet consectetur adipiscing elit ut aliquam
21
20
  </Card>
22
21
  </CardGrid>
23
- <Exe />
24
22
  </div>
25
23
  </template>
26
24
 
@@ -1,6 +1,6 @@
1
1
  # Customize
2
2
 
3
- Stying Nanosplash to your needs is easy!
3
+ Styling Nanosplash to your needs is easy!
4
4
 
5
5
  ```css
6
6
  /* Backdrop */
@@ -18,15 +18,15 @@ Add the following script tag inside of the `<body>` tag:
18
18
  <script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
19
19
  ```
20
20
 
21
- ```html{7}
21
+ ### Example
22
+
23
+ ```html{6}
22
24
  <html>
23
25
  <head>
24
- <meta charset="UTF-8" />
25
26
  <title>My awesome application 🚀</title>
26
27
  </head>
27
28
  <body>
28
29
  <script src="https://unpkg.com/nanosplash/dist/iife/ns.iife.js"></script>
29
- ...
30
30
  </body>
31
31
  </html>
32
32
  ```
@@ -53,5 +53,9 @@ const ns = useNs()
53
53
  ns.show('It works!')
54
54
  ```
55
55
 
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`.
56
+ For ease of use, add it to the window object for global access.
57
+
58
+ ```js{2}
59
+ import { useNs } from 'nanosplash'
60
+ window.ns = useNs()
61
+ ```
@@ -8,4 +8,9 @@ Here you can play around with Nanosplash and see how it works.
8
8
 
9
9
  <PlayGround />
10
10
 
11
- Select a method from the dropdown menu above and click "Run" to see it in action.
11
+ Open your browser console (developer tools).
12
+
13
+ - macOS: `⌘` `⌥` `i`
14
+ - Windows: `Ctrl` `⇧` `i`
15
+
16
+ Try to target different elements in the DOM. Nanosplash is available in the window scope as `ns`. Give it a shot!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nanosplash",
3
- "version": "3.1.0",
3
+ "version": "4.0.0",
4
4
  "author": {
5
5
  "name": "Isak K. Hauge",
6
6
  "email": "isakhauge@icloud.com",
@@ -14,7 +14,7 @@
14
14
  "module": "./dist/es/ns.js",
15
15
  "devDependencies": {
16
16
  "@types/jsdom": "^21.1.6",
17
- "@types/node": "^20.11.28",
17
+ "@types/node": "^20.11.30",
18
18
  "@types/rollup": "^0.54.0",
19
19
  "@vitest/coverage-v8": "^1.4.0",
20
20
  "@vitest/ui": "^1.4.0",
@@ -25,7 +25,6 @@
25
25
  "jsdom": "^24.0.0",
26
26
  "sass": "^1.72.0",
27
27
  "stylelint-prettier": "^5.0.0",
28
- "terser": "^5.29.2",
29
28
  "typescript": "5.4.2",
30
29
  "typescript-eslint": "^7.2.0",
31
30
  "vite": "^5.1.6",
@@ -70,20 +69,20 @@
70
69
  "license": "MIT",
71
70
  "private": false,
72
71
  "scripts": {
73
- "build": "bun build:all && bun build:docs",
74
- "build:es": "bun x -b tsc && cross-env entry=./src/ts/Nanosplash.ts format=es bun run -b vite build -m production --c vite.config.ts",
75
- "build:cjs": "bun x -b tsc && cross-env entry=./src/ts/Nanosplash.ts format=cjs bun run -b vite build -m production --c vite.config.ts",
76
- "build:iife": "bun x -b tsc && cross-env entry=./src/ts/main.ts format=iife bun run -b vite build -m production --c vite.config.ts",
77
- "build:all": "bun build:es && bun build:cjs && bun build:iife",
78
- "build:docs": "bun docs:build",
72
+ "build": "pnpm build:all && pnpm build:docs",
73
+ "build:es": "tsc && cross-env entry=./src/ts/Nanosplash.ts format=es vite build -m production --c vite.config.ts",
74
+ "build:cjs": "tsc && cross-env entry=./src/ts/Nanosplash.ts format=cjs vite build -m production --c vite.config.ts",
75
+ "build:iife": "tsc && cross-env entry=./src/ts/main.ts format=iife vite build -m production --c vite.config.ts",
76
+ "build:all": "pnpm build:es && pnpm build:cjs && pnpm build:iife",
77
+ "build:docs": "pnpm docs:build",
79
78
  "preview": "vite preview",
80
79
  "test": "vitest",
81
80
  "test:ui": "vitest --ui",
82
- "lint": "bunx eslint src/ts/**/*.ts --fix",
81
+ "lint": "eslint src/ts/**/*.ts --fix",
83
82
  "coverage": "vitest --coverage",
84
- "docs:dev": "bun x vitepress dev docs",
85
- "docs:build": "bun x vitepress build docs",
86
- "docs:preview": "bun x vitepress preview docs"
83
+ "docs:dev": "pnpm exec vitepress dev docs",
84
+ "docs:build": "pnpm exec vitepress build docs",
85
+ "docs:preview": "pnpm exec vitepress preview docs"
87
86
  },
88
87
  "source": "./src/main.ts",
89
88
  "type": "module",