|
1 | | -<script> |
| 1 | +<script lang="ts"> |
2 | 2 | import { onMount } from "svelte"; |
3 | 3 | import { options } from "./options"; |
4 | 4 | import { setup } from "./actions"; |
|
7 | 7 | import Icon from "libs/ui/svelte/components/Icon/Icon.svelte"; |
8 | 8 | import { Widget } from "@seelen-ui/lib"; |
9 | 9 | import { t } from "./i18n"; |
| 10 | + import { MissingIcon } from "libs/ui/svelte/components/Icon"; |
10 | 11 |
|
11 | 12 | onMount(() => { |
12 | 13 | setup(state); |
|
15 | 16 | function onCancel() { |
16 | 17 | Widget.getCurrent().webview.hide(); |
17 | 18 | } |
| 19 | +
|
| 20 | + const width = $derived( |
| 21 | + (state.menuRect.right - state.menuRect.left) / globalThis.devicePixelRatio |
| 22 | + ); |
| 23 | + const height = $derived( |
| 24 | + (state.menuRect.bottom - state.menuRect.top) / globalThis.devicePixelRatio |
| 25 | + ); |
18 | 26 | </script> |
19 | 27 |
|
20 | 28 | <div |
21 | | - class="power-menu" |
| 29 | + class="power-menu-overlay" |
22 | 30 | role="menu" |
23 | 31 | tabindex="-1" |
24 | | - on:click={onCancel} |
25 | | - on:keydown={(e) => { |
| 32 | + onclick={onCancel} |
| 33 | + onkeydown={(e) => { |
26 | 34 | if (e.key === "Escape") { |
27 | 35 | onCancel(); |
28 | 36 | } |
29 | 37 | }} |
30 | 38 | > |
31 | | - <div class="power-menu-user"> |
32 | | - <img |
33 | | - class="power-menu-user-profile" |
34 | | - src={convertFileSrc(state.user.profilePicturePath)} |
35 | | - alt="" |
36 | | - /> |
37 | | - <div class="power-menu-user-email"> |
38 | | - {state.user.email} |
| 39 | + <div |
| 40 | + class="power-menu" |
| 41 | + style:position="fixed" |
| 42 | + style:left="{state.menuRect.left / globalThis.devicePixelRatio}px" |
| 43 | + style:top="{state.menuRect.top / globalThis.devicePixelRatio}px" |
| 44 | + style:width="{width}px" |
| 45 | + style:height="{height}px" |
| 46 | + > |
| 47 | + <div class="power-menu-user"> |
| 48 | + {#if state.user.profilePicturePath} |
| 49 | + <img |
| 50 | + class="power-menu-user-profile" |
| 51 | + src={convertFileSrc(state.user.profilePicturePath)} |
| 52 | + alt="" |
| 53 | + /> |
| 54 | + {:else} |
| 55 | + <MissingIcon class="power-menu-user-profile" /> |
| 56 | + {/if} |
| 57 | + <div class="power-menu-user-email"> |
| 58 | + {state.user.email} |
| 59 | + </div> |
39 | 60 | </div> |
| 61 | + <div class="power-menu-bye-bye">{$t("goodbye", { 0: state.user.name })}</div> |
| 62 | + <ul class="power-menu-list"> |
| 63 | + {#each options as option} |
| 64 | + <li> |
| 65 | + <button onclick={option.onClick} class="power-menu-item"> |
| 66 | + <Icon iconName={option.icon as any} /> |
| 67 | + <span class="power-menu-item-label">{$t(option.key)}</span> |
| 68 | + </button> |
| 69 | + </li> |
| 70 | + {/each} |
| 71 | + </ul> |
| 72 | + <!-- <div class="power-menu-uptime">{$t("uptime")}: 2 hours 30 minutes</div> --> |
40 | 73 | </div> |
41 | | - <div class="power-menu-bye-bye">{$t("goodbye", [state.user.name])}</div> |
42 | | - <ul class="power-menu-list"> |
43 | | - {#each options as option} |
44 | | - <li> |
45 | | - <button on:click={option.onClick} class="power-menu-item"> |
46 | | - <Icon iconName={option.icon} /> |
47 | | - <span class="power-menu-item-label">{$t(option.key)}</span> |
48 | | - </button> |
49 | | - </li> |
50 | | - {/each} |
51 | | - </ul> |
52 | | - <!-- <div class="power-menu-uptime">{$t("uptime")}: 2 hours 30 minutes</div> --> |
53 | 74 | </div> |
54 | 75 |
|
55 | 76 | <style> |
|
0 commit comments