The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
feat(docs-search): componentize search result
Greg Richardson68b795879193
diff --git a/apps/docs/components/Clippy/ClippyModal.tsx b/apps/docs/components/Clippy/ClippyModal.tsxindex fee468e0991..22e5f90b915 100644--- a/apps/docs/components/Clippy/ClippyModal.tsx+++ b/apps/docs/components/Clippy/ClippyModal.tsx@@ -22,6 +22,7 @@ import {} from 'ui'import components from '~/components'import { useClippy } from './ClippyProvider'+import SearchResult, { SearchResultType } from './SearchResult'type Props = {onClose?: () => void@@ -226,28 +227,7 @@ const ClippyModal: FC<Props> = ({ onClose }) => {return (<div className="flex flex-col gap-3"><Link href={`${page.path}`}>- <a- className="flex flex-row items-center bg-scale-500 hover:bg-scale-700 transition p-4 rounded-md border border-scale-600 text-sm"- onClick={close}- >- <div className="w-6 h-6 flex items-center justify-center mr-4 rounded-md bg-scale-700">- <svg width="14" height="10" fill="none">- <path- fill-rule="evenodd"- clip-rule="evenodd"- d="M3.5 0c1.093 0 2.117.27 3 .743V10a6.344 6.344 0 0 0-3-.743c-1.093 0-2.617.27-3.5.743V.743C.883.27 2.407 0 3.5 0Z"- fill="hsla(153, 60%, 85%, 1)"- />- <path- fill-rule="evenodd"- clip-rule="evenodd"- d="M10.5 0c1.093 0 2.617.27 3.5.743V10c-.883-.473-2.407-.743-3.5-.743s-2.117.27-3 .743V.743a6.344 6.344 0 0 1 3-.743Z"- fill="hsla(153, 60%, 45%, 1)"- />- </svg>- </div>- <div className="flex flex-col gap-2 items-start">{page.meta.title}</div>- </a>+ <SearchResult type={SearchResultType.Document} title={page.meta.title} /></Link>{pageSections.length > 0 && (<div className="flex flex-row">@@ -255,27 +235,11 @@ const ClippyModal: FC<Props> = ({ onClose }) => {<div className="flex flex-col gap-3 items-stretch grow">{pageSections.map((section) => (<Link href={`${page.path}#${section.slug}`}>- <a- className="flex flex-row items-center bg-scale-500 hover:bg-scale-700 transition p-4 rounded-md border border-scale-600 text-sm"- onClick={close}- >- <div className="w-6 h-6 flex items-center justify-center mr-4 text-brand-1100 rounded-md bg-scale-700">- <svg width="12" height="12" fill="none">- <path- d="M3.75 1v10M8.25 1v10M1 3.75h10M1 8.25h10"- stroke="currentColor"- stroke-width="1.5"- stroke-linecap="round"- />- </svg>- </div>- <div className="flex flex-col gap-2 items-start">- <div className="rounded-xl bg-scale-700 pl-3 pr-3 pt-0.5 pb-0.5 text-xs text-scale-1100">- {page.meta.title}- </div>- <div>{section.heading}</div>- </div>- </a>+ <SearchResult+ type={SearchResultType.Section}+ title={section.heading}+ chip={page.meta.title}+ /></Link>))}</div>diff --git a/apps/docs/components/Clippy/SearchResult.tsx b/apps/docs/components/Clippy/SearchResult.tsxnew file mode 100644index 00000000000..09edfeaeee2--- /dev/null+++ b/apps/docs/components/Clippy/SearchResult.tsx@@ -0,0 +1,47 @@+import { FC } from 'react'+import { IconBookOpen, IconHash } from '~/../../packages/ui'++export enum SearchResultType {+ Document = 'document',+ Section = 'section',+}++type Props = {+ type: SearchResultType+ title: string+ chip?: string+}++const SearchResult: FC<Props> = ({ type, title, chip }) => {+ return (+ <a+ className="flex flex-row items-center bg-scale-500 hover:bg-scale-700 transition p-4 rounded-md border border-scale-600 text-sm cursor-pointer"+ onClick={close}+ >+ <div className="w-6 h-6 p-1 flex items-center justify-center mr-4 text-brand-1100 rounded-md bg-scale-700">+ {getIconByType(type)}+ </div>+ <div className="flex flex-col gap-2 items-start">+ {chip && (+ <div className="rounded-xl bg-scale-700 pl-3 pr-3 pt-0.5 pb-0.5 text-xs text-scale-1100">+ {chip}+ </div>+ )}+ <div>{title}</div>+ </div>+ </a>+ )+}++function getIconByType(type: SearchResultType) {+ switch (type) {+ case SearchResultType.Document:+ return <IconBookOpen />+ case SearchResultType.Section:+ return <IconHash />+ default:+ throw new Error(`Unknown search result type '${type}'`)+ }+}++export default SearchResult