Skip to content

Commit a085a7c

Browse files
authored
Merge pull request #389 from GCWing/fix/web-ui-announcement-eslint
fix(web-ui): ESLint errors in announcement components (CI)
2 parents fbccf5f + db3a634 commit a085a7c

2 files changed

Lines changed: 53 additions & 58 deletions

File tree

src/web-ui/src/shared/announcement-system/components/FeatureModalPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ const FeatureModalPage: React.FC<Props> = ({ page, active }) => {
9191
<div className="feature-modal-page__rule" aria-hidden />
9292
<div
9393
className="feature-modal-page__body"
94-
// eslint-disable-next-line react/no-danger
9594
dangerouslySetInnerHTML={{ __html: renderBody(page.body) }}
9695
/>
9796
</div>

src/web-ui/src/shared/announcement-system/components/MediaRenderer.tsx

Lines changed: 53 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,59 @@ interface Props {
77
active: boolean;
88
}
99

10+
interface LottieProps {
11+
src: string;
12+
active: boolean;
13+
}
14+
15+
const LottieRenderer: React.FC<LottieProps> = ({ src, active }) => {
16+
const [LottieComponent, setLottieComponent] =
17+
React.useState<React.ComponentType<any> | null>(null);
18+
const [loadError, setLoadError] = React.useState(false);
19+
20+
useEffect(() => {
21+
let cancelled = false;
22+
const pkg = '@lottiefiles/dotlottie-react';
23+
import(/* @vite-ignore */ pkg)
24+
.then((mod: any) => {
25+
if (!cancelled) setLottieComponent(() => mod.DotLottieReact ?? mod.default);
26+
})
27+
.catch(() => {
28+
if (!cancelled) setLoadError(true);
29+
});
30+
return () => { cancelled = true; };
31+
}, []);
32+
33+
if (loadError) {
34+
return (
35+
<div className="announcement-media">
36+
<div className="announcement-media__placeholder">
37+
Lottie library not available
38+
</div>
39+
</div>
40+
);
41+
}
42+
43+
if (!LottieComponent) {
44+
return (
45+
<div className="announcement-media">
46+
<div className="announcement-media__placeholder">Loading…</div>
47+
</div>
48+
);
49+
}
50+
51+
return (
52+
<div className="announcement-media">
53+
<LottieComponent
54+
src={src}
55+
autoplay={active}
56+
loop
57+
style={{ width: '100%', height: '100%' }}
58+
/>
59+
</div>
60+
);
61+
};
62+
1063
/**
1164
* Renders a media asset inside a modal page.
1265
*
@@ -68,61 +121,4 @@ const MediaRenderer: React.FC<Props> = ({ media, active }) => {
68121
);
69122
};
70123

71-
// ─── Lazy Lottie renderer ─────────────────────────────────────────────────────
72-
73-
interface LottieProps {
74-
src: string;
75-
active: boolean;
76-
}
77-
78-
const LottieRenderer: React.FC<LottieProps> = ({ src, active }) => {
79-
const [LottieComponent, setLottieComponent] =
80-
React.useState<React.ComponentType<any> | null>(null);
81-
const [loadError, setLoadError] = React.useState(false);
82-
83-
useEffect(() => {
84-
let cancelled = false;
85-
// Dynamically resolve the Lottie package name to avoid a hard static
86-
// dependency when the package is not yet installed.
87-
const pkg = '@lottiefiles/dotlottie-react';
88-
import(/* @vite-ignore */ pkg)
89-
.then((mod: any) => {
90-
if (!cancelled) setLottieComponent(() => mod.DotLottieReact ?? mod.default);
91-
})
92-
.catch(() => {
93-
if (!cancelled) setLoadError(true);
94-
});
95-
return () => { cancelled = true; };
96-
}, []);
97-
98-
if (loadError) {
99-
return (
100-
<div className="announcement-media">
101-
<div className="announcement-media__placeholder">
102-
Lottie library not available
103-
</div>
104-
</div>
105-
);
106-
}
107-
108-
if (!LottieComponent) {
109-
return (
110-
<div className="announcement-media">
111-
<div className="announcement-media__placeholder">Loading…</div>
112-
</div>
113-
);
114-
}
115-
116-
return (
117-
<div className="announcement-media">
118-
<LottieComponent
119-
src={src}
120-
autoplay={active}
121-
loop
122-
style={{ width: '100%', height: '100%' }}
123-
/>
124-
</div>
125-
);
126-
};
127-
128124
export default MediaRenderer;

0 commit comments

Comments
 (0)