@once-ui-system/fx 3.0.0-beta.1 → 3.0.0-beta.3

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.
@@ -1,3 +1,4 @@
1
+ @layer properties, theme, base, once-ui, components, utilities;
1
2
  @layer once-ui {
2
3
  .glitchLayer {
3
4
  pointer-events: none;
@@ -1,3 +1,4 @@
1
+ @layer properties, theme, base, once-ui, components, utilities;
1
2
  @layer once-ui {
2
3
  .overlay {
3
4
  opacity: 0;
package/dist/MatrixFx.js CHANGED
@@ -40,6 +40,10 @@ const MatrixFx = ({ ref: forwardedRef, speed: speedProp, colors = ["brand-solid-
40
40
  entries.forEach((entry) => {
41
41
  isVisibleRef.current = entry.isIntersecting;
42
42
  });
43
+ // The loop sleeps while offscreen (see `animate`); wake it on return.
44
+ if (isVisibleRef.current && !animationRef.current && animateFnRef.current) {
45
+ animationRef.current = requestAnimationFrame(animateFnRef.current);
46
+ }
43
47
  }, {
44
48
  // Start animating when 10% visible for smooth transitions
45
49
  threshold: 0.1,
@@ -224,9 +228,10 @@ const MatrixFx = ({ ref: forwardedRef, speed: speedProp, colors = ["brand-solid-
224
228
  animationRef.current = requestAnimationFrame(animate);
225
229
  return;
226
230
  }
227
- // Skip rendering if not visible in viewport
231
+ // Offscreen: stop the loop instead of spinning on empty frames. The
232
+ // IntersectionObserver restarts it when the grid comes back into view.
228
233
  if (!isVisibleRef.current) {
229
- animationRef.current = requestAnimationFrame(animate);
234
+ animationRef.current = undefined;
230
235
  return;
231
236
  }
232
237
  // FPS throttling
@@ -1,3 +1,4 @@
1
+ @layer properties, theme, base, once-ui, components, utilities;
1
2
  @layer once-ui {
2
3
  .revealFx {
3
4
  mask-size: 400% 100%;
@@ -1,3 +1,4 @@
1
+ @layer properties, theme, base, once-ui, components, utilities;
1
2
  @layer once-ui {
2
3
  .shineFx {
3
4
  --shine-base-opacity: 0.3;
@@ -1,3 +1,4 @@
1
+ @layer properties, theme, base, once-ui, components, utilities;
1
2
  @layer once-ui {
2
3
  .tiltFx {
3
4
  transition: transform 0.3s ease-out;
@@ -1,22 +1,43 @@
1
1
  import { Flex, type Speed } from "@once-ui-system/core";
2
2
  import type React from "react";
3
3
  type WeatherType = "rain" | "snow" | "leaves" | "lightning";
4
- interface WeatherFxProps extends React.ComponentProps<typeof Flex> {
4
+ interface WeatherFxProps extends Omit<React.ComponentProps<typeof Flex>, "onChange" | "defaultValue"> {
5
5
  type?: WeatherType;
6
6
  /** A multiplier on the designed pace (`1`), or `"slow"`/`"medium"`/`"fast"` (0.5, 1, 2). */
7
7
  speed?: Speed;
8
+ /**
9
+ * Colours to draw with: tokens (`brand-solid-medium`, `accent-weak`), custom
10
+ * properties (`--my-color`) or CSS colours. Leaves blend each colour into the
11
+ * next. Read again when the theme changes.
12
+ */
8
13
  colors?: string[];
14
+ /**
15
+ * How much weather: drops, flakes or leaves on screen (0 to 400). For
16
+ * lightning, how often it strikes: 10 is about every 1.5 s, 50 and up as
17
+ * often as is safe (never more than twice a second).
18
+ */
9
19
  intensity?: number;
20
+ /** Degrees the weather leans from straight down; positive drifts right. */
10
21
  angle?: number;
11
- /** Milliseconds to keep emitting before the weather stops (seconds until 3.0). Unset runs forever. */
22
+ /** Milliseconds the weather runs once it starts; then `active` turns off. Unset runs until `active` is false. */
12
23
  duration?: number;
13
- trigger?: "mount" | "hover" | "click" | "manual";
24
+ /**
25
+ * What starts the weather by itself: `mount` (on load), `hover` (while the
26
+ * pointer is over it; a tap toggles it on touch screens) or `click` (each
27
+ * click toggles it). Setting `active` drives it from outside, whatever the trigger.
28
+ */
29
+ trigger?: "mount" | "hover" | "click";
30
+ /** Whether the weather is running. Controlled; pair with `onActiveChange`. */
14
31
  active?: boolean;
32
+ /** The first value of `active` when uncontrolled. Defaults to `trigger === "mount"`. */
33
+ defaultActive?: boolean;
34
+ /** Called when the weather starts or stops by hover, click or `duration`. */
35
+ onActiveChange?: (active: boolean) => void;
15
36
  reducedMotion?: boolean | "auto";
16
37
  children?: React.ReactNode;
17
38
  }
18
39
  declare const WeatherFx: {
19
- ({ ref: forwardedRef, type, speed: speedProp, colors, intensity, angle, duration, trigger, active, reducedMotion, children, ...rest }: WeatherFxProps): React.JSX.Element;
40
+ ({ ref: forwardedRef, type, speed: speedProp, colors: colorsProp, intensity, angle, duration, trigger, active: activeProp, defaultActive, onActiveChange, reducedMotion, children, onClick, onMouseEnter, onMouseLeave, ...rest }: WeatherFxProps): React.JSX.Element;
20
41
  displayName: string;
21
42
  };
22
43
  export { WeatherFx };