All files / src/components/Header index.tsx

75% Statements 3/4
100% Branches 11/11
66.66% Functions 2/3
75% Lines 3/4

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 66 67 68 69 70 71          2x                         5x                                                                   1x                                    
import React from "react";
import * as style from "./index.module.scss";
 
import ReactGA from "react-ga4";
 
const Header = ({
  img = "",
  title = "",
  subTitle = "",
  authorImage = true,
  authorName = "",
}: {
  img?: string;
  title?: string;
  subTitle?: string;
  authorImage?: boolean;
  authorName?: string;
}) => (
  <div
    className="col-12 header"
    style={{ padding: 0 }}
    id="header"
    data-testid="header"
  >
    <div
      className={style.imgContainer}
      style={{
        backgroundImage: `linear-gradient( rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2) ), url(${img})`,
      }}
    >
      {title && <h1 className={style.uTitle}>{title}</h1>}
      {subTitle && (
        <div className={style.uSubtitle}>
          <div className={style.mLeft}>
            {authorImage && (
              <picture>
                <source
                  className={style.authorImage}
                  srcSet="/assets/avater.webp"
                  type="image/webp"
                  onClick={() =>
                    ReactGA.event({
                      category: "User",
                      action: "push tubone Avatar",
                    })
                  }
                />
                <img
                  className={style.authorImage}
                  src="/assets/avater.png"
                  alt={authorName}
                  onClick={() =>
                    ReactGA.event({
                      category: "User",
                      action: "push tubone Avatar",
                    })
                  }
                />
              </picture>
            )}
            <span className={style.authorName}>{authorName}</span>
          </div>
          <span className={style.text}>{subTitle}</span>
        </div>
      )}
    </div>
  </div>
);
 
export default Header;