Skip to content

Commit 6c72362

Browse files
committed
feat: implement login-password screen, enhance form handling, and update styling for improved user experience
1 parent 4c54fdf commit 6c72362

File tree

17 files changed

+313
-151
lines changed

17 files changed

+313
-151
lines changed

src/common/FormField/index.tsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { useRef } from "react";
22
import Label from "@/common/Label";
33
import type { LabelProps } from "@/common/Label";
44
import Input from "@/common/Input";
@@ -27,12 +27,18 @@ const FormField: React.FC<FormFieldProps> = ({
2727
inputWrapperClassName,
2828
errorTextClassName,
2929
}) => {
30-
const { id: inputId } = inputProps;
30+
const { id: inputId, className: inputSpecificClassName } = inputProps;
31+
const internalInputRef = useRef<HTMLInputElement>(null);
3132

32-
let inputCombinedClassName = inputProps.className || "";
33+
let inputCombinedClassName = inputSpecificClassName || "";
3334
const errorRingStyles = "border-error focus:ring-error focus:border-error";
3435

3536
let finalInputProps = { ...inputProps };
37+
delete finalInputProps.className;
38+
39+
if (inputIcon) {
40+
inputCombinedClassName += " pr-16";
41+
}
3642

3743
if (error) {
3844
inputCombinedClassName += ` ${errorRingStyles}`;
@@ -45,20 +51,23 @@ const FormField: React.FC<FormFieldProps> = ({
4551
<div
4652
className={`relative mt-1 rounded-md shadow-sm ${inputWrapperClassName || ""}`}
4753
>
48-
<Input
49-
{...finalInputProps}
50-
className={inputCombinedClassName}
51-
aria-invalid={!!error}
52-
aria-describedby={error ? `${inputId}-error` : undefined}
53-
/>
54-
<Label {...labelProps} htmlFor={inputId} isError={!!error} />
55-
{inputIcon && (
56-
<div
57-
className={`absolute inset-y-0 right-0 flex items-center rounded-r-md mt-px mt-3 ${isParentFocused ? "bg-primary/15" : ""}`}
58-
>
59-
{inputIcon}
60-
</div>
61-
)}
54+
<div className="relative w-full">
55+
<Input
56+
{...finalInputProps}
57+
ref={internalInputRef}
58+
className={inputCombinedClassName}
59+
aria-invalid={!!error}
60+
aria-describedby={error ? `${inputId}-error` : undefined}
61+
/>
62+
<Label {...labelProps} htmlFor={inputId} isError={!!error} />
63+
{inputIcon && (
64+
<div
65+
className={`absolute inset-y-0 right-0 flex items-center rounded-r-md mt-px mt-3 ${isParentFocused ? "bg-primary/15" : ""}`}
66+
>
67+
{inputIcon}
68+
</div>
69+
)}
70+
</div>
6271
</div>
6372
{error && (
6473
<div

src/common/Input/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
3636
ref,
3737
) => {
3838
const baseInputStyles =
39-
"block w-full px-3 py-4 h-14 border rounded focus:outline-none peer box-border";
39+
"block w-full px-3 py-4 h-14 border rounded focus:outline-none peer box-border overflow-hidden text-ellipsis whitespace-nowrap";
4040

4141
let borderAndFocusStyles = "";
4242
const hasError = className?.includes("border-error");

src/common/Tooltip/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ const Tooltip: React.FC<TooltipProps> = ({
3535

3636
return (
3737
<div
38-
className={`relative inline-block ${className || ""}`}
38+
className={`relative ${className || ""}`}
3939
onMouseEnter={() => setIsVisible(true)}
4040
onMouseLeave={() => setIsVisible(false)}
41-
onFocusCapture={() => setIsVisible(true)} // Show on focus as well for accessibility
42-
onBlurCapture={() => setIsVisible(false)} // Hide on blur
41+
onFocusCapture={() => setIsVisible(true)}
42+
onBlurCapture={() => setIsVisible(false)}
4343
>
4444
{children}
4545
{isVisible && text && (

src/context/BrandingProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ interface BrandingContextValues {
99
}
1010

1111
const defaultBrandingValues: BrandingContextValues = {
12-
primaryColor: "#0059d6",
13-
linkColor: "#007bad",
14-
pageBackground: "#f9fafb",
12+
primaryColor: "#635dff",
13+
linkColor: "#635dff",
14+
pageBackground: "#ffffff",
1515
logoUrl:
1616
"https://cdn.auth0.com/ulp/react-components/1.59/img/theme-generic/logo-generic.svg",
1717
};

src/mock-data/login-password.json

Lines changed: 11 additions & 32 deletions
Large diffs are not rendered by default.

src/mock-data/login.json

Lines changed: 71 additions & 71 deletions
Large diffs are not rendered by default.

src/screens/login-id/components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const Footer: React.FC = () => {
1111
{signupLink && (
1212
<a
1313
href={signupLink}
14-
className="text-sm font-bold text-link hover:text-link/60 focus:bg-link/15 focus:rounded p-1"
14+
className="text-sm font-bold text-link hover:text-link/80 focus:bg-link/15 focus:rounded p-1"
1515
>
1616
Sign up
1717
</a>

src/screens/login-id/components/Header.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React from "react";
22
import Logo from "@/common/Logo";
33

4-
// No props needed as it will use the hook internally
54
const Header: React.FC = () => {
65
return (
76
<>

src/screens/login-id/components/IdentifierForm.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const IdentifierForm: React.FC = () => {
3939
ref: identifierRef,
4040
autoComplete: "username",
4141
required: true,
42+
maxLength: 100,
4243
}}
4344
error={
4445
getFieldError("identifier", sdkErrors) ||
@@ -57,6 +58,7 @@ const IdentifierForm: React.FC = () => {
5758
inputProps={{
5859
ref: captchaRef,
5960
required: isCaptchaAvailable,
61+
maxLength: 15,
6062
}}
6163
error={getFieldError("captcha", sdkErrors)}
6264
/>
@@ -65,7 +67,7 @@ const IdentifierForm: React.FC = () => {
6567
{loginIdInstance?.screen?.links?.reset_password && (
6668
<a
6769
href={loginIdInstance?.screen?.links?.reset_password}
68-
className="text-sm text-link font-bold hover:text-link/60 focus:bg-link/15 focus:rounded p-1"
70+
className="text-sm text-link font-bold hover:text-link/80 focus:bg-link/15 focus:rounded p-1"
6971
>
7072
Forgot Password?
7173
</a>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from "react";
2+
import { useLoginPasswordManager } from "../hooks/userLoginPasswordManager";
3+
4+
const Footer: React.FC = () => {
5+
const { loginPasswordInstance } = useLoginPasswordManager();
6+
const signupLink = loginPasswordInstance?.screen?.links?.signup;
7+
8+
return (
9+
<div className="mt-4 text-left">
10+
<span className="text-sm pr-1">Don't have an account?</span>
11+
{signupLink && (
12+
<a
13+
href={signupLink}
14+
className="text-sm font-bold text-link hover:text-link/80 focus:bg-link/15 focus:rounded p-1"
15+
>
16+
Sign up
17+
</a>
18+
)}
19+
</div>
20+
);
21+
};
22+
23+
export default Footer;

0 commit comments

Comments
 (0)