Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Sync from GitHub via hub-sync
Browse files
src/components/hf-auth-button.tsx
CHANGED
|
@@ -23,14 +23,22 @@ interface HfAuthButtonProps {
|
|
| 23 |
export default function HfAuthButton({ variant = "badge" }: HfAuthButtonProps) {
|
| 24 |
const { oauth, isAuthAvailable, signIn, signOut } = useAuth();
|
| 25 |
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
if (oauth) {
|
| 29 |
const name =
|
| 30 |
oauth.userInfo?.preferred_username ?? oauth.userInfo?.name ?? "signed in";
|
| 31 |
const avatar = oauth.userInfo?.picture;
|
| 32 |
return (
|
| 33 |
-
<div className="inline-flex items-center gap-1.5 panel-raised bg-[var(--surface-0)]/85 backdrop-blur px-1.5
|
| 34 |
{avatar && (
|
| 35 |
// eslint-disable-next-line @next/next/no-img-element
|
| 36 |
<img
|
|
@@ -58,7 +66,7 @@ export default function HfAuthButton({ variant = "badge" }: HfAuthButtonProps) {
|
|
| 58 |
<button
|
| 59 |
onClick={signIn}
|
| 60 |
title="Sign in to access your private datasets"
|
| 61 |
-
className="cursor-pointer inline-flex items-center gap-1.5 text-[11px] tracking-wide text-cyan-300/80 hover:text-cyan-200 transition-colors"
|
| 62 |
>
|
| 63 |
<span aria-hidden>🤗</span>
|
| 64 |
<span>Sign in for private datasets</span>
|
|
@@ -74,7 +82,7 @@ export default function HfAuthButton({ variant = "badge" }: HfAuthButtonProps) {
|
|
| 74 |
<button
|
| 75 |
onClick={signIn}
|
| 76 |
title="Sign in to access your private datasets"
|
| 77 |
-
className="cursor-pointer inline-flex items-center gap-1.5 px-3 text-[11px] font-medium tracking-wide uppercase text-slate-400 hover:text-cyan-300 transition-colors"
|
| 78 |
>
|
| 79 |
<span aria-hidden>🤗</span>
|
| 80 |
<span>Sign in</span>
|
|
@@ -87,7 +95,7 @@ export default function HfAuthButton({ variant = "badge" }: HfAuthButtonProps) {
|
|
| 87 |
onClick={signIn}
|
| 88 |
title="Sign in with Hugging Face to access your private datasets"
|
| 89 |
aria-label="Sign in with Hugging Face to access your private datasets"
|
| 90 |
-
className="cursor-pointer inline-flex items-center rounded-md transition-opacity hover:opacity-90"
|
| 91 |
>
|
| 92 |
{/* eslint-disable-next-line @next/next/no-img-element */}
|
| 93 |
<img
|
|
|
|
| 23 |
export default function HfAuthButton({ variant = "badge" }: HfAuthButtonProps) {
|
| 24 |
const { oauth, isAuthAvailable, signIn, signOut } = useAuth();
|
| 25 |
|
| 26 |
+
// Stable slot — auth state resolves async on mount (config fetch, then
|
| 27 |
+
// localStorage rehydrate), so the rendered control changes from
|
| 28 |
+
// null → signed-out → signed-in. Reserve the height so the surrounding
|
| 29 |
+
// layout doesn't reflow each time. h-6 matches the badge image's
|
| 30 |
+
// intrinsic height and is also tall enough to contain the ghost/tab/pill
|
| 31 |
+
// variants without clipping.
|
| 32 |
+
if (!isAuthAvailable) {
|
| 33 |
+
return <span aria-hidden className="inline-block h-6" />;
|
| 34 |
+
}
|
| 35 |
|
| 36 |
if (oauth) {
|
| 37 |
const name =
|
| 38 |
oauth.userInfo?.preferred_username ?? oauth.userInfo?.name ?? "signed in";
|
| 39 |
const avatar = oauth.userInfo?.picture;
|
| 40 |
return (
|
| 41 |
+
<div className="inline-flex items-center h-6 gap-1.5 panel-raised bg-[var(--surface-0)]/85 backdrop-blur px-1.5 text-[11px] text-slate-300">
|
| 42 |
{avatar && (
|
| 43 |
// eslint-disable-next-line @next/next/no-img-element
|
| 44 |
<img
|
|
|
|
| 66 |
<button
|
| 67 |
onClick={signIn}
|
| 68 |
title="Sign in to access your private datasets"
|
| 69 |
+
className="cursor-pointer inline-flex items-center h-6 gap-1.5 text-[11px] tracking-wide text-cyan-300/80 hover:text-cyan-200 transition-colors"
|
| 70 |
>
|
| 71 |
<span aria-hidden>🤗</span>
|
| 72 |
<span>Sign in for private datasets</span>
|
|
|
|
| 82 |
<button
|
| 83 |
onClick={signIn}
|
| 84 |
title="Sign in to access your private datasets"
|
| 85 |
+
className="cursor-pointer inline-flex items-center h-6 gap-1.5 px-3 text-[11px] font-medium tracking-wide uppercase text-slate-400 hover:text-cyan-300 transition-colors"
|
| 86 |
>
|
| 87 |
<span aria-hidden>🤗</span>
|
| 88 |
<span>Sign in</span>
|
|
|
|
| 95 |
onClick={signIn}
|
| 96 |
title="Sign in with Hugging Face to access your private datasets"
|
| 97 |
aria-label="Sign in with Hugging Face to access your private datasets"
|
| 98 |
+
className="cursor-pointer inline-flex items-center h-6 rounded-md transition-opacity hover:opacity-90"
|
| 99 |
>
|
| 100 |
{/* eslint-disable-next-line @next/next/no-img-element */}
|
| 101 |
<img
|