import { Box, Icon, IconSrc } from 'folds';
import React, { ReactNode } from 'react';
-import { CompactLayout, ModernLayout } from '..';
+import { BubbleLayout, CompactLayout, ModernLayout } from '..';
import { MessageLayout } from '../../../state/settings';
export type EventContentProps = {
</Box>
);
- return messageLayout === MessageLayout.Compact ? (
- <CompactLayout before={beforeJSX}>{msgContentJSX}</CompactLayout>
- ) : (
- <ModernLayout before={beforeJSX}>{msgContentJSX}</ModernLayout>
- );
+ 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>;
}
import React, { ReactNode } from 'react';
-import { Box, as } from 'folds';
+import classNames from 'classnames';
+import { Box, ContainerColor, as, color } from 'folds';
import * as css from './layout.css';
+type BubbleArrowProps = {
+ variant: ContainerColor;
+};
+function BubbleLeftArrow({ variant }: BubbleArrowProps) {
+ return (
+ <svg
+ className={css.BubbleLeftArrow}
+ width="9"
+ height="8"
+ viewBox="0 0 9 8"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ fillRule="evenodd"
+ clipRule="evenodd"
+ d="M9.00004 8V0H4.82847C3.04666 0 2.15433 2.15428 3.41426 3.41421L8.00004 8H9.00004Z"
+ fill={color[variant].Container}
+ />
+ </svg>
+ );
+}
+
type BubbleLayoutProps = {
+ hideBubble?: boolean;
before?: ReactNode;
+ header?: ReactNode;
};
-export const BubbleLayout = as<'div', BubbleLayoutProps>(({ before, children, ...props }, ref) => (
- <Box gap="300" {...props} ref={ref}>
- <Box className={css.BubbleBefore} shrink="No">
- {before}
- </Box>
- <Box className={css.BubbleContent} direction="Column">
- {children}
+export const BubbleLayout = as<'div', BubbleLayoutProps>(
+ ({ hideBubble, before, header, children, ...props }, ref) => (
+ <Box gap="300" {...props} ref={ref}>
+ <Box className={css.BubbleBefore} shrink="No">
+ {before}
+ </Box>
+ <Box grow="Yes" direction="Column">
+ {header}
+ {hideBubble ? (
+ children
+ ) : (
+ <Box>
+ <Box
+ className={
+ hideBubble
+ ? undefined
+ : classNames(css.BubbleContent, before ? css.BubbleContentArrowLeft : undefined)
+ }
+ direction="Column"
+ >
+ {before ? <BubbleLeftArrow variant="SurfaceVariant" /> : null}
+ {children}
+ </Box>
+ </Box>
+ )}
+ </Box>
</Box>
- </Box>
-));
+ )
+);
export const AvatarBase = style({
paddingTop: toRem(4),
transition: 'transform 200ms cubic-bezier(0, 0.8, 0.67, 0.97)',
+ display: 'flex',
alignSelf: 'start',
selectors: {
minWidth: toRem(36),
});
-export const BubbleBefore = style([ModernBefore]);
+export const BubbleBefore = style({
+ minWidth: toRem(36),
+});
export const BubbleContent = style({
maxWidth: toRem(800),
padding: config.space.S200,
backgroundColor: color.SurfaceVariant.Container,
color: color.SurfaceVariant.OnContainer,
- borderRadius: config.radii.R400,
+ borderRadius: config.radii.R500,
+ position: 'relative',
+});
+
+export const BubbleContentArrowLeft = style({
+ borderTopLeftRadius: 0,
+});
+
+export const BubbleLeftArrow = style({
+ width: toRem(9),
+ height: toRem(8),
+
+ position: 'absolute',
+ top: 0,
+ left: toRem(-8),
+ zIndex: 1,
});
export const Username = style({
const mx = useMatrixClient();
const useAuthentication = useMediaAuthentication();
const senderId = mEvent.getSender() ?? '';
+
const [hover, setHover] = useState(false);
const { hoverProps } = useHover({ onHoverChange: setHover });
const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setHover });
);
const avatarJSX = !collapse && messageLayout !== MessageLayout.Compact && (
- <AvatarBase>
+ <AvatarBase
+ className={messageLayout === MessageLayout.Bubble ? css.BubbleAvatarBase : undefined}
+ >
<Avatar
className={css.MessageAvatar}
as="button"
return (
<MessageBase
- className={classNames(css.MessageBase, className)}
+ className={classNames(css.MessageBase, className, {
+ [css.MessageBaseBubbleCollapsed]: messageLayout === MessageLayout.Bubble && collapse,
+ })}
tabIndex={0}
space={messageSpacing}
collapse={collapse}
</CompactLayout>
)}
{messageLayout === MessageLayout.Bubble && (
- <BubbleLayout before={avatarJSX} onContextMenu={handleContextMenu}>
- {headerJSX}
+ <BubbleLayout before={avatarJSX} header={headerJSX} onContextMenu={handleContextMenu}>
{msgContentJSX}
</BubbleLayout>
)}
export const MessageBase = style({
position: 'relative',
});
+export const MessageBaseBubbleCollapsed = style({
+ paddingTop: 0,
+});
export const MessageOptionsBase = style([
DefaultReset,
},
]);
+export const BubbleAvatarBase = style({
+ paddingTop: 0,
+});
+
export const MessageAvatar = style({
cursor: 'pointer',
});
import { style } from '@vanilla-extract/css';
import { recipe } from '@vanilla-extract/recipes';
import { color, config, DefaultReset, toRem } from 'folds';
+import { ContainerColor } from './ContainerColor.css';
export const MarginSpaced = style({
marginBottom: config.space.S200,
overflow: 'hidden',
},
]);
-export const CodeBlockHeader = style({
- padding: `0 ${config.space.S200} 0 ${config.space.S300}`,
- borderBottomWidth: config.borderWidth.B300,
- gap: config.space.S200,
-});
+export const CodeBlockHeader = style([
+ ContainerColor({ variant: 'Surface' }),
+ {
+ padding: `0 ${config.space.S200} 0 ${config.space.S300}`,
+ borderBottomWidth: config.borderWidth.B300,
+ gap: config.space.S200,
+ },
+]);
export const CodeBlockInternal = style([
CodeFont,
{