All files / client/src/components RaisedCard.tsx

88.88% Statements 8/9
100% Branches 9/9
80% Functions 4/5
88.88% Lines 8/9

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      356x 356x 356x                     1x                                 1x                 3338x     3338x             3338x              
import { ReactElement, ReactNode } from "react";
import styled from "styled-components";
 
export enum HighlightStyle {
  INFO = "info",
  WARN = "warn",
}
 
interface Props {
  children: ReactNode;
  className?: string;
  "data-testid"?: string;
  isHighlighted?: boolean;
  highlightStyle?: HighlightStyle;
}
 
export const RaisedCard = ({
  children,
  className,
  "data-testid": dataTestId,
  isHighlighted = false,
  highlightStyle,
}: Props): ReactElement => (
  <Card
    className={className}
    data-testid={dataTestId}
    $isHighlighted={isHighlighted}
    $highlightStyle={highlightStyle}
  >
    {children}
  </Card>
);
 
const Card = styled.div<{
  $isHighlighted: boolean;
  $highlightStyle?: HighlightStyle;
}>`
  margin: 20px 0 20px 0;
  padding: 12px 8px 12px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fafafa;
  box-shadow: ${(props) => props.theme.shadowLower};
 
  ${(props) =>
    props.$isHighlighted &&
    `border: 1px solid ${
      props.$highlightStyle === HighlightStyle.WARN
        ? props.theme.borderCardWarnHighlight
        : props.theme.borderCardHighlight
    };`}
  ${(props) =>
    props.$isHighlighted &&
    `border-left: 5px solid ${
      props.$highlightStyle === HighlightStyle.WARN
        ? props.theme.borderCardWarnHighlight
        : props.theme.borderCardHighlight
    };`}
`;