|
4 | 4 | import logoLight from '$lib/assets/images/logo.svg'; |
5 | 5 | import logoDark from '$lib/assets/images/logo-dark.svg'; |
6 | 6 |
|
| 7 | + type AuthProp = |
| 8 | + | { loggedIn: true; email: string | null; portalHref: string } |
| 9 | + | { loggedIn: false; email: null; portalHref: string }; |
| 10 | +
|
7 | 11 | let { |
8 | 12 | showPricing = true, |
9 | | - showRegister = true |
| 13 | + showRegister = true, |
| 14 | + auth = { loggedIn: false, email: null, portalHref: '/portal/dashboard' } |
10 | 15 | }: { |
11 | 16 | showPricing?: boolean; |
12 | 17 | showRegister?: boolean; |
| 18 | + auth?: AuthProp; |
13 | 19 | } = $props(); |
14 | 20 |
|
15 | 21 | let menuOpen = $state(false); |
|
37 | 43 | {#each navLinks as link} |
38 | 44 | <a href={link.href}>{link.label}</a> |
39 | 45 | {/each} |
40 | | - <a href="/auth/login" class="nav-login">Log in</a> |
| 46 | + {#if auth.loggedIn} |
| 47 | + {#if auth.email} |
| 48 | + <span class="nav-user" aria-label="Signed in as {auth.email}">{auth.email}</span> |
| 49 | + {/if} |
| 50 | + <a href={auth.portalHref} class="nav-login">My portal</a> |
| 51 | + {:else} |
| 52 | + <a href="/auth/login" class="nav-login">Log in</a> |
| 53 | + {/if} |
41 | 54 | </nav> |
42 | 55 |
|
43 | 56 | <div class="header-actions"> |
|
58 | 71 | {#each navLinks as link} |
59 | 72 | <a href={link.href} onclick={() => (menuOpen = false)}>{link.label}</a> |
60 | 73 | {/each} |
61 | | - <a href="/auth/login" onclick={() => (menuOpen = false)}>Log in</a> |
| 74 | + {#if auth.loggedIn} |
| 75 | + {#if auth.email} |
| 76 | + <span class="mobile-user">{auth.email}</span> |
| 77 | + {/if} |
| 78 | + <a href={auth.portalHref} onclick={() => (menuOpen = false)}>My portal</a> |
| 79 | + {:else} |
| 80 | + <a href="/auth/login" onclick={() => (menuOpen = false)}>Log in</a> |
| 81 | + {/if} |
62 | 82 | </nav> |
63 | 83 | {/if} |
64 | 84 | </header> |
|
124 | 144 | font-weight: var(--pg-font-weight-bold); |
125 | 145 | } |
126 | 146 |
|
| 147 | + .nav-user { |
| 148 | + font-family: var(--pg-font-family); |
| 149 | + font-size: var(--pg-font-size-sm); |
| 150 | + color: var(--pg-text-secondary); |
| 151 | + max-width: 240px; |
| 152 | + overflow: hidden; |
| 153 | + text-overflow: ellipsis; |
| 154 | + white-space: nowrap; |
| 155 | + } |
| 156 | +
|
127 | 157 | @media only screen and (max-width: 768px) { |
128 | 158 | display: none; |
129 | 159 | } |
|
146 | 176 | padding: 0.5rem 1.5rem 1rem; |
147 | 177 | border-top: 1px solid var(--pg-strong-background); |
148 | 178 |
|
| 179 | + .mobile-user { |
| 180 | + font-family: var(--pg-font-family); |
| 181 | + font-size: var(--pg-font-size-sm); |
| 182 | + color: var(--pg-text-secondary); |
| 183 | + padding: 0.75rem 0 0.25rem; |
| 184 | + } |
| 185 | +
|
149 | 186 | a { |
150 | 187 | font-family: var(--pg-font-family); |
151 | 188 | font-size: var(--pg-font-size-lg); |
|
0 commit comments