Skip to content

Commit 1ace593

Browse files
committed
feat(auth): add loading state to login modal for improved user experience
- Enhanced the LoginModalContent component to include a loading state while fetching authentication providers. - Implemented skeleton loaders to prevent content layout shifts during loading. - Improved user feedback by displaying loading indicators before the authentication options are available. These changes enhance the overall user experience during the login process. Signed-off-by: Innei <[email protected]>
1 parent e69d120 commit 1ace593

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

apps/desktop/layer/renderer/src/modules/auth/LoginModalContent.tsx

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
2929
const { canClose = true, runtime } = props
3030

3131
const { t } = useTranslation()
32-
const { data: authProviders } = useAuthProviders()
32+
const { data: authProviders, isLoading } = useAuthProviders()
3333

3434
const isMobile = useMobile()
3535

@@ -79,25 +79,35 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
7979
)
8080
) : (
8181
<div className="mb-3 flex flex-col items-center justify-center gap-4">
82-
{providers.map(([key, provider]) => (
83-
<MotionButtonBase
84-
key={key}
85-
onClick={() => {
86-
if (key === "credential") {
87-
setIsEmail(true)
88-
} else {
89-
loginHandler(key, "app")
90-
}
91-
}}
92-
className="center hover:bg-material-medium relative w-full gap-2 rounded-xl border py-3 pl-5 font-semibold duration-200"
93-
>
94-
<img
95-
className="absolute left-9 h-5 dark:brightness-[0.85] dark:hue-rotate-180 dark:invert"
96-
src={provider.icon64}
97-
/>
98-
<span>{t("login.continueWith", { provider: provider.name })}</span>
99-
</MotionButtonBase>
100-
))}
82+
{isLoading
83+
? // Skeleton loaders to prevent CLS
84+
Array.from({ length: 4 })
85+
.fill(0)
86+
.map((_, index) => (
87+
<div
88+
key={index}
89+
className="bg-material-ultra-thick border-material-medium relative h-12 w-full animate-pulse rounded-xl border"
90+
/>
91+
))
92+
: providers.map(([key, provider]) => (
93+
<MotionButtonBase
94+
key={key}
95+
onClick={() => {
96+
if (key === "credential") {
97+
setIsEmail(true)
98+
} else {
99+
loginHandler(key, "app")
100+
}
101+
}}
102+
className="center hover:bg-material-medium relative w-full gap-2 rounded-xl border py-3 pl-5 font-semibold duration-200"
103+
>
104+
<img
105+
className="absolute left-9 h-5 dark:brightness-[0.85] dark:hue-rotate-180 dark:invert"
106+
src={provider.icon64}
107+
/>
108+
<span>{t("login.continueWith", { provider: provider.name })}</span>
109+
</MotionButtonBase>
110+
))}
101111
</div>
102112
)}
103113
<Divider className="mb-5 mt-6" />

0 commit comments

Comments
 (0)