New article
All checks were successful
Deploy / build-and-publish (push) Successful in 1m48s
Deploy / deploy (push) Successful in 13s

This commit is contained in:
2024-10-08 02:15:02 +03:00
parent 4d15eb0112
commit 93f92efefc
17 changed files with 914 additions and 11 deletions

View File

@@ -0,0 +1,45 @@
<script lang="ts">
let isHovered = false;
let x: number;
let y: number;
function mouseOver(event: MouseEvent) {
isHovered = true;
x = event.pageX + 5;
y = event.pageY + 5;
}
function mouseMove(event: MouseEvent) {
x = event.pageX + 5;
y = event.pageY + 5;
}
function mouseLeave() {
isHovered = false;
}
</script>
<span
on:mouseover={mouseOver}
on:mouseleave={mouseLeave}
on:mousemove={mouseMove}
>
<slot />
</span>
{#if isHovered}
<div
style="top: {y}px; left: {x}px;"
class="tooltip"
>
<slot name="title"></slot>
</div>
{/if}
<style>
.tooltip {
position: absolute;
padding: 8px 16px;
background-color: theme(colors.slate.900);
border: 1px solid theme(colors.slate.500);
border-radius: 8px;
}
</style>