Skip to content

Commit c90105b

Browse files
authored
chore: upgrade searchbox / add suggestions / fix theme (#312)
1 parent 9dbcaff commit c90105b

File tree

5 files changed

+90
-74
lines changed

5 files changed

+90
-74
lines changed

app/components/DocsLayout.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { DocsCalloutBytes } from '~/components/DocsCalloutBytes'
2929
import { ClientOnlySearchButton } from './ClientOnlySearchButton'
3030
import { twMerge } from 'tailwind-merge'
3131
import { partners } from '~/utils/partners'
32+
import { useThemeStore } from './ThemeToggle'
3233

3334
// Let's use zustand to wrap the local storage logic. This way
3435
// we'll get subscriptions for free and we can use it in other
@@ -321,6 +322,10 @@ export function DocsLayout({
321322
const versionConfig = useVersionConfig({ versions })
322323
const menuConfig = useMenuConfig({ config, frameworks, repo })
323324

325+
const { mode: themeMode } = useThemeStore()
326+
327+
const oramaThemeMode = themeMode === 'auto' ? 'system' : themeMode
328+
324329
const matches = useMatches()
325330
const lastMatch = last(matches)
326331

@@ -493,7 +498,10 @@ export function DocsLayout({
493498
onSelect={versionConfig.onSelect}
494499
/>
495500
</div>
496-
<ClientOnlySearchButton {...searchButtonParams}>
501+
<ClientOnlySearchButton
502+
{...searchButtonParams}
503+
colorScheme={oramaThemeMode}
504+
>
497505
Search
498506
</ClientOnlySearchButton>
499507
{menuItems}
@@ -554,6 +562,7 @@ export function DocsLayout({
554562
} as any,
555563
}}
556564
facetProperty={undefined}
565+
colorScheme={oramaThemeMode}
557566
/>
558567
)}
559568
</div>

app/components/Orama.tsx

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ export const searchBoxParams = {
44
endpoint: 'https://cloud.orama.run/v1/indexes/tanstack-dev-ur0ppd',
55
},
66
colorScheme: 'system' as 'light' | 'dark' | 'system',
7+
suggestions: [
8+
'What is TanStack?',
9+
'Why should I use TanStack query?',
10+
'Show me an example integration of useQuery hook',
11+
'How is TanStack router different than other routers?',
12+
'What is TanStack Table for?',
13+
'Code example using TanStack Store',
14+
],
715
facetProperty: 'category',
816
resultMap: {
917
description: 'content',

app/routes/_libraries/route.tsx

+14-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { getLibrary, libraries } from '~/libraries'
1717
import { Scarf } from '~/components/Scarf'
1818
import { searchBoxParams, searchButtonParams } from '~/components/Orama'
1919
import { ClientOnlySearchButton } from '~/components/ClientOnlySearchButton'
20-
import { ThemeToggle } from '~/components/ThemeToggle'
20+
import { ThemeToggle, useThemeStore } from '~/components/ThemeToggle'
2121
import { TbBrandBluesky, TbBrandTwitter } from 'react-icons/tb'
2222

2323
export const Route = createFileRoute('/_libraries')({
@@ -41,6 +41,10 @@ function LibrariesLayout() {
4141

4242
const [mounted, setMounted] = React.useState(false)
4343

44+
const { mode: themeMode } = useThemeStore()
45+
46+
const oramaThemeMode = themeMode === 'auto' ? 'system' : themeMode
47+
4448
React.useEffect(() => {
4549
setMounted(true)
4650
}, [])
@@ -242,7 +246,10 @@ function LibrariesLayout() {
242246
dark:bg-gray-900"
243247
>
244248
<div className="p-2 pb-0">
245-
<ClientOnlySearchButton {...searchButtonParams} />
249+
<ClientOnlySearchButton
250+
{...searchButtonParams}
251+
colorScheme={oramaThemeMode}
252+
/>
246253
</div>
247254
<div className="space-y-px text-sm p-2 border-b border-gray-500/10 dark:border-gray-500/20">
248255
{items}
@@ -259,7 +266,10 @@ function LibrariesLayout() {
259266
{logo}
260267
</div>
261268
<div className="p-2">
262-
<ClientOnlySearchButton {...searchButtonParams}>
269+
<ClientOnlySearchButton
270+
{...searchButtonParams}
271+
colorScheme={oramaThemeMode}
272+
>
263273
Search
264274
</ClientOnlySearchButton>
265275
</div>
@@ -284,7 +294,7 @@ function LibrariesLayout() {
284294
</div>
285295
{mounted ? (
286296
<div className="fixed z-50">
287-
<OramaSearchBox {...searchBoxParams} />
297+
<OramaSearchBox {...searchBoxParams} colorScheme={oramaThemeMode} />
288298
</div>
289299
) : null}
290300
</div>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@number-flow/react": "^0.4.1",
2525
"@octokit/graphql": "^7.0.2",
2626
"@octokit/rest": "^20.0.2",
27-
"@orama/react-components": "^0.0.25",
27+
"@orama/react-components": "^0.1.23",
2828
"@remix-run/node": "^2.8.1",
2929
"@sentry/react": "^8.35.0",
3030
"@sentry/vite-plugin": "^2.22.6",

0 commit comments

Comments
 (0)