Skip to content

Commit

Permalink
feat: rework signin page
Browse files Browse the repository at this point in the history
  • Loading branch information
mbret committed Feb 23, 2024
1 parent 6230126 commit f3e163d
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 130 deletions.
52 changes: 31 additions & 21 deletions packages/web/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { FC, Suspense, useEffect, useState } from "react"
import { AppNavigator } from "./navigation/AppNavigator"
import { ThemeProvider, Theme, StyledEngineProvider } from "@mui/material"
import {
ThemeProvider,
Theme,
StyledEngineProvider,
Fade,
Box
} from "@mui/material"
import { theme } from "./theme"
import { BlockingBackdrop } from "./common/BlockingBackdrop"
import { TourProvider } from "./app-tour/TourProvider"
Expand All @@ -11,7 +17,7 @@ import { UpdateAvailableDialog } from "./UpdateAvailableDialog"
import { RxDbProvider } from "./rxdb"
import { useObservers } from "./rxdb/sync/useObservers"
import { PreloadQueries } from "./PreloadQueries"
import { AppLoading } from "./AppLoading"
import { SplashScreen } from "./SplashScreen"
import { FirstTimeExperienceTours } from "./firstTimeExperience/FirstTimeExperienceTours"
import { DialogProvider } from "./dialog"
import { BlurContainer } from "./books/BlurContainer"
Expand All @@ -25,8 +31,7 @@ import {
usePersistSignals,
QueryClientProvider,
createLocalforageAdapter,
createSharedStoreAdapter,
QueryClient
createSharedStoreAdapter
} from "reactjrx"
import localforage from "localforage"
import { signalEntriesToPersist } from "./storage"
Expand Down Expand Up @@ -67,8 +72,8 @@ export function App() {
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>
<QueryClientProvider client={queryClient}>
<Suspense fallback={<AppLoading />}>
{!isAppReady && <AppLoading />}
<Suspense fallback={<SplashScreen show />}>
{/* <SplashScreen show={!isAppReady} /> */}
<RxDbProvider>
{isHydrated && (
<>
Expand All @@ -79,24 +84,29 @@ export function App() {
}
return Comp
},
<DialogProvider>
<TourProvider>
<AppNavigator />
<FirstTimeExperienceTours />
<ManageBookCollectionsDialog />
<ManageBookTagsDialog />
<ManageTagBooksDialog />
</TourProvider>
<UpdateAvailableDialog
serviceWorker={newServiceWorker}
/>
<ReplicateRemoteDb />
<BlockingBackdrop />
<Effects />
</DialogProvider>
<Fade in={isAppReady}>
<Box height="100%">
<DialogProvider>
<TourProvider>
<AppNavigator />
<FirstTimeExperienceTours />
<ManageBookCollectionsDialog />
<ManageBookTagsDialog />
<ManageTagBooksDialog />
</TourProvider>
<UpdateAvailableDialog
serviceWorker={newServiceWorker}
/>
<ReplicateRemoteDb />
<BlockingBackdrop />
<Effects />
</DialogProvider>
</Box>
</Fade>
)}
</>
)}

<PreloadQueries
onReady={() => {
setLoading((state) => ({
Expand Down
17 changes: 0 additions & 17 deletions packages/web/src/AppLoading.tsx

This file was deleted.

30 changes: 30 additions & 0 deletions packages/web/src/SplashScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Box, Fade } from "@mui/material"
import { memo, useState } from "react"
import { Logo } from "./common/Logo"

export const SplashScreen = memo(({ show }: { show: boolean }) => {
const [hidden, setHidden] = useState(false)

if (hidden) return null

return (
<Fade
in={show}
exit
onTransitionEnd={() => {
setHidden(true)
}}
timeout={500}
>
<Box
height="100%"
display="flex"
justifyContent="center"
alignItems="center"
alignContent="center"
>
<Logo />
</Box>
</Fade>
)
})
20 changes: 0 additions & 20 deletions packages/web/src/auth/Header.tsx

This file was deleted.

95 changes: 51 additions & 44 deletions packages/web/src/auth/LoginScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { useTheme, Button, Box, Link, Typography } from "@mui/material"
import { useTheme, Button, Box, Link, Typography, Stack } from "@mui/material"
import { Alert } from "@mui/material"
import { Header } from "./Header"
import { CenteredBox } from "../common/CenteredBox"
import { useTranslation } from "react-i18next"
import { Google } from "@mui/icons-material"
import { useSignIn } from "./useSignIn"
import { ErrorMessage, isCancelError } from "../errors"
import { OrDivider } from "../common/OrDivider"
import { links } from "@oboku/shared"
import { useMutation } from "reactjrx"
import { Logo } from "../common/Logo"

export const LoginScreen = () => {
const { signIn } = useSignIn()
Expand All @@ -20,49 +19,57 @@ export const LoginScreen = () => {
const { t } = useTranslation()

return (
<CenteredBox
style={{
flexShrink: 0,
paddingTop: theme.spacing(4),
paddingBottom: theme.spacing(4),
overflow: "scroll",
display: "flex",
flexDirection: "column"
}}
<Stack
flex={1}
flexDirection="column"
justifyContent="center"
alignItems="center"
gap={3}
px={2}
>
<Header />
{error && !isCancelError(error) ? (
<Box mb={2}>
<Alert severity="warning">
<ErrorMessage error={error} />
</Alert>
</Box>
) : null}
<Button
onClick={() => mutate()}
size="large"
fullWidth
startIcon={<Google />}
disabled={isPending}
<Box
style={{
display: "flex",
justifyContent: "center",
flexFlow: "row",
paddingBottom: theme.spacing(4)
}}
>
{t("authScreen.sign.google")}
</Button>
<Box mt={2}>
<Alert severity="info" variant="outlined">
Want more choices? Please let us know on{" "}
<Link href={links.discord} underline="hover">
discord
</Link>
</Alert>
<Logo />
</Box>
<OrDivider title="MORE" />
<Typography textAlign="center">
Visit{" "}
<Link href={links.site} underline="hover">
oboku
</Link>{" "}
for more information or help
</Typography>
</CenteredBox>
<Stack maxWidth={400}>
{error && !isCancelError(error) ? (
<Box mb={2}>
<Alert severity="warning">
<ErrorMessage error={error} />
</Alert>
</Box>
) : null}
<Button
onClick={() => mutate()}
size="large"
startIcon={<Google />}
disabled={isPending}
>
{t("authScreen.sign.google")}
</Button>
<Box mt={2}>
<Alert severity="info" variant="outlined">
Want more choices? Please let us know on{" "}
<Link href={links.discord} underline="hover">
discord
</Link>
</Alert>
</Box>
<OrDivider title="more" />
<Typography textAlign="center">
Visit{" "}
<Link href={links.site} underline="hover">
oboku
</Link>{" "}
for more information or help
</Typography>
</Stack>
</Stack>
)
}
24 changes: 0 additions & 24 deletions packages/web/src/common/CenteredBox.tsx

This file was deleted.

8 changes: 5 additions & 3 deletions packages/web/src/common/OrDivider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const OrDivider: FC<{ title?: string; style?: React.CSSProperties }> = ({
>
<div
style={{
borderBottom: "1px solid black",
borderBottom: `1px solid ${theme.palette.grey[600]}`,
height: 1,
width: "100%"
}}
Expand All @@ -31,11 +31,13 @@ export const OrDivider: FC<{ title?: string; style?: React.CSSProperties }> = ({
marginRight: theme.spacing(2)
}}
>
<Typography>{title}</Typography>
<Typography textTransform="uppercase" variant="body2">
{title}
</Typography>
</div>
<div
style={{
borderBottom: "1px solid black",
borderBottom: `1px solid ${theme.palette.grey[600]}`,
width: "100%"
}}
></div>
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ declare module "@mui/material/styles" {
export const theme = createTheme({
transitions: {
// So we have `transition: none;` everywhere
create: () => "none"
// create: () => "none"
},
palette: {
mode: `light`,
Expand Down

0 comments on commit f3e163d

Please sign in to comment.