Files
supabase/apps/studio/components/interfaces/Support/DocsSuggestions.tsx
Danny White 3960e6ac41 chore(deps): bump lucide-react to v1 (#51770)
## Problem

Lucide React v1 improves screen reader behaviour (icons are hidden from
assistive tech by default). It also removes brand icons such as GitHub.
We were still on Lucide 0.x across the monorepo.

## Solution

- Move every workspace onto one shared Lucide React v1 version via the
pnpm catalog.
- But Lucide React v1 [deprecated brand
icons](https://github.com/lucide-icons/lucide/blob/main/BRAND_LOGOS_STATEMENT.md)
- Meaning we need to handle any _old_ brand icons we used from Lucide
0.x.
- Luckily, that was just `GitHubIcon`. So...
- Add a `GithubIcon` in `packages/ui` that matches Lucide’s previous
GitHub icon, and use it wherever we imported GitHub from Lucide.
  - No other Lucide brand icons were in use.
- Studio “Continue with GitHub” sign-in still uses the existing SVG
asset (`github-icon.svg`), not this component.
- Keep the `Icon` suffix import style [recently
introduced](https://github.com/supabase/supabase/pull/51659)
- Monorepo apps now use `catalog` Lucide React v1.

## Review instructions

1. Open [Studio
preview](https://studio-staging-git-dnywh-bump-lucide-react-v1-supabase.vercel.app/dashboard/org)
on a project that is connected to GitHub:
   - Project home → Activity stats “GitHub” row
   - Org project list → GitHub badge on a connected project card/row
- Branches → GitHub link on a branch row, or “Sync with a GitHub branch”
   - Project Settings → Integrations → GitHub integration panel
2. Open
[/kb/guides/sample-guide](https://supabase.com/kb/guides/sample-guide) →
confirm “Go to the GitHub discussion” shows the icon.
3. Open
[/docs/reference/javascript](https://supabase.com/docs/reference/javascript)
→ confirm the header GitHub control still shows the icon. Or
[/docs/guides/troubleshooting/rls-simplified-BJTcS8](https://supabase.com/docs/guides/troubleshooting/rls-simplified-BJTcS8)
→ “View discussion on GitHub”.
2026-10-15 23:00:55 +00:00

94 lines
2.7 KiB
TypeScript

import { useDocsSearch, type DocsSearchResult } from 'common'
import { BookIcon, Loader2Icon } from 'lucide-react'
import { cn, GithubIcon } from 'ui'
import { useChangedSync } from '@/hooks/misc/useChanged'
import { DOCS_URL } from '@/lib/constants'
function useDocsSuggestions(subject: string) {
const { handleDocsSearchDebounced, resetSearch, searchState } = useDocsSearch()
const trimmedSubject = subject.trim()
const subjectChanged = useChangedSync(trimmedSubject)
if (subjectChanged && trimmedSubject) {
handleDocsSearchDebounced(trimmedSubject)
} else if (subjectChanged && !trimmedSubject) {
resetSearch()
}
return searchState
}
interface DocsSuggestionsProps {
searchString: string
}
export function DocsSuggestions({ searchString }: DocsSuggestionsProps) {
const searchState = useDocsSuggestions(searchString)
const results =
'results' in searchState
? searchState.results
: 'staleResults' in searchState
? searchState.staleResults
: []
const resultsStale = searchState.status === 'loading'
return (
<>
{searchState.status === 'loading' && <DocsSuggestions_Loading />}
{results.length > 0 && <DocsSuggestions_Results results={results} isStale={resultsStale} />}
</>
)
}
function DocsSuggestions_Loading() {
return (
<div className="flex items-center gap-2 text-sm text-foreground-light">
<Loader2Icon className="animate-spin" size={14} />
<span>Searching for relevant resources...</span>
</div>
)
}
interface DocsSuggestions_ResultsProps {
results: DocsSearchResult[]
isStale: boolean
}
function DocsSuggestions_Results({ results, isStale }: DocsSuggestions_ResultsProps) {
return (
<div>
<p className="text-sm text-foreground-light">
Below are some articles that might help with your issue
</p>
<ul
className={cn(
'flex flex-col gap-y-0.5 py-1 transition-opacity duration-200',
isStale ? 'opacity-50' : 'opacity-100'
)}
>
{results.slice(0, 5).map((page) => {
return (
<li key={page.id} className="flex items-center gap-x-1">
{page.type === 'github-discussions' ? (
<GithubIcon size={16} className="text-foreground-muted" />
) : (
<BookIcon size={16} className="text-foreground-muted" />
)}
<a
href={page.type === 'github-discussions' ? page.path : `${DOCS_URL}${page.path}`}
target="_blank"
rel="noreferrer"
className="text-sm text-foreground-light hover:text-foreground transition"
>
{page.title}
</a>
</li>
)
})}
</ul>
</div>
)
}