Skip to content

Commit 6a36d49

Browse files
gabalafoudrammock
andauthored
Use navbar-nav class on text links only (#1846)
This pull request fixes #1839 while also trying to simplify the way we use the Boostrap "navbar-nav" class. Prior to this PR, we have both: 1. "navbar-nav" **class** applied to **text** links rendered by "navbar-nav" **template** 2. "navbar-nav" class applied to **icon** links rendered by "navbar-icon-links" template This is what led to the bug in #1839 because I must have thought that the .navbar-nav selector was for the text links, **not** the icon links. I see two possible ways of resolving this ambiguity: 1. Keep the navbar-nav class on the text links, but remove it from the icon links. This requires adding some style rules to the icon links so they look the same with and without the class. This is the option shown in this PR. 3. Keep the navbar-nav class on both sets of links, but change the name of the navbar-nav template to something else. This would require updating the docs, and I think it would also require theme adopters to update their theme config files, which is why I didn't choose this option. --------- Co-authored-by: Daniel McCloy <dan@mccloy.info>
1 parent 2aaddff commit 6a36d49

File tree

8 files changed

+13
-8
lines changed

8 files changed

+13
-8
lines changed

src/pydata_sphinx_theme/assets/styles/components/_icon-links.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
flex-flow: row wrap;
88
column-gap: 1rem;
99
justify-content: space-evenly;
10+
align-items: center;
11+
padding-left: 0;
12+
margin-bottom: 0;
13+
list-style: none;
1014

1115
// Remove the padding so that we can define it with flexbox gap above
1216
li.nav-item a.nav-link {

src/pydata_sphinx_theme/assets/styles/components/_navbar-links.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
2-
* Navigation text links in the navbar
2+
* Navigation links in the navbar and icon links
33
*/
4-
.navbar-nav {
4+
.navbar-nav,
5+
.navbar-icon-links {
56
ul {
67
display: block;
78
list-style: none;

src/pydata_sphinx_theme/assets/styles/sections/_header.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
display: flex;
8686

8787
@include media-breakpoint-up($breakpoint-sidebar-primary) {
88-
// Center align on wide screens so the dropdown button is centered properly
88+
// Align on wide screens so the dropdown button is centered properly
8989
align-items: baseline;
9090
}
9191

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{%- endif -%}
2828
{%- endmacro -%}
2929
{%- if theme_icon_links -%}
30-
<ul class="navbar-icon-links navbar-nav"
30+
<ul class="navbar-icon-links"
3131
aria-label="{{ theme_icon_links_label }}">
3232
{%- for icon_link in theme_icon_links -%}
3333
{{ icon_link_nav_item(icon_link["url"], icon_link["icon"], icon_link["name"], icon_link.get("type", "fontawesome"), icon_link.get("attributes", {})) -}}

src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/navbar-nav.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{# Displays links to the top-level TOCtree elements, in the header navbar. #}
2-
<nav class="navbar-nav">
2+
<nav>
33
<ul class="bd-navbar-elements navbar-nav">
44
{{ generate_header_nav_html(n_links_before_dropdown=theme_header_links_before_dropdown, dropdown_text=theme_header_dropdown_text) }}
55
</ul>

tests/test_build/navbar_icon_links.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ul aria-label="Icon Links" class="navbar-icon-links navbar-nav">
1+
<ul aria-label="Icon Links" class="navbar-icon-links">
22
<li class="nav-item">
33
<a class="nav-link" data-bs-placement="bottom" data-bs-toggle="tooltip" href="https://site1.org" rel="noopener" target="_blank" title="FONTAWESOME">
44
<span>

tests/test_build/navbar_ix.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="me-auto navbar-header-items__center">
22
<div class="navbar-item">
3-
<nav class="navbar-nav">
3+
<nav>
44
<ul class="bd-navbar-elements navbar-nav">
55
<li class="nav-item pst-header-nav-item">
66
<a class="nav-link nav-internal" href="page1.html">

tests/test_build/sidebar_subpage.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="sidebar-header-items sidebar-primary__section">
33
<div class="sidebar-header-items__center">
44
<div class="navbar-item">
5-
<nav class="navbar-nav">
5+
<nav>
66
<ul class="bd-navbar-elements navbar-nav">
77
<li class="nav-item pst-header-nav-item">
88
<a class="nav-link nav-internal" href="../page1.html">

0 commit comments

Comments
 (0)