From 005158357efc0886a93d097e1d0f5738675c9c1e Mon Sep 17 00:00:00 2001
From: Ape Fede <75544302+ape-fede@users.noreply.github.com>
Date: Fri, 16 Dec 2022 19:00:56 -0300
Subject: [PATCH] chore: Changed tutorial models children
---
.../TutorialModal/TutorialModal.stories.tsx | 43 ++-----------------
src/widgets/TutorialModal/TutorialModal.tsx | 31 +++----------
src/widgets/TutorialModal/types.ts | 7 +--
3 files changed, 11 insertions(+), 70 deletions(-)
diff --git a/src/widgets/TutorialModal/TutorialModal.stories.tsx b/src/widgets/TutorialModal/TutorialModal.stories.tsx
index bf5cb28a..fe3d0092 100644
--- a/src/widgets/TutorialModal/TutorialModal.stories.tsx
+++ b/src/widgets/TutorialModal/TutorialModal.stories.tsx
@@ -77,20 +77,11 @@ const Body2 = () => {
export const WithUseModalNavbar: React.FC = (args: any) => {
const [visible, setVisible] = useState(true);
const { onPresentTutorialModal } = useTutorialModal({
- title: "Welcome to ApeSwap's Dex",
- description: "Easily trade ANY token on BNB Chain!",
+ title: "This is the tutorial {title}",
+ description: "This is the tutorial {description}",
t: translate,
onDismiss: () => setVisible(!visible),
- children: [
- {
- title: "title1",
- description: <>slide content 1>,
- },
- {
- title: "title2",
- description: <>slide content 2>,
- },
- ],
+ children: [<>this is the slide content>, <>fede is hot>],
readyText: "I'm Ready",
type: TutorialModals.BNB_DEX,
});
@@ -101,31 +92,3 @@ export const WithUseModalNavbar: React.FC = (args: any) => {
);
};
-
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-export const WithNavbar: React.FC = (args: any) => {
- const [visible, setVisible] = useState(true);
-
- return (
-
- <>
- {visible && (
- setVisible(!visible)}
- readyText="I'm Ready"
- type={TutorialModals.BNB_DEX}
- >
- {[
- { title: "title1", description: <>content1> },
- { title: "title2", description: <>content2> },
- ]}
-
- )}
-
- >
-
- );
-};
diff --git a/src/widgets/TutorialModal/TutorialModal.tsx b/src/widgets/TutorialModal/TutorialModal.tsx
index 7a9cf072..f61055ae 100644
--- a/src/widgets/TutorialModal/TutorialModal.tsx
+++ b/src/widgets/TutorialModal/TutorialModal.tsx
@@ -1,7 +1,6 @@
/** @jsxImportSource theme-ui */
import React, { useState } from "react";
import { Box } from "theme-ui";
-
import { CloseIcon } from "../../components/Svg";
import { Flex } from "../../components/Flex";
import { Modal } from "../Modal";
@@ -28,9 +27,9 @@ const TutorialModal: React.FC = ({ type, title, description, childr
};
const renderChildren = () => {
- return children.map((element, index) => (
-
- {step === index && (
+ return children?.map((element, i) => (
+
+ {step === i && (
= ({ type, title, description, childr
{t(`Step ${step + 1}`)}
-
-
- {element.title}
-
-
- {element.description}
+ {element}
)}
@@ -66,7 +52,7 @@ const TutorialModal: React.FC = ({ type, title, description, childr
};
const renderDots = () => {
- return [...Array(children.length)].map((_, index) => (
+ return [...Array(children?.length)].map((_, index) => (
setStep(index)} isActive={index === step} />
));
};
@@ -83,15 +69,12 @@ const TutorialModal: React.FC = ({ type, title, description, childr
{t(`${title}`)}
{t(`${description}`)}
- {/* If mobile wrap the children in a higher order component */}
- {/* {renderChildren()} */}
- {/* step, setStep, goNext */}
{renderChildren()}
{renderDots()}
-
diff --git a/src/widgets/TutorialModal/types.ts b/src/widgets/TutorialModal/types.ts
index 28f15c12..46f0861e 100644
--- a/src/widgets/TutorialModal/types.ts
+++ b/src/widgets/TutorialModal/types.ts
@@ -9,12 +9,7 @@ export interface TModalProps {
title: string;
readyText: string;
description?: string;
- children: Slide[];
-}
-
-export interface Slide {
- title: string;
- description: React.ReactNode;
+ children: React.ReactNode[];
}
export interface CountProps {