Skip to content

Commit

Permalink
bad ai
Browse files Browse the repository at this point in the history
  • Loading branch information
craigkai committed Jun 24, 2024
1 parent 653415a commit 1250815
Showing 1 changed file with 4 additions and 60 deletions.
64 changes: 4 additions & 60 deletions src/components/Match.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import * as Tooltip from '$components/ui/tooltip';
import { page } from '$app/stores';
import { showModal } from '$lib/helper.svelte';
import { onMount, onDestroy } from 'svelte';
let {
match,
Expand All @@ -12,62 +11,9 @@
const winClass = 'bg-green-300 dark:bg-green-700';
const lossClass = 'bg-red-300 dark:bg-red-700';
let tooltipVisible = false;
function toggleTooltip() {
tooltipVisible = !tooltipVisible;
}
function handleOutsideClick(event: MouseEvent) {
if (tooltipVisible && !event.target.closest('.tooltip-content')) {
tooltipVisible = false;
}
}
onMount(() => {
document.addEventListener('click', handleOutsideClick);
});
onDestroy(() => {
document.removeEventListener('click', handleOutsideClick);
});
</script>

<style>
.tooltip-content {
position: relative;
display: inline-block;
}
.tooltip-content div {
visibility: hidden;
background-color: #555;
color: #fff;
text-align: center;
border-radius: 6px;
padding: 5px 0;
position: absolute;
z-index: 1;
bottom: 125%; /* Position the tooltip above the text */
left: 50%;
margin-left: -60px;
opacity: 0;
transition: opacity 0.3s;
}
.tooltip-content:hover div {
visibility: visible;
opacity: 1;
}
.tooltip-content.show div {
visibility: visible;
opacity: 1;
}
</style>

<div class="tooltip-content">
<Tooltip.Root>
<Tooltip.Trigger>
<!-- svelte-ignore a11y_click_events_have_key_events -->
<!-- svelte-ignore a11y_no_static_element_interactions -->
Expand All @@ -78,8 +24,6 @@
showModal(match?.id, 'pool');
}
}}
ontouchstart={toggleTooltip}
onclick={toggleTooltip}
>
<span
class="p-1 rounded {showWinLoss &&
Expand Down Expand Up @@ -113,9 +57,9 @@
</div>
</Tooltip.Trigger>

<Tooltip.Content class:show={tooltipVisible}>
<Tooltip.Content>
{#if match?.team1_score && match?.team2_score}
<div>{match?.team1_score} to {match?.team2_score}</div>
<p>{match?.team1_score} to {match?.team2_score}</p>
{/if}
</Tooltip.Content>
</div>
</Tooltip.Root>

0 comments on commit 1250815

Please sign in to comment.