diff --git a/src/features/ui/components/modals/onboarding-flow-modal/onboarding-flow-modal.tsx b/src/features/ui/components/modals/onboarding-flow-modal/onboarding-flow-modal.tsx new file mode 100644 index 000000000..ce1445c94 --- /dev/null +++ b/src/features/ui/components/modals/onboarding-flow-modal/onboarding-flow-modal.tsx @@ -0,0 +1,115 @@ +import clsx from 'clsx'; +import React from 'react'; +import ReactSwipeableViews from 'react-swipeable-views'; + +import { endOnboarding } from 'soapbox/actions/onboarding'; +import { Stack, Modal, HStack } from 'soapbox/components/ui'; +import { useAppDispatch } from 'soapbox/hooks'; + +import AvatarSelectionModal from './steps/avatar-step'; +import BioStep from './steps/bio-step'; +import CompletedModal from './steps/completed-step'; +import CoverPhotoSelectionModal from './steps/cover-photo-selection-step'; +import DisplayNameStep from './steps/display-name-step'; +import SuggestedAccountsModal from './steps/suggested-accounts-step'; + +interface IOnboardingFlowModal { + onClose(): void; +} + +const OnboardingFlowModal: React.FC = ({ onClose }) => { + const dispatch = useAppDispatch(); + + const [currentStep, setCurrentStep] = React.useState(0); + + const handleSwipe = (nextStep: number) => { + setCurrentStep(nextStep); + }; + + const handlePreviousStep = () => { + setCurrentStep((prevStep) => Math.max(0, prevStep - 1)); + }; + + const handleDotClick = (nextStep: number) => { + setCurrentStep(nextStep); + }; + + const handleNextStep = () => { + setCurrentStep((prevStep) => Math.min(prevStep + 1, steps.length - 1)); + }; + + const handleComplete = () => { + dispatch(endOnboarding()); + onClose(); + }; + + const steps = [ + , + , + , + , + , + ]; + + steps.push(); + + const handleKeyUp = ({ key }: KeyboardEvent): void => { + switch (key) { + case 'ArrowLeft': + handlePreviousStep(); + break; + case 'ArrowRight': + handleNextStep(); + break; + } + }; + + React.useEffect(() => { + document.addEventListener('keyup', handleKeyUp); + + return () => { + document.removeEventListener('keyup', handleKeyUp); + }; + }, []); + + + return ( + + + + + {steps.map((step, i) => ( +
+
+ {step} +
+
+ ))} +
+ + {steps.map((_, i) => ( +