♻️(react) disable animation when Chromatic is running

We need to disable Javascript animation when Chromatic is taking
snapshots in order to avoid having changes detected each time a build
is ran.
This commit is contained in:
Nathan Vasse
2024-03-18 16:33:09 +01:00
committed by NathanVss
parent 9c614953b8
commit 06fca5b34e
2 changed files with 6 additions and 1 deletions

View File

@@ -6,6 +6,7 @@ import React, {
useRef,
} from "react";
import classNames from "classnames";
import isChromatic from "chromatic/isChromatic";
import { Button, ButtonProps } from ":/components/Button";
import { iconFromType, VariantType } from ":/utils/VariantUtils";
@@ -105,6 +106,9 @@ export const ProgressBar = ({ duration }: { duration: number }) => {
const content = useRef<HTMLDivElement>(null);
useEffect(() => {
if (isChromatic()) {
return;
}
content.current!.animate([{ width: "0%" }, { width: "100%" }], {
duration,
easing: "linear",