Files
cinny/src/app/components/message/placeholder/DefaultPlaceholder.tsx
T

40 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-12-16 21:55:15 +11:00
import React, { CSSProperties, useMemo } from 'react';
import { Avatar, Box, ContainerColor, as, color, toRem } from 'folds';
2023-10-06 13:44:06 +11:00
import { randomNumberBetween } from '../../../utils/common';
import { LinePlaceholder } from './LinePlaceholder';
2024-12-16 21:55:15 +11:00
import { ModernLayout } from '../layout';
2023-10-06 13:44:06 +11:00
const contentMargin: CSSProperties = { marginTop: toRem(3) };
2024-12-16 21:55:15 +11:00
export const DefaultPlaceholder = as<'div', { variant?: ContainerColor }>(
({ variant, ...props }, ref) => {
const nameSize = useMemo(() => randomNumberBetween(40, 100), []);
const msgSize = useMemo(() => randomNumberBetween(80, 200), []);
const msg2Size = useMemo(() => randomNumberBetween(80, 200), []);
return (
<ModernLayout
{...props}
ref={ref}
before={
<Avatar
style={{ backgroundColor: color[variant ?? 'SurfaceVariant'].Container }}
size="300"
/>
}
>
<Box style={contentMargin} grow="Yes" direction="Column" gap="200">
<Box grow="Yes" gap="200" alignItems="Center" justifyContent="SpaceBetween">
<LinePlaceholder variant={variant} style={{ maxWidth: toRem(nameSize) }} />
<LinePlaceholder variant={variant} style={{ maxWidth: toRem(50) }} />
</Box>
<Box grow="Yes" gap="200" wrap="Wrap">
<LinePlaceholder variant={variant} style={{ maxWidth: toRem(msgSize) }} />
<LinePlaceholder variant={variant} style={{ maxWidth: toRem(msg2Size) }} />
</Box>
2023-10-06 13:44:06 +11:00
</Box>
2024-12-16 21:55:15 +11:00
</ModernLayout>
);
}
);