Skip to content

Commit 18b5955

Browse files
authored
chore(docs): hide searchbar when appropriate (#11795)
1 parent e6eaa95 commit 18b5955

File tree

4 files changed

+534
-287
lines changed

4 files changed

+534
-287
lines changed

docs/components/DocSearch/searchInput.tsx

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,46 +19,46 @@ export function CustomSearchBox(props: UseSearchBoxProps) {
1919
}
2020

2121
return (
22-
<div>
23-
<form
24-
action=""
25-
role="search"
26-
noValidate
27-
onSubmit={(event) => {
28-
event.preventDefault()
29-
event.stopPropagation()
22+
<form
23+
action=""
24+
role="search"
25+
noValidate
26+
onSubmit={(event) => {
27+
event.preventDefault()
28+
event.stopPropagation()
3029

31-
if (inputRef.current) {
32-
inputRef.current.blur()
33-
}
34-
}}
35-
onReset={(event) => {
36-
event.preventDefault()
37-
event.stopPropagation()
30+
if (inputRef.current) {
31+
inputRef.current.blur()
32+
}
33+
}}
34+
onReset={(event) => {
35+
event.preventDefault()
36+
event.stopPropagation()
3837

39-
setQuery("")
38+
setQuery("")
4039

41-
if (inputRef.current) {
42-
inputRef.current.focus()
43-
}
40+
if (inputRef.current) {
41+
inputRef.current.focus()
42+
}
43+
}}
44+
className="relative"
45+
>
46+
<input
47+
ref={inputRef}
48+
autoComplete="off"
49+
autoCorrect="off"
50+
autoCapitalize="off"
51+
placeholder="Search..."
52+
spellCheck={false}
53+
maxLength={512}
54+
type="search"
55+
value={inputValue}
56+
onChange={(event) => {
57+
setQuery(event.currentTarget.value)
4458
}}
45-
className="relative max-md:ml-6"
46-
>
47-
<input
48-
ref={inputRef}
49-
autoComplete="off"
50-
autoCorrect="off"
51-
autoCapitalize="off"
52-
placeholder="Search..."
53-
spellCheck={false}
54-
maxLength={512}
55-
type="search"
56-
value={inputValue}
57-
onChange={(event) => {
58-
setQuery(event.currentTarget.value)
59-
}}
60-
className="w-full max-w-48 appearance-none rounded-lg bg-black/[.05] px-3 py-1.5 pr-2 text-base leading-tight transition-colors placeholder:text-gray-500 focus:!bg-transparent md:text-sm dark:bg-gray-50/10 dark:placeholder:text-gray-400"
61-
/>
59+
className="w-48 appearance-none rounded-lg bg-black/[.05] px-3 py-1.5 pr-2 text-base leading-tight transition-colors placeholder:text-gray-500 focus:!bg-transparent md:text-sm dark:bg-gray-50/10 dark:placeholder:text-gray-400 [aside_&]:w-full"
60+
/>
61+
<div>
6262
{inputValue.length ? (
6363
<button
6464
type="reset"
@@ -98,8 +98,8 @@ export function CustomSearchBox(props: UseSearchBoxProps) {
9898
CTRL K
9999
</kbd>
100100
)}
101-
<span hidden={!isSearchStalled}>Searching…</span>
102-
</form>
103-
</div>
101+
</div>
102+
<span hidden={!isSearchStalled}>Searching…</span>
103+
</form>
104104
)
105105
}

docs/components/DocSearch/wrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export default function () {
4848
}, [])
4949

5050
return (
51-
<div className="relative">
51+
<div className="relative [aside_&]:w-full max-md:[nav_&]:hidden">
5252
<InstantSearch
5353
indexName="next-auth"
5454
// @ts-expect-error
@@ -58,7 +58,7 @@ export default function () {
5858
<NoResultsBoundary>
5959
<Hits
6060
hitComponent={Hit}
61-
className="fixed left-2 top-28 z-50 mt-[50px] max-h-[calc(100dvh_-_120px)] w-[calc(100vw_-_16px)] overflow-y-auto rounded-md bg-neutral-100 p-2 shadow-lg md:absolute md:left-auto md:right-0 md:top-12 md:mt-auto md:w-96 dark:bg-neutral-800 [&>ol]:flex [&>ol]:flex-col [&>ol]:divide-y [&>ol]:divide-neutral-400/30 [&>ol]:dark:divide-neutral-900/50"
61+
className="fixed left-2 top-28 z-50 mt-[50px] max-h-[calc(100dvh_-_120px)] w-[calc(100vw_-_16px)] overflow-y-auto rounded-md bg-neutral-100 shadow-lg md:absolute md:left-auto md:right-0 md:top-12 md:mt-auto md:w-96 dark:bg-neutral-800 [&>ol]:flex [&>ol]:flex-col [&>ol]:divide-y [&>ol]:divide-neutral-400/30 [&>ol]:dark:divide-neutral-900/50"
6262
/>
6363
</NoResultsBoundary>
6464
</InstantSearch>

docs/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
"framer-motion": "^11.2.6",
3838
"next": "14.2.3",
3939
"next-sitemap": "^4.2.3",
40-
"nextra": "3.0.0-alpha.24",
41-
"nextra-theme-docs": "3.0.0-alpha.24",
40+
"nextra": "3.0.0-alpha.36",
41+
"nextra-theme-docs": "3.0.0-alpha.36",
4242
"react": "18.3.1",
4343
"react-dom": "18.3.1",
4444
"react-instantsearch": "^7.7.2",

0 commit comments

Comments
 (0)