mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
Some checks failed
Deploy to Netlify (dev) / Deploy to Netlify (push) Has been cancelled
* Add arrow to message bubbles and improve spacing * make bubble message avatar smaller * add bubble layout for event content * adjust bubble arrow * fix missing return statement for event content * hide bubble for event content * add new arrow to bubble message * fix avatar username relative alignment * fix types * fix code block header background * revert avatar size and make arrow less sharp * show event messages timestamp to right when bubble is hidden * fix avatar base css * move message header outside bubble * fix event time appears on left in hidden bubles
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { Box, Icon, IconSrc } from 'folds';
|
|
import React, { ReactNode } from 'react';
|
|
import { BubbleLayout, CompactLayout, ModernLayout } from '..';
|
|
import { MessageLayout } from '../../../state/settings';
|
|
|
|
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}
|
|
<Box
|
|
grow={messageLayout === MessageLayout.Compact ? undefined : 'Yes'}
|
|
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}
|
|
</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>;
|
|
}
|