/** @jsxImportSource react */ import { useState, useCallback, useRef } from 'react'; import { ALGOLIA } from '../../config'; import '@docsearch/css'; import './Search.css'; import { createPortal } from 'react-dom'; import * as docSearchReact from '@docsearch/react'; /** FIXME: This is still kinda nasty, but DocSearch is not ESM ready. */ const DocSearchModal = docSearchReact.DocSearchModal || (docSearchReact as any).default.DocSearchModal; const useDocSearchKeyboardEvents = docSearchReact.useDocSearchKeyboardEvents || (docSearchReact as any).default.useDocSearchKeyboardEvents; export default function Search() { const [isOpen, setIsOpen] = useState(false); const searchButtonRef = useRef(null); const [initialQuery, setInitialQuery] = useState(''); const onOpen = useCallback(() => { setIsOpen(true); }, [setIsOpen]); const onClose = useCallback(() => { setIsOpen(false); }, [setIsOpen]); const onInput = useCallback( (e) => { setIsOpen(true); setInitialQuery(e.key); }, [setIsOpen, setInitialQuery] ); useDocSearchKeyboardEvents({ isOpen, onOpen, onClose, onInput, searchButtonRef, }); return ( <> {isOpen && createPortal( { return items.map((item) => { // We transform the absolute URL into a relative URL to // work better on localhost, preview URLS. const a = document.createElement('a'); a.href = item.url; const hash = a.hash === '#overview' ? '' : a.hash; return { ...item, url: `${a.pathname}${hash}`, }; }); }} />, document.body )} ); } nch'>ci/workflow-for-next-branch Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-04-10attempt to fix the 'no commits' bug in changesetGravatar Fred K. Schott 1-1/+1
2022-04-10revert releaseGravatar Fred K. Schott 76-225/+329
2022-04-10Update astro changelogGravatar Fred K. Schott 1-29/+0
2022-04-11[ci] formatGravatar FredKSchott 3-34/+34
2022-04-10[ci] release (#3060)Gravatar github-actions[bot] 76-363/+288
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-04-10update changesetGravatar Fred K. Schott 1-1/+0
2022-04-10update changesetGravatar Fred K. Schott 1-1/+1
2022-04-10update lockfile (#3059)Gravatar Fred K. Schott 29-914/+698
2022-04-10correct changesetsGravatar Fred K. Schott 3-3/+11
2022-04-10chore: webapi test now use chai (#3048)Gravatar Juan Martín Seery 16-814/+539
2022-04-10update test names containing spacesGravatar Fred K. Schott 26-17/+17
2022-04-11[ci] formatGravatar FredKSchott 2-8/+7
2022-04-10Fix SSR static build public file copying. fixes #3016 (#3037)Gravatar Steve Lee 8-5/+48
* Fix SSR static build public file copying * chore: update lockfile * remove dirname and use URL constructor * Cleanup test and actually test what it says it tests Co-authored-by: Nate Moore <nate@skypack.dev>
2022-04-10fix our weird beta release issues (#3031)Gravatar Fred K. Schott 4-6/+116
2022-04-10update tailwind integration readmeGravatar Fred K. Schott 2-9/+38
2022-04-10Fixed MD Lint issues (#3038)Gravatar Rafid Muhymin Wafi 1-12/+11