add /signUp, update AuthLayout design

This commit is contained in:
Sidney Alcantara
2021-09-21 21:19:59 +10:00
parent 35508d4d04
commit a9166431ff
16 changed files with 347 additions and 110 deletions

View File

@@ -22,6 +22,7 @@ import routes from "constants/routes";
import AuthPage from "pages/Auth";
import SignOutPage from "pages/Auth/SignOut";
import SignUpPage from "pages/Auth/SignUp";
import TestPage from "pages/Test";
import RowyRunTestPage from "pages/RowyRunTest";
import PageNotFound from "pages/PageNotFound";
@@ -83,6 +84,11 @@ export default function App() {
path={routes.signOut}
render={() => <SignOutPage />}
/>
<Route
exact
path={routes.signUp}
render={() => <SignUpPage />}
/>
<Route
exact
path={routes.setup}

View File

@@ -55,12 +55,18 @@ export default function BrandedBackground() {
].join(", ")
};
}
#root {
cursor: default;
}
.wrapper {
display: grid;
place-items: center;
align-content: center;
gap: ${theme.spacing(3)};
grid-auto-rows: max-content;
cursor: default;
${["top", "right", "bottom", "left"]
.map(
(side) =>

Binary file not shown.

View File

@@ -0,0 +1,9 @@
import SvgIcon, { SvgIconProps } from "@mui/material/SvgIcon";
export default function Discord(props: SvgIconProps) {
return (
<SvgIcon viewBox="-7 -15 85 85" {...props}>
<path d="M60.1045 4.8978C55.5792 2.8214 50.7265 1.2916 45.6527 0.41542C45.5603 0.39851 45.468 0.440769 45.4204 0.525289C44.7963 1.6353 44.105 3.0834 43.6209 4.2216C38.1637 3.4046 32.7345 3.4046 27.3892 4.2216C26.905 3.0581 26.1886 1.6353 25.5617 0.525289C25.5141 0.443589 25.4218 0.40133 25.3294 0.41542C20.2584 1.2888 15.4057 2.8186 10.8776 4.8978C10.8384 4.9147 10.8048 4.9429 10.7825 4.9795C1.57795 18.7309 -0.943561 32.1443 0.293408 45.3914C0.299005 45.4562 0.335386 45.5182 0.385761 45.5576C6.45866 50.0174 12.3413 52.7249 18.1147 54.5195C18.2071 54.5477 18.305 54.5139 18.3638 54.4378C19.7295 52.5728 20.9469 50.6063 21.9907 48.5383C22.0523 48.4172 21.9935 48.2735 21.8676 48.2256C19.9366 47.4931 18.0979 46.6 16.3292 45.5858C16.1893 45.5041 16.1781 45.304 16.3068 45.2082C16.679 44.9293 17.0513 44.6391 17.4067 44.3461C17.471 44.2926 17.5606 44.2813 17.6362 44.3151C29.2558 49.6202 41.8354 49.6202 53.3179 44.3151C53.3935 44.2785 53.4831 44.2898 53.5502 44.3433C53.9057 44.6363 54.2779 44.9293 54.6529 45.2082C54.7816 45.304 54.7732 45.5041 54.6333 45.5858C52.8646 46.6197 51.0259 47.4931 49.0921 48.2228C48.9662 48.2707 48.9102 48.4172 48.9718 48.5383C50.038 50.6034 51.2554 52.5699 52.5959 54.435C52.6519 54.5139 52.7526 54.5477 52.845 54.5195C58.6464 52.7249 64.529 50.0174 70.6019 45.5576C70.6551 45.5182 70.6887 45.459 70.6943 45.3942C72.1747 30.0791 68.2147 16.7757 60.1968 4.9823C60.1772 4.9429 60.1437 4.9147 60.1045 4.8978ZM23.7259 37.3253C20.2276 37.3253 17.3451 34.1136 17.3451 30.1693C17.3451 26.225 20.1717 23.0133 23.7259 23.0133C27.308 23.0133 30.1626 26.2532 30.1066 30.1693C30.1066 34.1136 27.28 37.3253 23.7259 37.3253ZM47.3178 37.3253C43.8196 37.3253 40.9371 34.1136 40.9371 30.1693C40.9371 26.225 43.7636 23.0133 47.3178 23.0133C50.9 23.0133 53.7545 26.2532 53.6986 30.1693C53.6986 34.1136 50.9 37.3253 47.3178 37.3253Z" />
</SvgIcon>
);
}

View File

@@ -1,4 +1,11 @@
import { Paper, Typography, LinearProgress } from "@mui/material";
import {
Paper,
Typography,
LinearProgress,
Stack,
Link,
LinkProps,
} from "@mui/material";
import { alpha } from "@mui/material/styles";
import BrandedBackground from "assets/BrandedBackground";
import Logo from "assets/Logo";
@@ -7,17 +14,46 @@ import { useAppContext } from "contexts/AppContext";
import { homepage } from "@root/package.json";
export interface IAuthLayoutProps {
hideLogo?: boolean;
title?: React.ReactNode;
description?: React.ReactNode;
children: React.ReactNode;
loading?: boolean;
}
export default function AuthLayout({ children, loading }: IAuthLayoutProps) {
export default function AuthLayout({
hideLogo,
title,
description,
children,
loading,
}: IAuthLayoutProps) {
const { projectId } = useAppContext();
const linkProps: LinkProps = {
variant: "caption",
color: "text.secondary",
underline: "hover",
target: "_blank",
rel: "noopener noreferrer",
};
return (
<>
<div className="wrapper">
<BrandedBackground />
<div
style={{
textAlign: "center",
marginBottom: -8,
visibility: hideLogo ? "hidden" : "visible",
}}
>
<a href={homepage} target="_blank" rel="noopener noreferrer">
<Logo />
</a>
</div>
<Paper
component="main"
elevation={4}
@@ -26,28 +62,43 @@ export default function AuthLayout({ children, loading }: IAuthLayoutProps) {
position: "relative",
overflow: "hidden",
maxWidth: 400,
maxWidth: 360,
width: "100%",
p: 4,
px: 4,
py: 3,
minHeight: 300,
backgroundColor: (theme) =>
alpha(theme.palette.background.paper, 0.5),
backdropFilter: "blur(20px) saturate(150%)",
"--spacing-contents": (theme) => theme.spacing(4),
"& > * + *": { marginTop: "var(--spacing-contents)" },
display: "flex",
flexDirection: "column",
textAlign: "center",
"& > :not(style) + :not(style)": { mt: 6 },
} as any
}
>
<a href={homepage} target="_blank" rel="noopener noreferrer">
<Logo />
</a>
<Typography variant="body2" color="text.disabled" display="block">
Project: <span style={{ userSelect: "all" }}>{projectId}</span>
</Typography>
{children}
{title && (
<Typography component="h1" variant="h4">
{title}
</Typography>
)}
{description && (
<Typography variant="body1" style={{ marginTop: 8 }}>
{description}
</Typography>
)}
<Stack
spacing={4}
justifyContent="center"
alignItems="center"
style={{ textAlign: "center", flexGrow: 1 }}
>
{children}
</Stack>
{loading && (
<LinearProgress
@@ -60,7 +111,47 @@ export default function AuthLayout({ children, loading }: IAuthLayoutProps) {
}}
/>
)}
<Typography
variant="caption"
color="text.secondary"
display="block"
textAlign="center"
sx={{ pt: 1 }}
>
Project: <span style={{ userSelect: "all" }}>{projectId}</span>
</Typography>
</Paper>
</>
<Stack
spacing={1.25}
direction="row"
flexWrap="wrap"
justifyContent="center"
style={{ maxWidth: 360, width: "100%", padding: "0 4px" }}
>
<Link href={homepage} {...linkProps}>
{homepage.split("//").pop()?.replace(/\//g, "")}
</Link>
<Link href={homepage} {...linkProps}>
Discord
</Link>
<Link href={homepage} {...linkProps}>
Twitter
</Link>
<div style={{ flexGrow: 1, marginLeft: 0 }} />
<Link href={homepage} {...linkProps}>
Docs
</Link>
<Link href={homepage} {...linkProps}>
Privacy
</Link>
<Link href={homepage} {...linkProps}>
Terms
</Link>
</Stack>
</div>
);
}

View File

@@ -17,6 +17,9 @@ const useStyles = makeStyles((theme) =>
createStyles({
"@global": {
".rowy-firebaseui": {
width: "100%",
minHeight: 48,
"& .firebaseui-container": {
backgroundColor: "transparent",
color: theme.palette.text.primary,
@@ -89,8 +92,12 @@ const useStyles = makeStyles((theme) =>
maxWidth: "none",
minHeight: 48,
},
"& .firebaseui-idp-icon": {
display: "block",
},
"& .firebaseui-idp-text": {
...theme.typography.button,
fontSize: "1rem",
paddingLeft: theme.spacing(2),
paddingRight: Number(theme.spacing(2).replace("px", "")) + 18,
@@ -98,10 +105,10 @@ const useStyles = makeStyles((theme) =>
width: "100%",
textAlign: "center",
[theme.breakpoints.down("sm")]: {
"&.firebaseui-idp-text-long": { display: "none" },
"&.firebaseui-idp-text-short": { display: "table-cell" },
},
// [theme.breakpoints.down("sm")]: {
"&.firebaseui-idp-text-long": { display: "none" },
"&.firebaseui-idp-text-short": { display: "table-cell" },
// },
},
"& .firebaseui-idp-google": {
@@ -166,15 +173,15 @@ const useStyles = makeStyles((theme) =>
},
signInText: {
display: "none",
[theme.breakpoints.down("sm")]: { display: "block" },
fontSize: "1rem",
display: "block",
textAlign: "center",
color: theme.palette.text.primary,
margin: theme.spacing(3, 0, -3),
color: theme.palette.text.secondary,
margin: theme.spacing(-1, 0, -2.5),
},
skeleton: {
width: "100%",
marginBottom: "calc(var(--spacing-contents) * -1)",
"& > *": {
@@ -212,13 +219,15 @@ export default function FirebaseUi(props: Partial<FirebaseUiProps>) {
if (!signInOptions)
return (
<div
id="rowy-firebaseui-skeleton"
className={classes.skeleton}
style={{ marginBottom: 0 }}
>
<Skeleton variant="rectangular" />
</div>
<>
<Typography variant="button" className={classes.signInText}>
Continue with
</Typography>
<div id="rowy-firebaseui-skeleton" className={classes.skeleton}>
<Skeleton variant="rectangular" />
</div>
</>
);
const uiConfig: firebaseui.auth.Config = {
@@ -237,7 +246,7 @@ export default function FirebaseUi(props: Partial<FirebaseUiProps>) {
return (
<>
<Typography variant="button" className={classes.signInText}>
Sign in with
Continue with
</Typography>
<div id="rowy-firebaseui-skeleton" className={classes.skeleton}>

View File

@@ -1,9 +1,12 @@
export enum routes {
home = "/",
auth = "/auth",
impersonatorAuth = "/impersonatorAuth",
jwtAuth = "/jwtAuth",
signOut = "/signOut",
signUp = "/signUp",
authSetup = "/authSetup",
setup = "/setup",
pageNotFound = "/404",

View File

@@ -43,21 +43,27 @@ export default function ImpersonatorAuthPage() {
};
return (
<AuthLayout loading={loading}>
<div>
<Typography variant="h6" component="h1" gutterBottom>
Admin Authentication
</Typography>
<Typography gutterBottom>
Using an admin account, sign in as another user on this project to
test permissions and access controls.
</Typography>
<Typography>
Make sure the {name} Run service account has the{" "}
<b>Service Account Token Creator</b> IAM role.
</Typography>
</div>
<AuthLayout
loading={loading}
title="Admin Auth"
description={
<>
<Typography
variant="inherit"
component="span"
display="block"
gutterBottom
>
Using an admin account, sign in as another user on this project to
test permissions and access controls.
</Typography>
<Typography variant="inherit" component="span">
Make sure the {name} Run service account has the{" "}
<b>Service Account Token Creator</b> IAM role.
</Typography>
</>
}
>
{adminUser === undefined ? (
<FirebaseUi
uiConfig={{

View File

@@ -1,7 +1,7 @@
import { useState } from "react";
import { useSnackbar } from "notistack";
import { TextField, Typography, Button } from "@mui/material";
import { TextField, Button } from "@mui/material";
import { auth } from "../../firebase";
import AuthLayout from "components/Auth/AuthLayout";
@@ -27,11 +27,7 @@ export default function JwtAuthPage() {
};
return (
<AuthLayout loading={loading}>
<Typography variant="h6" component="h1">
Test Authentication
</Typography>
<AuthLayout loading={loading} title="Test Authentication">
<TextField
name="JWT"
label="JWT"

View File

@@ -2,37 +2,31 @@ import { Button } from "@mui/material";
import OpenInNewIcon from "@mui/icons-material/OpenInNew";
import AuthLayout from "components/Auth/AuthLayout";
import EmptyState from "components/EmptyState";
import FirebaseIcon from "assets/icons/Firebase";
import WIKI_LINKS from "constants/wikiLinks";
import { name } from "@root/package.json";
export default function AuthSetupGuide() {
return (
<AuthLayout>
<EmptyState
Icon={FirebaseIcon}
message="Set Up Firebase Authentication"
description={
<>
<span>
To sign in to {name}, set up Firebase Authentication in the
Firebase Console.
</span>
<Button
variant="contained"
color="primary"
endIcon={<OpenInNewIcon />}
href={WIKI_LINKS.setUpAuth}
target="_blank"
rel="noopener noreferrer"
>
Setup Guide
</Button>
</>
}
/>
<AuthLayout
title="Set Up Firebase Authentication"
description={
<>
To sign in to {name}, first set up Firebase Authentication in the
Firebase Console.
</>
}
>
<Button
variant="contained"
color="primary"
endIcon={<OpenInNewIcon />}
href={WIKI_LINKS.setUpAuth}
target="_blank"
rel="noopener noreferrer"
>
Setup Guide
</Button>
</AuthLayout>
);
}

View File

@@ -2,10 +2,8 @@ import { useEffect } from "react";
import { Link } from "react-router-dom";
import { Button } from "@mui/material";
import CheckIcon from "@mui/icons-material/Check";
import AuthLayout from "components/Auth/AuthLayout";
import EmptyState from "components/EmptyState";
import { auth } from "../../firebase";
export default function SignOutPage() {
@@ -14,16 +12,10 @@ export default function SignOutPage() {
}, []);
return (
<AuthLayout>
<EmptyState
message="Signed Out"
description={
<Button component={Link} to="/auth" variant="outlined" sx={{ mt: 3 }}>
Sign In Again
</Button>
}
Icon={CheckIcon}
/>
<AuthLayout title="Signed Out">
<Button component={Link} to="/auth" variant="outlined">
Sign In Again
</Button>
</AuthLayout>
);
}

122
src/pages/Auth/SignUp.tsx Normal file
View File

@@ -0,0 +1,122 @@
import { useLocation } from "react-router-dom";
import queryString from "query-string";
import { useMediaQuery, Stack, Paper, Typography, Button } from "@mui/material";
import { alpha } from "@mui/material/styles";
import DiscordIcon from "assets/icons/Discord";
import TwitterIcon from "@mui/icons-material/Twitter";
import Logo from "assets/Logo";
import AuthLayout from "components/Auth/AuthLayout";
import FirebaseUi from "components/Auth/FirebaseUi";
import { homepage } from "@root/package.json";
export default function SignUpPage() {
const { search } = useLocation();
const parsed = queryString.parse(search);
const uiConfig: firebaseui.auth.Config = {};
if (typeof parsed.redirect === "string" && parsed.redirect.length > 0) {
uiConfig.signInSuccessUrl = parsed.redirect;
}
return (
<Stack direction="row">
<Paper
elevation={4}
square
sx={{
display: { xs: "none", md: "block" },
width: 520,
gridColumn: 1,
gridRow: "1 / 4",
backgroundColor: (theme) =>
alpha(theme.palette.background.paper, 0.5),
backdropFilter: "blur(20px) saturate(150%)",
pt: (theme) => `max(env(safe-area-inset-top), ${theme.spacing(8)})`,
pb: (theme) =>
`max(env(safe-area-inset-bottom), ${theme.spacing(8)})`,
pl: (theme) => `max(env(safe-area-inset-left), ${theme.spacing(8)})`,
pr: 8,
}}
>
<Stack
direction="column"
justifyContent="space-between"
spacing={4}
style={{ height: "100%" }}
>
<a href={homepage} target="_blank" rel="noopener noreferrer">
<Logo size={2} />
</a>
<div>
<Typography
component="p"
variant="h5"
sx={{ fontWeight: "normal", fontSize: 28 / 16 + "rem" }}
paragraph
>
Manage Firestore data in a spreadsheet-like&nbsp;UI
</Typography>
<Typography
component="p"
variant="h5"
sx={{ fontWeight: "normal", fontSize: 28 / 16 + "rem" }}
paragraph
>
Write Cloud Functions effortlessly&nbsp;in the browser
</Typography>
<Typography
component="p"
variant="h5"
sx={{ fontWeight: "normal", fontSize: 28 / 16 + "rem" }}
paragraph
>
Connect to your favorite third&nbsp;party platforms
</Typography>
</div>
<Stack direction="row" spacing={1}>
<Button
variant="outlined"
startIcon={<DiscordIcon color="action" />}
>
Join our Community
</Button>
<Button
variant="outlined"
startIcon={<TwitterIcon color="action" />}
>
Follow on Twitter
</Button>
</Stack>
</Stack>
</Paper>
<div style={{ flexGrow: 1 }}>
<AuthLayout
hideLogo
title="Sign Up"
description={
<>
Welcome! To join this project, sign in with the email address
{parsed.email ? (
<>
: <b style={{ userSelect: "all" }}>{parsed.email}</b>
</>
) : (
" used to invite you."
)}
</>
}
>
<FirebaseUi uiConfig={uiConfig} />
</AuthLayout>
</div>
</Stack>
);
}

View File

@@ -14,7 +14,7 @@ export default function AuthPage() {
}
return (
<AuthLayout>
<AuthLayout title="Sign In">
<FirebaseUi uiConfig={uiConfig} />
</AuthLayout>
);

View File

@@ -18,20 +18,15 @@ export default function PageNotFound() {
if (!currentUser)
return (
<AuthLayout>
<EmptyState
message="Page Not Found"
description={
<Button
variant="outlined"
sx={{ mt: 3 }}
href={homepage}
endIcon={<GoIcon style={{ margin: "0 -0.33em" }} />}
>
{homepage.split("//")[1].replace(/\//g, "")}
</Button>
}
/>
<AuthLayout title="Page Not Found">
<Button
variant="outlined"
sx={{ mt: 3 }}
href={homepage}
endIcon={<GoIcon style={{ margin: "0 -0.33em" }} />}
>
{homepage.split("//")[1].replace(/\//g, "")}
</Button>
</AuthLayout>
);

View File

@@ -246,7 +246,7 @@ export default function SetupPage() {
};
return (
<>
<div className="wrapper">
<BrandedBackground />
<Paper
component="main"
@@ -428,6 +428,6 @@ export default function SetupPage() {
</DialogActions>
</form>
</Paper>
</>
</div>
);
}

View File

@@ -5,3 +5,11 @@
font-display: swap;
src: url("assets/SpaceGrotesk-Bold.woff2") format("woff2");
}
@font-face {
font-family: "Space Grotesk";
font-style: normal;
font-weight: 400;
font-display: swap;
src: url("assets/SpaceGrotesk-Regular.woff2") format("woff2");
}