Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
apps/docs
apps/www/.env.local.example
examples
packages
supabase

- uses: pnpm/action-setup@v4
Expand Down
42 changes: 30 additions & 12 deletions apps/docs/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,22 @@ import Link from 'next/link'
import { cn, IconBackground, TextLink } from 'ui'
import { IconPanel } from 'ui-patterns/IconPanel'

import { isFeatureEnabled } from 'common'
import MenuIconPicker from '~/components/Navigation/NavigationMenu/MenuIconPicker'
import { MIGRATION_PAGES } from '~/components/Navigation/NavigationMenu/NavigationMenu.constants'
import { GlassPanelWithIconPicker } from '~/features/ui/GlassPanelWithIconPicker'
import { IconPanelWithIconPicker } from '~/features/ui/IconPanelWithIconPicker'
import HomeLayout from '~/layouts/HomeLayout'
import { BASE_PATH } from '~/lib/constants'

const { sdkCsharp, sdkDart, sdkKotlin, sdkPython, sdkSwift } = isFeatureEnabled([
'sdk:csharp',
'sdk:dart',
'sdk:kotlin',
'sdk:python',
'sdk:swift',
])

const generateMetadata = async (_, parent: ResolvingMetadata): Promise<Metadata> => {
const parentAlternates = (await parent).alternates

Expand Down Expand Up @@ -119,31 +128,37 @@ const clientLibraries = [
title: 'Javascript',
icon: 'reference-javascript',
href: '/reference/javascript/introduction',
enabled: true,
},
{
title: 'Flutter',
icon: 'reference-dart',
href: '/reference/dart/introduction',
enabled: sdkDart,
},
{
title: 'Python',
icon: 'reference-python',
href: '/reference/python/introduction',
enabled: sdkPython,
},
{
title: 'C#',
icon: 'reference-csharp',
href: '/reference/csharp/introduction',
enabled: sdkCsharp,
},
{
title: 'Swift',
icon: 'reference-swift',
href: '/reference/swift/introduction',
enabled: sdkSwift,
},
{
title: 'Kotlin',
icon: 'reference-kotlin',
href: '/reference/kotlin/introduction',
enabled: sdkKotlin,
},
]

Expand Down Expand Up @@ -224,18 +239,21 @@ const HomePage = () => (
</div>

<div className="grid col-span-8 grid-cols-12 gap-6 not-prose">
{clientLibraries.map((library) => {
return (
<Link
href={library.href}
key={library.title}
passHref
className="col-span-6 md:col-span-4"
>
<IconPanelWithIconPicker {...library} />
</Link>
)
})}
{clientLibraries
.filter((library) => library.enabled)

.map((library) => {
return (
<Link
href={library.href}
key={library.title}
passHref
className="col-span-6 md:col-span-4"
>
<IconPanelWithIconPicker {...library} />
</Link>
)
})}
</div>
</div>

Expand Down
33 changes: 21 additions & 12 deletions apps/docs/components/HomePageCover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
import { ChevronRight, Play, Sparkles } from 'lucide-react'
import Link from 'next/link'

import { useBreakpoint } from 'common'
import { isFeatureEnabled, useBreakpoint } from 'common'
import { cn, IconBackground } from 'ui'
import { IconPanel } from 'ui-patterns/IconPanel'

import DocsCoverLogo from './DocsCoverLogo'

const { sdkDart: sdkDartEnabled, sdkKotlin: sdkKotlinEnabled } = isFeatureEnabled([
'sdk:dart',
'sdk:kotlin',
])

function AiPrompt({ className }: { className?: string }) {
return (
<Link
Expand Down Expand Up @@ -52,11 +57,13 @@ const HomePageCover = (props) => {
tooltip: 'Flutter',
icon: '/docs/img/icons/flutter-icon',
href: '/guides/getting-started/quickstarts/flutter',
enabled: sdkDartEnabled,
},
{
tooltip: 'Android Kotlin',
icon: '/docs/img/icons/kotlin-icon',
href: '/guides/getting-started/quickstarts/kotlin',
enabled: sdkKotlinEnabled,
},
{
tooltip: 'SvelteKit',
Expand Down Expand Up @@ -109,16 +116,18 @@ const HomePageCover = (props) => {
</div>
<div className="shrink-0">
<div className="flex flex-wrap md:grid md:grid-cols-5 gap-2 sm:gap-3">
{frameworks.map((framework, i) => (
<Link key={i} href={framework.href} passHref className="no-underline">
<IconPanel
iconSize={iconSize}
hideArrow
tooltip={framework.tooltip}
icon={framework.icon}
/>
</Link>
))}
{frameworks
.filter((framework) => framework.enabled !== false)
.map((framework, i) => (
<Link key={i} href={framework.href} passHref className="no-underline">
<IconPanel
iconSize={iconSize}
hideArrow
tooltip={framework.tooltip}
icon={framework.icon}
/>
</Link>
))}
</div>
<AiPrompt className="mt-6" />
</div>
Expand All @@ -135,7 +144,7 @@ const HomePageCover = (props) => {
<h1 className="m-0 mb-3 text-2xl sm:text-3xl text-foreground">{props.title}</h1>
<p className="m-0 text-foreground-light">
Learn how to get up and running with Supabase through tutorials, APIs and platform
resources.
resources. Differences TBD.
</p>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions apps/docs/components/Navigation/Navigation.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface NavMenuSection {
name: string
url?: `/${string}` | `https://${string}`
items: Partial<NavMenuSection>[]
enabled?: boolean
}

type MenuItem = {
Expand All @@ -20,6 +21,7 @@ type MenuItem = {
level?: string
hasLightIcon?: boolean
community?: boolean
enabled?: boolean
}

export type DropdownMenuItem = MenuItem & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { GLOBAL_MENU_ITEMS } from './NavigationMenu.constants'
/**
* Get TopNav active label based on current pathname
*/
export const useActiveMenuLabel = (GLOBAL_MENU_ITEMS) => {
export const useActiveMenuLabel = (menu: typeof GLOBAL_MENU_ITEMS) => {
const pathname = usePathname()
const [activeLabel, setActiveLabel] = useState('')

Expand All @@ -32,22 +32,26 @@ export const useActiveMenuLabel = (GLOBAL_MENU_ITEMS) => {
return setActiveLabel('Home')
}

for (let index = 0; index < GLOBAL_MENU_ITEMS.length; index++) {
const section = GLOBAL_MENU_ITEMS[index]
for (let index = 0; index < menu.length; index++) {
const section = menu[index]
if (section[0].enabled === false) continue

// check if first level menu items match beginning of url
if (section[0].href?.startsWith(pathname)) {
return setActiveLabel(section[0].label)
}
// check if second level menu items match beginning of url
if (section[0].menuItems) {
section[0].menuItems.map((menuItemGroup) =>
menuItemGroup.map(
(menuItem) => menuItem.href?.startsWith(pathname) && setActiveLabel(section[0].label)
)
menuItemGroup
.filter((menuItem) => menuItem.enabled !== false)
.map(
(menuItem) => menuItem.href?.startsWith(pathname) && setActiveLabel(section[0].label)
)
)
}
}
}, [pathname])
}, [pathname, menu])

return activeLabel
}
Expand All @@ -67,65 +71,14 @@ const GlobalNavigationMenu: FC = () => {
viewportClassName="mt-0 max-w-screen overflow-hidden border-0 rounded-none mt-1.5 rounded-md !border-x"
>
<NavigationMenuList className="px-6 space-x-2 h-[var(--header-height)]">
{GLOBAL_MENU_ITEMS.map((section, sectionIdx) =>
section[0].menuItems ? (
<NavigationMenuItem
key={`desktop-docs-menu-section-${section[0].label}-${sectionIdx}`}
className="text-sm relative h-full"
>
<NavigationMenuTrigger
className={cn(
navigationMenuTriggerStyle(),
triggerClassName,
activeLabel === section[0].label && 'text-foreground border-foreground'
)}
{GLOBAL_MENU_ITEMS.filter((section) => section[0].enabled !== false).map(
(section, sectionIdx) =>
section[0].menuItems ? (
<NavigationMenuItem
key={`desktop-docs-menu-section-${section[0].label}-${sectionIdx}`}
className="text-sm relative h-full"
>
{section[0].label === 'Home' ? (
<MenuIconPicker icon={section[0].icon || ''} />
) : (
section[0].label
)}
</NavigationMenuTrigger>
<NavigationMenuContent className="!top-[calc(100%+4px)] min-w-[14rem] max-h-[calc(100vh-4rem)] border-y w-screen md:w-64 overflow-hidden overflow-y-auto rounded-none md:rounded-md md:border border-overlay bg-overlay text-foreground-light shadow-md !duration-0">
<div className="p-3 md:p-1">
{section[0].menuItems?.map((menuItem, menuItemIndex) => (
<Fragment key={`desktop-docs-menu-section-${menuItemIndex}-${menuItemIndex}`}>
{menuItemIndex !== 0 && <MenubarSeparator className="bg-border-muted" />}
{menuItem.map((item, itemIdx) =>
!item.href ? (
<div
key={`desktop-docs-menu-section-label-${item.label}-${itemIdx}`}
className="font-mono tracking-wider flex items-center text-foreground-muted text-xs uppercase rounded-md p-2 leading-none"
>
{item.label}
</div>
) : (
<NavigationMenuLink
key={`desktop-docs-menu-section-label-${item.label}-${itemIdx}`}
asChild
>
<MenuItem
href={item.href}
title={item.label}
community={item.community}
icon={item.icon}
/>
</NavigationMenuLink>
)
)}
</Fragment>
))}
</div>
</NavigationMenuContent>
</NavigationMenuItem>
) : (
<NavigationMenuItem
key={`desktop-docs-menu-section-${section[0].label}-${sectionIdx}`}
className="text-sm relative h-full"
>
<NavigationMenuLink asChild>
<Link
href={section[0].href || '#'}
<NavigationMenuTrigger
className={cn(
navigationMenuTriggerStyle(),
triggerClassName,
Expand All @@ -137,10 +90,66 @@ const GlobalNavigationMenu: FC = () => {
) : (
section[0].label
)}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
)
</NavigationMenuTrigger>
<NavigationMenuContent className="!top-[calc(100%+4px)] min-w-[14rem] max-h-[calc(100vh-4rem)] border-y w-screen md:w-64 overflow-hidden overflow-y-auto rounded-none md:rounded-md md:border border-overlay bg-overlay text-foreground-light shadow-md !duration-0">
<div className="p-3 md:p-1">
{section[0].menuItems?.map((menuItem, menuItemIndex) => (
<Fragment
key={`desktop-docs-menu-section-${menuItemIndex}-${menuItemIndex}`}
>
{menuItemIndex !== 0 && <MenubarSeparator className="bg-border-muted" />}
{menuItem
.filter((item) => item.enabled !== false)
.map((item, itemIdx) =>
!item.href ? (
<div
key={`desktop-docs-menu-section-label-${item.label}-${itemIdx}`}
className="font-mono tracking-wider flex items-center text-foreground-muted text-xs uppercase rounded-md p-2 leading-none"
>
{item.label}
</div>
) : (
<NavigationMenuLink
key={`desktop-docs-menu-section-label-${item.label}-${itemIdx}`}
asChild
>
<MenuItem
href={item.href}
title={item.label}
community={item.community}
icon={item.icon}
/>
</NavigationMenuLink>
)
)}
</Fragment>
))}
</div>
</NavigationMenuContent>
</NavigationMenuItem>
) : (
<NavigationMenuItem
key={`desktop-docs-menu-section-${section[0].label}-${sectionIdx}`}
className="text-sm relative h-full"
>
<NavigationMenuLink asChild>
<Link
href={section[0].href || '#'}
className={cn(
navigationMenuTriggerStyle(),
triggerClassName,
activeLabel === section[0].label && 'text-foreground border-foreground'
)}
>
{section[0].label === 'Home' ? (
<MenuIconPicker icon={section[0].icon || ''} />
) : (
section[0].label
)}
</Link>
</NavigationMenuLink>
</NavigationMenuItem>
)
)}
</NavigationMenuList>
</NavigationMenu>
Expand Down
Loading
Loading