All files / src/components/common/FilePreview/layout PreviewHeader.tsx

14.28% Statements 1/7
0% Branches 0/8
0% Functions 0/2
14.28% Lines 1/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65                1x                                                                                                                
import { CloseIcon } from "@assets/icons";
import { StyledIconButton } from "@common/IconButton";
import { TruncateText } from "@common/Text";
import { Stack } from "@mui/material";
import { palette } from "@palette";
import { useCustomTheme } from "@theme/hooks/useCustomTheme";
import React from "react";
 
const PreviewHeader = ({
  onClose,
  title,
  actions,
}: {
  onClose?: () => void;
  title: string;
  actions?: React.ReactNode;
}) => {
  const { isDesktopView } = useCustomTheme();
  const color = isDesktopView ? palette.black[100] : palette.neutral.white;
  const iconSize = {
    container: isDesktopView ? 24 : 32,
    svg: isDesktopView ? 20 : 32,
  };
  const { container, svg } = iconSize;
  return (
    <Stack
      direction="row"
      alignItems="center"
      justifyItems="stretch"
      onClick={(event) => event.stopPropagation()}
      data-testid="preview-header"
    >
      {onClose && (
        <StyledIconButton
          sx={{
            height: `${container}px !important`,
            width: `${container}px !important`,
            padding: "0 !important",
          }}
          data-testid="close-preview-button"
          onClick={onClose}
        >
          <CloseIcon width={svg} height={svg} stroke={color} />
        </StyledIconButton>
      )}
      <TruncateText
        lineClamp={1}
        color={color}
        fontWeight="book"
        lineHeight="16.8px"
        align="center"
        flexGrow={1}
        data-testid="preview-title"
      >
        {title}
      </TruncateText>
      <Stack direction="row" alignItems="center" spacing="16px">
        {actions}
      </Stack>
    </Stack>
  );
};
 
export default PreviewHeader;