Skip to content

Commit 2958685

Browse files
committed
emotion: SignInForm
1 parent f06631b commit 2958685

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

site/src/pages/LoginPage/SignInForm.tsx

+32-33
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { makeStyles } from "@mui/styles";
2-
import { FormikTouched } from "formik";
3-
import { FC, useState } from "react";
4-
import { AuthMethods } from "api/typesGenerated";
1+
import { type Interpolation, type Theme } from "@emotion/react";
2+
import { type FormikTouched } from "formik";
3+
import { type FC, useState } from "react";
4+
import type { AuthMethods } from "api/typesGenerated";
55
import { PasswordSignInForm } from "./PasswordSignInForm";
66
import { OAuthSignInForm } from "./OAuthSignInForm";
7-
import { BuiltInAuthFormValues } from "./SignInForm.types";
7+
import { type BuiltInAuthFormValues } from "./SignInForm.types";
88
import Button from "@mui/material/Button";
99
import EmailIcon from "@mui/icons-material/EmailOutlined";
1010
import { Alert } from "components/Alert/Alert";
@@ -21,11 +21,11 @@ export const Language = {
2121
oidcSignIn: "OpenID Connect",
2222
};
2323

24-
const useStyles = makeStyles((theme) => ({
24+
const styles = {
2525
root: {
2626
width: "100%",
2727
},
28-
title: {
28+
title: (theme) => ({
2929
fontSize: theme.spacing(4),
3030
fontWeight: 400,
3131
margin: 0,
@@ -35,34 +35,34 @@ const useStyles = makeStyles((theme) => ({
3535
"& strong": {
3636
fontWeight: 600,
3737
},
38-
},
39-
alert: {
38+
}),
39+
alert: (theme) => ({
4040
marginBottom: theme.spacing(4),
41-
},
42-
divider: {
41+
}),
42+
divider: (theme) => ({
4343
paddingTop: theme.spacing(3),
4444
paddingBottom: theme.spacing(3),
4545
display: "flex",
4646
alignItems: "center",
4747
gap: theme.spacing(2),
48-
},
49-
dividerLine: {
48+
}),
49+
dividerLine: (theme) => ({
5050
width: "100%",
5151
height: 1,
5252
backgroundColor: theme.palette.divider,
53-
},
54-
dividerLabel: {
53+
}),
54+
dividerLabel: (theme) => ({
5555
flexShrink: 0,
5656
color: theme.palette.text.secondary,
5757
textTransform: "uppercase",
5858
fontSize: 12,
5959
letterSpacing: 1,
60-
},
61-
icon: {
60+
}),
61+
icon: (theme) => ({
6262
width: theme.spacing(2),
6363
height: theme.spacing(2),
64-
},
65-
}));
64+
}),
65+
} satisfies Record<string, Interpolation<Theme>>;
6666

6767
export interface SignInFormProps {
6868
isSigningIn: boolean;
@@ -90,23 +90,22 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
9090
const passwordEnabled = authMethods?.password.enabled ?? true;
9191
// Hide password auth by default if any OAuth method is enabled
9292
const [showPasswordAuth, setShowPasswordAuth] = useState(!oAuthEnabled);
93-
const styles = useStyles();
9493
const applicationName = getApplicationName();
9594

9695
return (
97-
<div className={styles.root}>
98-
<h1 className={styles.title}>
96+
<div css={styles.root}>
97+
<h1 css={styles.title}>
9998
Sign in to <strong>{applicationName}</strong>
10099
</h1>
101100

102101
{Boolean(error) && (
103-
<div className={styles.alert}>
102+
<div css={styles.alert}>
104103
<ErrorAlert error={error} />
105104
</div>
106105
)}
107106

108107
{Boolean(info) && Boolean(error) && (
109-
<div className={styles.alert}>
108+
<div css={styles.alert}>
110109
<Alert severity="info">{info}</Alert>
111110
</div>
112111
)}
@@ -120,10 +119,10 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
120119
)}
121120

122121
{passwordEnabled && showPasswordAuth && oAuthEnabled && (
123-
<div className={styles.divider}>
124-
<div className={styles.dividerLine} />
125-
<div className={styles.dividerLabel}>Or</div>
126-
<div className={styles.dividerLine} />
122+
<div css={styles.divider}>
123+
<div css={styles.dividerLine} />
124+
<div css={styles.dividerLabel}>Or</div>
125+
<div css={styles.dividerLine} />
127126
</div>
128127
)}
129128

@@ -141,17 +140,17 @@ export const SignInForm: FC<React.PropsWithChildren<SignInFormProps>> = ({
141140

142141
{passwordEnabled && !showPasswordAuth && (
143142
<>
144-
<div className={styles.divider}>
145-
<div className={styles.dividerLine} />
146-
<div className={styles.dividerLabel}>Or</div>
147-
<div className={styles.dividerLine} />
143+
<div css={styles.divider}>
144+
<div css={styles.dividerLine} />
145+
<div css={styles.dividerLabel}>Or</div>
146+
<div css={styles.dividerLine} />
148147
</div>
149148

150149
<Button
151150
fullWidth
152151
size="large"
153152
onClick={() => setShowPasswordAuth(true)}
154-
startIcon={<EmailIcon className={styles.icon} />}
153+
startIcon={<EmailIcon css={styles.icon} />}
155154
>
156155
Email and password
157156
</Button>

0 commit comments

Comments
 (0)