refactor(frontend): create shared/ui layer with skeleton components
This commit is contained in:
parent
a9132109da
commit
5355451e35
@ -1,20 +1 @@
|
|||||||
export function SkeletonBlock({
|
export { SkeletonBlock } from '../shared/ui/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,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
@ -1,25 +1 @@
|
|||||||
import { SkeletonBlock } from './SkeletonBlock';
|
export { TableSkeleton } from '../shared/ui/TableSkeleton';
|
||||||
|
|
||||||
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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|||||||
20
apps/frontend/src/shared/ui/SkeletonBlock.tsx
Normal file
20
apps/frontend/src/shared/ui/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/shared/ui/TableSkeleton.tsx
Normal file
25
apps/frontend/src/shared/ui/TableSkeleton.tsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import { SkeletonBlock } from '@/shared/ui/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>
|
||||||
|
);
|
||||||
|
}
|
||||||
2
apps/frontend/src/shared/ui/index.ts
Normal file
2
apps/frontend/src/shared/ui/index.ts
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export { SkeletonBlock } from './SkeletonBlock';
|
||||||
|
export { TableSkeleton } from './TableSkeleton';
|
||||||
Loading…
x
Reference in New Issue
Block a user