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

Fix hit area icon links buttons #1866

Merged
merged 6 commits into from
Jun 14, 2024

Conversation

gabalafou
Copy link
Collaborator

Part of #1865.

Fixes external issue Quansight-Labs/czi-scientific-python-mgmt#94.

This pull request started as a simple increase of the hit area for the navbar icon links, but then I realized that with #1846 having been merged, I could do a little bit of code cleanup at the same time.

Copy link
Collaborator Author

@gabalafou gabalafou left a comment

Choose a reason for hiding this comment

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

self-review

@@ -2,7 +2,30 @@
* Icon links in the navbar
*/

.navbar-icon-links {
.pst-navbar-icon {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realized that the navbar-btn class isn't defined by Bootstrap but we weren't using it, so I decided to delete navbar-btn everwhere and instead create a new class, pst-navbar-icon which I use to apply consistent styling to all the of the icon links and buttons.

@@ -169,7 +197,9 @@
background-color: inherit;
border: none;

@include icon-navbar-hover;
&:hover {
@include icon-hover;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hmm. This is the only place using this mixin now. I should look into unifying.

@@ -16,9 +16,9 @@
<span><i class="{{ icon }} fa-lg" aria-hidden="true"></i></span>
<span class="sr-only">{{ name }}</span>
{%- elif type == "local" -%}
<img src="{{ pathto(icon, 1) }}" class="icon-link-image" alt="{{ name }}"/>
<span><img src="{{ pathto(icon, 1) }}" class="icon-link-image" alt="{{ name }}"/></span>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The span is needed for the line-height property, which was the easiest way I found to get the underline to appear in a consistent place across all header nav items (text and icon links).

I suppose I should copy paste the following comment wherever the span is used?

{# Use <span> for line-height #}

Copy link
Collaborator Author

@gabalafou gabalafou left a comment

Choose a reason for hiding this comment

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

This is ready for review now

Copy link
Collaborator Author

@gabalafou gabalafou left a comment

Choose a reason for hiding this comment

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

This is ready for review now

border: none;

@include icon-navbar-hover;
padding: 0.5rem;
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is a substantive change (not just refactoring). Just flagging for other reviewers; I checked the PR build versus current main and I'm happy with the change (need to view in narrow viewport / on mobile to see the difference)

Copy link
Collaborator

@Carreau Carreau left a comment

Choose a reason for hiding this comment

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

I also had a visual look and all LGTM.

.theme-switch-button
.theme-switch[data-mode="#{$mode}"] {
display: inline; // inline needed for span height to be calculated using inherited font size and line height
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

{title}
</a>
</li>
"""
nav_item = "nav-item"
nav_link = "nav-link"
for link in links_data:
links_html.append(
dedent(
boilerplate.format(
active=" current active" if link.is_current else "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
active=" current active" if link.is_current else "",
active="current active" if link.is_current else "",

Maybe ? The space is added unconditionally in the formatted string above.

"pst-header-nav-item",
"",
)
html.replace(nav_item, "").replace(nav_link, "nav-link dropdown-item")
for html in links_html[n_links_before_dropdown:]
]
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need to do it in this PR, but after merge, maybe open an issue, we likely don't need to replace now that boilerplate have arguments. We can just slice links_html into solo and dropdown link and format differently.

@Carreau
Copy link
Collaborator

Carreau commented Jun 14, 2024

Ok, let's get that in.

@Carreau Carreau merged commit 4be630f into pydata:main Jun 14, 2024
29 checks passed
@gabalafou gabalafou deleted the fix-hit-area-icon-links-buttons branch June 27, 2024 09:41
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.

3 participants