From ffae3f89df6e26243c493f849719bf317fab735b Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 20 Sep 2023 13:57:33 -0500 Subject: [PATCH 1/8] Move Login page to UI --- src/components/big-card.tsx | 32 ++++++ src/containers/soapbox.tsx | 1 - src/features/auth-layout/index.tsx | 1 - .../auth-login/components/login-form.tsx | 100 ++++++++---------- .../auth-login/components/login-page.tsx | 10 +- src/features/ui/index.tsx | 3 + 6 files changed, 88 insertions(+), 59 deletions(-) create mode 100644 src/components/big-card.tsx diff --git a/src/components/big-card.tsx b/src/components/big-card.tsx new file mode 100644 index 000000000..2fcb7078a --- /dev/null +++ b/src/components/big-card.tsx @@ -0,0 +1,32 @@ +import React from 'react'; + +import { Card, CardBody, Stack, Text } from 'soapbox/components/ui'; + +interface IBigCard { + title: React.ReactNode + subtitle?: React.ReactNode + children: React.ReactNode +} + +const BigCard: React.FC = ({ title, subtitle, children }) => { + return ( + + +
+ + {title} + {subtitle && {subtitle}} + +
+ + +
+ {children} +
+
+
+
+ ); +}; + +export { BigCard }; \ No newline at end of file diff --git a/src/containers/soapbox.tsx b/src/containers/soapbox.tsx index deebda4ee..8f0015b87 100644 --- a/src/containers/soapbox.tsx +++ b/src/containers/soapbox.tsx @@ -104,7 +104,6 @@ const SoapboxMount = () => { )} - diff --git a/src/features/auth-layout/index.tsx b/src/features/auth-layout/index.tsx index df1d0dd4b..42cc1ba50 100644 --- a/src/features/auth-layout/index.tsx +++ b/src/features/auth-layout/index.tsx @@ -64,7 +64,6 @@ const AuthLayout = () => { - diff --git a/src/features/auth-login/components/login-form.tsx b/src/features/auth-login/components/login-form.tsx index d7871fc75..19f9e76bb 100644 --- a/src/features/auth-login/components/login-form.tsx +++ b/src/features/auth-login/components/login-form.tsx @@ -2,11 +2,9 @@ import React from 'react'; import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; import { Link } from 'react-router-dom'; -import { Button, Form, FormActions, FormGroup, Input, Stack } from 'soapbox/components/ui'; +import { Button, Form, FormActions, FormGroup, Input } from 'soapbox/components/ui'; import { useFeatures } from 'soapbox/hooks'; -import ConsumersList from './consumers-list'; - const messages = defineMessages({ username: { id: 'login.fields.username_label', @@ -35,62 +33,52 @@ const LoginForm: React.FC = ({ isLoading, handleSubmit }) => { const passwordLabel = intl.formatMessage(messages.password); return ( -
-
-

-
+
+ + + - - - - + - + + } + > + + - - - - } - > - - - - - - - - - -
-
+ + + + ); }; diff --git a/src/features/auth-login/components/login-page.tsx b/src/features/auth-login/components/login-page.tsx index 609af73a4..8817b6d39 100644 --- a/src/features/auth-login/components/login-page.tsx +++ b/src/features/auth-login/components/login-page.tsx @@ -1,13 +1,16 @@ import React, { useState } from 'react'; +import { FormattedMessage } from 'react-intl'; import { Redirect } from 'react-router-dom'; import { logIn, verifyCredentials, switchAccount } from 'soapbox/actions/auth'; import { fetchInstance } from 'soapbox/actions/instance'; import { closeModal } from 'soapbox/actions/modals'; +import { BigCard } from 'soapbox/components/big-card'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; import { getRedirectUrl } from 'soapbox/utils/redirect'; import { isStandalone } from 'soapbox/utils/state'; +import ConsumersList from './consumers-list'; import LoginForm from './login-form'; import OtpAuthForm from './otp-auth-form'; @@ -68,7 +71,12 @@ const LoginPage = () => { if (mfaAuthNeeded) return ; - return ; + return ( + }> + + + + ); }; export default LoginPage; diff --git a/src/features/ui/index.tsx b/src/features/ui/index.tsx index 77520d0a5..e8672be8d 100644 --- a/src/features/ui/index.tsx +++ b/src/features/ui/index.tsx @@ -134,6 +134,7 @@ import { FollowedTags, AboutPage, RegistrationPage, + LoginPage, } from './util/async-components'; import GlobalHotkeys from './util/global-hotkeys'; import { WrappedRoute } from './util/react-router-helpers'; @@ -357,6 +358,8 @@ const SwitchingColumnsArea: React.FC = ({ children }) => )} + + ); From 59a32b1a0f9954e3ba492b1a6f3e3d0fdec13674 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 20 Sep 2023 14:10:54 -0500 Subject: [PATCH 2/8] Refactor a bunch of components to use BigCard --- .../auth-login/components/otp-auth-form.tsx | 59 ++++---- .../components/password-reset-confirm.tsx | 45 +++--- .../auth-login/components/password-reset.tsx | 43 +++--- .../components/registration-page.tsx | 11 +- .../steps/avatar-selection-step.tsx | 106 ++++++------- src/features/onboarding/steps/bio-step.tsx | 92 +++++------- .../steps/cover-photo-selection-step.tsx | 142 ++++++++---------- .../onboarding/steps/display-name-step.tsx | 94 +++++------- .../steps/suggested-accounts-step.tsx | 58 +++---- 9 files changed, 279 insertions(+), 371 deletions(-) diff --git a/src/features/auth-login/components/otp-auth-form.tsx b/src/features/auth-login/components/otp-auth-form.tsx index 06423e5e6..a7b55d21d 100644 --- a/src/features/auth-login/components/otp-auth-form.tsx +++ b/src/features/auth-login/components/otp-auth-form.tsx @@ -3,6 +3,7 @@ import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; import { Redirect } from 'react-router-dom'; import { otpVerify, verifyCredentials, switchAccount } from 'soapbox/actions/auth'; +import { BigCard } from 'soapbox/components/big-card'; import { Button, Form, FormActions, FormGroup, Input } from 'soapbox/components/ui'; import { useAppDispatch } from 'soapbox/hooks'; @@ -47,41 +48,33 @@ const OtpAuthForm: React.FC = ({ mfa_token }) => { if (shouldRedirect) return ; return ( -
-
-

- -

-
+ }> +
+ + + -
- - + - - -
-
+ + + + + ); }; diff --git a/src/features/auth-login/components/password-reset-confirm.tsx b/src/features/auth-login/components/password-reset-confirm.tsx index 78ef26fd7..c079b418d 100644 --- a/src/features/auth-login/components/password-reset-confirm.tsx +++ b/src/features/auth-login/components/password-reset-confirm.tsx @@ -3,6 +3,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { Redirect } from 'react-router-dom'; import { resetPasswordConfirm } from 'soapbox/actions/security'; +import { BigCard } from 'soapbox/components/big-card'; import { Button, Form, FormActions, FormGroup, Input } from 'soapbox/components/ui'; import { useAppDispatch } from 'soapbox/hooks'; @@ -55,33 +56,25 @@ const PasswordResetConfirm = () => { } return ( -
-
-

- -

-
+ }> +
+ } errors={renderErrors()}> + + -
- - } errors={renderErrors()}> - - - - - - - -
-
+ + + + + ); }; diff --git a/src/features/auth-login/components/password-reset.tsx b/src/features/auth-login/components/password-reset.tsx index 6cc9109d3..11d1f42f0 100644 --- a/src/features/auth-login/components/password-reset.tsx +++ b/src/features/auth-login/components/password-reset.tsx @@ -3,6 +3,7 @@ import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { Redirect } from 'react-router-dom'; import { resetPassword } from 'soapbox/actions/security'; +import { BigCard } from 'soapbox/components/big-card'; import { Button, Form, FormActions, FormGroup, Input } from 'soapbox/components/ui'; import { useAppDispatch, useFeatures } from 'soapbox/hooks'; import toast from 'soapbox/toast'; @@ -36,32 +37,24 @@ const PasswordReset = () => { if (success) return ; return ( -
-
-

- -

-
+ }> +
+ + + -
- - - - - - - - - -
-
+ + + + + ); }; diff --git a/src/features/auth-login/components/registration-page.tsx b/src/features/auth-login/components/registration-page.tsx index c58633fa6..7f1e81ce5 100644 --- a/src/features/auth-login/components/registration-page.tsx +++ b/src/features/auth-login/components/registration-page.tsx @@ -1,18 +1,15 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; -import { Card, CardTitle, Stack } from 'soapbox/components/ui'; +import { BigCard } from 'soapbox/components/big-card'; import RegistrationForm from './registration-form'; const RegistrationPage: React.FC = () => { return ( - - - } /> - - - + }> + + ); }; diff --git a/src/features/onboarding/steps/avatar-selection-step.tsx b/src/features/onboarding/steps/avatar-selection-step.tsx index 55a54c514..149d5e3e3 100644 --- a/src/features/onboarding/steps/avatar-selection-step.tsx +++ b/src/features/onboarding/steps/avatar-selection-step.tsx @@ -3,7 +3,8 @@ import React from 'react'; import { defineMessages, FormattedMessage } from 'react-intl'; import { patchMe } from 'soapbox/actions/me'; -import { Avatar, Button, Card, CardBody, Icon, Spinner, Stack, Text } from 'soapbox/components/ui'; +import { BigCard } from 'soapbox/components/big-card'; +import { Avatar, Button, Icon, Spinner, Stack } from 'soapbox/components/ui'; import { useAppDispatch, useOwnAccount } from 'soapbox/hooks'; import toast from 'soapbox/toast'; import { isDefaultAvatar } from 'soapbox/utils/accounts'; @@ -64,69 +65,54 @@ const AvatarSelectionStep = ({ onNext }: { onNext: () => void }) => { }; return ( - - -
-
- - - - + } + subtitle={} + > + +
+ {account && ( + + )} - - - - -
+ {isSubmitting && ( +
+ +
+ )} -
- -
- {account && ( - - )} + - {isSubmitting && ( -
- -
- )} - - - - -
- - - - - {isDisabled && ( - - )} - -
-
+
- - + + + + + {isDisabled && ( + + )} + + + ); }; diff --git a/src/features/onboarding/steps/bio-step.tsx b/src/features/onboarding/steps/bio-step.tsx index c0a029d80..6b2862bbb 100644 --- a/src/features/onboarding/steps/bio-step.tsx +++ b/src/features/onboarding/steps/bio-step.tsx @@ -2,7 +2,8 @@ import React from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; import { patchMe } from 'soapbox/actions/me'; -import { Button, Card, CardBody, FormGroup, Stack, Text, Textarea } from 'soapbox/components/ui'; +import { BigCard } from 'soapbox/components/big-card'; +import { Button, FormGroup, Stack, Textarea } from 'soapbox/components/ui'; import { useAppDispatch, useOwnAccount } from 'soapbox/hooks'; import toast from 'soapbox/toast'; @@ -43,62 +44,49 @@ const BioStep = ({ onNext }: { onNext: () => void }) => { }; return ( - - + } + subtitle={} + > +
-
- - - - + } + labelText={} + errors={errors} + > +