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

Add minimize button to infowindow #2030

Merged
merged 12 commits into from
Nov 19, 2024
Merged

Add minimize button to infowindow #2030

merged 12 commits into from
Nov 19, 2024

Conversation

huggla
Copy link
Contributor

@huggla huggla commented Jun 25, 2024

I created a minimize button for the infowindow (like I've previously did for the popup #1949).

image

I'm not sure if or how the tabindex should be changed though.
image

@johnnyblasta
Copy link
Collaborator

You can read about tabindex here but 0 is a good value here. Negative value means the button cannot be focused on.

@tonnyandersson
Copy link
Collaborator

Seems to minimize a little too much, resulting in button covering text.

image

@huggla
Copy link
Contributor Author

huggla commented Jul 2, 2024

I can't reproduce, but it was probably caused by a mix of px/em/rem in padding/margin. Can you check if I managed to fix it?

@tonnyandersson
Copy link
Collaborator

Looks better now. But I noticed something else. If you:

  1. Click on an object to open the infowindow
  2. Minimize the infowindow
  3. Close the infowindow
  4. Click on a new object to open the infowindow

...you will notice that the infowindow opens in minimized mode. I don't think this should be the default behavior.

minimize

Fix so that infowindow doesn't remain minimized after clicking the close button.
@huggla
Copy link
Contributor Author

huggla commented Aug 13, 2024

I've fixed so infowindow doesn't remained minimized after clicking close.

@johnnyblasta
Copy link
Collaborator

Why is the icon different compared to the popup in #1949

@huggla
Copy link
Contributor Author

huggla commented Aug 23, 2024

Why is the icon different compared to the popup in #1949

The buttons were implemented differently in popup vs infowindow. In popup I could use a simple underscore as button, but infowindow needed an svg icon. As there was no minimize icon available, I chose the pinch icon.

@tonnyandersson
Copy link
Collaborator

LGTM.

But I think we should discuss the icons. It makes no sense to have different icon styles in similar elements. Not necessarily within the scope of this particular issue, but the discussion must be had.

@tonnyandersson
Copy link
Collaborator

So, I had a look at the code and I think that parts of the code could be written in a different way, more akin to how similar stuff in Origo is written (yes, I'm aware of the fact that the Origo code isn't 100% consistent in this regard, but still...).

Specifically, I'm referring to the resetInfowindow() and minimizeInfowindow() functions. Typically, the hidden class would be used rather than "manually" setting different style parameters. Sort of like this:

function resetInfowindow() {
  urvalListContainer.classList.remove('hidden');
  listContainer.classList.remove('hidden');
  exportContainer.classList.remove('hidden');
  groupFooterContainer.classList.remove('hidden');
  minimizeButton.setIcon(initialIcon);
  minimizeButton.setState('initial');
}

function minimizeInfowindow() {
  urvalListContainer.classList.add('hidden');
  listContainer.classList.add('hidden');
  exportContainer.classList.add('hidden');
  groupFooterContainer.classList.add('hidden');
  minimizeButton.setIcon(hiddenIcon);
  minimizeButton.setState('hidden');
}

function toggleInfowindow() {
  if (minimizeButton.getState() === 'hidden') {
    resetInfowindow();
  } else {
    minimizeInfowindow();
  }
}

There's probably an even more elegant way to do it, but I guess you get the idea.

NOT saying you must change this now, just stating my very own opinion in the matter. Perhaps a topic to discuss in the next meeting?

@huggla
Copy link
Contributor Author

huggla commented Oct 3, 2024

I've now made changes to the code according to our discussion, but I'm unsure of the correct placement of the const definitions below (Lint complains). Feedback appreciated.

const initialMinimizeButtonIcon = '#ic_close_fullscreen_24px';
const hiddenMinimizeButtonIcon = '#ic_open_in_full_24px';
const minimizeButton = createMinimizeButton();

@tonnyandersson
Copy link
Collaborator

I would have declared all three at the top (same as now) with let just like the other variables there, and then set them at the appropriate places.

I think the minimizeButton should be set in the render() function, before it is appended to the urvalContainer. The two icon variables can be set in the init() function.

@huggla
Copy link
Contributor Author

huggla commented Oct 21, 2024

I would have declared all three at the top (same as now) with let just like the other variables there, and then set them at the appropriate places.

I've been taught to never use a variable for something that can be a constant, but I'll do it like that if that's how you prefer it.

@huggla
Copy link
Contributor Author

huggla commented Oct 21, 2024

The two icon variables can be set in the init() function.

There are two blocks of variable definitions in init(), separated by an empty line, I've put the icons in the second block.

When and where should we put empty lines in the code?

@huggla
Copy link
Contributor Author

huggla commented Oct 21, 2024

I've updated my code.

@huggla huggla merged commit 873b700 into origo-map:master Nov 19, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants