Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added sidebar stickiness, icon clicking #155

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Added sidebar stickiness, icon clicking #155

wants to merge 1 commit into from

Conversation

AtibQur
Copy link
Contributor

@AtibQur AtibQur commented Jan 9, 2025

No description provided.

@AtibQur AtibQur requested a review from alexp-sssup January 9, 2025 13:04
let activeInfo = null; // Tracks currently visible info
let lastHoveredInfo = null; // Tracks last hovered info
let isPanelHovered = false; // Tracks if info panel is hovered
let hideTimeout = null; // Timeout for hiding info panel
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think timeouts are numerical ids, so we should initialize this with 0

function showInfo(info) {
activeInfo = info;
clearTimeout(hideTimeout); // Cancel timeout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should reset hideTimeout to 0 to avoid clearing it multiple times. It might be also sensible to add an if(hideTimeout) before, unless we are sure the timeout is active

class="flex flex-col gap-5 shrink-0 w-80 h-full z-10 p-2 bg-neutral-600 text-gray-100 opacity-95"
class:hidden={!activeInfo}
on:mouseover={() => {
isPanelHovered = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep all the logic in functions above

function hideInfo() {
activeInfo = null;
hideTimeout = setTimeout(() => {
if (!isPanelHovered) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can this happen? We call clearTimeout when setting isPanelHovered to true

}
function handleClick(icon) {
if (activeInfo === icon.info) {
activeInfo = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify if the indented UX here is to close a panel by clicking on it even if hovering?

/>
{:else}
<div class="grow" on:mouseover={(e) => showInfo(null)}></div>
<div class="grow" style="pointer-events: none;"></div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use tailwind CSS classes instead of a custom style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants