feat(frontend): add SkeletonBlock and TableSkeleton components
This commit is contained in:
parent
608e521674
commit
d7b5a376a0
20
apps/frontend/src/components/SkeletonBlock.tsx
Normal file
20
apps/frontend/src/components/SkeletonBlock.tsx
Normal file
@ -0,0 +1,20 @@
|
||||
export function SkeletonBlock({
|
||||
width,
|
||||
height,
|
||||
borderRadius = 4,
|
||||
}: {
|
||||
width?: string | number;
|
||||
height?: string | number;
|
||||
borderRadius?: number;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className="skeleton"
|
||||
style={{
|
||||
width: width ?? '100%',
|
||||
height: height ?? 16,
|
||||
borderRadius,
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
25
apps/frontend/src/components/TableSkeleton.tsx
Normal file
25
apps/frontend/src/components/TableSkeleton.tsx
Normal file
@ -0,0 +1,25 @@
|
||||
import { SkeletonBlock } from './SkeletonBlock';
|
||||
|
||||
const tdStyle = {
|
||||
borderBottom: '1px solid #eeeeee',
|
||||
padding: '10px 8px',
|
||||
verticalAlign: 'top',
|
||||
} satisfies React.CSSProperties;
|
||||
|
||||
type Column = { width: string };
|
||||
|
||||
export function TableSkeleton({ rows = 5, columns }: { rows?: number; columns: Column[] }) {
|
||||
return (
|
||||
<tbody>
|
||||
{Array.from({ length: rows }).map((_, i) => (
|
||||
<tr key={i}>
|
||||
{columns.map((col, j) => (
|
||||
<td key={j} style={tdStyle}>
|
||||
<SkeletonBlock height={12} width={col.width} />
|
||||
</td>
|
||||
))}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user