Skip to content

Commit ed994d6

Browse files
committed
chore: upgrade searchbox / add suggestions / fix theme
1 parent 6bfd2c8 commit ed994d6

File tree

5 files changed

+90
-119
lines changed

5 files changed

+90
-119
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
@@ -24,7 +24,7 @@ import { getLibrary, libraries } from '~/libraries'
2424
import { Scarf } from '~/components/Scarf'
2525
import { searchBoxParams, searchButtonParams } from '~/components/Orama'
2626
import { ClientOnlySearchButton } from '~/components/ClientOnlySearchButton'
27-
import { ThemeToggle } from '~/components/ThemeToggle'
27+
import { ThemeToggle, useThemeStore } from '~/components/ThemeToggle'
2828
import { TbBrandBluesky, TbBrandTwitter } from 'react-icons/tb'
2929

3030
export const Route = createFileRoute('/_libraries')({
@@ -47,6 +47,10 @@ function LibrariesLayout() {
4747

4848
const [mounted, setMounted] = React.useState(false)
4949

50+
const { mode: themeMode } = useThemeStore()
51+
52+
const oramaThemeMode = themeMode === 'auto' ? 'system' : themeMode
53+
5054
React.useEffect(() => {
5155
setMounted(true)
5256
}, [])
@@ -248,7 +252,10 @@ function LibrariesLayout() {
248252
dark:bg-gray-900"
249253
>
250254
<div className="p-2 pb-0">
251-
<ClientOnlySearchButton {...searchButtonParams} />
255+
<ClientOnlySearchButton
256+
{...searchButtonParams}
257+
colorScheme={oramaThemeMode}
258+
/>
252259
</div>
253260
<div className="space-y-px text-sm p-2 border-b border-gray-500/10 dark:border-gray-500/20">
254261
{items}
@@ -265,7 +272,10 @@ function LibrariesLayout() {
265272
{logo}
266273
</div>
267274
<div className="p-2">
268-
<ClientOnlySearchButton {...searchButtonParams}>
275+
<ClientOnlySearchButton
276+
{...searchButtonParams}
277+
colorScheme={oramaThemeMode}
278+
>
269279
Search
270280
</ClientOnlySearchButton>
271281
</div>
@@ -290,7 +300,7 @@ function LibrariesLayout() {
290300
</div>
291301
{mounted ? (
292302
<div className="fixed z-50">
293-
<OramaSearchBox {...searchBoxParams} />
303+
<OramaSearchBox {...searchBoxParams} colorScheme={oramaThemeMode} />
294304
</div>
295305
) : null}
296306
</div>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@headlessui/react": "1.7.18",
2121
"@octokit/graphql": "^7.0.2",
2222
"@octokit/rest": "^20.0.2",
23-
"@orama/react-components": "^0.0.25",
23+
"@orama/react-components": "^0.1.23",
2424
"@remix-run/node": "^2.8.1",
2525
"@sentry/react": "^8.35.0",
2626
"@sentry/vite-plugin": "^2.22.6",

0 commit comments

Comments
 (0)