Skip to content

Commit 7c4d177

Browse files
fix(apollo-vertex): address Copilot review on dashboard template
- glow-config: import the CSSProperties type from react instead of relying on a global React namespace. - DashboardLoading: type children as ReactNode (explicit import) and clear the nested exit timer on cleanup to avoid state updates after unmount. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 9335b3c commit 7c4d177

2 files changed

Lines changed: 26 additions & 18 deletions

File tree

apps/apollo-vertex/templates/dashboard/DashboardLoading.tsx

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"use client";
22

3-
import { useEffect, useState } from "react";
3+
import { type ReactNode, useEffect, useState } from "react";
44
import { useTranslation } from "react-i18next";
55

66
type Phase = "logo" | "skeleton" | "done";
77

88
interface DashboardLoadingProps {
9-
children: React.ReactNode;
9+
children: ReactNode;
1010
triggerReplay?: number;
1111
}
1212

@@ -86,33 +86,39 @@ function SkeletonPhase({ exiting }: { exiting: boolean }) {
8686
// Plays the logo → skeleton → content intro once, then renders children.
8787
// It owns its phase state from mount; to replay, the parent gives it a new
8888
// `key` so it remounts — no resetting state in response to a prop change.
89-
function LoadingSequence({ children }: { children: React.ReactNode }) {
89+
function LoadingSequence({ children }: { children: ReactNode }) {
9090
const [phase, setPhase] = useState<Phase>("logo");
9191
const [exiting, setExiting] = useState(false);
9292

9393
useEffect(() => {
9494
if (phase === "done") return;
9595

96+
let exitTimer: ReturnType<typeof setTimeout>;
97+
9698
if (phase === "logo") {
97-
const timer = setTimeout(() => {
99+
const enterTimer = setTimeout(() => {
98100
setExiting(true);
99-
setTimeout(() => {
101+
exitTimer = setTimeout(() => {
100102
setExiting(false);
101103
setPhase("skeleton");
102104
}, 500);
103105
}, 2000);
104-
return () => clearTimeout(timer);
106+
return () => {
107+
clearTimeout(enterTimer);
108+
clearTimeout(exitTimer);
109+
};
105110
}
106111

107-
if (phase === "skeleton") {
108-
const timer = setTimeout(() => {
109-
setExiting(true);
110-
setTimeout(() => {
111-
setPhase("done");
112-
}, 500);
113-
}, 1000);
114-
return () => clearTimeout(timer);
115-
}
112+
const enterTimer = setTimeout(() => {
113+
setExiting(true);
114+
exitTimer = setTimeout(() => {
115+
setPhase("done");
116+
}, 500);
117+
}, 1000);
118+
return () => {
119+
clearTimeout(enterTimer);
120+
clearTimeout(exitTimer);
121+
};
116122
}, [phase]);
117123

118124
if (phase === "done") {

apps/apollo-vertex/templates/dashboard/glow-config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { CSSProperties } from "react";
2+
13
export interface GlowConfig {
24
start: string;
35
end: string;
@@ -214,22 +216,22 @@ export function cardBgStyle(
214216
bg: string,
215217
opacity: number,
216218
gradient: CardGradient,
217-
): React.CSSProperties {
219+
): CSSProperties {
218220
if (gradient.enabled) {
219221
const alpha = gradient.opacity / 100;
220222
const style = {
221223
"--card-bg-override": `linear-gradient(${gradient.angle}deg, color-mix(in srgb, ${gradient.start} ${alpha * 100}%, transparent), color-mix(in srgb, ${gradient.end} ${alpha * 100}%, transparent))`,
222224
borderColor: "transparent",
223225
};
224226
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- CSS custom properties require assertion
225-
return style as unknown as React.CSSProperties;
227+
return style as unknown as CSSProperties;
226228
}
227229
const value =
228230
bg === "white"
229231
? `rgba(255,255,255,${opacity / 100})`
230232
: `color-mix(in srgb, var(--${bg}) ${opacity}%, transparent)`;
231233
// oxlint-disable-next-line typescript-eslint(no-unsafe-type-assertion) -- CSS custom properties require assertion
232-
return { "--card-bg-override": value } as unknown as React.CSSProperties;
234+
return { "--card-bg-override": value } as unknown as CSSProperties;
233235
}
234236

235237
export function getInsightCardClasses(

0 commit comments

Comments
 (0)