Dominic Elm commited on
feat: tweak ui for redirect screen (#23)
Browse files
packages/bolt/app/components/ui/LoadingDots.tsx
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import { memo, useEffect, useState } from 'react';
|
| 2 |
+
|
| 3 |
+
interface LoadingDotsProps {
|
| 4 |
+
text: string;
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
export const LoadingDots = memo(({ text }: LoadingDotsProps) => {
|
| 8 |
+
const [dotCount, setDotCount] = useState(0);
|
| 9 |
+
|
| 10 |
+
useEffect(() => {
|
| 11 |
+
const interval = setInterval(() => {
|
| 12 |
+
setDotCount((prevDotCount) => (prevDotCount + 1) % 4);
|
| 13 |
+
}, 500);
|
| 14 |
+
|
| 15 |
+
return () => clearInterval(interval);
|
| 16 |
+
}, []);
|
| 17 |
+
|
| 18 |
+
return (
|
| 19 |
+
<div className="flex justify-center items-center h-full">
|
| 20 |
+
<div className="relative">
|
| 21 |
+
<span>{text}</span>
|
| 22 |
+
<span className="absolute left-[calc(100%-12px)]">{'.'.repeat(dotCount)}</span>
|
| 23 |
+
<span className="invisible">...</span>
|
| 24 |
+
</div>
|
| 25 |
+
</div>
|
| 26 |
+
);
|
| 27 |
+
});
|
packages/bolt/app/routes/login.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
| 8 |
import { useFetcher, useLoaderData } from '@remix-run/react';
|
| 9 |
import { auth, type AuthAPI } from '@webcontainer/api';
|
| 10 |
import { useEffect, useState } from 'react';
|
|
|
|
| 11 |
import { createUserSession, isAuthenticated, validateAccessToken } from '~/lib/.server/sessions';
|
| 12 |
import { CLIENT_ID, CLIENT_ORIGIN } from '~/lib/constants';
|
| 13 |
import { request as doRequest } from '~/lib/fetch';
|
|
@@ -96,12 +97,16 @@ export default function Login() {
|
|
| 96 |
|
| 97 |
return (
|
| 98 |
<div className="min-h-screen flex items-center justify-center">
|
| 99 |
-
|
| 100 |
-
<
|
| 101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
</div>
|
| 103 |
-
|
| 104 |
-
</div>
|
| 105 |
</div>
|
| 106 |
);
|
| 107 |
}
|
|
|
|
| 8 |
import { useFetcher, useLoaderData } from '@remix-run/react';
|
| 9 |
import { auth, type AuthAPI } from '@webcontainer/api';
|
| 10 |
import { useEffect, useState } from 'react';
|
| 11 |
+
import { LoadingDots } from '~/components/ui/LoadingDots';
|
| 12 |
import { createUserSession, isAuthenticated, validateAccessToken } from '~/lib/.server/sessions';
|
| 13 |
import { CLIENT_ID, CLIENT_ORIGIN } from '~/lib/constants';
|
| 14 |
import { request as doRequest } from '~/lib/fetch';
|
|
|
|
| 97 |
|
| 98 |
return (
|
| 99 |
<div className="min-h-screen flex items-center justify-center">
|
| 100 |
+
{redirected ? (
|
| 101 |
+
<LoadingDots text="Authenticating" />
|
| 102 |
+
) : (
|
| 103 |
+
<div className="max-w-md w-full space-y-8 p-10 bg-white rounded-lg shadow">
|
| 104 |
+
<div>
|
| 105 |
+
<h2 className="mt-6 text-center text-3xl font-extrabold text-gray-900">Login</h2>
|
| 106 |
+
</div>
|
| 107 |
+
<LoginForm />
|
| 108 |
</div>
|
| 109 |
+
)}
|
|
|
|
| 110 |
</div>
|
| 111 |
);
|
| 112 |
}
|