Skip to content

Commit b9ca311

Browse files
fix: improve a11y in LoginForm
1 parent 6c4602b commit b9ca311

File tree

4 files changed

+29
-21
lines changed

4 files changed

+29
-21
lines changed

src/app/[channel]/(main)/login/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Suspense } from "react";
22
import { Loader } from "@/ui/atoms/Loader";
3-
import { LoginForm } from "@/ui/components/LoginForm";
3+
import { LoginForm } from "@/ui/components/LoginForm/LoginForm";
44

55
export default function LoginPage() {
66
return (

src/app/[channel]/(main)/orders/page.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CurrentUserOrderListDocument } from "@/gql/graphql";
22
import { executeGraphQL } from "@/lib/graphql";
3-
import { LoginForm } from "@/ui/components/LoginForm";
3+
import { LoginForm } from "@/ui/components/LoginForm/LoginForm";
44
import { OrderListItem } from "@/ui/components/OrderListItem";
55

66
export default async function OrderPage() {
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { LoginButton } from "./components/LoginButton";
12
import { saleorAuthClient } from "@/app/config";
23

34
export async function LoginForm() {
45
return (
56
<div className="mx-auto mt-16 w-full max-w-lg">
67
<form
7-
className="rounded border p-8 shadow-md"
8+
className="flex flex-col gap-y-2 rounded border p-8 shadow-md"
89
action={async (formData) => {
910
"use server";
1011

@@ -23,39 +24,30 @@ export async function LoginForm() {
2324
}
2425
}}
2526
>
26-
<div className="mb-2">
27-
<label className="sr-only" htmlFor="email">
28-
Email
29-
</label>
27+
<label>
28+
<span className="sr-only">Email</span>
3029
<input
3130
type="email"
3231
name="email"
3332
placeholder="Email"
3433
className="w-full rounded border bg-neutral-50 px-4 py-2"
34+
required
3535
/>
36-
</div>
37-
<div className="mb-4">
38-
<label className="sr-only" htmlFor="password">
39-
Password
40-
</label>
36+
</label>
37+
<label>
38+
<span className="sr-only">Password</span>
4139
<input
4240
type="password"
4341
name="password"
4442
placeholder="Password"
4543
autoCapitalize="off"
4644
autoComplete="off"
4745
className="w-full rounded border bg-neutral-50 px-4 py-2"
46+
required
4847
/>
49-
</div>
50-
51-
<button
52-
className="rounded bg-neutral-800 px-4 py-2 text-neutral-200 hover:bg-neutral-700"
53-
type="submit"
54-
>
55-
Log In
56-
</button>
48+
</label>
49+
<LoginButton />
5750
</form>
58-
<div></div>
5951
</div>
6052
);
6153
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use client";
2+
3+
import { useFormStatus } from "react-dom";
4+
5+
export const LoginButton = () => {
6+
const { pending } = useFormStatus();
7+
return (
8+
<button
9+
className="mt-2 self-start rounded bg-neutral-800 px-4 py-2 text-neutral-200 hover:bg-neutral-700 aria-disabled:opacity-80"
10+
type="submit"
11+
aria-disabled={pending}
12+
>
13+
{pending ? "Processing..." : "Log In"}
14+
</button>
15+
);
16+
};

0 commit comments

Comments
 (0)