@fluritheme/four-seasons 0.0.0-stage → 1.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.
- package/CHANGELOG.md +5 -0
- package/LICENSE +21 -0
- package/README.md +103 -2
- package/dist/badge.d.ts +1 -0
- package/dist/four-seasons.d.ts +35 -0
- package/dist/four-seasons.global.js +23 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +400 -0
- package/dist/overlay.d.ts +31 -0
- package/package.json +54 -4
package/CHANGELOG.md
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 František Gejdoš (Fluri, https://fluri.xyz)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,104 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Four Seasons by Fluri
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Petals, fireflies, leaves or snow: whatever season it is. Four Seasons.
|
|
4
|
+
|
|
5
|
+
**[Live demo →](https://fluri.xyz/four-seasons/)** · [All Fluri themes](https://fluri.xyz/themes/) · No-code install for WordPress, Shopify, Wix & more at [fluri.xyz](https://fluri.xyz/four-seasons/)
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
- Zero dependencies, about 10 KB minified
|
|
10
|
+
- Set it once: it changes on the 1st of March, June, September and December
|
|
11
|
+
- The visitor's half of the world comes from their time zone, so Sydney gets summer in December
|
|
12
|
+
- Petals and leaves turn over as they fall; fireflies wander and pulse
|
|
13
|
+
- On light pages, snow and fireflies switch to tints that show
|
|
14
|
+
- One canvas that ignores clicks, paused in background tabs; off for `prefers-reduced-motion`
|
|
15
|
+
- Works with plain HTML, React, Vue, Svelte, Astro, Next.js and anything else
|
|
16
|
+
- TypeScript types included
|
|
17
|
+
|
|
18
|
+
## Quick start: one line of HTML
|
|
19
|
+
|
|
20
|
+
Paste this before `</body>`:
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<script src="https://cdn.jsdelivr.net/npm/@fluritheme/four-seasons@1/dist/four-seasons.global.js" data-auto></script>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Pass options as JSON:
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
<script src="https://cdn.jsdelivr.net/npm/@fluritheme/four-seasons@1/dist/four-seasons.global.js" data-auto data-options='{"season":"auto"}'></script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The running effect is available as `window.FluriFourSeasons.instance`.
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## Install with npm
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
npm install @fluritheme/four-seasons
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { createFourSeasons, seasonOn, hemisphereOf } from "@fluritheme/four-seasons";
|
|
43
|
+
|
|
44
|
+
const seasons = createFourSeasons({
|
|
45
|
+
season: "auto", // or "spring", "summer", "autumn", "winter"
|
|
46
|
+
hemisphere: "auto", // from the visitor's time zone
|
|
47
|
+
density: 1,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
seasons.setSeason("autumn");
|
|
51
|
+
seasonOn(new Date(), hemisphereOf()); // "winter"
|
|
52
|
+
|
|
53
|
+
// When leaving the page or unmounting a component:
|
|
54
|
+
seasons.destroy();
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### React
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import { useEffect } from "react";
|
|
61
|
+
import { createFourSeasons } from "@fluritheme/four-seasons";
|
|
62
|
+
|
|
63
|
+
export function FourSeasons() {
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
const effect = createFourSeasons();
|
|
66
|
+
return () => effect.destroy();
|
|
67
|
+
}, []);
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Options
|
|
73
|
+
|
|
74
|
+
| Option | What it does | Default |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `season` | "auto", "spring", "summer", "autumn" or "winter" | `"auto"` |
|
|
77
|
+
| `hemisphere` | "auto", "north" or "south" | `"auto"` |
|
|
78
|
+
| `density` | How much falls, 0.2–2 | `1` |
|
|
79
|
+
| `wind` | Sideways drift, -1 to 1 | `0.3` |
|
|
80
|
+
| `root` | Limit to one element | document |
|
|
81
|
+
| `zIndex` | Stacking order | `2147483000` |
|
|
82
|
+
|
|
83
|
+
## Methods
|
|
84
|
+
|
|
85
|
+
- `setSeason(season)`
|
|
86
|
+
- `pause()`
|
|
87
|
+
- `resume()`
|
|
88
|
+
- `update(options)`
|
|
89
|
+
- `getState()`
|
|
90
|
+
- `destroy()`
|
|
91
|
+
|
|
92
|
+
## Great for
|
|
93
|
+
|
|
94
|
+
- Shops and cafés that follow the seasons
|
|
95
|
+
- Gardens, florists, travel and outdoor brands
|
|
96
|
+
- A seasonal touch you set once and never change
|
|
97
|
+
|
|
98
|
+
## No code? Use Fluri
|
|
99
|
+
|
|
100
|
+
Don’t want to touch code? [Fluri](https://fluri.xyz/four-seasons/) installs Four Seasons on WordPress, Shopify, Webflow, Wix, Squarespace and Framer with one snippet, with live settings and a dashboard. There are more than a dozen animated themes, from a pet dragon to a koi pond. [See them all →](https://fluri.xyz/themes/)
|
|
101
|
+
|
|
102
|
+
## License
|
|
103
|
+
|
|
104
|
+
MIT © František Gejdoš · [fluri.xyz](https://fluri.xyz)
|
package/dist/badge.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function showFluriBadge(slug: string): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type Season = "spring" | "summer" | "autumn" | "winter";
|
|
2
|
+
export type Hemisphere = "north" | "south";
|
|
3
|
+
export interface FourSeasonsOptions {
|
|
4
|
+
/** Limit it to one element. Default: the whole page. */
|
|
5
|
+
root?: HTMLElement;
|
|
6
|
+
/** Which season. Default "auto" (from the date). */
|
|
7
|
+
season?: Season | "auto";
|
|
8
|
+
/** Which half of the world. Default "auto" (from the visitor's time zone). */
|
|
9
|
+
hemisphere?: Hemisphere | "auto";
|
|
10
|
+
/** How much falls, 0.2–2. Default 1. */
|
|
11
|
+
density?: number;
|
|
12
|
+
/** Sideways drift, -1 to 1. Default 0.3. */
|
|
13
|
+
wind?: number;
|
|
14
|
+
/** Stacking order. Default 2147483000. */
|
|
15
|
+
zIndex?: number;
|
|
16
|
+
}
|
|
17
|
+
export interface FourSeasonsState {
|
|
18
|
+
season: Season;
|
|
19
|
+
hemisphere: Hemisphere;
|
|
20
|
+
count: number;
|
|
21
|
+
paused: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** The visitor's half of the world, guessed from their time zone. */
|
|
24
|
+
export declare function hemisphereOf(timeZone?: string): Hemisphere;
|
|
25
|
+
/** The season on a date (seasons start on the 1st of March, June, September and December). */
|
|
26
|
+
export declare function seasonOn(date: Date, hemisphere: Hemisphere): Season;
|
|
27
|
+
export declare function createFourSeasons(options?: FourSeasonsOptions): {
|
|
28
|
+
/** Switches season now ("auto" goes back to the calendar). */
|
|
29
|
+
setSeason(next: Season | "auto"): void;
|
|
30
|
+
update(next: Partial<FourSeasonsOptions>): void;
|
|
31
|
+
pause(): void;
|
|
32
|
+
resume(): void;
|
|
33
|
+
destroy(): void;
|
|
34
|
+
getState(): FourSeasonsState;
|
|
35
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*! @fluritheme/four-seasons v1.0.0 | MIT | https://fluri.xyz/four-seasons/ */
|
|
2
|
+
(()=>{function A(o={}){var n,h,b,S;let t=document.createElement("canvas");t.setAttribute("aria-hidden","true"),t.dataset.fluri="overlay",Object.assign(t.style,{position:o.root?"absolute":"fixed",inset:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:String((n=o.zIndex)!=null?n:2147483e3),contain:"strict"});let i=(h=o.root)!=null?h:document.body;o.root&&getComputedStyle(o.root).position==="static"&&(o.root.style.position="relative"),i.append(t);let r=t.getContext("2d"),d=matchMedia("(prefers-reduced-motion: reduce)").matches,s=0,a=0,m=!1,p=!1,y=null,v=1e3/((b=o.maxFPS)!=null?b:60)-1,x={canvas:t,ctx:r,width:0,height:0,reduced:d,origin(){if(!o.root)return{x:0,y:0};let c=o.root.getBoundingClientRect();return{x:c.left,y:c.top}},start(c){y=c,f(performance.now())},pause(){m=!0,cancelAnimationFrame(s)},resume(){p||!m||(m=!1,a=performance.now(),f(a))},destroy(){p=!0,cancelAnimationFrame(s),l.disconnect(),removeEventListener("resize",w),document.removeEventListener("visibilitychange",u),t.remove()}};function w(){let c=Math.min(2,devicePixelRatio||1),e=o.root?o.root.clientWidth:innerWidth,M=o.root?o.root.clientHeight:innerHeight;x.width=e,x.height=M,t.width=Math.round(e*c),t.height=Math.round(M*c),r.setTransform(c,0,0,c,0,0)}function f(c){if(m||p||(s=requestAnimationFrame(f),c-a<v))return;let e=Math.min(.05,(c-(a||c))/1e3);a=c,y==null||y(e,c/1e3)}function u(){document.hidden?cancelAnimationFrame(s):!m&&!p&&(a=performance.now(),f(a))}let l=new ResizeObserver(w);return l.observe((S=o.root)!=null?S:document.documentElement),addEventListener("resize",w),document.addEventListener("visibilitychange",u),w(),x}var g=(o,t)=>o+Math.random()*(t-o),E=(o,t,i)=>Math.max(t,Math.min(i,o));var R=/^(Australia\/|Pacific\/(Auckland|Chatham|Fiji|Tongatapu|Apia|Noumea|Port_Moresby)|Antarctica\/|America\/(Sao_Paulo|Argentina|Buenos_Aires|Santiago|Montevideo|Asuncion|La_Paz|Lima|Punta_Arenas)|Africa\/(Johannesburg|Maputo|Harare|Windhoek|Gaborone|Lusaka|Maseru|Mbabane)|Indian\/(Mauritius|Reunion|Antananarivo))/;function I(o){let t=o;if(t===void 0)try{t=Intl.DateTimeFormat().resolvedOptions().timeZone}catch{t=""}return R.test(t||"")?"south":"north"}function W(o,t){let i=["winter","spring","summer","autumn"],r=Math.floor((o.getMonth()+1)%12/3);return i[t==="north"?r:(r+2)%4]}var B={spring:["#ffc2d9","#ffa8c7","#ffe1ec","#f78fb3"],summer:["#ffe066","#ffd43b","#c0eb75"],autumn:["#e8590c","#f08c00","#c92a2a","#e67700","#a61e4d"],winter:["#ffffff","#e7f5ff","#d0ebff"]};function T(o={}){let t={season:"auto",hemisphere:"auto",density:1,wind:.3,zIndex:2147483e3,...o},r=matchMedia("(prefers-reduced-motion: reduce)").matches?null:A({root:t.root,zIndex:t.zIndex}),d=[],s="winter",a="north",m=!1,p=!1;function y(){var h,b,S,c;a=t.hemisphere==="auto"?I():t.hemisphere,s=t.season==="auto"?W(new Date,a):t.season;let l=(S=(b=getComputedStyle((h=t.root)!=null?h:document.body).backgroundColor.match(/[\d.]+/g))==null?void 0:b.map(Number))!=null?S:[255,255,255,0];p=((c=l[3])!=null?c:1)<.1||(l[0]*299+l[1]*587+l[2]*114)/1e3>150,x(!0)}function v(u){let l=r.width,n=r.height,h=B[s],b=s==="summer";return{x:g(-.1*l,1.1*l),y:u||b?g(0,n):g(-60,-10),s:s==="winter"?g(1.5,4.5):b?g(1.6,3):g(7,14),v:s==="winter"?g(30,80):b?g(8,22):g(35,85),r:g(0,6.28),vr:g(-1.6,1.6),seed:g(0,100),color:h[Math.random()*h.length|0]}}function x(u=!1){if(!r)return;let n=Math.round((s==="summer"?26:s==="winter"?90:34)*E(t.density,.2,2)*E(r.width*r.height/9e5,.35,2));for(u&&(d=[]);d.length<n;)d.push(v(!0));d.length=n}function w(u,l){if(!r)return;let{ctx:n,width:h,height:b}=r;n.clearRect(0,0,h,b);let S=E(t.wind,-1,1)*40;for(let c=0;c<d.length;c++){let e=d[c];if(s==="summer"){e.x+=Math.cos(l*.5+e.seed)*e.v*u,e.y+=Math.sin(l*.7+e.seed*1.3)*e.v*u;let F=.5+.5*Math.sin(l*1.6+e.seed*3);n.globalAlpha=.15+F*.85,n.fillStyle=p?"#d9a400":e.color,n.shadowColor=p?"#f2b600":e.color,n.shadowBlur=12*F,n.beginPath(),n.arc(e.x,e.y,e.s,0,6.2832),n.fill(),n.shadowBlur=0,(e.x<-40||e.x>h+40||e.y<-40||e.y>b+40)&&(d[c]=v(!0));continue}let M=Math.sin(l*1.3+e.seed)*(s==="winter"?14:34);if(e.y+=e.v*u,e.x+=(S+M)*u,e.r+=e.vr*u,e.y>b+20||e.x<-.15*h||e.x>1.15*h){d[c]=v(!1);continue}if(n.globalAlpha=s==="winter"?.9:.92,s==="winter"){n.fillStyle=p?"#a9c4dc":e.color,n.beginPath(),n.arc(e.x,e.y,e.s,0,6.2832),n.fill();continue}n.save(),n.translate(e.x,e.y),n.rotate(e.r),n.scale(1,.35+.65*Math.abs(Math.cos(l*1.4+e.seed))),n.fillStyle=e.color,n.beginPath(),s==="spring"?(n.moveTo(0,-e.s),n.bezierCurveTo(e.s*.9,-e.s*.5,e.s*.7,e.s*.8,0,e.s),n.bezierCurveTo(-e.s*.7,e.s*.8,-e.s*.9,-e.s*.5,0,-e.s)):(n.moveTo(0,-e.s*1.2),n.quadraticCurveTo(e.s,-e.s*.2,0,e.s*1.1),n.quadraticCurveTo(-e.s,-e.s*.2,0,-e.s*1.2)),n.fill(),s==="autumn"&&(n.strokeStyle="rgba(60,20,0,.35)",n.lineWidth=1,n.beginPath(),n.moveTo(0,-e.s),n.lineTo(0,e.s*1.5),n.stroke()),n.restore()}n.globalAlpha=1}y(),r==null||r.start(w);let f=()=>x();return addEventListener("resize",f),{setSeason(u){t.season=u,y()},update(u){Object.assign(t,u),y()},pause(){m=!0,r==null||r.pause()},resume(){m=!1,r==null||r.resume()},destroy(){removeEventListener("resize",f),r==null||r.destroy(),d=[]},getState(){return{season:s,hemisphere:a,count:d.length,paused:m}}}}var D="https://fluri.xyz/themes/",z=!1,_=`
|
|
3
|
+
:host{all:initial}
|
|
4
|
+
a{position:fixed;z-index:2147483600;display:inline-flex;align-items:center;gap:9px;padding:8px 10px 8px 9px;max-width:calc(100vw - 32px);
|
|
5
|
+
border-radius:999px;background:rgba(22,18,36,.88);-webkit-backdrop-filter:blur(12px) saturate(1.4);backdrop-filter:blur(12px) saturate(1.4);
|
|
6
|
+
border:1px solid rgba(255,255,255,.14);box-shadow:0 10px 30px rgba(10,6,30,.28),0 1px 0 rgba(255,255,255,.08) inset;
|
|
7
|
+
color:#fff;font:600 13px/1.2 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;letter-spacing:.01em;text-decoration:none;
|
|
8
|
+
opacity:0;transform:translateY(10px) scale(.98);transition:opacity .35s ease,transform .35s cubic-bezier(.2,.8,.2,1),background .2s}
|
|
9
|
+
a.in{opacity:1;transform:none}
|
|
10
|
+
a:hover{background:rgba(32,26,52,.96)}
|
|
11
|
+
a:focus-visible{outline:3px solid #a78bfa;outline-offset:3px}
|
|
12
|
+
.star{flex:none;display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:conic-gradient(from 210deg,#8b5cf6,#ec4899,#f59e0b,#8b5cf6);box-shadow:0 0 12px rgba(167,139,250,.55)}
|
|
13
|
+
.star svg{width:12px;height:12px;fill:#fff}
|
|
14
|
+
.txt{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
15
|
+
.txt b{font-weight:700;background:linear-gradient(90deg,#c4b5fd,#fbcfe8);-webkit-background-clip:text;background-clip:text;color:transparent}
|
|
16
|
+
.arrow{flex:none;transition:transform .2s}
|
|
17
|
+
a:hover .arrow{transform:translateX(2px)}
|
|
18
|
+
button{all:unset;flex:none;display:grid;place-items:center;width:20px;height:20px;margin-left:2px;border-radius:50%;color:rgba(255,255,255,.7);font:600 14px/1 system-ui;cursor:pointer}
|
|
19
|
+
button:hover{background:rgba(255,255,255,.14);color:#fff}
|
|
20
|
+
button:focus-visible{outline:2px solid #a78bfa}
|
|
21
|
+
@media (max-width:480px){a{font-size:12px;padding:7px 8px 7px 7px;gap:7px}.star{width:20px;height:20px}}
|
|
22
|
+
@media (prefers-reduced-motion:reduce){a{transition:opacity .2s}a,a.in{transform:none}}
|
|
23
|
+
`,O=["bottom-left","bottom-center","bottom-right","top-right"];function H(o,t){let i=o.style;i.top=i.bottom=i.left=i.right=i.transform="",t.startsWith("bottom")?i.bottom="16px":i.top="16px",t.endsWith("left")?i.left="16px":t.endsWith("right")?i.right="16px":(i.left="50%",i.marginLeft=-(o.offsetWidth/2)+"px"),t!=="bottom-center"&&(i.marginLeft="")}function q(o,t){let i=[[t.left+4,t.top+4],[t.right-4,t.top+4],[t.left+4,t.bottom-4],[t.right-4,t.bottom-4],[t.left+t.width/2,t.top+t.height/2]];for(let[r,d]of i)for(let s of document.elementsFromPoint(r,d))if(!(s===o||s===document.body||s===document.documentElement))for(let a=s;a&&a!==document.body;a=a.parentElement){let m=getComputedStyle(a).position;if(m==="fixed"||m==="sticky")return!0}return!1}function N(){try{let o=location.hostname;if(/(^|\.)fluri\.xyz$/.test(o)||/(^|\.)(codepen\.io|cdpn\.io)$/.test(o)||navigator.webdriver||/HeadlessChrome|Playwright|Puppeteer/i.test(navigator.userAgent))return!0}catch{}return!1}function k(o){if(z||typeof document=="undefined"||typeof window=="undefined"||N())return;z=!0;let t=()=>{let r=document.createElement("fluri-badge");r.setAttribute("style","all:initial");let d=r.attachShadow({mode:"open"}),s=document.createElement("style");s.textContent=_;let a=document.createElement("a");a.href=D+"?utm_source=npm&utm_medium=badge&utm_campaign="+encodeURIComponent(o),a.target="_blank",a.rel="noopener",a.setAttribute("aria-label","Unlock all themes on fluri.xyz (opens in a new tab)");let m=document.createElement("span");m.className="star",m.innerHTML='<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l2.4 6.6L21 11l-6.6 2.4L12 20l-2.4-6.6L3 11l6.6-2.4z"/></svg>';let p=document.createElement("span");p.className="txt",p.append("Unlock all themes on ");let y=document.createElement("b");y.textContent="fluri.xyz",p.append(y);let v=document.createElement("span");v.className="arrow",v.setAttribute("aria-hidden","true"),v.textContent="\u2192";let x=document.createElement("button");x.type="button",x.setAttribute("aria-label","Hide"),x.textContent="\xD7",x.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),a.classList.remove("in"),setTimeout(()=>r.remove(),350)}),a.append(m,p,v,x),d.append(s,a),document.body.appendChild(r);let w=O[0];for(let f of O)if(H(a,f),!q(r,a.getBoundingClientRect())){w=f;break}H(a,w),requestAnimationFrame(()=>requestAnimationFrame(()=>a.classList.add("in")))},i=()=>setTimeout(t,1200);document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i,{once:!0}):i()}function C(...o){return k("four-seasons"),T(...o)}var P={createFourSeasons:C};window.FluriFourSeasons=P;var L=document.currentScript;if(L&&L.hasAttribute("data-auto")){let o=()=>{let t={};try{t=JSON.parse(L.getAttribute("data-options")||"{}")}catch{}P.instance=C(t)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",o,{once:!0}):o()}})();
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from "./four-seasons.js";
|
|
2
|
+
import { createFourSeasons as base } from "./four-seasons.js";
|
|
3
|
+
/** createFourSeasons from Fluri. Also shows a small "Unlock all themes on fluri.xyz" badge. */
|
|
4
|
+
export declare function createFourSeasons(...args: Parameters<typeof base>): ReturnType<typeof base>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
/*! @fluritheme/four-seasons v1.0.0 | MIT | https://fluri.xyz/four-seasons/ */
|
|
2
|
+
|
|
3
|
+
// packages/four-seasons/src/overlay.ts
|
|
4
|
+
function createOverlay(o = {}) {
|
|
5
|
+
const canvas = document.createElement("canvas");
|
|
6
|
+
canvas.setAttribute("aria-hidden", "true");
|
|
7
|
+
canvas.dataset.fluri = "overlay";
|
|
8
|
+
Object.assign(canvas.style, {
|
|
9
|
+
position: o.root ? "absolute" : "fixed",
|
|
10
|
+
inset: "0",
|
|
11
|
+
width: "100%",
|
|
12
|
+
height: "100%",
|
|
13
|
+
pointerEvents: "none",
|
|
14
|
+
zIndex: String(o.zIndex ?? 2147483e3),
|
|
15
|
+
contain: "strict"
|
|
16
|
+
});
|
|
17
|
+
const host = o.root ?? document.body;
|
|
18
|
+
if (o.root && getComputedStyle(o.root).position === "static")
|
|
19
|
+
o.root.style.position = "relative";
|
|
20
|
+
host.append(canvas);
|
|
21
|
+
const ctx = canvas.getContext("2d");
|
|
22
|
+
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
23
|
+
let raf = 0, last = 0, paused = false, destroyed = false, frame = null;
|
|
24
|
+
const minStep = 1e3 / (o.maxFPS ?? 60) - 1;
|
|
25
|
+
const overlay = {
|
|
26
|
+
canvas,
|
|
27
|
+
ctx,
|
|
28
|
+
width: 0,
|
|
29
|
+
height: 0,
|
|
30
|
+
reduced,
|
|
31
|
+
origin() {
|
|
32
|
+
if (!o.root) return { x: 0, y: 0 };
|
|
33
|
+
const r = o.root.getBoundingClientRect();
|
|
34
|
+
return { x: r.left, y: r.top };
|
|
35
|
+
},
|
|
36
|
+
start(f) {
|
|
37
|
+
frame = f;
|
|
38
|
+
loop(performance.now());
|
|
39
|
+
},
|
|
40
|
+
pause() {
|
|
41
|
+
paused = true;
|
|
42
|
+
cancelAnimationFrame(raf);
|
|
43
|
+
},
|
|
44
|
+
resume() {
|
|
45
|
+
if (destroyed || !paused) return;
|
|
46
|
+
paused = false;
|
|
47
|
+
last = performance.now();
|
|
48
|
+
loop(last);
|
|
49
|
+
},
|
|
50
|
+
destroy() {
|
|
51
|
+
destroyed = true;
|
|
52
|
+
cancelAnimationFrame(raf);
|
|
53
|
+
ro.disconnect();
|
|
54
|
+
removeEventListener("resize", size);
|
|
55
|
+
document.removeEventListener("visibilitychange", vis);
|
|
56
|
+
canvas.remove();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
function size() {
|
|
60
|
+
const dpr = Math.min(2, devicePixelRatio || 1);
|
|
61
|
+
const w = o.root ? o.root.clientWidth : innerWidth;
|
|
62
|
+
const h = o.root ? o.root.clientHeight : innerHeight;
|
|
63
|
+
overlay.width = w;
|
|
64
|
+
overlay.height = h;
|
|
65
|
+
canvas.width = Math.round(w * dpr);
|
|
66
|
+
canvas.height = Math.round(h * dpr);
|
|
67
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
68
|
+
}
|
|
69
|
+
function loop(t) {
|
|
70
|
+
if (paused || destroyed) return;
|
|
71
|
+
raf = requestAnimationFrame(loop);
|
|
72
|
+
if (t - last < minStep) return;
|
|
73
|
+
const dt = Math.min(0.05, (t - (last || t)) / 1e3);
|
|
74
|
+
last = t;
|
|
75
|
+
frame?.(dt, t / 1e3);
|
|
76
|
+
}
|
|
77
|
+
function vis() {
|
|
78
|
+
if (document.hidden) cancelAnimationFrame(raf);
|
|
79
|
+
else if (!paused && !destroyed) {
|
|
80
|
+
last = performance.now();
|
|
81
|
+
loop(last);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const ro = new ResizeObserver(size);
|
|
85
|
+
ro.observe(o.root ?? document.documentElement);
|
|
86
|
+
addEventListener("resize", size);
|
|
87
|
+
document.addEventListener("visibilitychange", vis);
|
|
88
|
+
size();
|
|
89
|
+
return overlay;
|
|
90
|
+
}
|
|
91
|
+
var rand = (a, b) => a + Math.random() * (b - a);
|
|
92
|
+
var clamp = (v, a, b) => Math.max(a, Math.min(b, v));
|
|
93
|
+
|
|
94
|
+
// packages/four-seasons/src/four-seasons.ts
|
|
95
|
+
var SOUTH = /^(Australia\/|Pacific\/(Auckland|Chatham|Fiji|Tongatapu|Apia|Noumea|Port_Moresby)|Antarctica\/|America\/(Sao_Paulo|Argentina|Buenos_Aires|Santiago|Montevideo|Asuncion|La_Paz|Lima|Punta_Arenas)|Africa\/(Johannesburg|Maputo|Harare|Windhoek|Gaborone|Lusaka|Maseru|Mbabane)|Indian\/(Mauritius|Reunion|Antananarivo))/;
|
|
96
|
+
function hemisphereOf(timeZone) {
|
|
97
|
+
let tz = timeZone;
|
|
98
|
+
if (tz === void 0)
|
|
99
|
+
try {
|
|
100
|
+
tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
101
|
+
} catch {
|
|
102
|
+
tz = "";
|
|
103
|
+
}
|
|
104
|
+
return SOUTH.test(tz || "") ? "south" : "north";
|
|
105
|
+
}
|
|
106
|
+
function seasonOn(date, hemisphere) {
|
|
107
|
+
const north = ["winter", "spring", "summer", "autumn"];
|
|
108
|
+
const i = Math.floor((date.getMonth() + 1) % 12 / 3);
|
|
109
|
+
return north[hemisphere === "north" ? i : (i + 2) % 4];
|
|
110
|
+
}
|
|
111
|
+
var COLORS = {
|
|
112
|
+
spring: ["#ffc2d9", "#ffa8c7", "#ffe1ec", "#f78fb3"],
|
|
113
|
+
summer: ["#ffe066", "#ffd43b", "#c0eb75"],
|
|
114
|
+
autumn: ["#e8590c", "#f08c00", "#c92a2a", "#e67700", "#a61e4d"],
|
|
115
|
+
winter: ["#ffffff", "#e7f5ff", "#d0ebff"]
|
|
116
|
+
};
|
|
117
|
+
function createFourSeasons(options = {}) {
|
|
118
|
+
const o = {
|
|
119
|
+
season: "auto",
|
|
120
|
+
hemisphere: "auto",
|
|
121
|
+
density: 1,
|
|
122
|
+
wind: 0.3,
|
|
123
|
+
zIndex: 2147483e3,
|
|
124
|
+
...options
|
|
125
|
+
};
|
|
126
|
+
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
127
|
+
const ov = reduced ? null : createOverlay({ root: o.root, zIndex: o.zIndex });
|
|
128
|
+
let bits = [];
|
|
129
|
+
let season = "winter";
|
|
130
|
+
let hemi = "north";
|
|
131
|
+
let paused = false;
|
|
132
|
+
let light = false;
|
|
133
|
+
function resolve() {
|
|
134
|
+
hemi = o.hemisphere === "auto" ? hemisphereOf() : o.hemisphere;
|
|
135
|
+
season = o.season === "auto" ? seasonOn(/* @__PURE__ */ new Date(), hemi) : o.season;
|
|
136
|
+
const bg = getComputedStyle(o.root ?? document.body).backgroundColor;
|
|
137
|
+
const m = bg.match(/[\d.]+/g)?.map(Number) ?? [255, 255, 255, 0];
|
|
138
|
+
const alpha = m[3] ?? 1;
|
|
139
|
+
light = alpha < 0.1 || (m[0] * 299 + m[1] * 587 + m[2] * 114) / 1e3 > 150;
|
|
140
|
+
fill(true);
|
|
141
|
+
}
|
|
142
|
+
function spawn(anywhere) {
|
|
143
|
+
const W = ov.width, H = ov.height;
|
|
144
|
+
const list = COLORS[season];
|
|
145
|
+
const fly = season === "summer";
|
|
146
|
+
return {
|
|
147
|
+
x: rand(-0.1 * W, 1.1 * W),
|
|
148
|
+
y: anywhere || fly ? rand(0, H) : rand(-60, -10),
|
|
149
|
+
s: season === "winter" ? rand(1.5, 4.5) : fly ? rand(1.6, 3) : rand(7, 14),
|
|
150
|
+
v: season === "winter" ? rand(30, 80) : fly ? rand(8, 22) : rand(35, 85),
|
|
151
|
+
r: rand(0, 6.28),
|
|
152
|
+
vr: rand(-1.6, 1.6),
|
|
153
|
+
seed: rand(0, 100),
|
|
154
|
+
color: list[Math.random() * list.length | 0]
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
function fill(reset = false) {
|
|
158
|
+
if (!ov) return;
|
|
159
|
+
const base = season === "summer" ? 26 : season === "winter" ? 90 : 34;
|
|
160
|
+
const want = Math.round(
|
|
161
|
+
base * clamp(o.density, 0.2, 2) * clamp(ov.width * ov.height / 9e5, 0.35, 2)
|
|
162
|
+
);
|
|
163
|
+
if (reset) bits = [];
|
|
164
|
+
while (bits.length < want) bits.push(spawn(true));
|
|
165
|
+
bits.length = want;
|
|
166
|
+
}
|
|
167
|
+
function frame(dt, t) {
|
|
168
|
+
if (!ov) return;
|
|
169
|
+
const { ctx, width: W, height: H } = ov;
|
|
170
|
+
ctx.clearRect(0, 0, W, H);
|
|
171
|
+
const wind = clamp(o.wind, -1, 1) * 40;
|
|
172
|
+
for (let i = 0; i < bits.length; i++) {
|
|
173
|
+
const b = bits[i];
|
|
174
|
+
if (season === "summer") {
|
|
175
|
+
b.x += Math.cos(t * 0.5 + b.seed) * b.v * dt;
|
|
176
|
+
b.y += Math.sin(t * 0.7 + b.seed * 1.3) * b.v * dt;
|
|
177
|
+
const glow = 0.5 + 0.5 * Math.sin(t * 1.6 + b.seed * 3);
|
|
178
|
+
ctx.globalAlpha = 0.15 + glow * 0.85;
|
|
179
|
+
ctx.fillStyle = light ? "#d9a400" : b.color;
|
|
180
|
+
ctx.shadowColor = light ? "#f2b600" : b.color;
|
|
181
|
+
ctx.shadowBlur = 12 * glow;
|
|
182
|
+
ctx.beginPath();
|
|
183
|
+
ctx.arc(b.x, b.y, b.s, 0, 6.2832);
|
|
184
|
+
ctx.fill();
|
|
185
|
+
ctx.shadowBlur = 0;
|
|
186
|
+
if (b.x < -40 || b.x > W + 40 || b.y < -40 || b.y > H + 40) bits[i] = spawn(true);
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const sway = Math.sin(t * 1.3 + b.seed) * (season === "winter" ? 14 : 34);
|
|
190
|
+
b.y += b.v * dt;
|
|
191
|
+
b.x += (wind + sway) * dt;
|
|
192
|
+
b.r += b.vr * dt;
|
|
193
|
+
if (b.y > H + 20 || b.x < -0.15 * W || b.x > 1.15 * W) {
|
|
194
|
+
bits[i] = spawn(false);
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
ctx.globalAlpha = season === "winter" ? 0.9 : 0.92;
|
|
198
|
+
if (season === "winter") {
|
|
199
|
+
ctx.fillStyle = light ? "#a9c4dc" : b.color;
|
|
200
|
+
ctx.beginPath();
|
|
201
|
+
ctx.arc(b.x, b.y, b.s, 0, 6.2832);
|
|
202
|
+
ctx.fill();
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
ctx.save();
|
|
206
|
+
ctx.translate(b.x, b.y);
|
|
207
|
+
ctx.rotate(b.r);
|
|
208
|
+
ctx.scale(1, 0.35 + 0.65 * Math.abs(Math.cos(t * 1.4 + b.seed)));
|
|
209
|
+
ctx.fillStyle = b.color;
|
|
210
|
+
ctx.beginPath();
|
|
211
|
+
if (season === "spring") {
|
|
212
|
+
ctx.moveTo(0, -b.s);
|
|
213
|
+
ctx.bezierCurveTo(b.s * 0.9, -b.s * 0.5, b.s * 0.7, b.s * 0.8, 0, b.s);
|
|
214
|
+
ctx.bezierCurveTo(-b.s * 0.7, b.s * 0.8, -b.s * 0.9, -b.s * 0.5, 0, -b.s);
|
|
215
|
+
} else {
|
|
216
|
+
ctx.moveTo(0, -b.s * 1.2);
|
|
217
|
+
ctx.quadraticCurveTo(b.s, -b.s * 0.2, 0, b.s * 1.1);
|
|
218
|
+
ctx.quadraticCurveTo(-b.s, -b.s * 0.2, 0, -b.s * 1.2);
|
|
219
|
+
}
|
|
220
|
+
ctx.fill();
|
|
221
|
+
if (season === "autumn") {
|
|
222
|
+
ctx.strokeStyle = "rgba(60,20,0,.35)";
|
|
223
|
+
ctx.lineWidth = 1;
|
|
224
|
+
ctx.beginPath();
|
|
225
|
+
ctx.moveTo(0, -b.s);
|
|
226
|
+
ctx.lineTo(0, b.s * 1.5);
|
|
227
|
+
ctx.stroke();
|
|
228
|
+
}
|
|
229
|
+
ctx.restore();
|
|
230
|
+
}
|
|
231
|
+
ctx.globalAlpha = 1;
|
|
232
|
+
}
|
|
233
|
+
resolve();
|
|
234
|
+
ov?.start(frame);
|
|
235
|
+
const onResize = () => fill();
|
|
236
|
+
addEventListener("resize", onResize);
|
|
237
|
+
return {
|
|
238
|
+
/** Switches season now ("auto" goes back to the calendar). */
|
|
239
|
+
setSeason(next) {
|
|
240
|
+
o.season = next;
|
|
241
|
+
resolve();
|
|
242
|
+
},
|
|
243
|
+
update(next) {
|
|
244
|
+
Object.assign(o, next);
|
|
245
|
+
resolve();
|
|
246
|
+
},
|
|
247
|
+
pause() {
|
|
248
|
+
paused = true;
|
|
249
|
+
ov?.pause();
|
|
250
|
+
},
|
|
251
|
+
resume() {
|
|
252
|
+
paused = false;
|
|
253
|
+
ov?.resume();
|
|
254
|
+
},
|
|
255
|
+
destroy() {
|
|
256
|
+
removeEventListener("resize", onResize);
|
|
257
|
+
ov?.destroy();
|
|
258
|
+
bits = [];
|
|
259
|
+
},
|
|
260
|
+
getState() {
|
|
261
|
+
return { season, hemisphere: hemi, count: bits.length, paused };
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// packages/four-seasons/src/badge.ts
|
|
267
|
+
var SITE = "https://fluri.xyz/themes/";
|
|
268
|
+
var shown = false;
|
|
269
|
+
var CSS = `
|
|
270
|
+
:host{all:initial}
|
|
271
|
+
a{position:fixed;z-index:2147483600;display:inline-flex;align-items:center;gap:9px;padding:8px 10px 8px 9px;max-width:calc(100vw - 32px);
|
|
272
|
+
border-radius:999px;background:rgba(22,18,36,.88);-webkit-backdrop-filter:blur(12px) saturate(1.4);backdrop-filter:blur(12px) saturate(1.4);
|
|
273
|
+
border:1px solid rgba(255,255,255,.14);box-shadow:0 10px 30px rgba(10,6,30,.28),0 1px 0 rgba(255,255,255,.08) inset;
|
|
274
|
+
color:#fff;font:600 13px/1.2 ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;letter-spacing:.01em;text-decoration:none;
|
|
275
|
+
opacity:0;transform:translateY(10px) scale(.98);transition:opacity .35s ease,transform .35s cubic-bezier(.2,.8,.2,1),background .2s}
|
|
276
|
+
a.in{opacity:1;transform:none}
|
|
277
|
+
a:hover{background:rgba(32,26,52,.96)}
|
|
278
|
+
a:focus-visible{outline:3px solid #a78bfa;outline-offset:3px}
|
|
279
|
+
.star{flex:none;display:grid;place-items:center;width:22px;height:22px;border-radius:50%;background:conic-gradient(from 210deg,#8b5cf6,#ec4899,#f59e0b,#8b5cf6);box-shadow:0 0 12px rgba(167,139,250,.55)}
|
|
280
|
+
.star svg{width:12px;height:12px;fill:#fff}
|
|
281
|
+
.txt{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
282
|
+
.txt b{font-weight:700;background:linear-gradient(90deg,#c4b5fd,#fbcfe8);-webkit-background-clip:text;background-clip:text;color:transparent}
|
|
283
|
+
.arrow{flex:none;transition:transform .2s}
|
|
284
|
+
a:hover .arrow{transform:translateX(2px)}
|
|
285
|
+
button{all:unset;flex:none;display:grid;place-items:center;width:20px;height:20px;margin-left:2px;border-radius:50%;color:rgba(255,255,255,.7);font:600 14px/1 system-ui;cursor:pointer}
|
|
286
|
+
button:hover{background:rgba(255,255,255,.14);color:#fff}
|
|
287
|
+
button:focus-visible{outline:2px solid #a78bfa}
|
|
288
|
+
@media (max-width:480px){a{font-size:12px;padding:7px 8px 7px 7px;gap:7px}.star{width:20px;height:20px}}
|
|
289
|
+
@media (prefers-reduced-motion:reduce){a{transition:opacity .2s}a,a.in{transform:none}}
|
|
290
|
+
`;
|
|
291
|
+
var ORDER = ["bottom-left", "bottom-center", "bottom-right", "top-right"];
|
|
292
|
+
function place(a, c) {
|
|
293
|
+
const s = a.style;
|
|
294
|
+
s.top = s.bottom = s.left = s.right = s.transform = "";
|
|
295
|
+
if (c.startsWith("bottom")) s.bottom = "16px";
|
|
296
|
+
else s.top = "16px";
|
|
297
|
+
if (c.endsWith("left")) s.left = "16px";
|
|
298
|
+
else if (c.endsWith("right")) s.right = "16px";
|
|
299
|
+
else {
|
|
300
|
+
s.left = "50%";
|
|
301
|
+
s.marginLeft = -(a.offsetWidth / 2) + "px";
|
|
302
|
+
}
|
|
303
|
+
if (c !== "bottom-center") s.marginLeft = "";
|
|
304
|
+
}
|
|
305
|
+
function taken(host, r) {
|
|
306
|
+
const pts = [
|
|
307
|
+
[r.left + 4, r.top + 4],
|
|
308
|
+
[r.right - 4, r.top + 4],
|
|
309
|
+
[r.left + 4, r.bottom - 4],
|
|
310
|
+
[r.right - 4, r.bottom - 4],
|
|
311
|
+
[r.left + r.width / 2, r.top + r.height / 2]
|
|
312
|
+
];
|
|
313
|
+
for (const [x, y] of pts) {
|
|
314
|
+
for (const el of document.elementsFromPoint(x, y)) {
|
|
315
|
+
if (el === host || el === document.body || el === document.documentElement) continue;
|
|
316
|
+
for (let e = el; e && e !== document.body; e = e.parentElement) {
|
|
317
|
+
const p = getComputedStyle(e).position;
|
|
318
|
+
if (p === "fixed" || p === "sticky") return true;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
function isPreview() {
|
|
325
|
+
try {
|
|
326
|
+
const h = location.hostname;
|
|
327
|
+
if (/(^|\.)fluri\.xyz$/.test(h) || /(^|\.)(codepen\.io|cdpn\.io)$/.test(h)) return true;
|
|
328
|
+
if (navigator.webdriver) return true;
|
|
329
|
+
if (/HeadlessChrome|Playwright|Puppeteer/i.test(navigator.userAgent)) return true;
|
|
330
|
+
} catch {
|
|
331
|
+
}
|
|
332
|
+
return false;
|
|
333
|
+
}
|
|
334
|
+
function showFluriBadge(slug) {
|
|
335
|
+
if (shown || typeof document === "undefined" || typeof window === "undefined") return;
|
|
336
|
+
if (isPreview()) return;
|
|
337
|
+
shown = true;
|
|
338
|
+
const start = () => {
|
|
339
|
+
const host = document.createElement("fluri-badge");
|
|
340
|
+
host.setAttribute("style", "all:initial");
|
|
341
|
+
const root = host.attachShadow({ mode: "open" });
|
|
342
|
+
const style = document.createElement("style");
|
|
343
|
+
style.textContent = CSS;
|
|
344
|
+
const a = document.createElement("a");
|
|
345
|
+
a.href = SITE + "?utm_source=npm&utm_medium=badge&utm_campaign=" + encodeURIComponent(slug);
|
|
346
|
+
a.target = "_blank";
|
|
347
|
+
a.rel = "noopener";
|
|
348
|
+
a.setAttribute("aria-label", "Unlock all themes on fluri.xyz (opens in a new tab)");
|
|
349
|
+
const star = document.createElement("span");
|
|
350
|
+
star.className = "star";
|
|
351
|
+
star.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2l2.4 6.6L21 11l-6.6 2.4L12 20l-2.4-6.6L3 11l6.6-2.4z"/></svg>';
|
|
352
|
+
const txt = document.createElement("span");
|
|
353
|
+
txt.className = "txt";
|
|
354
|
+
txt.append("Unlock all themes on ");
|
|
355
|
+
const b = document.createElement("b");
|
|
356
|
+
b.textContent = "fluri.xyz";
|
|
357
|
+
txt.append(b);
|
|
358
|
+
const arrow = document.createElement("span");
|
|
359
|
+
arrow.className = "arrow";
|
|
360
|
+
arrow.setAttribute("aria-hidden", "true");
|
|
361
|
+
arrow.textContent = "\u2192";
|
|
362
|
+
const close = document.createElement("button");
|
|
363
|
+
close.type = "button";
|
|
364
|
+
close.setAttribute("aria-label", "Hide");
|
|
365
|
+
close.textContent = "\xD7";
|
|
366
|
+
close.addEventListener("click", (e) => {
|
|
367
|
+
e.preventDefault();
|
|
368
|
+
e.stopPropagation();
|
|
369
|
+
a.classList.remove("in");
|
|
370
|
+
setTimeout(() => host.remove(), 350);
|
|
371
|
+
});
|
|
372
|
+
a.append(star, txt, arrow, close);
|
|
373
|
+
root.append(style, a);
|
|
374
|
+
document.body.appendChild(host);
|
|
375
|
+
let corner = ORDER[0];
|
|
376
|
+
for (const c of ORDER) {
|
|
377
|
+
place(a, c);
|
|
378
|
+
if (!taken(host, a.getBoundingClientRect())) {
|
|
379
|
+
corner = c;
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
place(a, corner);
|
|
384
|
+
requestAnimationFrame(() => requestAnimationFrame(() => a.classList.add("in")));
|
|
385
|
+
};
|
|
386
|
+
const later = () => setTimeout(start, 1200);
|
|
387
|
+
if (document.readyState === "loading") document.addEventListener("DOMContentLoaded", later, { once: true });
|
|
388
|
+
else later();
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
// packages/four-seasons/src/index.ts
|
|
392
|
+
function createFourSeasons2(...args) {
|
|
393
|
+
showFluriBadge("four-seasons");
|
|
394
|
+
return createFourSeasons(...args);
|
|
395
|
+
}
|
|
396
|
+
export {
|
|
397
|
+
createFourSeasons2 as createFourSeasons,
|
|
398
|
+
hemisphereOf,
|
|
399
|
+
seasonOn
|
|
400
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface OverlayOptions {
|
|
2
|
+
root?: HTMLElement | undefined;
|
|
3
|
+
zIndex?: number | undefined;
|
|
4
|
+
maxFPS?: number | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface Overlay {
|
|
7
|
+
canvas: HTMLCanvasElement;
|
|
8
|
+
ctx: CanvasRenderingContext2D;
|
|
9
|
+
/** CSS pixel size of the drawing area. */
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
/** Area origin in viewport coordinates (for converting client points). */
|
|
13
|
+
origin(): {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
};
|
|
17
|
+
start(frame: (dt: number, t: number) => void): void;
|
|
18
|
+
pause(): void;
|
|
19
|
+
resume(): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
reduced: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function createOverlay(o?: OverlayOptions): Overlay;
|
|
24
|
+
export declare function surfacesIn(selector: string, root?: HTMLElement, limit?: number): HTMLElement[];
|
|
25
|
+
export declare const rand: (a: number, b: number) => number;
|
|
26
|
+
export declare const clamp: (v: number, a: number, b: number) => number;
|
|
27
|
+
/**
|
|
28
|
+
* Moves an overlay canvas behind the content of its host (the root, or the
|
|
29
|
+
* body) by giving the host its own stacking context. Returns an undo function.
|
|
30
|
+
*/
|
|
31
|
+
export declare function sendBehind(canvas: HTMLCanvasElement, root?: HTMLElement): () => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluritheme/four-seasons",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Four Seasons: seasonal particles that change by themselves. Cherry petals in spring, fireflies in summer, falling leaves in autumn, snow in winter, picked from the date and the visitor's hemisphere. Canvas, zero dependencies.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "František Gejdoš",
|
|
9
|
+
"url": "https://fluri.xyz/founder/",
|
|
10
|
+
"email": "fluritheme@gmail.com"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://fluri.xyz/four-seasons/",
|
|
13
|
+
"keywords": [
|
|
14
|
+
"seasons",
|
|
15
|
+
"seasonal",
|
|
16
|
+
"autumn",
|
|
17
|
+
"fall",
|
|
18
|
+
"leaves",
|
|
19
|
+
"falling-leaves",
|
|
20
|
+
"spring",
|
|
21
|
+
"petals",
|
|
22
|
+
"cherry-blossom",
|
|
23
|
+
"sakura",
|
|
24
|
+
"summer",
|
|
25
|
+
"fireflies",
|
|
26
|
+
"winter",
|
|
27
|
+
"snow",
|
|
28
|
+
"canvas",
|
|
29
|
+
"particles",
|
|
30
|
+
"website-effects",
|
|
31
|
+
"fluri"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": false,
|
|
34
|
+
"files": [
|
|
35
|
+
"dist",
|
|
36
|
+
"README.md",
|
|
37
|
+
"LICENSE",
|
|
38
|
+
"CHANGELOG.md"
|
|
39
|
+
],
|
|
40
|
+
"exports": {
|
|
41
|
+
".": {
|
|
42
|
+
"types": "./dist/index.d.ts",
|
|
43
|
+
"import": "./dist/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./global": "./dist/four-seasons.global.js",
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
48
|
+
"main": "./dist/index.js",
|
|
49
|
+
"module": "./dist/index.js",
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"unpkg": "./dist/four-seasons.global.js",
|
|
52
|
+
"jsdelivr": "./dist/four-seasons.global.js",
|
|
53
|
+
"publishConfig": {
|
|
54
|
+
"access": "public"
|
|
55
|
+
}
|
|
56
|
+
}
|