@@ -17,6 +17,7 @@ export default function Search(props) {
18 const onChange = useCallback((event) => {
18 const onChange = useCallback((event) => {
19 const query = event.target.value;
19 const query = event.target.value;
20 SetQuery(query);
21 SetQuery(query);
21 if (query.length) {
22 if (query.length) {
22 fetch(searchEndpoint(query))
23 fetch(searchEndpoint(query))
@@ -52,102 +53,117 @@ export default function Search(props) {
52 SetQuery("");
53 SetQuery("");
56+ // Locks document scrolling when search is open
57+ if (typeof document !== "undefined") {
58+ if (props.showSearch) {
59+ document.body.style.overflow = "hidden";
61+ document.body.style.overflow = "visible";
65+ if (props.showSearch) {
56− <div className="fixed w-screen h-screen bg-black bg-opacity-30 z-50 flex flex-col">
67+ <div className="fixed w-screen h-screen bg-washedWall z-50 flex flex-col items-center">
57− <div className="p-12 w-100 flex flex-col min-h-0">
68+ <div
69+ className="relative my-32 flex flex-col max-w-screen-lg w-10/12 md:w-10/12 lg:w-8/12 xl:w-6/12 rounded-xl bg-white"
58− <div className="relative flex flex-col" ref={searchRef}>
70+ ref={searchRef}
60− className="bg-white type-ui text-green rounded-xl border-transparent p-2 outline-none relative"
74+ className="type-ui text-green bg-transparent py-2 px-4 outline-none relative w-full"
61− onChange={onChange}
75+ onChange={onChange}
62− onFocus={onFocus}
76+ onFocus={onFocus}
63− placeholder="Search..."
77+ placeholder="Search..."
64− type="text"
78+ type="text"
65− value={query}
79+ value={query}
66− autoFocus={true}
80+ autoFocus={true}
68− {query.length > 0 && (
82+
70− onClick={clear}
84+ onClick={props.toggleSearch}
71− className="absolute right-3"
85+ className="absolute right-2 top-2 cursor-pointer"
74− <svg
87+ <p className="px-2 h-8 bg-wall flex items-center justify-center text-sm rounded">
79− xmlns="http://www.w3.org/2000/svg"
84− d="M0.39382 13.7045C-0.131273 14.2296 -0.131274 15.081 0.39382 15.6061C0.918913 16.1312 1.77026 16.1312 2.29535 15.6061L7.99999 9.90142L13.7047 15.6061C14.2297 16.1312 15.0811 16.1312 15.6062 15.6061C16.1313 15.081 16.1313 14.2296 15.6062 13.7046L9.90152 7.99989L15.6061 2.29535C16.1311 1.77026 16.1312 0.918913 15.6061 0.39382C15.081 -0.131273 14.2296 -0.131273 13.7045 0.39382L7.99999 6.09836L2.29548 0.393844C1.77038 -0.131249 0.919038 -0.131249 0.393945 0.393844C-0.131148 0.918937 -0.131148 1.77028 0.393945 2.29537L6.09846 7.99989L0.39382 13.7045Z"
93− className={
94+ className={
94− "bg-white overflow-scroll min-h-0 rounded-xl border-transparent mt-2 " +
95+ "overflow-scroll min-h-0 pb-2" +
95− (query.length > 0 ? "" : "hidden")
96+ (query.length > 0 ? "" : "hidden")
100+ results.length === 0 &&
101+ glossaryResults.length === 0 &&
103+ <div className="flex font-semibold text-sm p-3 py-8 w-full">
104+ <p className="mr-2 text-gray">No Results found for</p>
105+ <p className="font-semibold">"{query}"</p>
98− {active && glossaryResults.length > 0 && (
108+ {active && glossaryResults.length > 0 ? (
110+ <div className="flex font-semibold text-sm p-3 py-1 w-full bg-ultraDeepWall text-white">
111+ <p className="font-semibold text-sm">Glossary</p>
100− {glossaryResults.map(({ name, link, desc, symbol }) => {
114+ {glossaryResults.map(({ name, link, desc, symbol }) => {
101− return (
115+ return (
102− <div className="border-b border-gray">
116+ <Link href={link} as={link} key={link}>
103− <p className="font-semibold text-sm pb-4 text-gray pl-3 pt-2">
106− <li key={link} className="cursor-pointer hover:bg-wall">
117+ <div className="cursor-pointer hover:bg-wall">
107− <Link href={link} as={link}>
108− <div className="font-semibold px-3">
118+ <div className="font-semibold p-3">
109 {symbol.length > 0 && (
119 {symbol.length > 0 && (
110− <code className="mr-1">{symbol}</code>
120+ <code className="mr-1 bg-wall rounded px-1 py-0.5">
113− <p className="font-normal text-base pt-1 pb-4">
125+ <p className="font-normal text-base mt-1">{desc}</p>
124− {active && results.length > 0 && (
125− <ul className="p-2">
127− <p className="font-semibold text-sm pb-4 text-gray">
128− {results.length} results for "{query}"
132− .filter((e) => e.parent !== "Glossary")
133− .map(({ title, slug, content, parent }) => {
135− <li key={slug} className="cursor-pointer hover:bg-wall">
136− <Link href={slug} as={slug}>
138− <p className="font-medium text-base">
141− <p className="text-base font-regular">{content}</p>
133+ {active && results.length > 0 && (
136+ <p className="font-semibold text-sm p-3 py-1 bg-ultraDeepWall text-white">
137+ {results.length} results for "{query}"
141+ .filter((e) => e.parent !== "Glossary")
142+ .map(({ title, slug, content, parent }) => {
146+ className="cursor-pointer hover:bg-wall p-3"
148+ <Link href={slug} as={slug}>
150+ <p className="font-medium text-base">
153+ <p className="text-base font-regular text-small text-gray">