Skip to content

Commit 4c54fdf

Browse files
committed
chore: update package dependencies, enhance login and login-id screens with new components and improved structure
1 parent 69ce0a1 commit 4c54fdf

File tree

22 files changed

+811
-584
lines changed

22 files changed

+811
-584
lines changed

README.md

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ auth0-acul-samples/
9696
│ │ └── [screen-name]/
9797
│ │ ├── components/ # Components specific ONLY to this screen
9898
│ │ │ └── ...
99-
│ │ ├── hooks/ # Hooks specific ONLY to this screen
100-
│ │ └── index.tsx # Main screen component
99+
│ │ ├── hooks/ # Hooks specific ONLY to this screen (e.g., use<ScreenName>Manager, use<ScreenName>Form)
100+
│ │ └── index.tsx # Main screen component, orchestrates components from its ./components/ folder.
101101
│ ├── mock-data/ # Mock data JSON files for local screen development (e.g., login-id.json)
102102
│ └── utils/ # Shared utility functions
103103
│ └── mockContextLoader.ts # Utility to load mock sdk values to render screen in dev
@@ -148,37 +148,18 @@ This command, managed by `scripts/dev-screen.js`:
148148

149149
The screen components include proper integration with Auth0 ACUL SDK methods (like `handleLogin`, `handleSocialLogin`, etc.), but these methods won't perform actual authentication in this local mock data development environment.
150150

151-
<a id="technical-details"></a>
152-
153-
## 🔍 Technical Details
154-
155-
### Application Mounting in ACUL
156-
157-
In an Auth0 Advanced Customization for Universal Login (ACUL) environment, Auth0 provides the main HTML page. Your custom application, built with this template, doesn't bundle its own `index.html`. Instead, it needs to be dynamically injected into the DOM provided by Auth0.
158-
159-
The `src/main.tsx` file handles this by:
160-
161-
1. Creating a new `div` element.
162-
2. Assigning it an `id` (e.g., `root`).
163-
3. Appending this `div` to the `document.body`.
164-
4. Mounting the React application into this newly created `div`.
165-
166-
This ensures your custom UI is correctly rendered within the Auth0-hosted page. Here's a conceptual overview of how this is done in `src/main.tsx`:
167-
168-
```typescript
169-
const rootElement = document.createElement("div");
170-
rootElement.id = "root";
171-
document.body.appendChild(rootElement);
172-
```
173-
174151
### Auth0 ACUL SDK Integration
175152

176153
This template demonstrates how to integrate screen components with the Auth0 ACUL JavaScript SDK. Each screen follows these patterns:
177154

178-
- Initialize the appropriate SDK class for the screen (e.g., `LoginId`, `Login`, `LoginPassword`)
179-
- Set up proper form handling with the SDK methods
180-
- Handle errors and loading states appropriately
181-
- Follow Auth0's Universal Login design language
155+
- Initialize the appropriate SDK class for the screen (e.g., `LoginId`, `Login`, `LoginPassword`) typically within a custom hook in `src/screens/[screen-name]/hooks/use<ScreenName>Manager.ts`.
156+
- Screen-specific UI logic and form handling are often encapsulated in sub-components within `src/screens/[screen-name]/components/`, which utilize the screen's custom hooks (manager and form hooks) for data and actions.
157+
- Set up proper form handling with the SDK methods.
158+
- Handle errors and loading states appropriately.
159+
160+
<a id="technical-details"></a>
161+
162+
## 🔍 Technical Details
182163

183164
### Styling with Tailwind CSS
184165

package-lock.json

Lines changed: 197 additions & 197 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/Button/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Button: React.FC<ButtonProps> = ({
3838
switch (variant) {
3939
case "primary":
4040
variantStyles =
41-
"bg-primary text-white hover:bg-primary/90 focus:ring-3 focus:ring-primary/15 disabled:opacity-70 disabled:bg-primary/70 px-4 py-4 text-md rounded";
41+
"bg-primary text-white hover:bg-primary/90 focus:ring-4 focus:ring-primary/15 disabled:opacity-70 disabled:bg-primary/70 px-4 py-4 text-md rounded";
4242
break;
4343
case "secondary":
4444
variantStyles =
@@ -50,7 +50,7 @@ const Button: React.FC<ButtonProps> = ({
5050
break;
5151
case "social":
5252
variantStyles =
53-
"bg-background-widget text-text-default border border-gray-mid hover:bg-gray-100 focus:ring3 focus:ring-primary/15 disabled:opacity-70";
53+
"bg-background-widget text-text-default border border-gray-mid hover:bg-gray-100 focus:ring-4 focus:ring-primary/15 disabled:opacity-70";
5454
break;
5555
case "icon":
5656
variantStyles =

src/common/SocialProviderButton/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const SocialProviderButton: React.FC<SocialProviderButtonProps> = ({
1616
className = "",
1717
}) => {
1818
const baseStyles =
19-
"flex items-center justify-start w-full max-w-[320px] h-[52px] py-[14px] px-[16px] border rounded gap-x-4 focus:outline-none transition-colors duration-150 ease-in-out focus:ring-3 focus:ring-primary/15";
19+
"flex items-center justify-start w-full max-w-[320px] h-[52px] py-[14px] px-[16px] border rounded gap-x-4 focus:outline-none transition-colors duration-150 ease-in-out focus:ring-4 focus:ring-primary/15";
2020

2121
const enabledStyles =
2222
"bg-white border-gray-mid text-text-default hover:bg-gray-mid/20 focus:bg-primary/15 cursor-pointer";

src/mock-data/login-id.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"strategy": "google"
4444
},
4545
{
46-
"name": "twitter",
47-
"strategy": "twitter"
46+
"name": "linkedin",
47+
"strategy": "linkedin"
4848
}
4949
],
5050
"connection": {

src/mock-data/login-password.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@
3737
"code": "IN",
3838
"prefix": "91"
3939
},
40-
<<<<<<< HEAD
41-
"alternate_connections": [
42-
{
43-
"name": "google-oauth2",
44-
"strategy": "google"
45-
},
46-
{
47-
"name": "linkedin",
48-
"strategy": "linkedin"
49-
=======
5040
"errors": [
5141
{
5242
"code": "invalid-captcha",
@@ -57,7 +47,6 @@
5747
"code": "wrong-email-username-credentials",
5848
"message": "Incorrect email address, username, or password",
5949
"field": "password"
60-
>>>>>>> 6d648a5 (chore: css and sdk fixes for login screen)
6150
}
6251
],
6352
"connection": {

src/mock-data/login.json

Lines changed: 71 additions & 109 deletions
Large diffs are not rendered by default.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from "react";
2+
import Separator from "@/common/Separator";
3+
import SocialProviderButton from "@/common/SocialProviderButton";
4+
import { getIcon } from "@/utils/iconUtils";
5+
import { useLoginIdManager } from "../hooks/useLoginIdManager";
6+
7+
// No props needed as it uses hooks internally
8+
const AlternativeLogins: React.FC = () => {
9+
const { loginIdInstance, handleSocialLogin, handlePasskeyLogin } =
10+
useLoginIdManager();
11+
12+
const alternateConnections =
13+
loginIdInstance?.transaction?.alternateConnections;
14+
const isPasskeyAvailable = !!loginIdInstance?.screen?.data?.passkey;
15+
16+
const showSeparator =
17+
isPasskeyAvailable ||
18+
(alternateConnections && alternateConnections.length > 0);
19+
20+
return (
21+
<>
22+
{showSeparator && <Separator text={"OR"} />}
23+
24+
<div className="space-y-3 mt-4">
25+
{isPasskeyAvailable && (
26+
<SocialProviderButton
27+
key="passkey"
28+
providerName={"Passkey"}
29+
icon={getIcon("passkey")}
30+
onClick={() => handlePasskeyLogin()}
31+
/>
32+
)}
33+
{alternateConnections?.map((connection: any) => (
34+
<SocialProviderButton
35+
key={connection.name}
36+
providerName={
37+
connection.strategy
38+
? connection.strategy?.charAt(0)?.toUpperCase() +
39+
connection.strategy?.slice(1)
40+
: connection.name
41+
}
42+
icon={getIcon(connection.name)}
43+
onClick={() => handleSocialLogin(connection.name)}
44+
/>
45+
))}
46+
</div>
47+
</>
48+
);
49+
};
50+
51+
export default AlternativeLogins;
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 { useLoginIdManager } from "../hooks/useLoginIdManager";
3+
4+
const Footer: React.FC = () => {
5+
const { loginIdInstance } = useLoginIdManager();
6+
const signupLink = loginIdInstance?.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/60 focus:bg-link/15 focus:rounded p-1"
15+
>
16+
Sign up
17+
</a>
18+
)}
19+
</div>
20+
);
21+
};
22+
23+
export default Footer;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
import Logo from "@/common/Logo";
3+
4+
// No props needed as it will use the hook internally
5+
const Header: React.FC = () => {
6+
return (
7+
<>
8+
<Logo imageClassName="h-13" />
9+
<h1 className="text-2xl font-normal text-center text-text-default mt-6 mb-4">
10+
Welcome
11+
</h1>
12+
<p className="text-center text-text-default text-sm mb-4">
13+
Please enter your username or email address to continue.
14+
</p>
15+
</>
16+
);
17+
};
18+
19+
export default Header;

0 commit comments

Comments
 (0)