Skip to content

Commit 33fb96b

Browse files
gabalafoudrammock12rambaugresavagetgresavage
authored
Header nav link styles (focus, hover, current) (#1545)
* Implement header nav link styles * add comments * add comment * changes from implementation review * Consistent focus ring (first pass) (#1549) * wip * Style focus state in header nav * update focus ring style on all focussable elements * simplify * fix links in mobile sidebar overlay * put focus rings around a few more focusable elements * polish * update comment * review * better align focus ring on collapsible admonitions * comment and simplify sphinx-togglebutton focus ring * make css override more explicit * Fix SD link-card focus ring and on homepage, bring links inside card * Update docs/index.md --------- Co-authored-by: Daniel McCloy <[email protected]> * Resolve current sidebar link notch and focus ring (#1561) * Fix sidebar current notch * focus-ring-radius * missed a spot 0.125rem * keep focus ring on top * Restyle Sphinx Design tabs (#1555) * restyle sphinx design tabs * increase panel border radius * increase line height, zero padding-y * use shadow variable * Update src/pydata_sphinx_theme/assets/styles/extensions/_sphinx_design.scss * Update src/pydata_sphinx_theme/assets/styles/extensions/_sphinx_design.scss * Fix tabbed panel colors (#1567) * update feature focus (#1569) * docs: add instructions for custom SVG icons (#1490) * docs: add instructions for custom SVG icons * docs: minor tweaks in SVG icon instructions * docs: some more tweaks to SVG icon instructions * Update docs/user_guide/header-links.rst Co-authored-by: Rambaud Pierrick <[email protected]> * Change literalinclude to code-block in header links * Update docs/user_guide/header-links.rst Co-authored-by: Daniel McCloy <[email protected]> * Update docs/user_guide/header-links.rst * Update docs/user_guide/header-links.rst * Update docs/user_guide/header-links.rst * Update docs/user_guide/header-links.rst * Update docs/user_guide/header-links.rst --------- Co-authored-by: tgresavage <[email protected]> Co-authored-by: Rambaud Pierrick <[email protected]> Co-authored-by: Daniel McCloy <[email protected]> * fix: make table background transparent (#1546) * fix: make table background transparent * fix: make table background transparent * fix: add color-theme option to html tag (#1536) * Silence warnings (#1542) * avoid webpack warning during asset compile * avoid frozen modules warning during import * try to make jupyterlite quieter * add config option to silence warnings * fix tests * add docs * hide conditional warning logic in utils * bump: 0.14.2 → 0.14.3 * chore: back to dev * docs: add the list of component using a directive (#1476) * fix: create the component list automatically * fix: read the first comment as documentation * docs: add disclaimer on .html suffix * docs: document every component with a simple one liner * fix: use regex to identify comments * update component branch (#15) * Change default logo alt text (#1472) * Default logo alt text only if no extra text * change default logo * use docstitle as default logo alt text * update docs to reflect change * Apply suggestions from code review Co-authored-by: Daniel McCloy <[email protected]> * use string formatting operator * Update docs/user_guide/branding.rst * docs fixes * Update docs/user_guide/branding.rst * add test * Update pyproject.toml * revert to original --------- Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: Rambaud Pierrick <[email protected]> * chore(i18n) catalan (#1488) i18n: Translate sphinx.po in ca 100% translated source file: 'sphinx.po' on 'ca'. Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> * Build(deps): Bump postcss and css-loader (#1494) Bumps [postcss](https://github.com/postcss/postcss) to 8.4.31 and updates ancestor dependency [css-loader](https://github.com/webpack-contrib/css-loader). These dependencies need to be updated together. Updates `postcss` from 8.4.21 to 8.4.31 - [Release notes](https://github.com/postcss/postcss/releases) - [Changelog](https://github.com/postcss/postcss/blob/main/CHANGELOG.md) - [Commits](postcss/postcss@8.4.21...8.4.31) Updates `css-loader` from 3.6.0 to 6.8.1 - [Release notes](https://github.com/webpack-contrib/css-loader/releases) - [Changelog](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md) - [Commits](webpack-contrib/css-loader@v3.6.0...v6.8.1) --- updated-dependencies: - dependency-name: postcss dependency-type: indirect - dependency-name: css-loader dependency-type: direct:development ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Revert "Build(deps): Bump postcss and css-loader" (#1509) Revert "Build(deps): Bump postcss and css-loader (#1494)" This reverts commit 185a37a. * Update pst docs buttons (#1502) * call them button-links * copy edit * docs: link back to GitHub from PyPI metadata (#1504) This will add a "Source" link in the PyPI page. * navigation_with_keys = False (#1503) * navigation_with_keys = False * None -> False * Apply suggestions from code review --------- Co-authored-by: Daniel McCloy <[email protected]> * fix: convert "stable" to actual version number (#1512) * convert "stable" to actual version number * fix tests re: navigation_with_keys * try bumping autoapi * refactor: use nbsphinx as the default execution lib (#1482) * refactor: use nbsphinx as the default execution lib * add nbstripout to the pre-commits' * add pandoc to the readthedocs deps * refactor: clean the notebook * move the example to the correct folder * fix: solve link issue * install pandoc in the test environment * fix: display of large table in executed cells * avoid Userwarnings from matplotlib * hide the matplotlib wrning management cell * Update readthedocs.yml * build: use pandoc_binary to install pandoc * docs: add reference to pandoc in the setup * update docs * remove pypandoc_binary * Update pyproject.toml Co-authored-by: gabalafou <[email protected]> * ci: use back setup-pandoc * Trigger CI build --------- Co-authored-by: Gabriel Fouasnon <[email protected]> * BUG - Clear alt_text in conf.py (#1471) * comment out alt_text in conf.py * set alt_text to empty string * remove alt_text from conf.py * fix: use 12rambau fork until it's merged with nikeee repo (#1517) * deps: drop support for Sphinx 5 (#1516) * remove ref to myst-nb * update minimal supported version of sphinx * Fix: (webpack.config.js) css-loader API change (#1508) * Fix: (webpack.config.js) css-loader API change The build was broken in <https://github.com/pydata/pydata-sphinx-theme/commit/185a37aa36820f77bffa4c87a772092e9e7cc380>/<https://github.com/pydata/pydata-sphinx-theme/pull/1494>. This change fixes the build, and it seems to be in accordance with the current API as described at <https://github.com/webpack-contrib/css-loader/blob/c6f36cf91ac61743a70e81cfb077faa0f8730ebe/README.md#boolean>. Closes <#1507>. * dedup * restore version bump --------- Co-authored-by: Daniel McCloy <[email protected]> * Fix duplicate HTML IDs (#1425) * Fix duplicate HTML IDs * fix tests * Do not animate the version admonitions colors. (#1424) Otherwise a delay has to be added to the accessibility color contrast checks, to wait for the colors to fully transition. * BUG - Remove redundant ARIA in breadcrumb navigation (#1426) * style(i18n): French Typo fixed (#1430) * Add the ability to add a center section to the footer (#1432) * Add a center section for the footer * Add docs for footer_center * Add a test site for the center footer * test it in our own docs * remove new test site * add footer test --------- Co-authored-by: Daniel McCloy <[email protected]> * Build(deps): Bump actions/checkout from 3 to 4 (#1433) Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](actions/checkout@v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add dropdown_text argument to generate_header_nav_html (#1423) * Add dropdown_text argument to generate_header_nav_html * Add a test, fix typo in theme.conf and remove header_dropdown_text from docs/conf.py * fixed? --------- Co-authored-by: Daniel McCloy <[email protected]> * fix: rollback ref and Id changes (#1438) * bump: version 0.13.3 → 0.14.0 (#1440) * bump version * update version switcher * back to dev * fix: change the z-index of the dropdown (#1442) In order to be on top of the primary sidebar on small screens. * fix: set the same background for dark/light (#1443) * fix: set the same background for dark/light et the same background color for all state of the search field. It is currently only applied when hovered * fix: wrong css selector * Update src/pydata_sphinx_theme/assets/styles/components/_search.scss * Update src/pydata_sphinx_theme/assets/styles/components/_search.scss * Fix duplicate HTML IDs * fix tests * unique_html_id * backwards-compat generate_header_nav_html * feedback review * update fixture * ughhhh...caching * code cleanup * fix test snapshot * put comment inside def --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Denis Bitouzé <[email protected]> Co-authored-by: Stuart Mumford <[email protected]> Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Alenka Frim <[email protected]> Co-authored-by: Rambaud Pierrick <[email protected]> * chore: build the devcontainer automatically in codespace (#1483) * chore: build the devcontainer automaticallyin codespace * refactor: lint * add pandoc to the environment * Fix font color in search input box (#1524) * Fix color * Use --pst-color-text-base * docs: add DecentralChain (#1528) Co-authored-by: jourlez <[email protected]> * Updates for file src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po in ru [Manual Sync] (#1527) i18n: Translate sphinx.po in ru [Manual Sync] 96% of minimum 20% translated source file: 'sphinx.po' on 'ru'. Sync of partially translated files: untranslated content is included with an empty translation or source language content depending on file format Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> * ignore transient errors in windows build CI (#1520) * use warning list * clean up notebook * refactor to pass on all platforms? * simplify * fix logic * iterate backwards * fix plaform detection? also don't log unnecessarily�[H * ignore empty string warnings * remove notebook metawarning * Revert "remove notebook metawarning" This reverts commit 42f4672. * try again * debug the mysterious empty warning * escape color codes * import * triage by intermittency, not by platform; better var names * simplify * fix list.remove * undo what I broke * Update tests/utils/check_warnings.py * refactor: remove extention on component set-up (#1529) * use event.key for search shortcut (#1525) * use event.key for search shortcut * suggestions from review * caps lock --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: gabalafou <[email protected]> Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ned Batchelder <[email protected]> Co-authored-by: Adam Porter <[email protected]> Co-authored-by: Denis Bitouzé <[email protected]> Co-authored-by: Stuart Mumford <[email protected]> Co-authored-by: Alenka Frim <[email protected]> Co-authored-by: Harutaka Kawamura <[email protected]> Co-authored-by: jourlez <[email protected]> * fix: use a directive instead of raw html * fix: make links externals * fix: set reference in paragraphs * fix: missing parameter * fix: use the stem for the component name * refactor: remove never used variables * standardize component descriptions --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: gabalafou <[email protected]> Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ned Batchelder <[email protected]> Co-authored-by: Adam Porter <[email protected]> Co-authored-by: Denis Bitouzé <[email protected]> Co-authored-by: Stuart Mumford <[email protected]> Co-authored-by: Alenka Frim <[email protected]> Co-authored-by: Harutaka Kawamura <[email protected]> Co-authored-by: jourlez <[email protected]> * fix: primer link in docs (#1556) * docs: add data-content (#1559) Reproduce the change made in Sphinx 7 sphinx-doc/sphinx@8e730ae#diff-a5066e933cbf65adc46e0d1ab9a0b44e0a53ca64cc95dca7e6aa902aed6bd468R105 * Obviate background-from-color-variable (#1558) * Obviate background-from-color-variable * backwards compatibility --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: gresavage <[email protected]> Co-authored-by: tgresavage <[email protected]> Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: gabalafou <[email protected]> Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ned Batchelder <[email protected]> Co-authored-by: Adam Porter <[email protected]> Co-authored-by: Denis Bitouzé <[email protected]> Co-authored-by: Stuart Mumford <[email protected]> Co-authored-by: Alenka Frim <[email protected]> Co-authored-by: Harutaka Kawamura <[email protected]> Co-authored-by: jourlez <[email protected]> Co-authored-by: Chris Holdgraf <[email protected]> * simplify (do not change state of hover) * fix icon links * forgot to add pydata-icon.js * Restore hover styles to sidebar toggles --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Daniel McCloy <[email protected]> Co-authored-by: Rambaud Pierrick <[email protected]> Co-authored-by: gresavage <[email protected]> Co-authored-by: tgresavage <[email protected]> Co-authored-by: transifex-integration[bot] <43880903+transifex-integration[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ned Batchelder <[email protected]> Co-authored-by: Adam Porter <[email protected]> Co-authored-by: Denis Bitouzé <[email protected]> Co-authored-by: Stuart Mumford <[email protected]> Co-authored-by: Alenka Frim <[email protected]> Co-authored-by: Harutaka Kawamura <[email protected]> Co-authored-by: jourlez <[email protected]> Co-authored-by: Chris Holdgraf <[email protected]>
1 parent 4839dc2 commit 33fb96b

File tree

9 files changed

+139
-23
lines changed

9 files changed

+139
-23
lines changed

docs/_static/pydata-icon.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*******************************************************************************
2+
* Set a custom icon for PyData
3+
*/
4+
FontAwesome.library.add(
5+
(faListOldStyle = {
6+
prefix: "fa-custom",
7+
iconName: "pydata",
8+
icon: [
9+
24, // viewBox width
10+
24, // viewBox height
11+
[], // ligature
12+
"e002", // unicode codepoint - private use area
13+
"M12.1,17.8v5.8l-5-2.9v-5.8L12.1,17.8z M12.1,12v5.8l-5-2.9V9.1L12.1,12z M17,9.1L12.1,12v5.8l4.9-2.9V9.1z M12.1,6.2L7,9.1l5,2.9L17,9.1L12.1,6.2z M17,9.1V3.3l-4.9-2.8v5.8L17,9.1z",
14+
],
15+
})
16+
);

docs/_static/pydata-logo.png

-1.86 KB
Binary file not shown.

docs/conf.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@
153153
{
154154
"name": "PyData",
155155
"url": "https://pydata.org",
156-
"icon": "_static/pydata-logo.png",
157-
"type": "local",
158-
"attributes": {"target": "_blank"},
156+
"icon": "fa-custom fa-pydata",
159157
},
160158
],
161159
# alternative way to set twitter and github header icons
@@ -226,7 +224,7 @@
226224
# so a file named "default.css" will overwrite the builtin "default.css".
227225
html_static_path = ["_static"]
228226
html_css_files = ["custom.css"]
229-
html_js_files = ["custom-icon.js"]
227+
html_js_files = ["pydata-icon.js", "custom-icon.js"]
230228
todo_include_todos = True
231229

232230
# -- favicon options ---------------------------------------------------------

src/pydata_sphinx_theme/assets/styles/abstracts/_links.scss

+80
Original file line numberDiff line numberDiff line change
@@ -184,3 +184,83 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
184184
}
185185
}
186186
}
187+
188+
/*
189+
Mixin for links in the header (and the More dropdown toggle).
190+
191+
The mixin assumes it will be applied to some element X with a markup structure
192+
like: X > .nav-link, or X > .dropdown-toggle.
193+
194+
It also assumes X.current is how the app annotates which item in the header nav
195+
corresponds to the section in the docs that the user is currently reading.
196+
*/
197+
@mixin header-link {
198+
// Target the child and not the parent because we want the underline in the
199+
// mobile sidebar to only span the width of the text not the entire row/line.
200+
> .nav-link,
201+
> .dropdown-toggle {
202+
border-radius: 2px;
203+
color: var(--pst-color-text-muted);
204+
font-weight: 700;
205+
206+
&:focus-visible {
207+
box-shadow: none; // override Bootstrap
208+
outline: 3px solid var(--pst-color-accent);
209+
outline-offset: 3px;
210+
}
211+
}
212+
213+
> .nav-link {
214+
// Set up pseudo-element for hover and current states below.
215+
position: relative;
216+
&::before {
217+
content: "";
218+
display: block;
219+
position: absolute;
220+
top: 0;
221+
right: 0;
222+
bottom: 0;
223+
left: 0;
224+
background-color: transparent;
225+
}
226+
227+
// Underline on hover.
228+
// - Don't use text-decoration because it will wrap across two lines if
229+
// the link text also wraps across two lines.
230+
// - Use pseudo-element in order to avoid the border-radius values
231+
// rounding the edges of the underline. (And since a header link can be
232+
// both focused and hovered at the same time and we want the focus ring
233+
// but not the underline to be rounded, we cannot use a box shadow or
234+
// bottom border link element to create the underline, or else it will
235+
// be rounded and if we apply border-radius 0 then the hovered focus
236+
// ring would go from rounded to sharp. So we have to use the
237+
// pseudo-element.)
238+
&:hover {
239+
color: var(--pst-color-secondary);
240+
text-decoration: none; // override the link-style-hover mixin
241+
&::before {
242+
border-bottom: 3px solid var(--pst-color-secondary);
243+
}
244+
}
245+
}
246+
247+
> .dropdown-toggle {
248+
&:hover {
249+
text-decoration: none;
250+
box-shadow: 0 0 0 $focus-ring-width var(--pst-color-link-hover); // purple focus ring
251+
// Brighten the text on hover (muted -> base)
252+
color: var(--pst-color-text-base);
253+
}
254+
}
255+
256+
&.current {
257+
> .nav-link {
258+
color: var(--pst-color-primary);
259+
260+
// Underline the current navbar item
261+
&::before {
262+
border-bottom: 3px solid var(--pst-color-primary);
263+
}
264+
}
265+
}
266+
}

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

+9
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
padding-left: 0;
1414
padding-right: 0;
1515
@include icon-navbar-hover;
16+
&:focus {
17+
color: inherit;
18+
}
1619
}
1720

1821
// Spacing and centering
@@ -50,4 +53,10 @@
5053
height: 1.5em;
5154
border-radius: 0.2rem;
5255
}
56+
57+
.fa-pydata {
58+
stroke: var(--pst-color-background);
59+
stroke-linejoin: round;
60+
stroke-width: 0.35;
61+
}
5362
}

src/pydata_sphinx_theme/assets/styles/components/_search.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@
149149
background-color: var(--pst-color-surface);
150150

151151
&:hover {
152-
border: 2px solid var(--pst-color-link-hover);
152+
box-shadow: 0 0 0 $focus-ring-width var(--pst-color-link-hover);
153153
}
154154

155155
&:focus-visible {

src/pydata_sphinx_theme/assets/styles/components/_switcher-version.scss

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@ button.btn.version-switcher__button {
66
@include media-breakpoint-up($breakpoint-sidebar-primary) {
77
margin-bottom: unset;
88
}
9-
10-
@include link-style-hover;
9+
&:hover {
10+
box-shadow: 0 0 0 $focus-ring-width var(--pst-color-secondary);
11+
border-color: transparent;
12+
}
1113
&:active {
1214
color: var(--pst-color-text-base);
1315
border-color: var(--pst-color-border);
1416
}
17+
&:focus-visible {
18+
border-color: transparent;
19+
}
1520
}
1621

1722
.version-switcher__menu {

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

+12-7
Original file line numberDiff line numberDiff line change
@@ -84,23 +84,28 @@
8484

8585
@include media-breakpoint-up($breakpoint-sidebar-primary) {
8686
// Center align on wide screens so the dropdown button is centered properly
87-
align-items: center;
87+
align-items: baseline;
8888
}
8989

90-
li a.nav-link {
91-
@include link-style-text;
90+
li.pst-header-nav-item {
91+
margin-inline: 5px; // breathing room so hover, focus styles do not overlap
92+
&:first-child {
93+
margin-inline-start: 0;
94+
}
95+
&:last-child {
96+
margin-inline-end: 0;
97+
}
98+
@include header-link;
9299
}
93100

94-
// Current page is always underlined in the navbar
95-
> .current > .nav-link {
96-
@include link-navbar-current;
101+
li a.nav-link.dropdown-item {
102+
@include link-style-text;
97103
}
98104

99105
// Dropdowns for the extra links
100106
.dropdown {
101107
button {
102108
display: unset;
103-
color: var(--pst-color-text-muted);
104109
border: none;
105110
@include link-style-hover;
106111
}

src/pydata_sphinx_theme/toctree.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def generate_header_nav_before_dropdown(n_links_before_dropdown):
9191
page = toc.attributes["parent"] if page == "self" else page
9292

9393
# If this is the active ancestor page, add a class so we highlight it
94-
current = " current active" if page == active_header_page else ""
94+
current = "current active" if page == active_header_page else ""
9595

9696
# sanitize page title for use in the html output if needed
9797
if title is None:
@@ -108,14 +108,14 @@ def generate_header_nav_before_dropdown(n_links_before_dropdown):
108108
# If it's an absolute one then we use the external class and
109109
# the complete url.
110110
is_absolute = bool(urlparse(page).netloc)
111-
link_status = "external" if is_absolute else "internal"
111+
link_status = "nav-external" if is_absolute else "nav-internal"
112112
link_href = page if is_absolute else context["pathto"](page)
113113

114114
# create the html output
115115
links_html.append(
116116
f"""
117-
<li class="nav-item{current}">
118-
<a class="nav-link nav-{link_status}" href="{link_href}">
117+
<li class="nav-item pst-header-nav-item {current}">
118+
<a class="nav-link {link_status}" href="{link_href}">
119119
{title}
120120
</a>
121121
</li>
@@ -126,7 +126,7 @@ def generate_header_nav_before_dropdown(n_links_before_dropdown):
126126
for external_link in context["theme_external_links"]:
127127
links_html.append(
128128
f"""
129-
<li class="nav-item">
129+
<li class="nav-item pst-header-nav-item">
130130
<a class="nav-link nav-external" href="{ external_link["url"] }">
131131
{ external_link["name"] }
132132
</a>
@@ -140,9 +140,12 @@ def generate_header_nav_before_dropdown(n_links_before_dropdown):
140140

141141
# Wrap the final few header items in a "more" dropdown
142142
links_dropdown = [
143-
# 🐲 brittle code, relies on the assumption that the code above
144-
# gives each link in the nav a `nav-link` CSS class
145-
html.replace("nav-link", "nav-link dropdown-item")
143+
# 🐲 brittle code because it relies on the code above to build the HTML in a particular way
144+
html.replace("nav-link", "nav-link dropdown-item").replace(
145+
# Prevents the header-link mixin from applying to links within the dropdown
146+
"pst-header-nav-item",
147+
"",
148+
)
146149
for html in links_html[n_links_before_dropdown:]
147150
]
148151

@@ -177,7 +180,7 @@ def generate_header_nav_html(
177180
dropdown_id = unique_html_id("pst-nav-more-links")
178181
links_dropdown_html = "\n".join(links_dropdown)
179182
out += f"""
180-
<li class="nav-item dropdown">
183+
<li class="nav-item dropdown pst-header-nav-item">
181184
<button class="btn dropdown-toggle nav-item" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-controls="{dropdown_id}">
182185
{_(dropdown_text)}
183186
</button>

0 commit comments

Comments
 (0)