import React, { CSSProperties, useMemo } from 'react'; import { Text, as } from 'folds'; import classNames from 'classnames'; import * as css from './layout.css'; import { isStationeryTheme, useTheme } from '../../../hooks/useTheme'; import { STATIONERY_NAME_INK } from '../../../utils/paperSafeInk'; export const MessageBase = as<'div', css.MessageBaseVariants>( ({ className, highlight, selected, collapse, autoCollapse, space, newMessage, ...props }, ref) => (
) ); export const AvatarBase = as<'span'>(({ className, ...props }, ref) => ( )); export const Username = as<'span'>(({ as: AsUsername = 'span', className, style, ...props }, ref) => { const theme = useTheme(); const isStationery = isStationeryTheme(theme); const userColor = typeof (style as CSSProperties | undefined)?.color === 'string' ? ((style as CSSProperties).color as string) : undefined; const safeStyle = useMemo((): CSSProperties | undefined => { if (!isStationery) return style as CSSProperties | undefined; return { ...(style as CSSProperties | undefined), // Name in ink; keep their color as an accent underline color: STATIONERY_NAME_INK, ...(userColor ? { ['--username-accent' as string]: userColor, textDecorationColor: userColor } : null), }; }, [style, isStationery, userColor]); return (