-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13541 from ethereum/shadcn-search
Shadcn migration - search modal
- Loading branch information
Showing
12 changed files
with
238 additions
and
359 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,32 @@ | ||
import * as React from "react" | ||
import { Button, forwardRef } from "@chakra-ui/react" | ||
import { DocSearchButton, DocSearchButtonProps } from "@docsearch/react" | ||
import { useTranslation } from "react-i18next" | ||
import { DocSearchButton } from "@docsearch/react" | ||
|
||
import { getSearchButtonStyles } from "./utils" | ||
import { Button, type ButtonProps } from "../ui/buttons/Button" | ||
|
||
const SearchButton = forwardRef<DocSearchButtonProps, "button">( | ||
const SearchButton = React.forwardRef<HTMLButtonElement, ButtonProps>( | ||
(props, ref) => { | ||
const { t } = useTranslation("common") | ||
|
||
return ( | ||
<Button | ||
as={DocSearchButton} | ||
ref={ref} | ||
className="DocSearch-Button" | ||
{...getSearchButtonStyles()} | ||
variant="ghost" | ||
className="me-3 border border-disabled hover:border-primary-hover" | ||
{...props} | ||
/> | ||
asChild | ||
> | ||
<DocSearchButton | ||
translations={{ | ||
buttonText: t("search"), | ||
buttonAriaLabel: t("search"), | ||
}} | ||
/> | ||
</Button> | ||
) | ||
} | ||
) | ||
|
||
SearchButton.displayName = "SearchButton" | ||
|
||
export default SearchButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
import * as React from "react" | ||
import { chakra } from "@chakra-ui/react" | ||
import { DocSearchModal, DocSearchModalProps } from "@docsearch/react" | ||
|
||
import { getSearchModalStyles } from "./utils" | ||
|
||
type ModalPropsNoScroll = Omit<DocSearchModalProps, "initialScrollY"> | ||
|
||
const DocSearchModalWithChakra = chakra( | ||
(props: ModalPropsNoScroll & { className?: string }) => { | ||
const { className, ...docModalProps } = props | ||
const windowScrollY = typeof window === "undefined" ? 0 : window.scrollY | ||
return ( | ||
<div className={className}> | ||
<DocSearchModal initialScrollY={windowScrollY} {...docModalProps} /> | ||
</div> | ||
) | ||
} | ||
) | ||
|
||
const SearchModal = (props: ModalPropsNoScroll) => { | ||
return <DocSearchModalWithChakra {...props} sx={getSearchModalStyles()} /> | ||
const SearchModal = (props: ModalPropsNoScroll & { className?: string }) => { | ||
const { className, ...docModalProps } = props | ||
const windowScrollY = typeof window === "undefined" ? 0 : window.scrollY | ||
return ( | ||
<div className={className}> | ||
<DocSearchModal initialScrollY={windowScrollY} {...docModalProps} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default SearchModal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.