Skip to content

Commit 9cd6b51

Browse files
committed
Fix Tooltip naming conflict with $state rune
1 parent b792349 commit 9cd6b51

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/lib/components/common/Tooltip.svelte

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@
112112
<script lang="ts">
113113
import { tick } from 'svelte';
114114
115-
let state = $state<TooltipState>({ text: '', x: 0, y: 0, visible: false, position: 'bottom' });
115+
let tooltipState: TooltipState = $state({ text: '', x: 0, y: 0, visible: false, position: 'bottom' });
116116
let tooltipEl: HTMLDivElement | undefined = $state();
117-
let adjustment = $state({ x: 0, y: 0 });
117+
let adjustment: { x: number; y: number } = $state({ x: 0, y: 0 });
118118
119119
tooltipStore.subscribe(async (s) => {
120-
state = s;
120+
tooltipState = s;
121121
adjustment = { x: 0, y: 0 }; // Reset adjustment
122122
if (s.visible) {
123123
// Wait for DOM update, then check viewport collision
@@ -155,7 +155,7 @@
155155
let transform = $derived.by(() => {
156156
const { x, y } = adjustment;
157157
const adj = (x !== 0 || y !== 0) ? ` translate(${x}px, ${y}px)` : '';
158-
switch (state.position) {
158+
switch (tooltipState.position) {
159159
case 'top':
160160
return `translateX(-50%) translateY(-100%)${adj}`;
161161
case 'left':
@@ -169,15 +169,15 @@
169169
});
170170
</script>
171171

172-
{#if state.visible}
172+
{#if tooltipState.visible}
173173
<div
174174
bind:this={tooltipEl}
175175
class="tooltip"
176-
style="left: {state.x}px; top: {state.y}px; transform: {transform};{state.maxWidth ? ` max-width: ${state.maxWidth}px;` : ''}"
176+
style="left: {tooltipState.x}px; top: {tooltipState.y}px; transform: {transform};{tooltipState.maxWidth ? ` max-width: ${tooltipState.maxWidth}px;` : ''}"
177177
>
178-
<span class="text">{state.text}</span>
179-
{#if state.shortcut}
180-
<span class="shortcut">{state.shortcut}</span>
178+
<span class="text">{tooltipState.text}</span>
179+
{#if tooltipState.shortcut}
180+
<span class="shortcut">{tooltipState.shortcut}</span>
181181
{/if}
182182
</div>
183183
{/if}

0 commit comments

Comments
 (0)