import React, { useCallback } from 'react'; import styled from '@emotion/styled'; import { color, fontWeight } from 'styled-system'; import { useTheme } from 'hooks'; import { COLOR_DARK, COLOR_LIGHT } from 'theme'; import { Maybe, RichTextContentSegment, RichTextContentStringColorEnum, RichTextContentStringStyle, } from 'expo-schema'; const RichText = styled('span')(color, fontWeight, { fontFamily: 'CircularStd-Book', }); const ContentWrapper = styled.div``; export const MessageContent: React.FC = ({ richTextContent }) => { const { activeThemeMode } = useTheme(); const textColor = activeThemeMode === 'dark' ? COLOR_DARK.title : COLOR_LIGHT.title; const { id: segmentId, strings } = richTextContent; const getTextDecoration = useCallback((style: Maybe | undefined) => { const underLine = style?.underline ? 'underline' : 'none'; return style?.strikethrough ? 'line-through' : underLine; }, []); const getFontStyle = (style: RichTextContentStringStyle) => style?.italics ? 'italic' : 'normal'; return ( {strings.map(({ id, style, value }) => { return ( {value} ); })} ); }; export type RichTextContentProps = { richTextContent: RichTextContentSegment; };