All files / app/features/landing CouchersIntroduction.tsx

95% Statements 19/20
66.66% Branches 2/3
80% Functions 4/5
94.44% Lines 17/18

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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 1741x 1x 1x 1x 1x           1x 1x           2x                                                                         2x                         1x 2x 2x 2x   2x 1x   2x                                                                                                                                                                                                 2x  
import { Stack, styled, Typography, useMediaQuery } from "@mui/material";
import Button from "components/Button";
import { Trans, useTranslation } from "i18n";
import { GLOBAL, LANDING } from "i18n/namespaces";
import { useRouter } from "next/router";
import {
  couchersAppStoreURL,
  couchersGooglePlayURL,
  signupRoute,
  whatIsCouchSurfingRoute,
} from "routes";
import { theme } from "theme";
 
function AppStoreBadges({ appStoreHeight = 38 }: { appStoreHeight?: number }) {
  const {
    t,
    i18n: { language: locale },
  } = useTranslation(GLOBAL);
  return (
    <Stack
      direction="row"
      spacing={1}
      sx={{
        marginTop: 2,
        width: "fit-content",
        mx: { xs: "auto", md: 0 },
      }}
    >
      <a href={couchersAppStoreURL} target="_blank" rel="noopener noreferrer">
        <img
          src={`/img/app-store-badge/${locale}.svg`}
          alt={t("app_store_badge_a11y")}
          style={{
            height: `${appStoreHeight}px`,
            width: "auto",
            display: "block",
          }}
        />
      </a>
      <a href={couchersGooglePlayURL} target="_blank" rel="noopener noreferrer">
        <img
          src={`/img/google-play-badge/${locale}.svg`}
          alt={t("google_play_badge_a11y")}
          style={{
            height: `${appStoreHeight}px`,
            width: "auto",
            display: "block",
          }}
        />
      </a>
    </Stack>
  );
}
 
const StyledIntroduction = styled("div")(({ theme }) => ({
  flexDirection: "column",
  display: "flex",
  textAlign: "left",
  width: "45%",
 
  [theme.breakpoints.down("md")]: {
    width: "100%",
    alignItems: "center",
    textAlign: "center",
  },
}));
 
const CouchersIntroduction = () => {
  const { t } = useTranslation([GLOBAL, LANDING]);
  const router = useRouter();
  const isMobile = useMediaQuery(theme.breakpoints.down("md"));
 
  const routeToSignupPage = () => {
    router.push(signupRoute);
  };
  const routeToLearnMore = () => {
    router.push(whatIsCouchSurfingRoute);
  };
 
  return (
    <StyledIntroduction>
      <Typography
        lineHeight={1.1}
        fontWeight="bold"
        sx={{
          fontSize: "3.5rem",
 
          [theme.breakpoints.down("md")]: {
            width: "100%",
            marginBottom: theme.spacing(2),
            fontSize: "2rem",
          },
        }}
      >
        {t("landing:introduction_title")}
      </Typography>
      <>
        <Typography
          sx={{
            marginTop: theme.spacing(3),
            marginBottom: theme.spacing(1),
            position: "relative",
            fontWeight: 400,
            fontSize: "1.3rem",
          }}
        >
          <Trans
            i18nKey="landing:introduction_subtitle"
            components={{
              bold: <strong style={{ fontWeight: 700 }} />,
            }}
          />
        </Typography>
        <Typography
          sx={{
            fontWeight: "bold",
            fontSize: "1.2rem",
          }}
        >
          {t("landing:introduction_subtitle2")}
        </Typography>
        {!isMobile && (
          <>
            <Stack direction="row" spacing={2} sx={{ marginTop: 4 }}>
              <Button
                onClick={routeToSignupPage}
                size="large"
                color="primary"
                sx={{
                  minWidth: theme.spacing(20),
                  fontSize: "1.2rem",
                  paddingX: theme.spacing(3),
                }}
              >
                {t("global:join_us")}
              </Button>
              <Button
                onClick={routeToLearnMore}
                size="large"
                variant="outlined"
                color="primary"
                sx={{
                  minWidth: theme.spacing(20),
                  fontSize: "1.2rem",
                  paddingX: theme.spacing(3),
                }}
              >
                {t("global:learn_more")}
              </Button>
            </Stack>
            <AppStoreBadges appStoreHeight={42} />
          </>
        )}
        {isMobile && (
          <>
            <Button
              onClick={routeToLearnMore}
              size="large"
              variant="text"
              color="primary"
              sx={{ mt: 2, fontSize: "1.1rem", textDecoration: "underline" }}
            >
              {t("global:learn_more")}
            </Button>
            <AppStoreBadges />
          </>
        )}
      </>
    </StyledIntroduction>
  );
};
 
export default CouchersIntroduction;