@brightlocal/ui-components 1.2.4 → 1.4.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.
@@ -0,0 +1,28 @@
1
+ "use client";
2
+
3
+ import { useSyncExternalStore } from "react";
4
+
5
+ const QUERY = "(prefers-reduced-motion: reduce)";
6
+
7
+ function subscribe(callback: () => void) {
8
+ const mql = window.matchMedia(QUERY);
9
+ mql.addEventListener("change", callback);
10
+ return () => mql.removeEventListener("change", callback);
11
+ }
12
+
13
+ function getSnapshot() {
14
+ return window.matchMedia(QUERY).matches;
15
+ }
16
+
17
+ function getServerSnapshot() {
18
+ return false;
19
+ }
20
+
21
+ /**
22
+ * Returns `true` when the user prefers reduced motion.
23
+ * Listens to OS/browser preference changes in real time.
24
+ * SSR-safe: defaults to `false` on the server.
25
+ */
26
+ export function usePrefersReducedMotion() {
27
+ return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
28
+ }
package/src/index.ts CHANGED
@@ -55,6 +55,7 @@ export * from "./components/split-layout";
55
55
  export * from "./components/switch";
56
56
  export * from "./components/table";
57
57
  export * from "./components/tabs";
58
+ export * from "./components/text-reveal-motion";
58
59
  export * from "./components/textarea";
59
60
  export * from "./components/toggle";
60
61
  export * from "./components/toggle-group";
@@ -68,6 +69,7 @@ export * from "./blocks/sidebar";
68
69
 
69
70
  // Hooks
70
71
  export * from "./hooks/use-mobile";
72
+ export * from "./hooks/use-prefers-reduced-motion";
71
73
 
72
74
  // Utils
73
75
  export * from "./lib/utils";