20231210 TIL
let hoveredKeyword = null;
<div class="modal-keywords red">
<span
on:click={() => hoveredKeyword = keyword}
on:mouseover={() => hoveredKeyword = keyword}
on:mouseout={() => hoveredKeyword = null}
class="red-span"
class:active={hoveredKeyword === keyword}>
#{keyword} 
<div class="speech-bubble">
{description}
</div>
</span>
</div>
.speech-bubble {
display: none;
position: absolute;
top: 40px;
left: 50%;
transform: translateX(-50%);
padding: 7px 9px;
background-color: #0E0D0D;
color: #FFF;
border-radius: 5px;
z-index: 1;
font-size: 12px;
line-height: 16px;
font-weight: 400;
letter-spacing: -0.5px;
}
.speech-bubble::after {
content: '';
position: absolute;
top: -9px;
left: 50%;
transform: translateX(-50%);
border-width: 5px;
border-style: solid;
border-color: transparent transparent black transparent;
}
.modal-keywords .green-span:hover, .modal-keywords .green-span.active {
background-color: rgba(96, 173, 124, 0.40);
}
.modal-keywords .red-span:hover, .modal-keywords .red-span.active {
background-color: rgba(146, 0, 0, 0.40);
}
.modal-keywords span:hover .speech-bubble, .modal-keywords span.active .speech-bubble {
display: block;
width: 122px;
}