mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
fix: enhance tooltip functionality and update last login display
This commit is contained in:
@@ -74,9 +74,16 @@ export function tooltip(node: HTMLElement, text: string) {
|
||||
if (!currentText || currentText.trim() === '') return;
|
||||
const el = document.createElement('div');
|
||||
el.className =
|
||||
'fixed z-50 rounded bg-neutral-800 px-2 py-1 text-sm text-white shadow-lg opacity-0 pointer-events-none transition-opacity duration-150';
|
||||
'fixed z-50 rounded bg-neutral-800 px-2 py-1 text-sm text-white shadow-lg opacity-0 transition-opacity duration-150';
|
||||
el.style.maxWidth = '90%';
|
||||
el.style.wordBreak = 'break-word';
|
||||
|
||||
el.addEventListener('mouseover', () => {
|
||||
clearTimeout(hideTimeout);
|
||||
if (tooltipEl) tooltipEl.style.opacity = '1';
|
||||
});
|
||||
el.addEventListener('mouseout', mouseOut);
|
||||
|
||||
const lines = currentText.split('\n');
|
||||
if (lines.length > 1) {
|
||||
el.innerHTML = '';
|
||||
@@ -172,6 +179,7 @@ export function tooltip(node: HTMLElement, text: string) {
|
||||
|
||||
function mouseOver() {
|
||||
clearTimeout(hideTimeout);
|
||||
if (tooltipEl) tooltipEl.style.opacity = '1';
|
||||
showTimeout = setTimeout(() => {
|
||||
if (!tooltipEl) createTooltip();
|
||||
else updateContent();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import { getToken } from '$lib/utils/auth';
|
||||
import Modal from '$lib/components/Modal.svelte';
|
||||
import { user } from '$lib/stores/user';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
export let data: PageData;
|
||||
|
||||
@@ -36,6 +37,8 @@
|
||||
let showDeleteModal = false;
|
||||
let showRoleModal = false;
|
||||
let modalError = '';
|
||||
let now = new Date();
|
||||
let interval: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
$: isOwner = data.user && $user ? data.user?.uuid === $user.uuid : false;
|
||||
|
||||
@@ -111,6 +114,15 @@
|
||||
showDeleteModal = false;
|
||||
window.location.href = '/';
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
interval = setInterval(() => {
|
||||
now = new Date();
|
||||
}, 1000);
|
||||
return () => {
|
||||
if (interval) clearInterval(interval);
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -146,7 +158,9 @@
|
||||
<User class="h-8 w-8 text-neutral-400" />
|
||||
</span>
|
||||
{/if}
|
||||
<span use:tooltip={data.user?.uuid || 'Unknown UUID'}>
|
||||
{data.user?.displayName || data.user?.username}
|
||||
</span>
|
||||
</h1>
|
||||
{#if data.user?.displayName && data.user?.displayName !== data.user?.username}
|
||||
<div class="mb-2 flex items-center justify-center">
|
||||
@@ -183,7 +197,7 @@
|
||||
class="text-neutral-400"
|
||||
use:tooltip={new Date(data.user?.lastLogin).toLocaleString()}
|
||||
>
|
||||
Last login {dateToRelativeString(new Date(data.user?.lastLogin))}
|
||||
Last login {dateToRelativeString(new Date(data.user?.lastLogin), true, false, now)}
|
||||
</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user