Skip to content

The open alternative to Salesforce, designed for AI.

1.3 KB
Raw Blame
import { styled } from '@linaria/react';
import { motion } from 'framer-motion';
import Linkify from 'linkify-react';
import { Collapsible } from 'twenty-ui/primitives/layout';
import { themeCssVariables } from 'twenty-ui/theme';

const StyledThreadMessageBody = styled(motion.div)`
  color: ${themeCssVariables.font.color.primary};
  margin-top: ${themeCssVariables.spacing[4]};
  overflow-wrap: break-word;
  white-space: pre-line;

  a {
    color: ${themeCssVariables.font.color.primary};

    text-decoration: underline;
    text-decoration-color: ${themeCssVariables.font.color.primary};

    &:hover {
      color: ${themeCssVariables.font.color.tertiary};
      text-decoration-color: ${themeCssVariables.border.color.strong};
    }
  }
`;

type EmailThreadMessageBodyProps = {
  body: string;
  isDisplayed: boolean;
};

export const EmailThreadMessageBody = ({
  body,
  isDisplayed,
}: EmailThreadMessageBodyProps) => {
  return (
    <Collapsible.Root open={isDisplayed}>
      <Collapsible.Panel duration="fast">
        <StyledThreadMessageBody>
          <Linkify
            options={{
              target: '_blank',
              rel: 'noopener noreferrer',
            }}
          >
            {body}
          </Linkify>
        </StyledThreadMessageBody>
      </Collapsible.Panel>
    </Collapsible.Root>
  );
};