Skip to content

Commit d4b4e02

Browse files
committed
Improve accessibility of the login form
- Add ARIA labels to input fields for better screen reader support - Implement keyboard navigation for the login form elements - Fix semantic HTML issues for assistive technologies
1 parent 66f91d2 commit d4b4e02

File tree

1 file changed

+46
-38
lines changed

1 file changed

+46
-38
lines changed

apps/OpenSign/src/routes/Login.js

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ function Login(props) {
744744
};
745745

746746
const GetLoginData = async () => {
747-
setState({...state, loading: true})
747+
setState({ ...state, loading: true })
748748
try {
749749
Parse.serverURL = localStorage.getItem("baseUrl");
750750
Parse.initialize(localStorage.getItem("parseAppId"));
@@ -925,6 +925,7 @@ function Login(props) {
925925
<Title title={"Login Page"} />
926926
{state.loading && (
927927
<div
928+
aria-live="assertive"
928929
style={{
929930
position: "fixed",
930931
width: "100vw",
@@ -936,63 +937,66 @@ function Login(props) {
936937
}}
937938
>
938939
<div
940+
role="status"
939941
style={{
940942
position: "fixed",
941943
fontSize: "50px",
942944
color: "#3ac9d6",
943945
top: "50%",
944-
left: "45%"
946+
left: "50%",
947+
transform: 'translate(-50%, -50%)'
945948
}}
946949
className="loader-37"
947-
></div>
950+
>
951+
<span className="sr-only">Loading...</span>
952+
</div>
948953
</div>
949954
)}
950955
{props.isloginVisible && props.isloginVisible ? (
951-
<div>
956+
<div aria-labelledby="loginHeading" role="region">
952957
<div className="md:m-10 lg:m-16 md:p-4 lg:p-10 p-5 bg-[#ffffff] md:border-[1px] md:border-gray-400 ">
953958
<div className="w-[250px] h-[66px] inline-block">
954959
{state.hideNav ? (
955-
<img src={image} width="100%" alt="" />
960+
<img src={image} width="100%" alt="The image displays the OpenSign logo with a stylized blue square with an open corner, accompanied by the tagline Seal the Deal, Openly." />
956961
) : (
957-
<img src={image} width="100%" alt="" />
962+
<img src={image} width="100%" alt="The image displays the OpenSign logo with a stylized blue square with an open corner, accompanied by the tagline Seal the Deal, Openly." />
958963
)}
959964
</div>
960965
<div className="grid grid-cols-1 md:grid-cols-2 gap-x-2">
961-
<div className="">
966+
<div>
962967
<div>
963-
<form onSubmit={handleSubmit}>
964-
<h2 className="text-[30px] mt-6">Welcome Back !</h2>
965-
<span className="text-[12px] text-[#878787]">
966-
Login to your account
967-
</span>
968-
<div className="shadow-md rounded my-4">
968+
<form onSubmit={handleSubmit} aria-label="Login Form">
969+
<h1 className="text-[30px] mt-6">Welcome Back!</h1>
970+
<fieldset className="outline outline-1 outline-slate-300/50 my-4">
971+
<legend className="text-xs font-bold px-6 mt-4">Login to your account</legend>
969972
<div className="px-6 py-4">
970-
<label className="block text-xs">Username</label>
973+
<label className="block text-xs" htmlFor="email">Username</label>
971974
<input
975+
id="email"
972976
type="text"
973-
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded focus:outline-none text-xs"
977+
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"
974978
name="email"
975979
value={state.email}
976980
onChange={handleChange}
977981
required
978982
/>
979983
<hr className="my-2 border-none" />
980-
<label className="block text-xs">Password</label>
984+
<label className="block text-xs" htmlFor="password">Password</label>
981985
<div className="relative">
982986
<input
987+
id="password"
983988
type={state.passwordVisible ? "text" : "password"}
984-
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded focus:outline-none text-xs"
989+
className="px-3 py-2 w-full border-[1px] border-gray-300 rounded text-xs"
985990
name="password"
986991
value={state.password}
987992
onChange={handleChange}
988993
required
989994
/>
990995
<span
991-
className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${
992-
state.passwordVisible
993-
? "text-[#007bff]"
994-
: "text-black"
995-
}`}
996+
className={`absolute top-[50%] right-[10px] -translate-y-[50%] cursor-pointer ${state.passwordVisible
997+
? "text-[#007bff]"
998+
: "text-black"
999+
}`}
9961000
onClick={togglePasswordVisibility}
9971001
>
9981002
{state.passwordVisible ? (
@@ -1003,32 +1007,32 @@ function Login(props) {
10031007
</span>
10041008
</div>
10051009
</div>
1006-
</div>
1007-
<div className="flex flex-row justify-between items-center text-xs px-4 py-2">
1010+
</fieldset>
1011+
<div className="flex flex-row justify-between items-center px-4 py-2">
10081012
<div>
1009-
<label className="form-check-label">
1013+
<label className="form-check-label inline-block cursor-pointer" htmlFor="rememberpassword">
10101014
<input
10111015
type="checkbox"
1012-
className="form-check-input"
1016+
className="form-check-input mr-2"
10131017
value=""
1018+
id="rememberpassword"
10141019
/>
1015-
<span className="text-center pl-1">
1016-
Remember Password
1017-
</span>
1020+
<span className="text-[13px] pl-1">Remember Password</span>
10181021
</label>
10191022
</div>
10201023
<div>
1021-
<span className="text-[13px]">
1022-
<NavLink to={`/forgetpassword`}>
1023-
Forgot Password ?
1024-
</NavLink>
1025-
</span>
1024+
<NavLink
1025+
to="/forgetpassword"
1026+
className="text-[13px] underline focus:outline-none focus:ring-2 focus:ring-blue-600"
1027+
>
1028+
Forgot Password?
1029+
</NavLink>
10261030
</div>
10271031
</div>
10281032
<div className="flex flex-col md:flex-row justify-between items-stretch gap-8 text-center text-xs font-bold mt-2">
10291033
<button
10301034
type="submit"
1031-
className="rounded-sm bg-[#3ac9d6] text-white w-full py-3 shadow uppercase"
1035+
className="rounded-sm bg-[#3ac9d6] text-white w-full py-3 shadow outline-none uppercase focus:ring-2 focus:ring-blue-600"
10321036
disabled={state.loading}
10331037
>
10341038
{state.loading ? "Loading..." : "Login"}
@@ -1093,7 +1097,7 @@ function Login(props) {
10931097
}}
10941098
>
10951099
{props.appInfo.googleClietId &&
1096-
props.appInfo.googleClietId !== "" ? (
1100+
props.appInfo.googleClietId !== "" ? (
10971101
<GoogleSignInBtn
10981102
GoogleCred={props.appInfo.googleClietId}
10991103
thirdpartyLoginfn={thirdpartyLoginfn}
@@ -1107,14 +1111,18 @@ function Login(props) {
11071111
{!state.hideNav && (
11081112
<div className="self-center">
11091113
<div className="mx-auto md:w-[300px] lg:w-[500px]">
1110-
<img src={login_img} alt="bisec" width="100%" />
1114+
<img src={login_img} alt="The image illustrates a person from behind, seated at a desk with a four-monitor computer setup, in an environment with a light blue and white color scheme, featuring a potted plant to the right." width="100%" />
11111115
</div>
11121116
</div>
11131117
)}
11141118
</div>
11151119
</div>
11161120

1117-
<div id="snackbar" style={{ backgroundColor: state.toastColor }}>
1121+
<div
1122+
id="snackbar"
1123+
role="alert"
1124+
style={{ backgroundColor: state.toastColor }}
1125+
>
11181126
{state.toastDescription}
11191127
</div>
11201128
</div>

0 commit comments

Comments
 (0)