11<script lang =" ts" >
2- import { page } from ' $app/stores' ;
2+ import { page } from ' $app/stores' ; // TODO: Update to newer API when refactoring
33import { user } from ' $lib/services/auth' ;
44import { signInWithGithub , signOut , isAdmin } from ' $lib/services/auth' ;
55import { onMount } from ' svelte' ;
@@ -24,13 +24,20 @@ onMount(() => {
2424 // Mark component as mounted
2525 isMounted = true ;
2626
27+ // Set a small timeout to ensure smooth loading and prevent flashing
28+ setTimeout (() => {
29+ if (isMounted ) {
30+ // Only set authLoading to false if we have user data or after a timeout
31+ if ($user || ! $user ) {
32+ authLoading = false ;
33+ }
34+ }
35+ }, 300 );
36+
2737 // Set up a subscription to the user store
2838 const unsubscribe = user .subscribe (async (value ) => {
29- // Only set authLoading to false if we're mounted
39+ // Only update user data if we're mounted
3040 if (isMounted ) {
31- // Small delay to ensure DOM is ready
32- authLoading = false ;
33-
3441 // Check if the user is an admin
3542 if (value ) {
3643 isUserAdmin = await isAdmin (value .id );
@@ -194,16 +201,17 @@ $: if ($page) {
194201 {/if }
195202 </ul >
196203 <div
197- class ="mr-4 flex min-w-[70px] items-center justify-end gap-3 opacity-100 transition-opacity duration-200 sm:mr-2 md:mr-0 {authLoading
204+ class ="mr-4 flex min-w-[70px] items-center justify-end gap-3 transition-opacity duration-300 sm:mr-2 md:mr-0 {authLoading
198205 ? ' invisible opacity-0'
199- : ' ' }"
206+ : ' visible opacity-100' }"
207+ style =" will-change: opacity;"
200208 >
201209 {#if $user }
202210 <a
203211 href ={githubUrl }
204212 target =" _blank"
205213 rel =" noopener noreferrer"
206- class =" text-sm font-medium text-[var(--color-heading )] transition-colors duration-200 hover:text-[var(--color-accent )]"
214+ class =" text-sm font-medium text-[var(--color-username )] transition-colors duration-200 hover:text-[color-mix(in_oklab, var(--color-username)_80%,white )]"
207215 >
208216 @{username }
209217 </a >
@@ -258,14 +266,15 @@ $: if ($page) {
258266 {/if }
259267 </ul >
260268 <div
261- class ="mt-2 flex items-center justify-start gap-3 px-1 {authLoading ? ' invisible opacity-0' : ' ' }"
269+ class ="mt-2 flex items-center justify-start gap-3 px-1 transition-opacity duration-300 {authLoading ? ' invisible opacity-0' : ' visible opacity-100' }"
270+ style =" will-change: opacity;"
262271 >
263272 {#if $user }
264273 <a
265274 href ={githubUrl }
266275 target =" _blank"
267276 rel =" noopener noreferrer"
268- class =" text-sm font-medium text-[var(--color-heading )] transition-colors duration-200 hover:text-[var(--color-accent )]"
277+ class =" text-sm font-medium text-[var(--color-username )] transition-colors duration-200 hover:text-[color-mix(in_oklab, var(--color-username)_80%,white )]"
269278 >
270279 @{username }
271280 </a >
@@ -312,4 +321,13 @@ header {
312321 left : 0 ;
313322 right : 0 ;
314323}
324+
325+ /* Ensure username is always purple */
326+ a [href *= ' github.com' ] {
327+ color : var (--color-username ) !important ;
328+ }
329+
330+ a [href *= ' github.com' ]:hover {
331+ color : color-mix(in oklab, var (--color-username ) 80% , white ) !important ;
332+ }
315333 </style >
0 commit comments