Skip to content

Commit 7a9ec65

Browse files
committed
feat: add mobile search dialog box and styling
Signed-off-by: Mike Fiedler <[email protected]>
1 parent 51f7034 commit 7a9ec65

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

pep_sphinx_extensions/pep_theme/static/mq.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
nav#pep-sidebar {
1818
display: none;
1919
}
20+
/* Show mobile search container on small screens */
21+
.mobile-search-container {
22+
display: block;
23+
}
2024
pre {
2125
font-size: 0.8175rem;
2226
}
@@ -46,6 +50,10 @@
4650
float: left;
4751
margin-right: 2%;
4852
}
53+
/* Hide mobile search container on larger screens */
54+
.mobile-search-container {
55+
display: none;
56+
}
4957
/* Make less prominent when sidebar ToC is available */
5058
details > summary {
5159
font-size: 1rem;

pep_sphinx_extensions/pep_theme/templates/page.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ <h1>Python Enhancement Proposals</h1>
4646
<span class="visually-hidden">Toggle light / dark / auto colour theme</span>
4747
</button>
4848
</header>
49+
{# Mobile search box - visible only on small screens #}
50+
<div id="mobile-search" class="mobile-search-container"></div>
4951
<article data-pagefind-body>
5052
{# Add pagefind meta for the title to improve search result display #}
5153
<div data-pagefind-meta="title:{{ title }}" style="display:none;"></div>
@@ -73,6 +75,12 @@ <h2>Contents</h2>
7375
window.addEventListener('DOMContentLoaded', (event) => {
7476
// Initialize pagefind for desktop sidebar
7577
new PagefindUI({ element: "#search", showSubResults: true });
78+
79+
// Initialize pagefind for mobile view
80+
const mobileSearch = document.getElementById('mobile-search');
81+
if (mobileSearch && window.innerWidth <= 640) {
82+
new PagefindUI({ element: "#mobile-search", showSubResults: false });
83+
}
7684
});
7785
</script>
7886
</body>

0 commit comments

Comments
 (0)