Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade searchbox / add suggestions / fix theme #312

Merged
merged 1 commit into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/components/DocsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { DocsCalloutBytes } from '~/components/DocsCalloutBytes'
import { ClientOnlySearchButton } from './ClientOnlySearchButton'
import { twMerge } from 'tailwind-merge'
import { partners } from '~/utils/partners'
import { useThemeStore } from './ThemeToggle'

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

const { mode: themeMode } = useThemeStore()

const oramaThemeMode = themeMode === 'auto' ? 'system' : themeMode

tannerlinsley marked this conversation as resolved.
Show resolved Hide resolved
const matches = useMatches()
const lastMatch = last(matches)

Expand Down Expand Up @@ -493,7 +498,10 @@ export function DocsLayout({
onSelect={versionConfig.onSelect}
/>
</div>
<ClientOnlySearchButton {...searchButtonParams}>
<ClientOnlySearchButton
{...searchButtonParams}
colorScheme={oramaThemeMode}
>
Search
</ClientOnlySearchButton>
{menuItems}
Expand Down Expand Up @@ -554,6 +562,7 @@ export function DocsLayout({
} as any,
}}
facetProperty={undefined}
colorScheme={oramaThemeMode}
/>
)}
</div>
Expand Down
8 changes: 8 additions & 0 deletions app/components/Orama.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ export const searchBoxParams = {
endpoint: 'https://cloud.orama.run/v1/indexes/tanstack-dev-ur0ppd',
},
colorScheme: 'system' as 'light' | 'dark' | 'system',
suggestions: [
'What is TanStack?',
'Why should I use TanStack query?',
'Show me an example integration of useQuery hook',
'How is TanStack router different than other routers?',
'What is TanStack Table for?',
'Code example using TanStack Store',
],
facetProperty: 'category',
resultMap: {
description: 'content',
Expand Down
18 changes: 14 additions & 4 deletions app/routes/_libraries/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getLibrary, libraries } from '~/libraries'
import { Scarf } from '~/components/Scarf'
import { searchBoxParams, searchButtonParams } from '~/components/Orama'
import { ClientOnlySearchButton } from '~/components/ClientOnlySearchButton'
import { ThemeToggle } from '~/components/ThemeToggle'
import { ThemeToggle, useThemeStore } from '~/components/ThemeToggle'
import { TbBrandBluesky, TbBrandTwitter } from 'react-icons/tb'

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

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

const { mode: themeMode } = useThemeStore()

const oramaThemeMode = themeMode === 'auto' ? 'system' : themeMode

React.useEffect(() => {
setMounted(true)
}, [])
Expand Down Expand Up @@ -242,7 +246,10 @@ function LibrariesLayout() {
dark:bg-gray-900"
>
<div className="p-2 pb-0">
<ClientOnlySearchButton {...searchButtonParams} />
<ClientOnlySearchButton
{...searchButtonParams}
colorScheme={oramaThemeMode}
/>
</div>
<div className="space-y-px text-sm p-2 border-b border-gray-500/10 dark:border-gray-500/20">
{items}
Expand All @@ -259,7 +266,10 @@ function LibrariesLayout() {
{logo}
</div>
<div className="p-2">
<ClientOnlySearchButton {...searchButtonParams}>
<ClientOnlySearchButton
{...searchButtonParams}
colorScheme={oramaThemeMode}
>
Search
</ClientOnlySearchButton>
</div>
Expand All @@ -284,7 +294,7 @@ function LibrariesLayout() {
</div>
{mounted ? (
<div className="fixed z-50">
<OramaSearchBox {...searchBoxParams} />
<OramaSearchBox {...searchBoxParams} colorScheme={oramaThemeMode} />
</div>
) : null}
</div>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"@number-flow/react": "^0.4.1",
"@octokit/graphql": "^7.0.2",
"@octokit/rest": "^20.0.2",
"@orama/react-components": "^0.0.25",
"@orama/react-components": "^0.1.23",
"@remix-run/node": "^2.8.1",
"@sentry/react": "^8.35.0",
"@sentry/vite-plugin": "^2.22.6",
Expand Down
Loading
Loading