mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
fix: adjust spacing for custom search properly (#7164)
This commit is contained in:
parent
03516dc3a7
commit
fe064a87a6
6 changed files with 48 additions and 16 deletions
|
@ -692,6 +692,16 @@ declare module '@theme/Navbar/MobileSidebar/Header' {
|
||||||
export default function NavbarMobileSidebarHeader(): JSX.Element;
|
export default function NavbarMobileSidebarHeader(): JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declare module '@theme/Navbar/Search' {
|
||||||
|
import type {ReactNode} from 'react';
|
||||||
|
|
||||||
|
export interface Props {
|
||||||
|
readonly children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function NavbarSearch(props: Props): JSX.Element;
|
||||||
|
}
|
||||||
|
|
||||||
declare module '@theme/NavbarItem/DefaultNavbarItem' {
|
declare module '@theme/NavbarItem/DefaultNavbarItem' {
|
||||||
import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
|
import type {Props as NavbarNavLinkProps} from '@theme/NavbarItem/NavbarNavLink';
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ import {
|
||||||
} from '@docusaurus/theme-common';
|
} from '@docusaurus/theme-common';
|
||||||
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
|
import NavbarMobileSidebarToggle from '@theme/Navbar/MobileSidebar/Toggle';
|
||||||
import NavbarLogo from '@theme/Navbar/Logo';
|
import NavbarLogo from '@theme/Navbar/Logo';
|
||||||
|
import NavbarSearch from '@theme/Navbar/Search';
|
||||||
import styles from './styles.module.css';
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
function useNavbarItems() {
|
function useNavbarItems() {
|
||||||
|
@ -73,7 +74,11 @@ export default function NavbarContent(): JSX.Element {
|
||||||
<>
|
<>
|
||||||
<NavbarItems items={rightItems} />
|
<NavbarItems items={rightItems} />
|
||||||
<NavbarColorModeToggle className={styles.colorModeToggle} />
|
<NavbarColorModeToggle className={styles.colorModeToggle} />
|
||||||
{autoAddSearchBar && <SearchBar />}
|
{autoAddSearchBar && (
|
||||||
|
<NavbarSearch>
|
||||||
|
<SearchBar />
|
||||||
|
</NavbarSearch>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import type {Props} from '@theme/Navbar/Search';
|
||||||
|
|
||||||
|
import styles from './styles.module.css';
|
||||||
|
|
||||||
|
export default function NavbarSearch({children}: Props): JSX.Element {
|
||||||
|
return <div className={styles.searchBox}>{children}</div>;
|
||||||
|
}
|
|
@ -8,11 +8,16 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import type {Props} from '@theme/NavbarItem/SearchNavbarItem';
|
import type {Props} from '@theme/NavbarItem/SearchNavbarItem';
|
||||||
import SearchBar from '@theme/SearchBar';
|
import SearchBar from '@theme/SearchBar';
|
||||||
|
import NavbarSearch from '@theme/Navbar/Search';
|
||||||
|
|
||||||
export default function SearchNavbarItem({mobile}: Props): JSX.Element | null {
|
export default function SearchNavbarItem({mobile}: Props): JSX.Element | null {
|
||||||
if (mobile) {
|
if (mobile) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <SearchBar />;
|
return (
|
||||||
|
<NavbarSearch>
|
||||||
|
<SearchBar />
|
||||||
|
</NavbarSearch>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@ import {DocSearchButton, useDocSearchKeyboardEvents} from '@docsearch/react';
|
||||||
import type {SearchClient} from 'algoliasearch/lite';
|
import type {SearchClient} from 'algoliasearch/lite';
|
||||||
import {useAlgoliaContextualFacetFilters} from '@docusaurus/theme-search-algolia/client';
|
import {useAlgoliaContextualFacetFilters} from '@docusaurus/theme-search-algolia/client';
|
||||||
import Translate, {translate} from '@docusaurus/Translate';
|
import Translate, {translate} from '@docusaurus/Translate';
|
||||||
import styles from './styles.module.css';
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
DocSearchModal as DocSearchModalType,
|
DocSearchModal as DocSearchModalType,
|
||||||
|
@ -233,7 +232,6 @@ function DocSearch({
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
|
|
||||||
<div className={styles.searchBox}>
|
|
||||||
<DocSearchButton
|
<DocSearchButton
|
||||||
onTouchStart={importDocSearchModalIfNeeded}
|
onTouchStart={importDocSearchModalIfNeeded}
|
||||||
onFocus={importDocSearchModalIfNeeded}
|
onFocus={importDocSearchModalIfNeeded}
|
||||||
|
@ -245,7 +243,6 @@ function DocSearch({
|
||||||
buttonAriaLabel: translatedSearchLabel,
|
buttonAriaLabel: translatedSearchLabel,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
|
|
||||||
{isOpen &&
|
{isOpen &&
|
||||||
DocSearchModal &&
|
DocSearchModal &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue