|
23 | 23 | Navbar,
|
24 | 24 | Icon,
|
25 | 25 | Layout,
|
26 |
| - Link, |
27 | 26 | Tooltip,
|
28 |
| - Card, |
29 | 27 | ActionMenu,
|
30 | 28 | ToggleButton,
|
31 | 29 | Button,
|
32 | 30 | Avatar,
|
33 |
| - Typography |
| 31 | + Typography, |
| 32 | + Popover |
34 | 33 | } from '@appwrite.io/pink-svelte';
|
35 | 34 | import { toggleCommandCenter } from '$lib/commandCenter/commandCenter.svelte';
|
36 | 35 | import {
|
|
209 | 208 | </Button.Button>
|
210 | 209 | <span slot="tooltip">{isMac() ? '⌘ + K' : 'Ctrl + K'}</span></Tooltip>
|
211 | 210 | </Layout.Stack>
|
212 |
| - <Link.Button |
213 |
| - on:click={() => { |
214 |
| - showAccountMenu = !showAccountMenu; |
215 |
| - shouldAnimateThemeToggle = false; |
216 |
| - if (showAccountMenu) { |
217 |
| - trackEvent(Click.MenuDropDownClick); |
218 |
| - } |
219 |
| - }}> |
220 |
| - <div style:user-select="none"> |
| 211 | + <Popover let:toggle let:showing> |
| 212 | + <button |
| 213 | + type="button" |
| 214 | + on:click|preventDefault={(e) => { |
| 215 | + toggle(e); |
| 216 | + shouldAnimateThemeToggle = false; |
| 217 | + if (showing) { |
| 218 | + trackEvent(Click.MenuDropDownClick); |
| 219 | + } |
| 220 | + }} |
| 221 | + style:user-select="none"> |
221 | 222 | <Avatar size="s" src={avatar} />
|
222 |
| - </div> |
223 |
| - </Link.Button> |
224 |
| - {#if showAccountMenu} |
225 |
| - <div class="account-container"> |
226 |
| - <Card.Base padding="xxxs" shadow={true}> |
| 223 | + </button> |
| 224 | + <svelte:fragment slot="tooltip" let:toggle> |
| 225 | + <ActionMenu.Root noPadding> |
227 | 226 | <Layout.Stack gap="xxs">
|
228 |
| - <ActionMenu.Root> |
229 |
| - <Layout.Stack gap="xxs"> |
230 |
| - <div |
231 |
| - style:padding-inline-start="10px" |
232 |
| - style:padding-inline-end="8px" |
233 |
| - style:padding-block="4px"> |
234 |
| - <Typography.Text variant="m-500"> |
235 |
| - {$user.email} |
236 |
| - </Typography.Text> |
237 |
| - </div> |
238 |
| - <ActionMenu.Item.Anchor |
239 |
| - trailingIcon={IconUser} |
240 |
| - size="l" |
241 |
| - href={`${base}/account`}> |
242 |
| - Account</ActionMenu.Item.Anchor> |
| 227 | + <div |
| 228 | + style:padding-inline-start="10px" |
| 229 | + style:padding-inline-end="8px" |
| 230 | + style:padding-block="4px"> |
| 231 | + <Typography.Text variant="m-500"> |
| 232 | + {$user.email} |
| 233 | + </Typography.Text> |
| 234 | + </div> |
| 235 | + <ActionMenu.Item.Anchor |
| 236 | + trailingIcon={IconUser} |
| 237 | + on:click={toggle} |
| 238 | + size="l" |
| 239 | + href={`${base}/account`}> |
| 240 | + Account</ActionMenu.Item.Anchor> |
243 | 241 |
|
244 |
| - <ActionMenu.Item.Button |
245 |
| - trailingIcon={IconLogoutRight} |
246 |
| - size="l" |
247 |
| - on:click={() => logout()}>Sign out</ActionMenu.Item.Button> |
248 |
| - <div |
249 |
| - style:padding-inline-start="10px" |
250 |
| - style:padding-inline-end="8px"> |
251 |
| - <Layout.Stack |
252 |
| - justifyContent="space-between" |
253 |
| - direction="row" |
254 |
| - alignItems="center"> |
255 |
| - <Typography.Text>Theme</Typography.Text> |
256 |
| - <div |
257 |
| - class:keepTransformTransition={shouldAnimateThemeToggle}> |
258 |
| - <ToggleButton |
259 |
| - bind:active={activeTheme} |
260 |
| - on:change={() => { |
261 |
| - setTimeout(() => { |
262 |
| - shouldAnimateThemeToggle = true; |
263 |
| - }, 150); |
264 |
| - }} |
265 |
| - buttons={[ |
266 |
| - { |
267 |
| - id: 'light', |
268 |
| - label: 'Light', |
269 |
| - icon: IconSun |
270 |
| - }, |
271 |
| - { |
272 |
| - id: 'dark', |
273 |
| - label: 'Dark', |
274 |
| - icon: IconMoon |
275 |
| - }, |
276 |
| - { |
277 |
| - id: 'auto', |
278 |
| - label: 'System', |
279 |
| - icon: IconMode |
280 |
| - } |
281 |
| - ]}></ToggleButton> |
282 |
| - </div> |
283 |
| - </Layout.Stack> |
| 242 | + <ActionMenu.Item.Button |
| 243 | + trailingIcon={IconLogoutRight} |
| 244 | + size="l" |
| 245 | + on:click={() => logout()}>Sign out</ActionMenu.Item.Button> |
| 246 | + <div style:padding-inline-start="10px" style:padding-inline-end="8px"> |
| 247 | + <Layout.Stack |
| 248 | + justifyContent="space-between" |
| 249 | + direction="row" |
| 250 | + alignItems="center"> |
| 251 | + <Typography.Text>Theme</Typography.Text> |
| 252 | + <div class:keepTransformTransition={shouldAnimateThemeToggle}> |
| 253 | + <ToggleButton |
| 254 | + bind:active={activeTheme} |
| 255 | + on:change={() => { |
| 256 | + setTimeout(() => { |
| 257 | + shouldAnimateThemeToggle = true; |
| 258 | + }, 150); |
| 259 | + }} |
| 260 | + buttons={[ |
| 261 | + { |
| 262 | + id: 'light', |
| 263 | + label: 'Light', |
| 264 | + icon: IconSun |
| 265 | + }, |
| 266 | + { |
| 267 | + id: 'dark', |
| 268 | + label: 'Dark', |
| 269 | + icon: IconMoon |
| 270 | + }, |
| 271 | + { |
| 272 | + id: 'auto', |
| 273 | + label: 'System', |
| 274 | + icon: IconMode |
| 275 | + } |
| 276 | + ]}></ToggleButton> |
284 | 277 | </div>
|
285 | 278 | </Layout.Stack>
|
286 |
| - </ActionMenu.Root> |
| 279 | + </div> |
287 | 280 | </Layout.Stack>
|
288 |
| - </Card.Base> |
289 |
| - </div> |
290 |
| - <button |
291 |
| - class="account-backdrop" |
292 |
| - aria-label="Account menu" |
293 |
| - on:click={() => { |
294 |
| - showAccountMenu = false; |
295 |
| - }}></button> |
296 |
| - {/if} |
| 281 | + </ActionMenu.Root> |
| 282 | + </svelte:fragment> |
| 283 | + </Popover> |
297 | 284 | </div>
|
298 | 285 | </div>
|
299 | 286 | </Navbar.Base>
|
|
405 | 392 | }
|
406 | 393 | }
|
407 | 394 |
|
408 |
| - .account-container { |
409 |
| - position: absolute; |
410 |
| - right: var(--space-7); |
411 |
| - top: var(--base-44); |
412 |
| - width: 244px; |
413 |
| - display: flex; |
414 |
| - z-index: 1; |
415 |
| - } |
416 |
| -
|
417 |
| - .account-backdrop { |
418 |
| - position: absolute; |
419 |
| - left: 0; |
420 |
| - top: 0; |
421 |
| - width: 100vw; |
422 |
| - height: 100vh; |
423 |
| - background-color: transparent; |
424 |
| - } |
425 |
| -
|
426 | 395 | /* The default drop list has a max-inline width of 280px, which squeezes the support modal. */
|
427 | 396 | :global(.extended-width) {
|
428 | 397 | max-inline-size: none;
|
|
0 commit comments