Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

refactor(cmdk): typing and docs search

Greg Richardson74065416c469
diff --git a/packages/ui/src/components/Command/AiCommand.tsx b/packages/ui/src/components/Command/AiCommand.tsx
index dd39deb4b34..ae1bdcf8f06 100644
--- a/packages/ui/src/components/Command/AiCommand.tsx
+++ b/packages/ui/src/components/Command/AiCommand.tsx
@@ -518,6 +518,7 @@ const AiCommand = ({ query, setQuery, page }: AiCommandProps) => {
{showActions && promptIndex === i + 1 && (
<CommandGroup heading="" forceMount className="!pt-0 !pl-[60px]">
<CommandItem
+ type="command"
onSelect={() => {
if (!query) {
alert("You've selected me")
@@ -530,6 +531,7 @@ const AiCommand = ({ query, setQuery, page }: AiCommandProps) => {
</CommandItem>
{promptData.length > 1 && (
<CommandItem
+ type="command"
forceMount
onSelect={() => {
if (!query) {
@@ -545,7 +547,7 @@ const AiCommand = ({ query, setQuery, page }: AiCommandProps) => {
<span>Back to previous version</span>
</CommandItem>
)}
- <CommandItem forceMount>
+ <CommandItem type="command" forceMount>
<IconCopy className="mr-2" />
<span>Run in SQL editor</span>
</CommandItem>
@@ -562,6 +564,7 @@ const AiCommand = ({ query, setQuery, page }: AiCommandProps) => {
const key = question.replace(/\s+/g, '_')
return (
<CommandItem
+ type="command"
onSelect={() => {
if (!query) {
handleClippyConfirm(question)
diff --git a/packages/ui/src/components/Command/Command.utils.tsx b/packages/ui/src/components/Command/Command.utils.tsx
index 06c5b5fd85c..1e346f884c7 100644
--- a/packages/ui/src/components/Command/Command.utils.tsx
+++ b/packages/ui/src/components/Command/Command.utils.tsx
@@ -9,24 +9,27 @@ import { ModalProps } from '../Modal/Modal'
import { useCommandMenu } from './CommandMenuProvider'
import { LoadingLine } from './LoadingLine'
-const Command = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive>
->(({ className, ...props }, ref) => (
- <CommandPrimitive
- ref={ref}
- className={cn('flex h-full w-full flex-col overflow-hidden', className)}
- {...props}
- />
-))
+type CommandPrimitiveElement = React.ElementRef<typeof CommandPrimitive>
+type CommandPrimitiveProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive>
+
+export const Command = React.forwardRef<CommandPrimitiveElement, CommandPrimitiveProps>(
+ ({ className, ...props }, ref) => (
+ <CommandPrimitive
+ ref={ref}
+ className={cn('flex h-full w-full flex-col overflow-hidden', className)}
+ {...props}
+ />
+ )
+)
+
Command.displayName = CommandPrimitive.displayName
-interface CommandDialogProps extends ModalProps {
+export interface CommandDialogProps extends ModalProps {
onKeyDown?: KeyboardEventHandler<HTMLDivElement>
page?: number | string
}
-const CommandDialog = ({ children, onKeyDown, page, ...props }: CommandDialogProps) => {
+export const CommandDialog = ({ children, onKeyDown, page, ...props }: CommandDialogProps) => {
const [animateBounce, setAnimateBounce] = React.useState(false)
React.useEffect(() => {
@@ -45,10 +48,7 @@ const CommandDialog = ({ children, onKeyDown, page, ...props }: CommandDialogPro
animateBounce ? 'scale-[101.5%]' : 'scale-100'
)}
>
- {/* <DialogContent className="p-0 shadow-2xl [&_[dialog-overlay]]:bg-red-100"> */}
<Command
- // onKeyDown={onKeyDown}
- // shouldFilter={false}
className={[
'[&_[cmdk-group]]:px-2 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-scale-800 [&_[cmdk-input]]:h-12',
@@ -63,29 +63,25 @@ const CommandDialog = ({ children, onKeyDown, page, ...props }: CommandDialogPro
>
{children}
</Command>
- {/* </DialogContent> */}
</Modal>
)
}
-type CommandPrimitiveInputProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
+CommandDialog.displayName = 'CommandDialog'
-type CommandInputProps = CommandPrimitiveInputProps & {
- _key?: string | number
-}
+type CommandPrimitiveInputElement = React.ElementRef<typeof CommandPrimitive.Input>
+type CommandPrimitiveInputProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>
-const CommandInput = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Input>,
- CommandInputProps
->(({ className, value, onValueChange, _key, ...props }, ref) => {
+export const CommandInput = React.forwardRef<
+ CommandPrimitiveInputElement,
+ CommandPrimitiveInputProps
+>(({ className, value, onValueChange, ...props }, ref) => {
const { isLoading } = useCommandMenu()
return (
<div className="flex flex-col items-center" cmdk-input-wrapper="">
- {/* <IconSearch strokeWidth={2} className="text-scale-1200 mr-2 h-4 w-4 shrink-0 opacity-50" /> */}
<CommandPrimitive.Input
value={value}
- key={_key}
autoFocus
onValueChange={onValueChange}
ref={ref}
@@ -104,22 +100,27 @@ const CommandInput = React.forwardRef<
CommandInput.displayName = CommandPrimitive.Input.displayName
-const CommandList = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.List>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
->(({ className, ...props }, ref) => (
- <CommandPrimitive.List
- ref={ref}
- className={cn('overflow-y-auto overflow-x-hidden', className)}
- {...props}
- />
-))
+type CommandPrimitiveListElement = React.ElementRef<typeof CommandPrimitive.List>
+type CommandPrimitiveListProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>
+
+export const CommandList = React.forwardRef<CommandPrimitiveListElement, CommandPrimitiveListProps>(
+ ({ className, ...props }, ref) => (
+ <CommandPrimitive.List
+ ref={ref}
+ className={cn('overflow-y-auto overflow-x-hidden', className)}
+ {...props}
+ />
+ )
+)
CommandList.displayName = CommandPrimitive.List.displayName
-const CommandEmpty = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Empty>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
+type CommandPrimitiveEmptyElement = React.ElementRef<typeof CommandPrimitive.Empty>
+type CommandPrimitiveEmptyProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>
+
+export const CommandEmpty = React.forwardRef<
+ CommandPrimitiveEmptyElement,
+ CommandPrimitiveEmptyProps
>((props, ref) => (
<CommandPrimitive.Empty
ref={ref}
@@ -130,20 +131,15 @@ const CommandEmpty = React.forwardRef<
CommandEmpty.displayName = CommandPrimitive.Empty.displayName
+type CommandPrimitiveGroupElement = React.ElementRef<typeof CommandPrimitive.Group>
type CommandPrimitiveGroupProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>
-type CommandGroupProps = CommandPrimitiveGroupProps & {
- _key?: string | number
-}
-
-const CommandGroup = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Group>,
- CommandGroupProps
->(({ className, _key, ...props }, ref) => (
+export const CommandGroup = React.forwardRef<
+ CommandPrimitiveGroupElement,
+ CommandPrimitiveGroupProps
+>(({ className, ...props }, ref) => (
<CommandPrimitive.Group
- key={_key}
ref={ref}
- // forceMount={props.forceMount}
className={cn(
'overflow-hidden py-3 px-2 text-scale-700 dark:text-scale-800 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:pb-1.5 [&_[cmdk-group-heading]]:text-sm [&_[cmdk-group-heading]]:font-normal [&_[cmdk-group-heading]]:text-scale-900 [&_[cmdk-group-heading]]:dark:text-sca-300',
className
@@ -154,9 +150,14 @@ const CommandGroup = React.forwardRef<
CommandGroup.displayName = CommandPrimitive.Group.displayName
-const CommandSeparator = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Separator>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>
+type CommandPrimitiveSeparatorElement = React.ElementRef<typeof CommandPrimitive.Separator>
+type CommandPrimitiveSeparatorProps = React.ComponentPropsWithoutRef<
+ typeof CommandPrimitive.Separator
+>
+
+export const CommandSeparator = React.forwardRef<
+ CommandPrimitiveSeparatorElement,
+ CommandPrimitiveSeparatorProps
>(({ className, ...props }, ref) => (
<CommandPrimitive.Separator
ref={ref}
@@ -170,22 +171,23 @@ const CommandSeparator = React.forwardRef<
{...props}
/>
))
+
CommandSeparator.displayName = CommandPrimitive.Separator.displayName
-interface ICommandItem extends React.ElementRef<typeof CommandPrimitive.Item> {
+type CommandPrimitiveItemElement = React.ElementRef<typeof CommandPrimitive.Item>
+type CommandPrimitiveItemProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
+
+export interface CommandItemProps extends CommandPrimitiveItemProps {
type: 'link' | 'command'
}
-const CommandItem = React.forwardRef<
- ICommandItem,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
- // @ts-ignore
->(({ className, type, ...props }, ref) => (
- <CommandPrimitive.Item
- ref={ref}
- className={cn(
- type === 'link'
- ? `
+export const CommandItem = React.forwardRef<CommandPrimitiveItemElement, CommandItemProps>(
+ ({ className, type, ...props }, ref) => (
+ <CommandPrimitive.Item
+ ref={ref}
+ className={cn(
+ type === 'link'
+ ? `
bg-scale-300/90
border border-[#ddd]/90
dark:border-[#282828]/90
@@ -206,7 +208,7 @@ const CommandItem = React.forwardRef<
aria-selected:scale-[100.3%]
group
data-[disabled]:pointer-events-none data-[disabled]:opacity-50`
- : `
+ : `
py-3 px-2
text-scale-1100
relative flex
@@ -222,29 +224,31 @@ const CommandItem = React.forwardRef<
data-[disabled]:pointer-events-none
data-[disabled]:opacity-50
`,
- className
- )}
- {...props}
- />
-))
-
-const CommandItemStale = React.forwardRef<
- React.ElementRef<typeof CommandPrimitive.Item>,
- React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>
->(({ className, ...props }, ref) => (
- <CommandPrimitive.Item
- ref={ref}
- className={cn(
- 'text-scale-1100 relative flex cursor-default select-none items-center rounded-md py-1.5 px-2 text-sm outline-none aria-selected:bg-scale-500 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:aria-selected:bg-scale-500',
- className
- )}
- {...props}
- />
-))
+ className
+ )}
+ {...props}
+ />
+ )
+)
CommandItem.displayName = CommandPrimitive.Item.displayName
-const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => {
+export const CommandItemStale = React.forwardRef<CommandPrimitiveItemElement, CommandItemProps>(
+ ({ className, ...props }, ref) => (
+ <CommandPrimitive.Item
+ ref={ref}
+ className={cn(
+ 'text-scale-1100 relative flex cursor-default select-none items-center rounded-md py-1.5 px-2 text-sm outline-none aria-selected:bg-scale-500 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 dark:aria-selected:bg-scale-500',
+ className
+ )}
+ {...props}
+ />
+ )
+)
+
+CommandItemStale.displayName = 'CommandItemStale'
+
+export const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => {
return (
<div
className={cn(
@@ -258,22 +262,11 @@ const CommandShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLDivEl
/>
)
}
+
CommandShortcut.displayName = 'CommandShortcut'
-const CommandLabel = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
+export const CommandLabel = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => {
return <span {...props} className={cn('grow', className)} />
}
-export {
- Command,
- CommandDialog,
- CommandInput,
- CommandList,
- CommandEmpty,
- CommandGroup,
- CommandItem,
- CommandItemStale,
- CommandShortcut,
- CommandSeparator,
- CommandLabel,
-}
+CommandShortcut.displayName = 'CommandLabel'
diff --git a/packages/ui/src/components/Command/CommandMenu.tsx b/packages/ui/src/components/Command/CommandMenu.tsx
index e0f8c87791c..4b9c3613930 100644
--- a/packages/ui/src/components/Command/CommandMenu.tsx
+++ b/packages/ui/src/components/Command/CommandMenu.tsx
@@ -99,6 +99,7 @@ const CommandMenu = () => {
.flatMap((item) => item.subItems)
.map((item) => (
<SearchOnlyItem
+ key={item.url}
icon={item.icon}
isSubItem={isSubItem}
onSelect={() => {
@@ -158,6 +159,7 @@ const CommandMenu = () => {
<>
<CommandGroup heading="Documentation" forceMount>
<CommandItem
+ type="command"
onSelect={() => {
handleSetPages([...pages, COMMAND_ROUTES.AI], false)
}}
@@ -177,6 +179,7 @@ const CommandMenu = () => {
</span>
</CommandItem>
<CommandItem
+ type="command"
onSelect={() => handleSetPages([...pages, COMMAND_ROUTES.DOCS_SEARCH], true)}
forceMount
>
@@ -198,7 +201,7 @@ const CommandMenu = () => {
<CommandGroup heading="Navigation">
{navItems.docsTools.map((item) => (
- <CommandItem onSelect={() => router.push(item.url)}>
+ <CommandItem key={item.url} type="link" onSelect={() => router.push(item.url)}>
<IconArrowRight className="text-scale-900" />
<CommandLabel>
Go to <span className="font-bold"> {item.label}</span>
@@ -209,7 +212,7 @@ const CommandMenu = () => {
<CommandGroup heading="Support">
{navItems.docsSupport.map((item) => (
- <CommandItem onSelect={() => router.push(item.url)}>
+ <CommandItem key={item.url} type="link" onSelect={() => router.push(item.url)}>
<IconLifeBuoy className="text-scale-900" />
<CommandLabel>
Go to <span className="font-bold"> {item.label}</span>
@@ -220,7 +223,7 @@ const CommandMenu = () => {
<CommandGroup heading="General">
{navItems.docsGeneral.map((item) => (
- <CommandItem onSelect={() => router.push(item.url)}>
+ <CommandItem key={item.url} type="link" onSelect={() => router.push(item.url)}>
{item?.icon && iconPicker[item.icon]}
<CommandLabel>{item.label}</CommandLabel>
</CommandItem>
@@ -228,7 +231,10 @@ const CommandMenu = () => {
</CommandGroup>
<CommandGroup heading="Settings">
- <CommandItem onSelect={() => handleSetPages([...pages, 'Theme'], false)}>
+ <CommandItem
+ type="link"
+ onSelect={() => handleSetPages([...pages, 'Theme'], false)}
+ >
<IconMonitor className="mr-2" />
Change theme
</CommandItem>
@@ -241,7 +247,7 @@ const CommandMenu = () => {
<AiCommand query={search} setQuery={setSearch} page={page} />
)}
{page === COMMAND_ROUTES.DOCS_SEARCH && (
- <DocsSearch query={search} setQuery={setSearch} page={page} router={router} />
+ <DocsSearch query={search} setQuery={setSearch} />
)}
{page === COMMAND_ROUTES.THEME && <ThemeOptions />}
</CommandList>
diff --git a/packages/ui/src/components/Command/DocsSearch.tsx b/packages/ui/src/components/Command/DocsSearch.tsx
index 89140a903f4..da87b4cf609 100644
--- a/packages/ui/src/components/Command/DocsSearch.tsx
+++ b/packages/ui/src/components/Command/DocsSearch.tsx
@@ -27,130 +27,31 @@ const questions = [
'How do I set up authentication?',
]
-function getEdgeFunctionUrl() {
- const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL?.replace(/\/$/, '')
-
- // if (IS_PLATFORM) {
- if (true) {
- // @ts-ignore
- const [schemeAndProjectId, domain, tld] = supabaseUrl.split('.')
- return `${schemeAndProjectId}.functions.${domain}.${tld}`
- } else {
- return `${supabaseUrl}/functions/v1`
- }
-}
-
-const edgeFunctionUrl = getEdgeFunctionUrl()
-
-function promptDataReducer(
- state: any[],
- action: {
- index?: number
- answer?: string | undefined
- status?: string
- query?: string | undefined
- type?: 'remove-last-item' | string
- }
-) {
- // console.log('running reducer')
- // console.log('what is currently in', ...state)
- // console.log('what is the action payload', action)
- // set a standard state to use later
- let current = [...state]
-
- console.log(action)
-
- if (action.type) {
- switch (action.type) {
- case 'remove-last-item':
- console.log('removing last item')
- current.pop()
- return [...current]
- break
-
- default:
- break
- }
- }
-
- // check that an index is present
- if (action.index === undefined) return [...state]
-
- if (!current[action.index]) {
- current[action.index] = { query: '', answer: '', status: '' }
- }
-
- // if (action.answer !== undefined) {
- current[action.index].answer = action.answer
- // }
- if (action.query) {
- current[action.index].query = action.query
- }
- if (action.status) {
- current[action.index].status = action.status
- }
-
- // console.log('what i will update with', current)
- console.log(current)
- return [...current]
-
- throw Error('Unknown action.')
-}
-
export interface DocsSearchProps {
query?: string
setQuery?: (query: string) => void
- page?: string
- router: any
}
-const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
- const { isDarkMode } = useTheme()
-
- // const { close, query, setQuery } = useSearch()
- const [answer, setAnswer] = useState<string | undefined>('')
- const [results, setResults] = useState<any[]>([])
- const [isResponding, setIsResponding] = useState(false)
- const [hasClippyError, setHasClippyError] = useState(false)
+const DocsSearch = ({ query, setQuery }: DocsSearchProps) => {
+ const [results, setResults] = useState<any[]>()
const [hasSearchError, setHasSearchError] = useState(false)
- const [selectedTab, setSelectedTab] = useState('clippy-panel')
- const eventSourceRef = useRef<SSE>()
const supabaseClient = useSupabaseClient()
const { isLoading, setIsLoading } = useCommandMenu()
- const [promptIndex, setPromptIndex] = useState(0)
- const [promptData, dispatchPromptData] = useReducer(promptDataReducer, [])
-
- const cantHelp = answer?.trim() === "Sorry, I don't know how to help with that."
- const status = isLoading
- ? 'Clippy is searching...'
- : isResponding
- ? 'Clippy is responding...'
- : cantHelp || hasClippyError
- ? 'Clippy has failed you'
- : undefined
-
- const handleSearchConfirm = useCallback(
+ const handleSearch = useCallback(
async (query: string) => {
- console.log('query', query)
- // console.log('query', query)
-
- // setResults(undefined)
- setAnswer(undefined)
- setIsResponding(false)
- setHasClippyError(false)
setHasSearchError(false)
setIsLoading(true)
const { error, data: pageSections } = await supabaseClient.functions.invoke('search', {
- body: { query: query },
+ body: { query },
})
setIsLoading(false)
if (error) {
setIsLoading(false)
- setIsResponding(false)
+
setHasSearchError(true)
console.error(error)
return
@@ -158,41 +59,28 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
if (!Array.isArray(pageSections)) {
setIsLoading(false)
- setIsResponding(false)
setHasSearchError(true)
console.error('Malformed response')
return
}
- setResults(undefined)
setResults(pageSections)
},
[supabaseClient]
)
- // console.log('current index', promptIndex)
-
function handleResetPrompt() {
- eventSourceRef.current?.close()
- eventSourceRef.current = undefined
setQuery('')
setResults(undefined)
- setAnswer(undefined)
- setIsResponding(false)
- setHasClippyError(false)
setHasSearchError(false)
}
- // console.log(promptData)
-
- const debounceFn = useMemo(() => debounce(handleSearchConfirm, 1000), [])
+ const debouncedSearch = useMemo(() => debounce(handleSearch, 1000), [handleSearch])
+ // TODO: can we do this w/o useEffect if query comes from context?
useEffect(() => {
- // if (query) {
- // handleSearchConfirm(query)
- // }
if (query) {
- debounceFn(query)
+ debouncedSearch(query)
}
}, [query])
@@ -233,10 +121,6 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
function TextHighlighter(props) {
const [searchText, setSearchText] = useState('')
- // const handleSearch = (event) => {
- // setSearchText(event.target.value.trim().toLowerCase())
- // }
-
const highlightMatches = (text) => {
if (!query) {
return text
@@ -256,8 +140,7 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
return (
<>
- {results &&
- results.length > 0 &&
+ {results?.length > 0 &&
results.map((page, i) => {
const pageSections = page.sections.filter((section) => !!section.heading)
return (
@@ -271,9 +154,10 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
forceMount
key={`${page.meta.title}-item-index-${i}`}
value={`${page.meta.title}-item-index-${i}`}
- type={'link'}
+ type="link"
onSelect={() => {
- router.push(`${page.path}`)
+ // TODO: replace with Next.js router/Link when cross-project link logic solved
+ window.location.assign(`/docs/${page.path}`)
}}
>
<div className="grow flex gap-3 items-center">
@@ -299,8 +183,11 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
forceMount
className="ml-3 mb-3"
onSelect={() => {
- router.push(
- `${page.path}${page.type === 'reference' ? '/' : '#'}${section.slug}`
+ // TODO: replace with Next.js router/Link when cross-project link logic solved
+ window.location.assign(
+ `/docs/${page.path}${page.type === 'reference' ? '/' : '#'}${
+ section.slug
+ }`
)
}}
key={`${page.meta.title}__${section.heading}-item-index-${i}`}
@@ -331,7 +218,7 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
</CommandGroup>
)
})}
- {results?.length <= 0 && (
+ {results?.length === 0 && (
<CommandGroup heading="" forceMount>
{questions.map((question) => {
const key = question.replace(/\s+/g, '_')
@@ -340,10 +227,11 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
disabled={isLoading}
onSelect={() => {
if (!query) {
- handleSearchConfirm(question)
+ handleSearch(question)
setQuery(question)
}
}}
+ type="command"
forceMount
key={key}
>
@@ -354,9 +242,8 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
})}
</CommandGroup>
)}
- {isLoading && (
+ {isLoading && !results && (
<div className="p-6 grid gap-6 my-4">
- {/* <Loading active>{}</Loading> */}
<p className="text-lg text-scale-900 text-center">Searching for results</p>
</div>
)}
@@ -381,68 +268,6 @@ const DocsSearch = ({ query, setQuery, page, router }: DocsSearchProps) => {
</Button>
</div>
)}
-
- {/* <Tabs.Panel id="clippy-panel" label="Ask Clippy"> */}
- {/* {!isLoading && !answer && !hasClippyError && (
- <div className="">
- <div className="mt-2">
- <h2 className="text-sm text-scale-1100">Not sure where to start?</h2>
-
- <ul className="text-sm mt-4 text-scale-1100 grid md:flex gap-4 flex-wrap max-w-3xl">
- {questions.map((question) => {
- const key = question.replace(/\s+/g, '_')
- return (
- <li key={key}>
- <button
- className="hover:bg-slate-400 hover:dark:bg-slate-400 px-4 py-2 bg-slate-300 dark:bg-slate-200 rounded-lg transition-colors"
- onClick={() => {
- setQuery(question)
- handleClippyConfirm(question)
- }}
- >
- {question}
- </button>
- </li>
- )
- })}
- </ul>
- </div>
- </div>
- )} */}
-
- {hasClippyError && (
- <div className="p-6 flex flex-col items-center gap-6 mt-4">
- <IconAlertTriangle className="text-amber-900" strokeWidth={1.5} size={21} />
- <p className="text-lg text-scale-1200 text-center">
- Sorry, looks like Clippy is having a hard time!
- </p>
- <p className="text-sm text-scale-900 text-center">Please try again in a bit.</p>
- {/* <Button size="tiny" type="secondary" onClick={handleResetPrompt}>
- Try again?
- </Button> */}
- </div>
- )}
- <div className="absolute right-0 top-0 mt-3 mr-4 hidden md:block"></div>
-
- <div className="absolute bottom-0 w-full bg-scale-200">
- <div className="text-scale-1100 px-3">
- <div className="flex justify-between items-center text-xs">
- <div className="flex items-centerp gap-1 py-2 text-scale-800">
- <span>Powered by OpenAI.</span>
- </div>
- <div className="flex items-center gap-6 py-1">
- {status ? (
- <span className="bg-scale-400 rounded-lg py-1 px-2 items-center gap-2 hidden md:flex">
- {(isLoading || isResponding) && <IconLoader size={14} className="animate-spin" />}
- {status}
- </span>
- ) : (
- <></>
- )}
- </div>
- </div>
- </div>
- </div>
</>
)
}