From 3eb7f241bf3d8e361788f2ff8aef7b0fcf55ccca Mon Sep 17 00:00:00 2001 From: William Grant Date: Mon, 26 Feb 2024 11:34:04 +1100 Subject: [PATCH] feat: fix back button positioning relative to related component we can now pass children to a container that holds the back button --- .../registration/RegistrationStages.tsx | 82 +++++++++---------- .../registration/RegistrationUserDetails.tsx | 51 ++++++------ .../registration/components/BackButton.tsx | 19 +++++ .../registration/stages/CreatAccount.tsx | 11 +-- 4 files changed, 89 insertions(+), 74 deletions(-) diff --git a/ts/components/registration/RegistrationStages.tsx b/ts/components/registration/RegistrationStages.tsx index 251e08788..58931c4ab 100644 --- a/ts/components/registration/RegistrationStages.tsx +++ b/ts/components/registration/RegistrationStages.tsx @@ -30,7 +30,6 @@ import { Storage, setSignInByLinking, setSignWithRecoveryPhrase } from '../../ut import { Flex } from '../basic/Flex'; import { SpacerLG, SpacerSM } from '../basic/Text'; import { SessionIcon, SessionIconButton } from '../icon'; -import { BackButton } from './components'; import { CreateAccount, RestoreAccount, Start } from './stages'; const StyledRegistrationContainer = styled(Flex)` @@ -207,53 +206,46 @@ export const RegistrationStages = () => { }); return ( - - {step === Onboarding.Start ? null : ( -
- + + + + +
+
- )} - - + { + void shell.openExternal('https://getsession.org/faq'); + }} + /> -
- -
- - { - void shell.openExternal('https://getsession.org/faq'); - }} - /> - - { - void shell.openExternal('https://getsession.org'); - }} - /> - + { + 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/RegistrationUserDetails.tsx b/ts/components/registration/RegistrationUserDetails.tsx index 8eb0e774c..f332de3b0 100644 --- a/ts/components/registration/RegistrationUserDetails.tsx +++ b/ts/components/registration/RegistrationUserDetails.tsx @@ -1,6 +1,7 @@ import { MAX_USERNAME_BYTES } from '../../session/constants'; import { SpacerLG } from '../basic/Text'; import { SessionInput2 } from '../inputs'; +import { BackButtonWithininContainer } from './components/BackButton'; const DisplayNameInput = (props: { stealAutoFocus?: boolean; @@ -59,29 +60,31 @@ export const RegistrationUserDetails = (props: Props) => { } return ( -
- {props.showSeedField && ( - <> - - - - )} - {props.showDisplayNameField && ( - <> - - - - )} -
+ +
+ {props.showSeedField && ( + <> + + + + )} + {props.showDisplayNameField && ( + <> + + + + )} +
+
); }; diff --git a/ts/components/registration/components/BackButton.tsx b/ts/components/registration/components/BackButton.tsx index 105a91cc2..636790772 100644 --- a/ts/components/registration/components/BackButton.tsx +++ b/ts/components/registration/components/BackButton.tsx @@ -1,3 +1,4 @@ +import { ReactNode } from 'react'; import { useDispatch } from 'react-redux'; import { AccountCreation, @@ -7,8 +8,26 @@ import { setAccountRestorationStep, setOnboardingStep, } from '../../../state/onboarding/ducks/registration'; +import { Flex } from '../../basic/Flex'; import { SessionIconButton } from '../../icon'; +export const BackButtonWithininContainer = ({ + children, + margin, +}: { + children: ReactNode; + margin?: string; +}) => { + return ( + +
+ +
+ {children} +
+ ); +}; + export const BackButton = () => { const dispatch = useDispatch(); diff --git a/ts/components/registration/stages/CreatAccount.tsx b/ts/components/registration/stages/CreatAccount.tsx index 706d1b1cc..1b2f0cc27 100644 --- a/ts/components/registration/stages/CreatAccount.tsx +++ b/ts/components/registration/stages/CreatAccount.tsx @@ -16,6 +16,7 @@ import { SessionIdEditable } from '../../basic/SessionIdEditable'; import { signUp } from '../RegistrationStages'; import { RegistrationUserDetails } from '../RegistrationUserDetails'; import { TermsAndConditions } from '../TermsAndConditions'; +import { BackButtonWithininContainer } from '../components/BackButton'; import { sanitizeDisplayNameOrToast } from './RestoreAccount'; const StyledContainer = styled.div` @@ -48,11 +49,11 @@ export const CreateAccount = () => { alignItems="center" margin={'0 0 0 calc(var(--margins-sm) * -1)'} > - {/* */} - -
- {window.i18n('yourUniqueSessionID')} -
+ +
+ {window.i18n('yourUniqueSessionID')} +
+