Skip to content

Commit 4f866c5

Browse files
committed
Responsive dropdown
1 parent 661aee1 commit 4f866c5

File tree

3 files changed

+44
-5
lines changed

3 files changed

+44
-5
lines changed

docs/source/_assets/less/docsearch.less

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.algolia-autocomplete {
22
width: 100%;
33

4-
.ds-dataset-1 {
4+
[class^="ds-dataset-"] {
55
.algolia-docsearch-suggestion--text {
66
.algolia-docsearch-suggestion--highlight {
77
box-shadow: inset 0 -2px 0 0 rgba(68, 168, 179,.8)
@@ -12,4 +12,30 @@
1212
background: rgba(68, 168, 179, .1)
1313
}
1414
}
15+
}
16+
17+
@media (max-width: 768px) {
18+
19+
.algolia-autocomplete.algolia-autocomplete-right {
20+
.ds-dropdown-menu {
21+
width: 100vw !important;
22+
max-width: ~"calc(100vw - 32px) !important";
23+
min-width: ~"calc(100vw - 32px) !important";
24+
}
25+
26+
.algolia-docsearch-suggestion.algolia-docsearch-suggestion .algolia-docsearch-suggestion--subcategory-column {
27+
display: none;
28+
29+
&:before {
30+
display: none;
31+
}
32+
}
33+
.algolia-docsearch-suggestion.algolia-docsearch-suggestion .algolia-docsearch-suggestion--content {
34+
width: 100%;
35+
36+
&:before {
37+
display: none;
38+
}
39+
}
40+
}
1541
}

docs/source/_layouts/documentation.blade.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@section('body')
77
<div class="min-h-screen">
8-
<div class="border-b border-smoke flex-none px-8 py-6 w-14/5 md:w-full md:max-w-xs fixed border-smoke bg-smoke-light border-r-2 z-50">
8+
<div class="hidden border-b border-smoke flex-none px-8 py-6 w-4/5 md:w-full md:max-w-xs flex-none border-r-2 border-smoke md:flex flex-col fixed border-smoke bg-smoke-light border-r-2 z-50">
99
<div class="mb-4">
1010
<div class="hidden md:flex md:justify-center">
1111
<a href="/" class="flex justify-center">
@@ -23,6 +23,7 @@
2323
</div>
2424
</div>
2525
</div>
26+
2627
<div id="sidebar" class="hidden z-40 fixed pin-y pin-l overflow-y-scroll scrolling-touch bg-smoke-light w-4/5 md:w-full md:max-w-xs flex-none border-r-2 border-smoke md:flex flex-col">
2728
<div class="p-8 flex-1 overflow-y-scroll">
2829
<nav id="nav" class="text-base overflow-y-scroll">
@@ -177,6 +178,12 @@
177178
<svg class="w-4 h-4 cursor-pointer text-grey" role="button" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M10 8.586L2.929 1.515 1.515 2.929 8.586 10l-7.071 7.071 1.414 1.414L10 11.414l7.071 7.071 1.414-1.414L11.414 10l7.071-7.071-1.414-1.414L10 8.586z"/></svg>
178179
</div>
179180
</div>
181+
<div id="search-mobile" class="absolute pin-r pin-y px-4 flex items-center relative">
182+
<input type="text" id="searchbox-mobile" class="rounded bg-white border border-smoke py-2 pr-4 pl-10 block w-full opacity-75 ds-input">
183+
<div class="pointer-events-none absolute pin-y pin-l pl-8 flex items-center opacity-75">
184+
<svg class="pointer-events-none text-slate w-4 h-4" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"><path d="M12.9 14.32a8 8 0 1 1 1.41-1.41l5.35 5.33-1.42 1.42-5.33-5.34zM8 14A6 6 0 1 0 8 2a6 6 0 0 0 0 12z"/></svg>
185+
</div>
186+
</div>
180187
</div>
181188
</div>
182189
<div id="content" class="px-6 pb-8 pt-20 md:pt-16 w-full max-w-lg mx-auto">

docs/source/_layouts/master.blade.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@
2828
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
2929
<script type="text/javascript">
3030
docsearch({
31-
// appId: 'FMDGKF8GP7',
3231
apiKey: '3df93446658cd9c4e314d4c02a052188',
3332
indexName: 'tailwindcss',
34-
inputSelector: '#searchbox',
35-
debug: true // Set debug to true if you want to inspect the dropdown
33+
inputSelector: '#searchbox'
34+
});
35+
36+
// For mobile ( will be fixed soon, see : https://github.com/algolia/docsearch/issues/230 )
37+
docsearch({
38+
apiKey: '3df93446658cd9c4e314d4c02a052188',
39+
indexName: 'tailwindcss',
40+
inputSelector: '#searchbox-mobile',
41+
debug: true
3642
});
3743
</script>
3844
<script>

0 commit comments

Comments
 (0)