Skip to content

Commit

Permalink
chore: Partial progress
Browse files Browse the repository at this point in the history
  • Loading branch information
ape-fede committed Dec 20, 2022
1 parent 0051583 commit b941cf5
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/widgets/TutorialModal/TutorialModal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export const WithUseModalNavbar: React.FC = (args: any) => {
children: [<>this is the slide content</>, <>fede is hot</>],
readyText: "I'm Ready",
type: TutorialModals.BNB_DEX,
isConnected: true,
});
return (
<StorybookLayout {...args}>
Expand Down
18 changes: 14 additions & 4 deletions src/widgets/TutorialModal/TutorialModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,18 @@ const Circle: React.FC<CountProps> = ({ index, goToStep, isActive }) => {
/>
);
};
const TutorialModal: React.FC<TModalProps> = ({ type, title, description, children, onDismiss, readyText, t }) => {
const [step, setStep] = useState(0);
const TutorialModal: React.FC<TModalProps> = ({
type,
title,
description,
children,
onDismiss,
readyText,
t,
isConnected,
}) => {
const [step, setStep] = useState<number>(0);
const slideNumber = isConnected ? step + 1 : step;

const handleNext = () => {
setStep(step + 1);
Expand All @@ -30,7 +40,7 @@ const TutorialModal: React.FC<TModalProps> = ({ type, title, description, childr
return children?.map((element, i) => (
<Flex>
{step === i && (
<Flex sx={{ width: "100%", flexWrap: "wrap", mt: 30 }}>
<Flex sx={{ width: "100%", flexWrap: "wrap", mt: ["15px", "15px", "30px"] }}>
<Flex sx={{ width: "100%" }}>
<Text
sx={{
Expand Down Expand Up @@ -62,7 +72,7 @@ const TutorialModal: React.FC<TModalProps> = ({ type, title, description, childr
<Flex className="tutorial-modal" sx={styles.modalCon}>
<CloseIcon width={22} onClick={onDismiss} sx={{ cursor: "pointer", position: "absolute", right: "20px" }} />
<Flex sx={styles.contentBody}>
<Box sx={dynamicStyles.showApe({ step, type })} />
<Box sx={dynamicStyles.showApe({ slideNumber, type })} />
<Flex sx={styles.rightCon}>
<Flex sx={styles.right}>
<Flex sx={styles.modalHeader}>
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/TutorialModal/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ export const modalProps = {
};

export const dynamicStyles: Record<string, (props: any) => ThemeUIStyleObject> = {
showApe: ({ step, type }: ShowApeType) => ({
showApe: ({ slideNumber, type }: ShowApeType) => ({
alignSelf: ["center", "center", ""],
width: ["200px", "200px", "340px"],
height: ["200px", "200px", "340px"],
marginTop: "20px",
background: `url(images/tutorial-modals/${type}-${step}.svg)`,
background: `url(images/tutorial-modals/${type}-${slideNumber}.svg)`,
backgroundRepeat: "no-repeat",
backgroundPosition: "center",
backgroundSize: "cover",
Expand Down
3 changes: 2 additions & 1 deletion src/widgets/TutorialModal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface TModalProps {
readyText: string;
description?: string;
children: React.ReactNode[];
isConnected: boolean;
}

export interface CountProps {
Expand Down Expand Up @@ -41,7 +42,7 @@ export enum TutorialModals {
export type TutorialModalTypes = `${TutorialModals}`;

export interface ShowApeType {
step: number;
slideNumber: number;
type: TutorialModalTypes | string;
isDark: boolean;
}
2 changes: 2 additions & 0 deletions src/widgets/TutorialModal/useTutorialModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const useTutorialModal = ({
onDismiss,
readyText,
t,
isConnected,
}: TModalProps): ReturnType => {
const [onPresentTutorialModal] = useModal(
<TutorialModal
Expand All @@ -24,6 +25,7 @@ const useTutorialModal = ({
onDismiss={onDismiss}
readyText={readyText}
t={t}
isConnected={isConnected}
>
{children}
</TutorialModal>,
Expand Down

0 comments on commit b941cf5

Please sign in to comment.