@mccustomapps/helaui 0.1.7 → 0.1.10
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/README.md +32 -4
- package/dist/index.cjs +6 -6
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -6
- package/dist/rain-background.css +4 -1
- package/package.json +1 -1
- package/src/assets/rain/builtinImages.ts +1 -1
- package/dist/assets/rain/builtinImages.ts +0 -7
package/README.md
CHANGED
|
@@ -207,22 +207,50 @@ const mandala = new SunMandala({ src: '/my-mandala.png' });
|
|
|
207
207
|
|
|
208
208
|
### RainBackground
|
|
209
209
|
|
|
210
|
-
An animated **tropical rain** background with
|
|
210
|
+
An animated **tropical rain** background with falling food/leaf sprites. Built-in artwork is inlined in the JS bundle (no extra files to copy into `public/`).
|
|
211
211
|
|
|
212
212
|
```js
|
|
213
213
|
import { RainBackground } from '@mccustomapps/helaui';
|
|
214
214
|
import '@mccustomapps/helaui/rain-background.css';
|
|
215
215
|
|
|
216
216
|
const rain = new RainBackground();
|
|
217
|
-
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
**Next.js (App Router)** — use a Client Component. `RainBackground` already mounts itself on `document.body`; do not insert `rain.element` a second time.
|
|
220
|
+
|
|
221
|
+
```tsx
|
|
222
|
+
'use client';
|
|
223
|
+
|
|
224
|
+
import { useEffect } from 'react';
|
|
225
|
+
import { RainBackground } from '@mccustomapps/helaui';
|
|
226
|
+
import '@mccustomapps/helaui/rain-background.css';
|
|
227
|
+
|
|
228
|
+
export function HelaRain() {
|
|
229
|
+
useEffect(() => {
|
|
230
|
+
const rain = new RainBackground();
|
|
231
|
+
return () => rain.destroy();
|
|
232
|
+
}, []);
|
|
233
|
+
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
218
236
|
```
|
|
219
237
|
|
|
220
238
|
**Options — `RainBackgroundOptions`**
|
|
221
239
|
|
|
222
240
|
| Option | Type | Default | Description |
|
|
223
241
|
|---|---|---|---|
|
|
224
|
-
| `images` | `string[]` | built-in
|
|
225
|
-
| `
|
|
242
|
+
| `images` | `string[]` | built-in artwork | Image URLs |
|
|
243
|
+
| `density` | `number` | `28` | Number of particles |
|
|
244
|
+
| `minSize` / `maxSize` | `number` | `28` | Particle width in pixels |
|
|
245
|
+
| `minDuration` / `maxDuration` | `number` | `8` / `18` | Fall duration in seconds |
|
|
246
|
+
| `target` | `HTMLElement` | `document.body` | Mount container |
|
|
247
|
+
| `zIndex` | `number` | `0` | Stacking order |
|
|
248
|
+
|
|
249
|
+
```js
|
|
250
|
+
new RainBackground({
|
|
251
|
+
images: ['/rain/fritter.png', '/rain/leaf.png'],
|
|
252
|
+
});
|
|
253
|
+
```
|
|
226
254
|
|
|
227
255
|
**Helpers**
|
|
228
256
|
|
package/dist/index.cjs
CHANGED
|
@@ -404,6 +404,9 @@ function randomBetween(min, max) {
|
|
|
404
404
|
function pick(items) {
|
|
405
405
|
return items[Math.floor(Math.random() * items.length)];
|
|
406
406
|
}
|
|
407
|
+
function toImageUrl(source) {
|
|
408
|
+
return typeof source === "string" ? source : source.src;
|
|
409
|
+
}
|
|
407
410
|
var RainBackground = class {
|
|
408
411
|
element;
|
|
409
412
|
constructor(options = {}) {
|
|
@@ -430,15 +433,12 @@ var RainBackground = class {
|
|
|
430
433
|
target.prepend(this.element);
|
|
431
434
|
}
|
|
432
435
|
createDrop(images, minSize, maxSize, minDuration, maxDuration) {
|
|
433
|
-
const drop = document.createElement("
|
|
436
|
+
const drop = document.createElement("div");
|
|
434
437
|
const duration = randomBetween(minDuration, maxDuration);
|
|
435
438
|
const size = randomBetween(minSize, maxSize);
|
|
439
|
+
const src = toImageUrl(pick(images));
|
|
436
440
|
drop.className = "helaui-rain-background__drop";
|
|
437
|
-
drop.
|
|
438
|
-
drop.alt = "";
|
|
439
|
-
drop.decoding = "async";
|
|
440
|
-
drop.loading = "lazy";
|
|
441
|
-
drop.draggable = false;
|
|
441
|
+
drop.style.backgroundImage = `url(${JSON.stringify(src)})`;
|
|
442
442
|
drop.style.setProperty("--helaui-rain-x", `${randomBetween(0, 100)}%`);
|
|
443
443
|
drop.style.setProperty("--helaui-rain-size", `${size}px`);
|
|
444
444
|
drop.style.setProperty("--helaui-rain-duration", `${duration.toFixed(2)}s`);
|
package/dist/index.d.cts
CHANGED
|
@@ -138,7 +138,7 @@ declare class TextField {
|
|
|
138
138
|
destroy(): void;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/** Built-in rain sprite URLs
|
|
141
|
+
/** Built-in rain sprite URLs (inlined as data URLs in the published package). */
|
|
142
142
|
declare const BUILTIN_RAIN_IMAGES: readonly [string, string, string, string];
|
|
143
143
|
|
|
144
144
|
interface RainBackgroundOptions {
|
package/dist/index.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ declare class TextField {
|
|
|
138
138
|
destroy(): void;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/** Built-in rain sprite URLs
|
|
141
|
+
/** Built-in rain sprite URLs (inlined as data URLs in the published package). */
|
|
142
142
|
declare const BUILTIN_RAIN_IMAGES: readonly [string, string, string, string];
|
|
143
143
|
|
|
144
144
|
interface RainBackgroundOptions {
|
package/dist/index.js
CHANGED
|
@@ -351,6 +351,9 @@ function randomBetween(min, max) {
|
|
|
351
351
|
function pick(items) {
|
|
352
352
|
return items[Math.floor(Math.random() * items.length)];
|
|
353
353
|
}
|
|
354
|
+
function toImageUrl(source) {
|
|
355
|
+
return typeof source === "string" ? source : source.src;
|
|
356
|
+
}
|
|
354
357
|
var RainBackground = class {
|
|
355
358
|
element;
|
|
356
359
|
constructor(options = {}) {
|
|
@@ -377,15 +380,12 @@ var RainBackground = class {
|
|
|
377
380
|
target.prepend(this.element);
|
|
378
381
|
}
|
|
379
382
|
createDrop(images, minSize, maxSize, minDuration, maxDuration) {
|
|
380
|
-
const drop = document.createElement("
|
|
383
|
+
const drop = document.createElement("div");
|
|
381
384
|
const duration = randomBetween(minDuration, maxDuration);
|
|
382
385
|
const size = randomBetween(minSize, maxSize);
|
|
386
|
+
const src = toImageUrl(pick(images));
|
|
383
387
|
drop.className = "helaui-rain-background__drop";
|
|
384
|
-
drop.
|
|
385
|
-
drop.alt = "";
|
|
386
|
-
drop.decoding = "async";
|
|
387
|
-
drop.loading = "lazy";
|
|
388
|
-
drop.draggable = false;
|
|
388
|
+
drop.style.backgroundImage = `url(${JSON.stringify(src)})`;
|
|
389
389
|
drop.style.setProperty("--helaui-rain-x", `${randomBetween(0, 100)}%`);
|
|
390
390
|
drop.style.setProperty("--helaui-rain-size", `${size}px`);
|
|
391
391
|
drop.style.setProperty("--helaui-rain-duration", `${duration.toFixed(2)}s`);
|
package/dist/rain-background.css
CHANGED
|
@@ -11,12 +11,15 @@
|
|
|
11
11
|
top: -20%;
|
|
12
12
|
left: var(--helaui-rain-x, 50%);
|
|
13
13
|
width: var(--helaui-rain-size, 48px);
|
|
14
|
-
height:
|
|
14
|
+
height: var(--helaui-rain-size, 48px);
|
|
15
15
|
opacity: var(--helaui-rain-opacity, 0.85);
|
|
16
16
|
will-change: transform;
|
|
17
17
|
animation: helaui-rain-fall var(--helaui-rain-duration, 10s) linear infinite;
|
|
18
18
|
animation-delay: var(--helaui-rain-delay, 0s);
|
|
19
19
|
transform: rotate(var(--helaui-rain-rotation, 0deg));
|
|
20
|
+
background-size: contain;
|
|
21
|
+
background-repeat: no-repeat;
|
|
22
|
+
background-position: center;
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
@keyframes helaui-rain-fall {
|
package/package.json
CHANGED
|
@@ -3,5 +3,5 @@ import kokis from './kokis.png';
|
|
|
3
3
|
import leaf from './leaf.png';
|
|
4
4
|
import swirl from './swirl.png';
|
|
5
5
|
|
|
6
|
-
/** Built-in rain sprite URLs
|
|
6
|
+
/** Built-in rain sprite URLs (inlined as data URLs in the published package). */
|
|
7
7
|
export const BUILTIN_RAIN_IMAGES = [fritter, swirl, kokis, leaf] as const;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import fritter from './fritter.png';
|
|
2
|
-
import kokis from './kokis.png';
|
|
3
|
-
import leaf from './leaf.png';
|
|
4
|
-
import swirl from './swirl.png';
|
|
5
|
-
|
|
6
|
-
/** Built-in rain sprite URLs shipped with HelaUI. */
|
|
7
|
-
export const BUILTIN_RAIN_IMAGES = [fritter, swirl, kokis, leaf] as const;
|