mirror of
https://github.com/supabase/supabase.git
synced 2026-10-08 10:55:06 +03:00
## Context More groundwork for the Explorer - initializing the home page Note that nothing here is functional, all just visual still <img width="1387" height="960" alt="image" src="https://github.com/user-attachments/assets/d4967578-edbd-476f-8150-d9d5e9d66666" /> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added a new Explorer landing page with an assistant chat form. * Added quick actions for creating notebooks and SQL work. * Added notebook and chat template cards for faster project exploration. * **Improvements** * Explorer content now fills the available page height. * Assistant send button styling now reflects whether submission is available. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
118 lines
3.9 KiB
TypeScript
118 lines
3.9 KiB
TypeScript
import { useParams } from 'common'
|
|
import { AnimatePresence, motion } from 'framer-motion'
|
|
import { Home, MessageCirclePlus, NotebookText, Plus } from 'lucide-react'
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/router'
|
|
import { ComponentProps, ReactNode, useState } from 'react'
|
|
import { cn, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from 'ui'
|
|
|
|
import { ProjectLayoutWithAuth } from '../ProjectLayout'
|
|
import { EditorTabs } from '../Tabs/Tabs'
|
|
import { type ExplorerResourceType } from './ExplorerLayout.constants'
|
|
import { ExplorerNavChats } from './ExplorerNavChats'
|
|
import { ExplorerNavHome } from './ExplorerNavHome'
|
|
import { ExplorerNavNotebooks } from './ExplorerNavNotebooks'
|
|
|
|
export interface ExplorerLayoutProps extends ComponentProps<typeof ProjectLayoutWithAuth> {
|
|
children: ReactNode
|
|
title?: string
|
|
}
|
|
|
|
export const ExplorerLayout = ({ browserTitle, children, title }: ExplorerLayoutProps) => {
|
|
const [section, setSection] = useState<ExplorerResourceType>()
|
|
|
|
// [Joshen] Temporary, to hook up with tabs store
|
|
const activeTabLabel = 'Active Tab Label'
|
|
|
|
const mergedBrowserTitle = {
|
|
...browserTitle,
|
|
section: title ?? browserTitle?.section,
|
|
entity: browserTitle?.entity ?? activeTabLabel,
|
|
}
|
|
|
|
return (
|
|
<ProjectLayoutWithAuth
|
|
product="Explorer"
|
|
browserTitle={mergedBrowserTitle}
|
|
productMenu={
|
|
<div className="relative h-full overflow-hidden">
|
|
<AnimatePresence mode="wait">
|
|
{section === undefined && <ExplorerNavHome key="home" onSelectSection={setSection} />}
|
|
{section === 'notebook' && (
|
|
<ExplorerNavNotebooks key="notebooks" onBack={() => setSection(undefined)} />
|
|
)}
|
|
{section === 'chat' && (
|
|
<ExplorerNavChats key="chats" onBack={() => setSection(undefined)} />
|
|
)}
|
|
</AnimatePresence>
|
|
</div>
|
|
}
|
|
>
|
|
<div className="flex flex-col h-full">
|
|
<div className={cn('h-10 md:min-h-(--header-height) flex items-center bg-surface-100')}>
|
|
<EditorTabs
|
|
isCollapseButtonHidden
|
|
customTabs={<HomeTabButton />}
|
|
newTabButton={<NewTabButton />}
|
|
/>
|
|
</div>
|
|
<div className="h-full">{children}</div>
|
|
</div>
|
|
</ProjectLayoutWithAuth>
|
|
)
|
|
}
|
|
|
|
const TabClassName =
|
|
'flex items-center justify-center min-w-(--header-height) min-h-(--header-height) hover:bg-surface-100 shrink-0 border-b'
|
|
|
|
const HomeTabButton = () => {
|
|
const router = useRouter()
|
|
const { ref } = useParams()
|
|
const isActive = router.pathname.endsWith('/explorer')
|
|
|
|
return (
|
|
<Link href={`/project/${ref}/explorer`} className={cn(TabClassName, 'border-r')}>
|
|
<Home
|
|
size={14}
|
|
strokeWidth={1.5}
|
|
className={cn(
|
|
isActive ? 'text-foreground' : 'text-foreground-lighter hover:text-foreground-light'
|
|
)}
|
|
/>
|
|
<span className="sr-only">Open Explorer home</span>
|
|
</Link>
|
|
)
|
|
}
|
|
|
|
const NewTabButton = () => {
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>
|
|
<motion.button
|
|
className={TabClassName}
|
|
onClick={() => {}}
|
|
initial={{ opacity: 0, scale: 0.8, x: -10 }}
|
|
animate={{ opacity: 1, scale: 1, x: 0 }}
|
|
transition={{ duration: 0.2 }}
|
|
>
|
|
<Plus
|
|
size={16}
|
|
strokeWidth={1.5}
|
|
className="text-foreground-lighter hover:text-foreground-light"
|
|
/>
|
|
</motion.button>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent className="w-40" align="end">
|
|
<DropdownMenuItem className="gap-x-2">
|
|
<NotebookText size={14} />
|
|
<span>New notebook</span>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuItem disabled className="gap-x-2">
|
|
<MessageCirclePlus size={14} />
|
|
<span>New chat</span>
|
|
</DropdownMenuItem>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
)
|
|
}
|