diff --git a/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx b/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx index da8ada3362..540707005b 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/nostr-signin-modal.tsx @@ -1,7 +1,4 @@ import React, { useState } from 'react'; -import { FormattedMessage } from 'react-intl'; - -import { Modal, Stack } from 'soapbox/components/ui'; import AccountStep from './steps/account-step'; import ExtensionStep from './steps/extension-step'; @@ -18,50 +15,22 @@ const NostrSigninModal: React.FC = ({ onClose }) => { const [accountId, setAccountId] = useState(); - const handleClose = () => { - onClose('NOSTR_SIGNIN'); - }; + const handleClose = () => onClose('NOSTR_SIGNIN'); - const renderStep = () => { - switch (step) { - case 0: - return ; - case 1: - return ; - case 2: - return ; - case 3: - return ; - case 4: - return ; - } - }; - - const renderModalTitle = () => { - switch (step) { - case 0: - return ; - case 1: - return ; - case 2: - return ; - case 3: - return ; - default: - return null; - } - }; - - return ( - - - {renderStep()} - - - ); + switch (step) { + case 0: + return ; + case 1: + return ; + case 2: + return ; + case 3: + return ; + case 4: + return ; + default: + return null; + } }; export default NostrSigninModal; diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx index 8df2447fae..320c21aef4 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/account-step.tsx @@ -1,15 +1,18 @@ import { NSchema as n } from 'nspec'; import React, { useMemo } from 'react'; +import { FormattedMessage } from 'react-intl'; import { useAccount } from 'soapbox/api/hooks'; -import { Avatar, Text, Stack, Emoji, Button, Tooltip } from 'soapbox/components/ui'; +import { Avatar, Text, Stack, Emoji, Button, Tooltip, HStack, Modal } from 'soapbox/components/ui'; import { useInstance } from 'soapbox/hooks'; interface IAccountStep { accountId: string; + setStep(step: number): void; + onClose(): void; } -const AccountStep: React.FC = ({ accountId }) => { +const AccountStep: React.FC = ({ accountId, setStep, onClose }) => { const { account } = useAccount(accountId); const instance = useInstance(); @@ -18,50 +21,58 @@ const AccountStep: React.FC = ({ accountId }) => { [account?.acct], ); + const goBack = () => setStep(1); + if (!account) { return null; } return ( - - - + } onClose={onClose}> + + + - - + + - - - {isBech32 ? ( - account.acct.slice(0, 13) - ) : ( - account.acct - )} - - - - - - {!account.ditto.is_registered && ( - - - - - - You need an account on {instance.title} to continue. - + + + {isBech32 ? account.acct.slice(0, 13) : account.acct} + + - - - )} - + + {account.ditto.is_registered ? ( + + + + + ) : ( + + + + + + You need an account on {instance.title} to continue. + + + + + + + + + )} + + ); }; diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx index b7fa74ae4d..1e5afd869d 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/extension-step.tsx @@ -2,34 +2,36 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; import { nostrExtensionLogIn } from 'soapbox/actions/nostr'; -import Button from 'soapbox/components/ui/button/button'; -import Stack from 'soapbox/components/ui/stack/stack'; +import { Button, Stack, Modal } from 'soapbox/components/ui'; import { useAppDispatch } from 'soapbox/hooks'; import EmojiGraphic from '../components/emoji-graphic'; interface IExtensionStep { setStep: (step: number) => void; + onClose(): void; } -const ExtensionStep: React.FC = ({ setStep }) => { +const ExtensionStep: React.FC = ({ setStep, onClose }) => { const dispatch = useAppDispatch(); const onClick = () => dispatch(nostrExtensionLogIn()); const onClickAlt = () => setStep(1); return ( - - + } onClose={onClose}> + + - + - - + + + ); }; diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx index 7b043eac53..57de1dd375 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/identity-step.tsx @@ -1,12 +1,8 @@ import React, { useState } from 'react'; +import { FormattedMessage } from 'react-intl'; import { accountLookup } from 'soapbox/actions/accounts'; -import Button from 'soapbox/components/ui/button/button'; -import Form from 'soapbox/components/ui/form/form'; -import FormGroup from 'soapbox/components/ui/form-group/form-group'; -import HStack from 'soapbox/components/ui/hstack/hstack'; -import Input from 'soapbox/components/ui/input/input'; -import Stack from 'soapbox/components/ui/stack/stack'; +import { Button, Form, FormGroup, HStack, Input, Stack, Modal } from 'soapbox/components/ui'; import { useAppDispatch } from 'soapbox/hooks'; import EmojiGraphic from '../components/emoji-graphic'; @@ -15,9 +11,10 @@ import NostrExtensionIndicator from '../components/nostr-extension-indicator'; interface IIdentityStep { setAccountId(accountId: string): void; setStep(step: number): void; + onClose(): void; } -const IdentityStep: React.FC = ({ setAccountId, setStep }) => { +const IdentityStep: React.FC = ({ setAccountId, setStep, onClose }) => { const dispatch = useAppDispatch(); const [loading, setLoading] = useState(false); @@ -53,36 +50,38 @@ const IdentityStep: React.FC = ({ setAccountId, setStep }) => { } return ( -
- - + } onClose={onClose}> + + + - + - - - + + + - - + + - - - - + + +
+ + ); }; diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/key-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/key-step.tsx index a31433a07e..f474b6b71b 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/key-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/key-step.tsx @@ -1,32 +1,35 @@ import React from 'react'; +import { FormattedMessage } from 'react-intl'; -import Button from 'soapbox/components/ui/button/button'; -import Stack from 'soapbox/components/ui/stack/stack'; +import { Button, Stack, Modal } from 'soapbox/components/ui'; import EmojiGraphic from '../components/emoji-graphic'; import NostrExtensionIndicator from '../components/nostr-extension-indicator'; interface IKeyStep { setStep(step: number): void; + onClose(): void; } -const KeyStep: React.FC = ({ setStep }) => { +const KeyStep: React.FC = ({ setStep, onClose }) => { return ( - - + } onClose={onClose}> + + - + - - + + - + + - + ); }; diff --git a/src/features/ui/components/modals/nostr-signin-modal/steps/register-step.tsx b/src/features/ui/components/modals/nostr-signin-modal/steps/register-step.tsx index af6f7020d7..4e6cdbc5e1 100644 --- a/src/features/ui/components/modals/nostr-signin-modal/steps/register-step.tsx +++ b/src/features/ui/components/modals/nostr-signin-modal/steps/register-step.tsx @@ -1,15 +1,19 @@ import React from 'react'; +import { FormattedMessage } from 'react-intl'; -import Stack from 'soapbox/components/ui/stack/stack'; +import { Stack, Modal } from 'soapbox/components/ui'; interface IRegisterStep { + onClose(): void; } -const RegisterStep: React.FC = () => { +const RegisterStep: React.FC = ({ onClose }) => { return ( - - register step - + } onClose={onClose}> + + register step + + ); };