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 2 commits into
base: main
Choose a base branch
from
Open

Added sidebar stickiness, icon clicking #155

wants to merge 2 commits 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not very sure what you meant by this, but when we leave the panel, isPanelHovered is set to false. After the timeout got called and is over, the rest of variables get set to null and 0 which says that there is no hovering over the panel

Copy link
Member

Choose a reason for hiding this comment

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

isPanelHovered can only be false here. When set to true we also call clearTimeout, so the code will never run in the first place.

}
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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The intention with this is that when we hover over the panel/icon and click on a icon, the panel closes. The reason behind this was to be able to immediately go to the command line instead of moving the mouse from the panel and waiting that small moment to wait for timeout to be over before you're able to see/type. It felt move efficient. Please let me know if you want to keep it or be changed

/>
{: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

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.

isPanelHovered can only be false here. When set to true we also call clearTimeout, so the code will never run in the first place.

@AtibQur AtibQur requested a review from alexp-sssup January 11, 2025 13:50
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