From 67b1ff257d55d21e5967fb8acdcf6e1df768115c Mon Sep 17 00:00:00 2001 From: Erik Seliger Date: Sat, 7 Oct 2023 01:56:41 +0200 Subject: [PATCH 1/6] Cleanup auth and init pages design This PR wraps up the outstanding changes mentioned in https://github.com/sourcegraph/sourcegraph/issues/14773 and designed in https://www.figma.com/file/L5ZdNBGAnHQQUGGmp6tdQS/%2312695-%E2%80%93-Sign-in-%2F-Out-UX-%5BDone%5D?type=design&node-id=17-2040&mode=design&t=gJokKWRG2kC09J9M-0. Since all the implementations of the pages were done slightly different, I consolidated them. I also added a bunch of stories for easier review and regression testing. No one wants the login page to break :) --- .../web/src/auth/AuthPageWrapper.module.scss | 15 ++ client/web/src/auth/AuthPageWrapper.tsx | 47 +++++ .../web/src/auth/CloudSignUpPage.module.scss | 5 - client/web/src/auth/CloudSignUpPage.story.tsx | 8 + client/web/src/auth/CloudSignUpPage.tsx | 1 - client/web/src/auth/OrDivider.story.tsx | 2 +- client/web/src/auth/PostSignUpPage.story.tsx | 2 +- .../src/auth/RequestAccessPage.module.scss | 3 + .../web/src/auth/RequestAccessPage.story.tsx | 17 ++ client/web/src/auth/RequestAccessPage.tsx | 171 ++++++++---------- .../src/auth/ResetPasswordPage.module.scss | 5 +- .../web/src/auth/ResetPasswordPage.story.tsx | 67 +++++++ client/web/src/auth/ResetPasswordPage.tsx | 162 +++++++---------- client/web/src/auth/SignInPage.module.scss | 3 + client/web/src/auth/SignInPage.story.tsx | 56 +++--- client/web/src/auth/SignInPage.tsx | 164 +++++++++-------- .../src/auth/SignInSignUpCommon.module.scss | 23 --- client/web/src/auth/SignUpForm.tsx | 116 +++++------- client/web/src/auth/SignUpPage.module.scss | 3 + client/web/src/auth/SignUpPage.story.tsx | 60 ++++++ client/web/src/auth/SignUpPage.tsx | 45 ++--- client/web/src/auth/SignupEmailField.tsx | 21 +-- client/web/src/auth/UnlockAccount.module.scss | 3 + client/web/src/auth/UnlockAccount.story.tsx | 57 ++++++ client/web/src/auth/UnlockAccount.tsx | 50 +++-- .../web/src/auth/VsCodeSignUpPage.story.tsx | 74 ++++++++ client/web/src/auth/VsCodeSignUpPage.tsx | 9 +- .../auth/components/ExternalsAuth.module.scss | 13 ++ .../web/src/auth/components/ExternalsAuth.tsx | 11 +- .../web/src/components/branding/BrandLogo.tsx | 6 +- .../site-admin/init/SiteInitPage.module.scss | 9 +- .../site-admin/init/SiteInitPage.story.tsx | 41 +++++ .../src/site-admin/init/SiteInitPage.test.tsx | 12 +- .../web/src/site-admin/init/SiteInitPage.tsx | 68 +++---- 34 files changed, 822 insertions(+), 527 deletions(-) create mode 100644 client/web/src/auth/AuthPageWrapper.module.scss create mode 100644 client/web/src/auth/AuthPageWrapper.tsx create mode 100644 client/web/src/auth/RequestAccessPage.module.scss create mode 100644 client/web/src/auth/RequestAccessPage.story.tsx create mode 100644 client/web/src/auth/ResetPasswordPage.story.tsx create mode 100644 client/web/src/auth/SignInPage.module.scss delete mode 100644 client/web/src/auth/SignInSignUpCommon.module.scss create mode 100644 client/web/src/auth/SignUpPage.module.scss create mode 100644 client/web/src/auth/SignUpPage.story.tsx create mode 100644 client/web/src/auth/UnlockAccount.module.scss create mode 100644 client/web/src/auth/UnlockAccount.story.tsx create mode 100644 client/web/src/auth/VsCodeSignUpPage.story.tsx create mode 100644 client/web/src/site-admin/init/SiteInitPage.story.tsx diff --git a/client/web/src/auth/AuthPageWrapper.module.scss b/client/web/src/auth/AuthPageWrapper.module.scss new file mode 100644 index 000000000000..f91244de0e83 --- /dev/null +++ b/client/web/src/auth/AuthPageWrapper.module.scss @@ -0,0 +1,15 @@ +.logo { + display: block; + width: 4rem; + margin-bottom: 1rem; +} + +.wrapper { + width: 100%; + display: flex; + align-items: center; + justify-content: center; + margin-top: 20vh; + flex-direction: column; + flex: 1 1 auto; +} diff --git a/client/web/src/auth/AuthPageWrapper.tsx b/client/web/src/auth/AuthPageWrapper.tsx new file mode 100644 index 000000000000..4927150360ca --- /dev/null +++ b/client/web/src/auth/AuthPageWrapper.tsx @@ -0,0 +1,47 @@ +import React from 'react' + +import { useIsLightTheme } from '@sourcegraph/shared/src/theme' +import { H1, LinkOrSpan, Text } from '@sourcegraph/wildcard' + +import { BrandLogo } from '../components/branding/BrandLogo' + +import styles from './AuthPageWrapper.module.scss' + +interface Props { + /** Title of the page. */ + title: string + /** Optional second line item. */ + description?: string + sourcegraphDotComMode: boolean + className?: string +} + +export type AuthPageWrapperProps = React.PropsWithChildren + +export const AuthPageWrapper: React.FunctionComponent = ({ + title, + description, + sourcegraphDotComMode, + className, + children, +}) => { + const isLightTheme = useIsLightTheme() + + return ( + <> +
+ + + +

{title}

+ {description && {description}} +
{children}
+
+ + ) +} diff --git a/client/web/src/auth/CloudSignUpPage.module.scss b/client/web/src/auth/CloudSignUpPage.module.scss index 23f020e1abbe..26ca6f2125a4 100644 --- a/client/web/src/auth/CloudSignUpPage.module.scss +++ b/client/web/src/auth/CloudSignUpPage.module.scss @@ -112,8 +112,3 @@ height: 3rem !important; flex-shrink: 0; } - -.externals-auth-button { - background: var(--white); - color: var(--black) !important; -} diff --git a/client/web/src/auth/CloudSignUpPage.story.tsx b/client/web/src/auth/CloudSignUpPage.story.tsx index 54830bc5f482..c27d45a06e68 100644 --- a/client/web/src/auth/CloudSignUpPage.story.tsx +++ b/client/web/src/auth/CloudSignUpPage.story.tsx @@ -32,6 +32,14 @@ const context: Pick ) diff --git a/client/web/src/auth/OrDivider.story.tsx b/client/web/src/auth/OrDivider.story.tsx index eca9383b014c..9d502b31b8db 100644 --- a/client/web/src/auth/OrDivider.story.tsx +++ b/client/web/src/auth/OrDivider.story.tsx @@ -9,7 +9,7 @@ import { OrDivider } from './OrDivider' const decorator: DecoratorFn = story =>
{story()}
const config: Meta = { - title: 'web/OrDivider', + title: 'web/auth/OrDivider', decorators: [decorator], } diff --git a/client/web/src/auth/PostSignUpPage.story.tsx b/client/web/src/auth/PostSignUpPage.story.tsx index d16b94862dc0..4cc0f1f7f5d7 100644 --- a/client/web/src/auth/PostSignUpPage.story.tsx +++ b/client/web/src/auth/PostSignUpPage.story.tsx @@ -6,7 +6,7 @@ import { WebStory } from '../components/WebStory' import { PostSignUpPage } from './PostSignUpPage' const config: Meta = { - title: 'web/src/auth/PostSignUpPage', + title: 'web/auth/PostSignUpPage', } export default config diff --git a/client/web/src/auth/RequestAccessPage.module.scss b/client/web/src/auth/RequestAccessPage.module.scss new file mode 100644 index 000000000000..9f591d6f94a7 --- /dev/null +++ b/client/web/src/auth/RequestAccessPage.module.scss @@ -0,0 +1,3 @@ +.wrapper { + width: 27.5rem; +} diff --git a/client/web/src/auth/RequestAccessPage.story.tsx b/client/web/src/auth/RequestAccessPage.story.tsx new file mode 100644 index 000000000000..b6a9f28c1e5a --- /dev/null +++ b/client/web/src/auth/RequestAccessPage.story.tsx @@ -0,0 +1,17 @@ +import type { Meta, Story } from '@storybook/react' + +import { WebStory } from '../components/WebStory' + +import { RequestAccessPage } from './RequestAccessPage' + +const config: Meta = { + title: 'web/auth/RequestAccessPage', +} + +export default config + +export const Default: Story = () => {() => } + +export const Done: Story = () => ( + {() => } +) diff --git a/client/web/src/auth/RequestAccessPage.tsx b/client/web/src/auth/RequestAccessPage.tsx index 029c591a57ad..2d79eb4a5aee 100644 --- a/client/web/src/auth/RequestAccessPage.tsx +++ b/client/web/src/auth/RequestAccessPage.tsx @@ -1,23 +1,22 @@ import React, { useEffect, useState } from 'react' -import classNames from 'classnames' import { Navigate, Route, Routes, useLocation, useNavigate } from 'react-router-dom' -import { Text, Link, ErrorAlert, Form, Input, Button, LoadingSpinner, TextArea, Label } from '@sourcegraph/wildcard' +import { Text, Link, ErrorAlert, Form, Input, TextArea, Container, Alert } from '@sourcegraph/wildcard' -import { HeroPage } from '../components/HeroPage' +import { LoaderButton } from '../components/LoaderButton' import { PageTitle } from '../components/PageTitle' import type { SourcegraphContext } from '../jscontext' import { PageRoutes } from '../routes.constants' import { eventLogger } from '../tracking/eventLogger' import { checkRequestAccessAllowed } from '../util/checkRequestAccessAllowed' -import { SourcegraphIcon } from './icons' +import { AuthPageWrapper } from './AuthPageWrapper' import { getReturnTo } from './SignInSignUpCommon' -import RequestAccessSignUpCommonStyles from './SignInSignUpCommon.module.scss' +import styles from './RequestAccessPage.module.scss' -interface RequestAccessFormProps { +export interface RequestAccessFormProps { onSuccess: () => void onError: (error?: any) => void xhrHeaders: SourcegraphContext['xhrHeaders'] @@ -69,59 +68,50 @@ const RequestAccessForm: React.FunctionComponent = ({ on } } return ( -
- - -