mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-21 09:14:42 +08:00
41 lines
1.0 KiB
TypeScript
41 lines
1.0 KiB
TypeScript
// 图片占位符组件 - 实现骨架屏效果(支持暗色模式)
|
|
const ImagePlaceholder = ({ aspectRatio }: { aspectRatio: string }) => (
|
|
<div
|
|
className={`w-full ${aspectRatio} rounded-lg`}
|
|
style={{
|
|
background:
|
|
'linear-gradient(90deg, var(--skeleton-color) 25%, var(--skeleton-highlight) 50%, var(--skeleton-color) 75%)',
|
|
backgroundSize: '200% 100%',
|
|
animation: 'shine 1.5s infinite',
|
|
}}
|
|
>
|
|
<style>{`
|
|
@keyframes shine {
|
|
0% { background-position: -200% 0; }
|
|
100% { background-position: 200% 0; }
|
|
}
|
|
|
|
/* 亮色模式变量 */
|
|
:root {
|
|
--skeleton-color: #f0f0f0;
|
|
--skeleton-highlight: #e0e0e0;
|
|
}
|
|
|
|
/* 暗色模式变量 */
|
|
@media (prefers-color-scheme: dark) {
|
|
:root {
|
|
--skeleton-color: #2d2d2d;
|
|
--skeleton-highlight: #3d3d3d;
|
|
}
|
|
}
|
|
|
|
.dark {
|
|
--skeleton-color: #2d2d2d;
|
|
--skeleton-highlight: #3d3d3d;
|
|
}
|
|
`}</style>
|
|
</div>
|
|
);
|
|
|
|
export { ImagePlaceholder };
|