@unpunnyfuns/swatchbook-blocks 0.20.0 → 0.20.1

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/dist/index.mjs CHANGED
@@ -2068,13 +2068,31 @@ function GradientPalette({ filter, caption, sortBy = "path", sortDir = "asc" })
2068
2068
  //#endregion
2069
2069
  //#region src/internal/prefers-reduced-motion.ts
2070
2070
  /**
2071
+ * True when rendering inside Chromatic's snapshot runner. Chromatic's
2072
+ * browser ships a recognisable user-agent string; checked here so
2073
+ * motion-looping components can fall back to their static state for
2074
+ * deterministic snapshots without needing a global Chromatic parameter
2075
+ * (globally forcing `prefersReducedMotion: true` broke Chromatic's
2076
+ * verification parser in our setup — see commit 893331f).
2077
+ */
2078
+ function isChromatic() {
2079
+ if (typeof navigator === "undefined") return false;
2080
+ return navigator.userAgent.includes("Chromatic");
2081
+ }
2082
+ /**
2071
2083
  * Reactive `prefers-reduced-motion: reduce` detector. Returns the current
2072
- * match and updates if the user toggles the OS-level preference.
2084
+ * match and updates if the user toggles the OS-level preference. Also
2085
+ * returns `true` under Chromatic to keep animated samples deterministic
2086
+ * during visual regression capture.
2073
2087
  */
2074
2088
  function usePrefersReducedMotion() {
2075
2089
  const [reduced, setReduced] = useState(false);
2076
2090
  useEffect(() => {
2077
2091
  if (typeof window === "undefined") return;
2092
+ if (isChromatic()) {
2093
+ setReduced(true);
2094
+ return;
2095
+ }
2078
2096
  const query = window.matchMedia("(prefers-reduced-motion: reduce)");
2079
2097
  setReduced(query.matches);
2080
2098
  const onChange = (e) => setReduced(e.matches);