Skip to content

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

Add version picker

Terry Suttona01bc564b323
diff --git a/apps/docs/components/Navigation/Navigation.types.ts b/apps/docs/components/Navigation/Navigation.types.ts
index 3422099a2ae..76afaa7b1c6 100644
--- a/apps/docs/components/Navigation/Navigation.types.ts
+++ b/apps/docs/components/Navigation/Navigation.types.ts
@@ -19,5 +19,6 @@ export interface References {
library?: string
versions: string[]
icon: string
+ currentVersion?: string
}
}
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
index a7371f83601..e06c497a23a 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenuRefList.tsx
@@ -11,6 +11,7 @@ import useWindowLocation from '~/hooks/useWindowLocation'
import { useNavigationMenuContext } from './NavigationMenu.Context'
import { find } from 'lodash'
import { useMenuActiveRefId } from '~/hooks/useMenuState'
+import RevVersionDropdown from '~/components/RefVersionDropdown'
const allFunctions = Object.values(clientLibsCommonSections.sections.functions)
@@ -170,13 +171,14 @@ const NavigationMenuRefList = ({ currentLevel, setLevel, id, lib }) => {
src={`${router.basePath}` + menu.icon ?? `/img/icons/menu/${id}.svg`}
className="rounded"
/>
- <h2
+ <span
className={['font-mono text-sm text-brand-1200 ', !menu.title && 'capitalize'].join(
' '
)}
>
{menu.title}
- </h2>
+ </span>
+ <RevVersionDropdown />
</div>
{/* )} */}
diff --git a/apps/docs/components/RefVersionDropdown.tsx b/apps/docs/components/RefVersionDropdown.tsx
new file mode 100644
index 00000000000..513d0128082
--- /dev/null
+++ b/apps/docs/components/RefVersionDropdown.tsx
@@ -0,0 +1,78 @@
+import { Badge, Dropdown } from 'ui'
+import { useRouter } from 'next/router'
+import { REFERENCES } from './Navigation/NavigationMenu/NavigationMenu.constants'
+
+const RevVersionDropdown = () => {
+ const { asPath, push } = useRouter()
+ const pathSegments = asPath.split('/')
+
+ const library = pathSegments.length >= 3 ? pathSegments[2] : undefined
+ const libraryMeta = REFERENCES?.[library] ?? undefined
+ const versions = libraryMeta?.versions ?? []
+
+ const currentVersion = versions.includes(pathSegments[pathSegments.indexOf(library) + 1])
+ ? pathSegments[pathSegments.indexOf(library) + 1]
+ : versions[0]
+
+ const onSelectVersion = (version: string) => {
+ if (!library) return
+ if (version === versions[0]) {
+ push(`/reference/${library}/start`)
+ } else {
+ push(`/reference/${library}/${version}/start`)
+ }
+ }
+
+ return (
+ <Dropdown
+ size="small"
+ align="start"
+ side="bottom"
+ overlay={
+ <>
+ <Dropdown.Label>Stable releases</Dropdown.Label>
+ {versions.map((version, index) => (
+ <Dropdown.Item key={version} onClick={() => onSelectVersion(version)}>
+ <span className={`${currentVersion === version ? 'font-bold' : ''}`}>
+ Version {version}
+ </span>
+ <Dropdown.RightSlot>
+ {index === 0 && <Badge size="small">Latest</Badge>}
+ </Dropdown.RightSlot>
+ </Dropdown.Item>
+ ))}
+ </>
+ }
+ >
+ <div className="w-24">
+ <div
+ className="
+ flex
+ group
+ items-center
+ justify-between
+ bg-scaleA-200
+ border
+ transition
+ hover:border-scale-600
+ hover:bg-scaleA-300
+ border-scale-500 pl-1.5 pr-1.5 w-full h-[32px] rounded
+ font-mono
+ rounded-tl-none
+ rounded-bl-none
+ "
+ >
+ <div>
+ <span className="flex items-center gap-2 text-scale-900 text-xs group-hover:text-scale-1200 transition">
+ <span>version</span>
+ <span className="text-scale-1200 text-sm group-hover:text-scale-1200 transition">
+ {currentVersion}
+ </span>
+ </span>
+ </div>
+ </div>
+ </div>
+ </Dropdown>
+ )
+}
+export default RevVersionDropdown