Skip to content

Commit e70717b

Browse files
committed
Add login page
Mantine theme is used to style the inputs and buttons. This allows global color changes to be changed easily and accurately.
1 parent f5428c7 commit e70717b

File tree

5 files changed

+145
-7
lines changed

5 files changed

+145
-7
lines changed

frontend/peerprep/app/app.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
html,
99
body {
10-
@apply bg-white dark:bg-gray-950;
10+
background-color: var(--mantine-color-custom-grey-9);
1111

1212
@media (prefers-color-scheme: dark) {
1313
color-scheme: dark;

frontend/peerprep/app/assets/images/logo.svg

Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { Grid, TextInput, Button, PasswordInput, Divider, Text, Image } from "@mantine/core";
2+
import { useForm } from "@mantine/form";
3+
import { Link } from "react-router";
4+
import logo from "../assets/images/logo.svg";
5+
6+
export function meta() {
7+
return [
8+
{ title: "PeerPrep - Login" },
9+
{ name: "description", content: "Welcome to PeerPrep!" },
10+
];
11+
}
12+
13+
export default function Login() {
14+
const form = useForm({
15+
initialValues: {
16+
email: "",
17+
password: "",
18+
},
19+
20+
validate: {
21+
email: (value) => (/^\S+@\S+$/.test(value) ? null : "Invalid email"),
22+
password: (value) =>
23+
value.length < 6 ? "Password must be at least 6 characters" : null,
24+
},
25+
});
26+
27+
return (
28+
<Grid>
29+
<Grid.Col span={12}>
30+
<Grid justify="center" gutter={"xs"} mt={{ base: 20, md: 200 }}>
31+
<Grid.Col span={{ base: 12, md: 4 }}>
32+
<Image src={logo} alt="PeerPrep Logo" />
33+
<form onSubmit={form.onSubmit((values) => console.log(values))}>
34+
<Grid.Col span={12}>
35+
<TextInput
36+
label="Email"
37+
placeholder="Enter your email"
38+
type="email"
39+
key={form.key("email")}
40+
{...form.getInputProps('email')}
41+
error={undefined}
42+
/>
43+
</Grid.Col>
44+
<Grid.Col span={12}>
45+
<PasswordInput
46+
label="Password"
47+
placeholder="Enter your password"
48+
type="password"
49+
key={form.key("password")}
50+
{...form.getInputProps('password')}
51+
/>
52+
</Grid.Col>
53+
<Grid.Col span={12} mt="md">
54+
<Button type="submit" fullWidth autoContrast>
55+
Login
56+
</Button>
57+
</Grid.Col>
58+
</form>
59+
<Grid.Col span={12} mt="md">
60+
<Divider my="xs" />
61+
</Grid.Col>
62+
<Grid.Col span={12} mt="md" className="text-center">
63+
<Text span>Don't have an account? </Text><Link to="/signup"><Text span td="underline" c="blue" className="cursor-pointer">Sign up!</Text></Link>
64+
</Grid.Col>
65+
</Grid.Col>
66+
</Grid>
67+
</Grid.Col>
68+
</Grid>
69+
);
70+
}

frontend/peerprep/app/root.tsx

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ import {
77
ScrollRestoration,
88
} from "react-router";
99

10-
import '@mantine/core/styles.css';
11-
import { createTheme, MantineProvider } from '@mantine/core';
10+
import "@mantine/core/styles.css";
11+
import {
12+
createTheme,
13+
MantineProvider,
14+
Container,
15+
Button,
16+
Input,
17+
} from "@mantine/core";
1218

1319
import type { Route } from "./+types/root";
1420
import "./app.css";
@@ -28,6 +34,55 @@ export const links: Route.LinksFunction = () => [
2834

2935
const theme = createTheme({
3036
/** mantine theme overrides */
37+
colors: {
38+
"brand-yellow": [
39+
"#fff9df",
40+
"#fff2ca",
41+
"#ffe399",
42+
"#ffd463",
43+
"#ffc736",
44+
"#ffc01e",
45+
"#ffba02",
46+
"#e4a300",
47+
"#cb9100",
48+
"#af7c00",
49+
],
50+
"custom-gray": [
51+
"#f5f5f4",
52+
"#e7e7e7",
53+
"#cdcdcd",
54+
"#b2b2b2",
55+
"#9a9a9a",
56+
"#8b8b8b",
57+
"#848484",
58+
"#717171",
59+
"#646464",
60+
"#343231",
61+
],
62+
},
63+
64+
components: {
65+
Button: Button.extend({
66+
defaultProps: {
67+
variant: "filled",
68+
color: "brand-yellow",
69+
c: "custom-gray.9",
70+
},
71+
}),
72+
73+
Input: Input.extend({
74+
}),
75+
76+
InputWrapper: Input.Wrapper.extend({
77+
classNames: {
78+
label: "text-white",
79+
error: "text-red-500",
80+
},
81+
}),
82+
},
83+
84+
primaryColor: "brand-yellow",
85+
primaryShade: { light: 6, dark: 6 },
3186
});
3287

3388
export function Layout({ children }: { children: React.ReactNode }) {
@@ -50,8 +105,8 @@ export function Layout({ children }: { children: React.ReactNode }) {
50105

51106
export default function App() {
52107
return (
53-
<MantineProvider theme={theme}>
54-
{<Outlet />}
108+
<MantineProvider theme={theme} defaultColorScheme="dark">
109+
<Container fluid>{<Outlet />}</Container>
55110
</MantineProvider>
56111
);
57112
}

frontend/peerprep/app/routes.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
import { type RouteConfig, index } from "@react-router/dev/routes";
1+
import { type RouteConfig, index, route } from "@react-router/dev/routes";
22

3-
export default [index("routes/home.tsx")] satisfies RouteConfig;
3+
export default [
4+
index("routes/home.tsx"),
5+
route("login", "pages/login.tsx"),
6+
route("signup", "pages/signup.tsx"),
7+
] satisfies RouteConfig;

0 commit comments

Comments
 (0)