From bcb926b6edc5fdade334ed2845b8b82deea3bf09 Mon Sep 17 00:00:00 2001 From: William Grant Date: Fri, 15 Mar 2024 17:15:06 +1100 Subject: [PATCH] feat: started initial work on onboarding step animation --- .../registration/RegistrationStages.tsx | 77 ++++++++++--------- .../registration/components/BackButton.tsx | 9 ++- .../components/OnboardingContainer.tsx | 38 +++++++++ .../registration/components/index.tsx | 5 +- .../registration/stages/CreateAccount.tsx | 14 +++- .../registration/stages/RestoreAccount.tsx | 16 +++- ts/components/registration/stages/Start.tsx | 5 +- 7 files changed, 115 insertions(+), 49 deletions(-) create mode 100644 ts/components/registration/components/OnboardingContainer.tsx diff --git a/ts/components/registration/RegistrationStages.tsx b/ts/components/registration/RegistrationStages.tsx index 592c9404f..86abfe673 100644 --- a/ts/components/registration/RegistrationStages.tsx +++ b/ts/components/registration/RegistrationStages.tsx @@ -1,4 +1,5 @@ import { shell } from 'electron'; +import { AnimatePresence } from 'framer-motion'; import { useDispatch } from 'react-redux'; import { useMount } from 'react-use'; import styled from 'styled-components'; @@ -78,46 +79,48 @@ export const RegistrationStages = () => { }); return ( - - - - -
- -
+ + - { - void shell.openExternal('https://getsession.org/faq'); - }} - /> + - { - void shell.openExternal('https://getsession.org'); - }} - /> +
+ +
+ + { + void shell.openExternal('https://getsession.org/faq'); + }} + /> + + { + void shell.openExternal('https://getsession.org'); + }} + /> +
-
- - - {step === Onboarding.Start ? : null} - {step === Onboarding.CreateAccount ? : null} - {step === Onboarding.RestoreAccount ? : null} - -
+ + + {step === Onboarding.Start ? : null} + {step === Onboarding.CreateAccount ? : null} + {step === Onboarding.RestoreAccount ? : null} + + + ); }; diff --git a/ts/components/registration/components/BackButton.tsx b/ts/components/registration/components/BackButton.tsx index 9892ecc05..392c1b650 100644 --- a/ts/components/registration/components/BackButton.tsx +++ b/ts/components/registration/components/BackButton.tsx @@ -14,21 +14,23 @@ import { SessionIconButton } from '../../icon'; export const BackButtonWithininContainer = ({ children, margin, + callback, }: { children: ReactNode; margin?: string; + callback?: () => void; }) => { return (
- +
{children}
); }; -export const BackButton = () => { +export const BackButton = ({ callback }: { callback?: () => void }) => { const dispatch = useDispatch(); return ( @@ -41,6 +43,9 @@ export const BackButton = () => { dispatch(setOnboardingStep(Onboarding.Start)); dispatch(setAccountRestorationStep(AccountRestoration.RecoveryPassword)); dispatch(setAccountCreationStep(AccountCreation.DisplayName)); + if (callback) { + callback(); + } }} /> ); diff --git a/ts/components/registration/components/OnboardingContainer.tsx b/ts/components/registration/components/OnboardingContainer.tsx new file mode 100644 index 000000000..b096effc2 --- /dev/null +++ b/ts/components/registration/components/OnboardingContainer.tsx @@ -0,0 +1,38 @@ +import { motion } from 'framer-motion'; +import { ReactNode } from 'react'; +import styled from 'styled-components'; + +type OnboardContainerProps = { + animate?: boolean; + children: ReactNode; + key: string; + direction: 'left' | 'right'; +}; + +export const OnboardContainer = (props: OnboardContainerProps) => { + const { animate = false, children, key, direction: _direction } = props; + const OnboardContainerInner = styled(motion.div)` + width: 100%; + `; + + const direction = _direction === 'left' ? -1 : 1; + + const fadeSlideVariants = { + initial: { x: 50 * direction, opacity: 0 }, + animate: { x: 0, opacity: 1 }, + exit: { x: -50 * direction, opacity: 0 }, + }; + + return ( + + {children} + + ); +}; diff --git a/ts/components/registration/components/index.tsx b/ts/components/registration/components/index.tsx index e43463515..d9cdc114a 100644 --- a/ts/components/registration/components/index.tsx +++ b/ts/components/registration/components/index.tsx @@ -1,10 +1,7 @@ import styled from 'styled-components'; import { BackButton } from './BackButton'; import { Hero } from './Hero'; - -const OnboardContainer = styled.div` - width: 100%; -`; +import { OnboardContainer } from './OnboardingContainer'; const OnboardHeading = styled.h3` padding: 0; diff --git a/ts/components/registration/stages/CreateAccount.tsx b/ts/components/registration/stages/CreateAccount.tsx index e862b0200..3e704a5f2 100644 --- a/ts/components/registration/stages/CreateAccount.tsx +++ b/ts/components/registration/stages/CreateAccount.tsx @@ -4,6 +4,7 @@ import { SettingsKey } from '../../../data/settings-key'; import { trigger } from '../../../shims/events'; import { AccountCreation, + Onboarding, setAccountCreationStep, } from '../../../state/onboarding/ducks/registration'; import { @@ -82,8 +83,17 @@ export const CreateAccount = () => { }; return ( - - + + { + setDisplayNameError(''); + }} + > { }; return ( - + {step === AccountRestoration.RecoveryPassword || step === AccountRestoration.DisplayName ? ( - + { + setDisplayNameError(''); + setRecoveryPasswordError(''); + setProgress(0); + }} + > { const dispatch = useDispatch(); return ( - <> + { @@ -36,6 +37,6 @@ export const Start = () => { /> - + ); };