Files
cinny/src/app/components/message/content/EventContent.tsx
T

45 lines
1.4 KiB
TypeScript
Raw Normal View History

2023-10-06 13:44:06 +11:00
import { Box, Icon, IconSrc } from 'folds';
import React, { ReactNode } from 'react';
import { BubbleLayout, CompactLayout, ModernLayout } from '..';
import { MessageLayout } from '../../../state/settings';
2023-10-06 13:44:06 +11:00
export type EventContentProps = {
messageLayout: number;
time: ReactNode;
iconSrc: IconSrc;
content: ReactNode;
};
export function EventContent({ messageLayout, time, iconSrc, content }: EventContentProps) {
const beforeJSX = (
<Box gap="300" justifyContent="SpaceBetween" alignItems="Center" grow="Yes">
{messageLayout === MessageLayout.Compact && time}
2023-10-06 13:44:06 +11:00
<Box
grow={messageLayout === MessageLayout.Compact ? undefined : 'Yes'}
2023-10-06 13:44:06 +11:00
alignItems="Center"
justifyContent="Center"
>
<Icon style={{ opacity: 0.6 }} size="50" src={iconSrc} />
</Box>
</Box>
);
const msgContentJSX = (
<Box justifyContent="SpaceBetween" alignItems="Baseline" gap="200">
{content}
{messageLayout !== MessageLayout.Compact && time}
2023-10-06 13:44:06 +11:00
</Box>
);
if (messageLayout === MessageLayout.Compact) {
return <CompactLayout before={beforeJSX}>{msgContentJSX}</CompactLayout>;
}
if (messageLayout === MessageLayout.Bubble) {
return (
<BubbleLayout hideBubble before={beforeJSX}>
{msgContentJSX}
</BubbleLayout>
);
}
return <ModernLayout before={beforeJSX}>{msgContentJSX}</ModernLayout>;
2023-10-06 13:44:06 +11:00
}