Skip to content

Commit f02399c

Browse files
committed
Coveo: Add mobile support
1 parent 3479ca1 commit f02399c

File tree

4 files changed

+61
-3
lines changed

4 files changed

+61
-3
lines changed

assets/css/v2/style.css

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ ol li:last-child {
410410
.grid-container {
411411
display: grid;
412412
grid-template-columns: var(--sidebar-width) 1fr;
413-
grid-template-rows: var(--header-height) 1fr auto;
413+
grid-template-rows: auto 1fr auto;
414414
grid-template-areas:
415415
"sidebar header"
416416
"sidebar content"
@@ -533,6 +533,11 @@ ol li:last-child {
533533
height: 2.5rem;
534534
}
535535

536+
.header__search--mobile--search--button {
537+
cursor: pointer;
538+
display: none;
539+
}
540+
536541
.header__search {
537542
display: block;
538543
width: auto;
@@ -638,6 +643,31 @@ ol li:last-child {
638643
border-top: 1px solid oklch(var(--color-divider));
639644
}
640645

646+
/* Coveo toggling */
647+
#search-standalone-header-panel:checked ~ .grid-container {
648+
& :has([data-mode="mobile"]) {
649+
.header__search[data-mode="mobile"] {
650+
position: absolute;
651+
top: 100%;
652+
width: 100%;
653+
padding-top: 0;
654+
655+
#search-standalone-header {
656+
display: unset;
657+
658+
atomic-search-box {
659+
width: calc(100% + 2rem);
660+
margin-left: -1rem;
661+
}
662+
}
663+
}
664+
665+
.header + * {
666+
margin-top: 2rem;
667+
}
668+
}
669+
}
670+
641671
/* sidebar toggling */
642672
#sidebar-panel:checked ~ .grid-container {
643673
grid-template-columns: 1fr;
@@ -899,8 +929,14 @@ ol li:last-child {
899929
}
900930
}
901931
.header-container {
932+
.header__search--mobile--search--button {
933+
display: block;
934+
}
935+
902936
.header__search {
903-
display: none;
937+
#search-standalone-header {
938+
display: none;
939+
}
904940
}
905941
}
906942
}

assets/js/coveo.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,20 @@ async function atomicCoveo() {
103103
document.addEventListener('DOMContentLoaded', async () => {
104104
atomicCoveo();
105105
});
106+
107+
window.addEventListener('resize', () => {
108+
const MODES = [
109+
// my really bad enum
110+
'desktop',
111+
'mobile',
112+
];
113+
const search = document.getElementById('header__search');
114+
115+
if (search) {
116+
if (window.innerWidth < 68 * 16) {
117+
search.setAttribute('data-mode', MODES[1]);
118+
} else {
119+
search.setAttribute('data-mode', MODES[0]);
120+
}
121+
}
122+
});

layouts/_default/baseof.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
{{ if or ( not hugo.IsServer ) ( not ( in .Site.Params.buildtype "package" ) ) }}
4242
{{ partial "universal-tag.html" . }}
4343
{{ end }}
44+
<input type="checkbox" id="search-standalone-header-panel" class="search-standalone-header-panel" hidden/>
4445
<input type="checkbox" id="sidebar-panel" class="sidebar-panel" hidden/>
4546
<div class="grid-container">
4647
<aside class="sidebar">

layouts/partials/header.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@
1010
</label>
1111
</div>
1212
{{ if ( not ( in .Site.Params.buildtype "package" ) ) }}
13-
<div class="header__search">
13+
<!-- Mobile button -->
14+
<label class="header__search--mobile--search--button" id="header__search--mobile--search--button" for="search-standalone-header-panel">
15+
{{ partial "lucide" (dict "context" . "icon" "search") }}
16+
</label>
17+
<div class="header__search" id="header__search" data-mode="mobile">
1418
<!-- Standalone search box. -->
1519
{{ partial "coveo-atomic-search.html" (dict "id" "search-standalone-header") }}
1620
</div>

0 commit comments

Comments
 (0)