Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor(ui): replace startup v2 Lottie with v3 Loader (#8423)

Andrew Huangd2729a10e72a
diff --git a/frontend/src/components/COMPONENT_LIFECYCLE.md b/frontend/src/components/COMPONENT_LIFECYCLE.md
index c0de4ba269..77dfa6cb55 100644
--- a/frontend/src/components/COMPONENT_LIFECYCLE.md
+++ b/frontend/src/components/COMPONENT_LIFECYCLE.md
@@ -15,7 +15,6 @@ The [V3 migration ledger](V3_MIGRATION.md) tracks source removal, coverage, and
| `ContentLoader`, `FormControl`, `GenericFieldLabel`, `PageHeader`, `Tag` | Blocked | The V3 replacements require consumer-specific composition or accessibility changes. |
| `SecretInput`, `SecretPathInput` | Blocked | Security-sensitive or specialist behavior needs workflow-level parity validation. |
| `NoticeBannerV2` | Blocked | Verify that V3 `Alert` covers existing layout and action requirements. |
-| `Lottie` | Blocked | V3 `Loader` is the replacement, but the application entry point still needs the V2 compatibility path. |
### Removed unused V2 families
diff --git a/frontend/src/components/v2/Lottie/Lottie.tsx b/frontend/src/components/v2/Lottie/Lottie.tsx
deleted file mode 100644
index 61c67cb24b..0000000000
--- a/frontend/src/components/v2/Lottie/Lottie.tsx
+++ /dev/null
@@ -1,33 +0,0 @@
-import { forwardRef, ReactNode } from "react";
-import { DotLottieReact, Mode } from "@lottiefiles/dotlottie-react";
-
-export type LottieProps = {
- // Kudos to https://itnext.io/react-polymorphic-components-with-typescript-f7ce72ea7af2
- children?: ReactNode;
- icon?: string;
- iconMode?: Mode;
- className?: string;
- isAutoPlay?: boolean;
-};
-
-// The onMouseEnter/onMouseLeave play/stop handlers were removed: this component's
-// only consumer is the router's indeterminate page loader, and an indeterminate
-// loader must not stop while the wait continues (stop() resets to frame 0, a fully
-// drawn mark that reads as a hung app until the pointer re-enters).
-// Hover-to-play icons inline their own DotLottieReact player instead.
-export const Lottie = forwardRef<HTMLDivElement, LottieProps>(
- ({ children, icon, iconMode, isAutoPlay, ...props }, ref): JSX.Element => {
- return (
- <div {...props} ref={ref}>
- <DotLottieReact
- mode={iconMode}
- src={`/lotties/${icon}.json`}
- loop
- autoplay={isAutoPlay}
- className="h-full w-full"
- />
- {children}
- </div>
- );
- }
-);
diff --git a/frontend/src/components/v2/Lottie/index.tsx b/frontend/src/components/v2/Lottie/index.tsx
deleted file mode 100644
index 70d571e42f..0000000000
--- a/frontend/src/components/v2/Lottie/index.tsx
+++ /dev/null
@@ -1 +0,0 @@
-export { Lottie } from "./Lottie";
diff --git a/frontend/src/components/v2/index.tsx b/frontend/src/components/v2/index.tsx
index ea22cbf5a2..d67f5d6146 100644
--- a/frontend/src/components/v2/index.tsx
+++ b/frontend/src/components/v2/index.tsx
@@ -16,7 +16,6 @@ export * from "./GenericFieldLabel";
export * from "./HoverCardv2";
export * from "./IconButton";
export * from "./Input";
-export * from "./Lottie";
export * from "./Modal";
export * from "./NoticeBannerV2";
export * from "./PageHeader";
diff --git a/frontend/src/components/v3/generic/Loader/Loader.stories.tsx b/frontend/src/components/v3/generic/Loader/Loader.stories.tsx
index ac76683061..223c7f6cb6 100644
--- a/frontend/src/components/v3/generic/Loader/Loader.stories.tsx
+++ b/frontend/src/components/v3/generic/Loader/Loader.stories.tsx
@@ -9,10 +9,8 @@ import { Loader } from "./Loader";
* `Loader` is the branded Infisical loading animation — the stroke-draw of the
* logo mark. It is the single source for that animation: the mark, the four
* tints, and the size scale all live here, and every product call site composes
- * it rather than naming a Lottie asset itself. `main.tsx` is the deliberate
- * exception: the entry module has to keep importing the `v2` barrel to hold
- * `@app/context` in the entry chunk, so the router's pending component stays on
- * `v2/Lottie`.
+ * it rather than naming a Lottie asset itself, including the router's full-page
+ * pending state in `main.tsx`.
*
* Reach for `Loader` when the surface is Infisical's own and the wait is
* unmeasurable: full-page route transitions (`PageLoader`), pending `Button`
diff --git a/frontend/src/components/v3/generic/Loader/Loader.tsx b/frontend/src/components/v3/generic/Loader/Loader.tsx
index 43d115f7e1..deab23f2ab 100644
--- a/frontend/src/components/v3/generic/Loader/Loader.tsx
+++ b/frontend/src/components/v3/generic/Loader/Loader.tsx
@@ -1,6 +1,5 @@
-import { type ComponentProps, useEffect, useRef } from "react";
+import { type ComponentProps, useEffect, useRef, useSyncExternalStore } from "react";
import { type DotLottie, DotLottieReact } from "@lottiefiles/dotlottie-react";
-import { useReducedMotion } from "motion/react";
import { cn } from "../../utils";
@@ -30,6 +29,12 @@ const sizeStyles: Record<LoaderSize, string> = {
lg: "w-32"
};
+const subscribeToReducedMotion = (onChange: () => void) => {
+ const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");
+ mediaQuery.addEventListener("change", onChange);
+ return () => mediaQuery.removeEventListener("change", onChange);
+};
+
function Loader({
className,
label = "Loading",
@@ -37,7 +42,11 @@ function Loader({
variant = "neutral",
...props
}: LoaderProps) {
- const prefersReducedMotion = Boolean(useReducedMotion());
+ const prefersReducedMotion = useSyncExternalStore(
+ subscribeToReducedMotion,
+ () => window.matchMedia("(prefers-reduced-motion: reduce)").matches,
+ () => false
+ );
const animationRef = useRef<DotLottie | null>(null);
useEffect(() => {
diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx
index 43d926fbb3..e3e4904c2c 100644
--- a/frontend/src/main.tsx
+++ b/frontend/src/main.tsx
@@ -6,11 +6,7 @@ import { QueryClientProvider } from "@tanstack/react-query";
import { createRouter, RouterProvider } from "@tanstack/react-router";
import NProgress from "nprogress";
-// Load-bearing import: the entry module pulling in this barrel is what keeps
-// @app/context in the entry chunk. Pointing this at a deeper path re-partitions
-// the chunks and breaks module init order, which took the app down on boot.
-// Neither lint nor typecheck catches it, so only a real build does.
-import { Lottie } from "./components/v2";
+import { Loader } from "./components/v3/generic/Loader";
import { initializeTheme } from "./components/v3/platform/ThemeProvider";
import { queryClient } from "./hooks/api/reactQuery";
import { initializePlatform } from "./lib/fn/platform";
@@ -80,7 +76,7 @@ const router = createRouter({
context: { serverConfig: null, queryClient },
defaultPendingComponent: () => (
<div className="flex h-full w-full items-center justify-center bg-page [#root>&]:h-screen">
- <Lottie isAutoPlay icon="infisical_loading" className="h-32 w-32" />
+ <Loader variant="brand" className="h-32 w-32" label="Loading page" />
</div>
),
defaultNotFoundComponent: NotFoundPage,