Skip to content

Commit

Permalink
added tooltip on left menu (#124)
Browse files Browse the repository at this point in the history
Co-authored-by: appelskrutt34 <[email protected]>
  • Loading branch information
appelskrutt34 and appelskrutt34 authored Mar 30, 2024
1 parent 4572f4e commit b3a7ebd
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 23 deletions.
61 changes: 38 additions & 23 deletions src/lib/components/navbar/LeftMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { layoutState } from '$lib/stores/layout-state.js'
import AlphaIcon from '$lib/components/icons/AlphaIcon.svelte'
import Logout from '$lib/components/icons/Logout.svelte'
import Home from '../icons/Home.svelte'
import Tooltip from "$lib/components/popups/Tooltip.svelte"
import { onMount } from 'svelte'
let sync
Expand Down Expand Up @@ -98,42 +99,56 @@ $: if ($webRTC.call.length || $swarm.voice_channel.some(a => a.address === $user
on:change={() => selectAvatar()}
style="width: 0; height: 0;"
/>
<div class:border_rgb={in_voice} class="button myavatar" on:click="{() => changeProfilePic()}">
{#if !$user.customAvatar}
<img class="avatar" src="data:image/png;base64,{avatar}" alt="" />
{:else}
<img class="avatar custom" src={$user.customAvatar} alt="" />
{/if}
</div>
<div on:click="{() => goto('/dashboard')}" class="button">
<Home />
</div>
<div on:click="{messagesRouteAndMenu}" class="button">
<MessageIcon />
</div>
<div on:click="{groupRouteAndMenu}" class="button">
<GroupIcon />
</div>
<Tooltip title="Avatar">
<div class:border_rgb={in_voice} class="button myavatar" on:click="{() => changeProfilePic()}">
{#if !$user.customAvatar}
<img class="avatar" src="data:image/png;base64,{avatar}" alt="" />
{:else}
<img class="avatar custom" src={$user.customAvatar} alt="" />
{/if}
</div>
</Tooltip>
<Tooltip title="Dashboard">
<div on:click="{() => goto('/dashboard')}" class="button">
<Home />
</div>
</Tooltip>
<Tooltip title="Messages">
<div on:click="{messagesRouteAndMenu}" class="button">
<MessageIcon />
</div>
</Tooltip>
<Tooltip title="Groups">
<div on:click="{groupRouteAndMenu}" class="button">
<GroupIcon />
</div>
</Tooltip>
<!-- <div on:click={() => goto("/boards")} class="button">
<BoardIcon/>
</div> -->
<!-- <a class='button' href="/webrtc"><img class="icon" src={financeIcon} alt="finance"></a> -->
</div>
<div class="draggable"></div>
<div class="nav">
<div on:click="{() => goto('/settings/node')}" class="button">
<SettingsIcon />
</div>
<a class='button' href="/" on:click={handleLogout}>
<Logout/>
</a>
<Tooltip title="Settings">
<div on:click="{() => goto('/settings/node')}" class="button">
<SettingsIcon />
</div>
</Tooltip>
<Tooltip title="Logout">
<a class='button' href="/" on:click={handleLogout}>
<Logout/>
</a>
</Tooltip>
<XkrLogo grey="{true}" />
<div
<Tooltip title="Github">
<div
on:click="{() =>
openURL('https://github.com/kryptokrona/hugin-desktop/issues/new/choose')}"
>
<AlphaIcon />
</div>
</Tooltip>
</div>
</div>

Expand Down
41 changes: 41 additions & 0 deletions src/lib/components/popups/Tooltip.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script>
export let title = '';
let isHovered = false;
let x;
let y;
function mouseOver(event) {
isHovered = true;
x = event.pageX + 5;
y = event.pageY + 5;
}
function mouseMove(event) {
x = event.pageX + 5;
y = event.pageY + 5;
}
function mouseLeave() {
isHovered = false;
}
</script>

<div on:mouseover={mouseOver} on:mouseleave={mouseLeave} on:mousemove={mouseMove}>
<slot />
</div>

{#if isHovered}
<div style="top: {y}px; left: {x}px;" class='tooltip'>{title}</div>
{/if}

<style>
.tooltip {
z-index: 999;
border-radius: 4px;
padding: 6px;
position: absolute;
border: 1px solid var(--text-color);
color: var(--text-color);
background-color: var(--backgound-color);
}
</style>

0 comments on commit b3a7ebd

Please sign in to comment.