Skip to content

Commit 498bb53

Browse files
committed
back to algolia search
1 parent 50547e0 commit 498bb53

File tree

11 files changed

+821
-415
lines changed

11 files changed

+821
-415
lines changed

app/components/ClientOnlySearchButton.tsx

Lines changed: 0 additions & 32 deletions
This file was deleted.

app/components/DocsLayout.tsx

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,16 @@ import {
1313
useNavigate,
1414
useParams,
1515
} from '@tanstack/react-router'
16-
import { OramaSearchBox } from '@orama/react-components'
17-
import { Carbon } from '~/components/Carbon'
1816
import { Select } from '~/components/Select'
1917
import { useLocalStorage } from '~/utils/useLocalStorage'
2018
import { DocsLogo } from '~/components/DocsLogo'
2119
import { last, capitalize } from '~/utils/utils'
2220
import type { SelectOption } from '~/components/Select'
2321
import type { ConfigSchema, MenuItem } from '~/utils/config'
2422
import { create } from 'zustand'
25-
import { searchBoxParams, searchButtonParams } from '~/components/Orama'
2623
import { Framework, getFrameworkOptions } from '~/libraries'
2724
import { DocsCalloutQueryGG } from '~/components/DocsCalloutQueryGG'
2825
import { DocsCalloutBytes } from '~/components/DocsCalloutBytes'
29-
import { ClientOnlySearchButton } from './ClientOnlySearchButton'
3026
import { twMerge } from 'tailwind-merge'
3127
import { partners } from '~/utils/partners'
3228
import { useThemeStore } from './ThemeToggle'
@@ -35,7 +31,7 @@ import {
3531
GadLeftRailSquare,
3632
GadRightRailSquare,
3733
} from './GoogleScripts'
38-
import { DocContainer } from './DocContainer'
34+
import { SearchButton } from './SearchButton'
3935

4036
// Let's use zustand to wrap the local storage logic. This way
4137
// we'll get subscriptions for free and we can use it in other
@@ -306,7 +302,6 @@ type DocsLayoutProps = {
306302
frameworks: Framework[]
307303
versions: string[]
308304
repo: string
309-
stableRandoms: number[]
310305
children: React.ReactNode
311306
}
312307

@@ -330,10 +325,6 @@ export function DocsLayout({
330325
const versionConfig = useVersionConfig({ versions })
331326
const menuConfig = useMenuConfig({ config, frameworks, repo })
332327

333-
const { mode: themeMode } = useThemeStore()
334-
335-
const oramaThemeMode = themeMode === 'auto' ? 'system' : themeMode
336-
337328
const matches = useMatches()
338329
const lastMatch = last(matches)
339330

@@ -510,12 +501,7 @@ export function DocsLayout({
510501
onSelect={versionConfig.onSelect}
511502
/>
512503
</div>
513-
<ClientOnlySearchButton
514-
{...searchButtonParams}
515-
colorScheme={oramaThemeMode}
516-
>
517-
Search
518-
</ClientOnlySearchButton>
504+
<SearchButton />
519505
{menuItems}
520506
</div>
521507
</details>
@@ -533,7 +519,7 @@ export function DocsLayout({
533519
{logo}
534520
</div>
535521
<div className="px-4">
536-
<ClientOnlySearchButton {...searchButtonParams} />
522+
<SearchButton />
537523
</div>
538524
<div className="flex gap-2 px-4">
539525
<Select
@@ -561,23 +547,6 @@ export function DocsLayout({
561547
<div
562548
className={`min-h-screen flex flex-col lg:flex-row w-full transition-all duration-300`}
563549
>
564-
<div className="fixed z-50">
565-
{mounted && (
566-
<OramaSearchBox
567-
{...searchBoxParams}
568-
searchParams={{
569-
threshold: 0,
570-
where: {
571-
category: {
572-
eq: capitalize(libraryId!) as string,
573-
},
574-
} as any,
575-
}}
576-
facetProperty={undefined}
577-
colorScheme={oramaThemeMode}
578-
/>
579-
)}
580-
</div>
581550
{smallMenu}
582551
{largeMenu}
583552
<div className="flex flex-col max-w-full min-w-0 w-full min-h-0 relative">

app/components/Orama.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

app/components/SearchButton.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as React from 'react'
2+
import { BiCommand } from 'react-icons/bi'
3+
import { MdSearch } from 'react-icons/md'
4+
import { twMerge } from 'tailwind-merge'
5+
import { useSearchContext } from '~/contexts/SearchContext'
6+
7+
interface SearchButtonProps {
8+
className?: string
9+
children?: React.ReactNode
10+
}
11+
12+
export function SearchButton({ className }: SearchButtonProps) {
13+
const { openSearch } = useSearchContext()
14+
15+
return (
16+
<button
17+
onClick={openSearch}
18+
className={twMerge(
19+
'flex items-center justify-between w-full p-2 text-left bg-gray-500/10 rounded-lg opacity-80 hover:opacity-100 transition-opacity duration-300',
20+
className
21+
)}
22+
>
23+
<div className="flex items-center gap-2 text-sm">
24+
<MdSearch className="text-lg" /> Search...
25+
</div>
26+
<div className="flex items-center bg-gray-500/10 rounded-lg px-2 py-1 gap-1 font-bold text-xs">
27+
<BiCommand /> + K
28+
</div>
29+
</button>
30+
)
31+
}

0 commit comments

Comments
 (0)