Advertisement
kopyl

Untitled

Sep 26th, 2022
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 12.34 KB | None | 0 0
  1. import Image from "next/image";
  2. import { Box, Typography } from "@mui/material";
  3. import { OnboardingButton } from "components/onboarding/buttons";
  4. import iconArrow from "assets/svg/onboarding/icon-small-arrow-white.svg";
  5. import { OnboardingLink } from "components/onboarding";
  6. import topBarLeft from "assets/svg/onboarding/tutorial/top-bar-left.svg";
  7. import chromeBarLeft from "assets/svg/onboarding/tutorial/chrome-bar-left.svg";
  8. import chromeAwsTab from "assets/svg/onboarding/tutorial/chrome-aws-tab.svg";
  9. import topBarArrow from "assets/svg/onboarding/tutorial/top-bar-arrow.svg";
  10. import lowerBarLeft from "assets/svg/onboarding/tutorial/lower-bar-left.svg";
  11. import lowerBarRight from "assets/svg/onboarding/tutorial/lower-bar-right.svg";
  12. import iconLock from "assets/svg/onboarding/tutorial/icon-lock.svg";
  13. import { Link } from "./aws-link";
  14. import iconShare from "assets/svg/onboarding/tutorial/icon-url-share.svg";
  15. import iconStar from "assets/svg/onboarding/tutorial/icon-star.svg";
  16. import iconsRightUrlBar from "assets/svg/onboarding/tutorial/icons-right-url-bar.svg";
  17. import mainWhole from "assets/svg/onboarding/tutorial/main-whole.svg";
  18. import breadCrumbs from "assets/svg/onboarding/tutorial/breadcrumbs.svg";
  19. import awsHeaderLeft from "assets/svg/onboarding/tutorial/aws-header-left.svg";
  20. import awsHeaderRight from "assets/svg/onboarding/tutorial/aws-header-right.svg";
  21. import { useEffect, useRef, useState } from "react";
  22. import { useOnboarding } from "context/OnboardingContext";
  23.  
  24. const steps = [
  25.   {
  26.     description: "We’ll open AWS console in a new tab",
  27.     icon: <Image src="" alt="We'll open a new tab" />,
  28.   },
  29.   {
  30.     description:
  31.       "Scroll down, check the checkbox, and press the button “Create stack”",
  32.     icon: <Image src="" alt="Connect on AWS" />,
  33.   },
  34.   {
  35.     description: "Then you can close AWS console, we’ll do the rest :)",
  36.     icon: <Image src="" alt="Now you can close AWS" />,
  37.   },
  38. ];
  39.  
  40. const StepDots = ({ step }: any) => {
  41.   return (
  42.     <Box
  43.      sx={{
  44.        display: "flex",
  45.        alignItems: "center",
  46.        gap: "10px",
  47.      }}
  48.    >
  49.       {[1, 2, 3].map((_, index) => (
  50.         <Box
  51.          key={index}
  52.          sx={{
  53.            width: "5px",
  54.            height: "5px",
  55.            borderRadius: "100%",
  56.            background:
  57.              step === index
  58.                ? "rgba(255, 255, 255, 1)"
  59.                : "rgba(255, 255, 255, 0.3)",
  60.            transition: "background 0.3s",
  61.          }}
  62.        ></Box>
  63.       ))}
  64.     </Box>
  65.   );
  66. };
  67.  
  68. const AwsTile = ({ children, title, style }: any) => {
  69.   return (
  70.     <Box
  71.      sx={{
  72.        boxShadow: "0px 1px 1px rgba(0, 0, 0, 0.3)",
  73.        maxWidth: "900px",
  74.        ...style,
  75.        alignSelf: "normal",
  76.      }}
  77.    >
  78.       <Box
  79.        sx={{
  80.          padding: "21px 20px 24px 20px",
  81.          background: "#FAFAFA",
  82.          borderBottom: "1px solid #EAEDED",
  83.        }}
  84.      >
  85.         <Box
  86.          sx={{
  87.            display: "flex",
  88.            gap: "7px",
  89.          }}
  90.        >
  91.           <Typography
  92.            sx={{
  93.              fontWeight: 700,
  94.              lineHeight: "22px",
  95.              fontSize: "18px",
  96.              color: "#17191E",
  97.            }}
  98.          >
  99.             {title}
  100.           </Typography>
  101.         </Box>
  102.       </Box>
  103.       <Box
  104.        sx={{
  105.          background: "#FFFFFF",
  106.          padding: "17px 20px",
  107.        }}
  108.      >
  109.         {children}
  110.       </Box>
  111.     </Box>
  112.   );
  113. };
  114.  
  115. const SmallestTitle = ({ children, style }: any) => (
  116.   <Typography
  117.    sx={{
  118.      fontSize: "14px",
  119.      lineHeight: "22px",
  120.      color: "#16191E",
  121.      ...style,
  122.    }}
  123.  >
  124.     {children}
  125.   </Typography>
  126. );
  127.  
  128. const SmallLabel = ({ children, style }: any) => (
  129.   <Typography
  130.    sx={{
  131.      fontSize: "12px",
  132.      lineHeight: "16px",
  133.      color: "#555B63",
  134.      ...style,
  135.    }}
  136.  >
  137.     {children}
  138.   </Typography>
  139. );
  140.  
  141. const AwsInput = ({ children, style }: any) => (
  142.   <Box
  143.    sx={{
  144.      padding: "8px 9px",
  145.      borderRadius: "2px",
  146.      border: "1px solid #AAB7B8",
  147.      ...style,
  148.    }}
  149.  >
  150.     <Typography
  151.      sx={{
  152.        fontSize: "14px",
  153.        lineHeight: "16px",
  154.        color: "#16191F",
  155.      }}
  156.    >
  157.       {children}
  158.     </Typography>
  159.   </Box>
  160. );
  161.  
  162. const TutorialVisual = ({ tutorialStep }: any) => {
  163.   const awsUI = useRef<any>();
  164.   const [overlayVisibe, setOverlayVisible] = useState(true);
  165.   // const [overlayVisibe, setOverlayVisible] = useState(false);
  166.   const [tabZIndex, setTabZIndex] = useState(3);
  167.  
  168.   useEffect(() => {
  169.     console.log("tutorialStep", tutorialStep);
  170.  
  171.     if (tutorialStep === 1) {
  172.       setOverlayVisible(false);
  173.       setTimeout(() => {
  174.         awsUI.current.scrollTop = 10000;
  175.       }, 500);
  176.       setTimeout(() => {
  177.         setTabZIndex(0);
  178.       }, 150);
  179.       setTimeout(() => {
  180.         setOverlayVisible(true);
  181.       }, 1000);
  182.     }
  183.   }, [tutorialStep]);
  184.  
  185.   return (
  186.     <Box
  187.      className="outer"
  188.      sx={{
  189.        display: "flex",
  190.        flexDirection: "column",
  191.        borderRadius: "9px",
  192.        height: "100%", // allows scrolling
  193.        border: "1px solid #414141",
  194.        opacity: tutorialStep === 2 ? 0 : 1,
  195.        transition: "opacity 0.3s",
  196.        position: "relative",
  197.        overflow: "hidden",
  198.      }}
  199.    >
  200.       <Box
  201.        sx={{
  202.          width: "100%",
  203.          height: "100%",
  204.          position: "absolute",
  205.          inset: 0,
  206.          background: "rgba(0, 0, 0, 0.7)",
  207.          zIndex: 2,
  208.          opacity: overlayVisibe ? 1 : 0,
  209.          transition: "opacity 0.3s",
  210.          pointerEvents: "none",
  211.        }}
  212.      />
  213.       <Box>
  214.         <Box
  215.          sx={{
  216.            display: "flex",
  217.            justifyContent: "space-between",
  218.            background: "#202124",
  219.          }}
  220.        >
  221.           <Box
  222.            sx={{
  223.              display: "flex",
  224.              alignItems: "end",
  225.            }}
  226.          >
  227.             <Image src={chromeBarLeft} alt=""></Image>
  228.             <Image
  229.              style={{
  230.                zIndex: tabZIndex,
  231.              }}
  232.              src={chromeAwsTab}
  233.              alt=""
  234.            ></Image>
  235.           </Box>
  236.           <Image src={topBarArrow} alt=""></Image>
  237.         </Box>
  238.         <Box
  239.          sx={{
  240.            display: "flex",
  241.            background: "#35363A",
  242.          }}
  243.        >
  244.           <Image src={lowerBarLeft} alt=""></Image>
  245.           <Box
  246.            sx={{
  247.              flex: 1,
  248.              borderBottom: "1px solid #606164",
  249.              padding: "4px 0",
  250.            }}
  251.          >
  252.             <Box
  253.              sx={{
  254.                display: "flex",
  255.                alignItems: "center",
  256.                padding: "0 10px",
  257.                height: "100%",
  258.                background: "#202024",
  259.                borderRadius: "100vw",
  260.              }}
  261.            >
  262.               <Image src={iconLock} alt=""></Image>
  263.               <Typography
  264.                sx={{
  265.                  flex: 1,
  266.                  fontSize: "12px",
  267.                  lineHeight: "14px",
  268.                  color: "#FFFFFF",
  269.                  marginLeft: "10px",
  270.                  whiteSpace: "nowrap",
  271.                  textOverflow: "ellipsis",
  272.                  width: "100px",
  273.                  overflow: "hidden",
  274.                }}
  275.              >
  276.                 <Link />
  277.               </Typography>
  278.               <Image src={iconsRightUrlBar} alt=""></Image>
  279.             </Box>
  280.           </Box>
  281.           <Image src={lowerBarRight} alt=""></Image>
  282.         </Box>
  283.         <Box
  284.          sx={{
  285.            display: "flex",
  286.            justifyContent: "space-between",
  287.            background: "#232F3E",
  288.            height: "41px",
  289.            borderBottom: "1px solid #606164",
  290.          }}
  291.        >
  292.           <Image src={awsHeaderLeft} alt=""></Image>
  293.           <Image src={awsHeaderRight} alt=""></Image>
  294.         </Box>
  295.       </Box>
  296.  
  297.       <Box
  298.        ref={awsUI}
  299.        sx={{
  300.          flex: 1,
  301.          backgroundColor: "#F2F3F3",
  302.          padding: "21px 40px",
  303.          display: "flex",
  304.          flexDirection: "column",
  305.          alignItems: "flex-start",
  306.          width: "100%",
  307.          overflow: "auto",
  308.          scrollBehavior: "smooth",
  309.        }}
  310.      >
  311.         <Box>
  312.           <Image src={breadCrumbs} alt=""></Image>
  313.         </Box>
  314.         <Typography
  315.          sx={{
  316.            fontSize: "28px",
  317.            lineHeight: "36px",
  318.            color: "#16191E",
  319.            marginTop: "28px",
  320.          }}
  321.        >
  322.           Quck create stack
  323.         </Typography>
  324.         <AwsTile
  325.          style={{
  326.            marginTop: "20px",
  327.          }}
  328.          title="Template"
  329.        >
  330.           <SmallestTitle>Template URL</SmallestTitle>
  331.           <SmallestTitle>
  332.             https://digger-aws-connection-template.s3.amazonaws.com/roleTemplate.yml
  333.           </SmallestTitle>
  334.           <SmallestTitle
  335.            style={{
  336.              marginTop: "20px",
  337.            }}
  338.          >
  339.             Stack description
  340.           </SmallestTitle>
  341.           <SmallestTitle>
  342.             This stack creates an IAM role that can be used by Digger for use in
  343.             deployments.
  344.           </SmallestTitle>
  345.         </AwsTile>
  346.         <AwsTile
  347.          style={{
  348.            marginTop: "20px",
  349.          }}
  350.          title="Stack name"
  351.        >
  352.           <SmallestTitle>Stack name</SmallestTitle>
  353.           <AwsInput
  354.            style={{
  355.              marginTop: "7px",
  356.            }}
  357.          >
  358.             DiggerRoleStack-0b6e93fb-0008-43f4-ab9c-8d554ad981f9
  359.           </AwsInput>
  360.           <SmallLabel
  361.            style={{
  362.              marginTop: "4px",
  363.            }}
  364.          >
  365.             Stack name can include letters (A-Z and a-z), numbers (0-9), and
  366.             dashes (-).
  367.           </SmallLabel>
  368.         </AwsTile>
  369.       </Box>
  370.     </Box>
  371.   );
  372. };
  373.  
  374. export const Tutorial = () => {
  375.   const { tutorialStep, setTutorialStep } = useOnboarding();
  376.   const changeStep = (step: any) => {
  377.     setTutorialStep(step);
  378.   };
  379.   const [tutorialVisibe, setTutorialVisibe] = useState(true);
  380.  
  381.   useEffect(() => {
  382.     if (tutorialStep === 2) {
  383.       setTimeout(() => {
  384.         setTutorialVisibe(false);
  385.       }, 150);
  386.     } else {
  387.       setTutorialVisibe(true);
  388.     }
  389.   }, [tutorialStep]);
  390.  
  391.   return (
  392.     <Box
  393.      sx={{
  394.        display: "flex",
  395.        marginTop: "50px",
  396.        flexDirection: "column",
  397.        gap: "27px",
  398.        transition: "height 0.3s",
  399.        flex: 1,
  400.      }}
  401.    >
  402.       <Box
  403.        sx={{
  404.          width: "100%",
  405.          height: tutorialStep === 2 ? "116px" : "60%",
  406.          overflow: "hidden",
  407.          background: tutorialStep === 2 ? "rgba(0, 0, 0, 0.3)" : "transparent",
  408.          borderRadius: "5px",
  409.          transition: "0.3s",
  410.        }}
  411.      >
  412.         {tutorialVisibe && <TutorialVisual tutorialStep={tutorialStep} />}
  413.      </Box>
  414.      <Box
  415.        sx={{
  416.          display: "flex",
  417.          gap: "50px",
  418.        }}
  419.      >
  420.        <Box
  421.          sx={{
  422.            display: "flex",
  423.            alignItems: "center",
  424.            flex: 1,
  425.            gap: "24px",
  426.            height: "40px",
  427.          }}
  428.        >
  429.          <StepDots step={tutorialStep} />
  430.          <Typography>{steps[tutorialStep].description}</Typography>
  431.        </Box>
  432.        <Box
  433.          sx={{
  434.            display: "flex",
  435.            alignItems: "center",
  436.          }}
  437.        >
  438.          {tutorialStep !== 2 && (
  439.            <OnboardingButton
  440.              buttonSize="small"
  441.              EndIcon={iconArrow}
  442.              outlinedIcon
  443.              noflex
  444.              onClick={() => changeStep((prev: any) => Math.min(prev + 1, 2))}
  445.            >
  446.              Next
  447.            </OnboardingButton>
  448.          )}
  449.          {tutorialStep === 2 && (
  450.            <Box
  451.              sx={{
  452.                display: "flex",
  453.                gap: "24px",
  454.              }}
  455.            >
  456.              <OnboardingLink secondary onClick={() => changeStep(0)}>
  457.                Replay tutorial
  458.              </OnboardingLink>
  459.              <OnboardingLink href="https://youtu.be/KNmeK_vhy1A">
  460.                Watch video explanation
  461.              </OnboardingLink>
  462.            </Box>
  463.          )}
  464.        </Box>
  465.      </Box>
  466.    </Box>
  467.  );
  468. };
  469.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement