Skip to content

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

feat: floating mobile toolbar (#43444)

Francesco Sansalvadore156f90401852
diff --git a/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsx b/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsx
index f56e4d31024..698585feebd 100644
--- a/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsx
+++ b/apps/studio/components/interfaces/App/CommandMenu/CommandMenu.tsx
@@ -21,6 +21,17 @@ import { useConfigureOrganizationCommand, useProjectSwitchCommand } from './OrgP
import { useSupportCommands } from './Support'
import { useConnectCommands } from '@/components/interfaces/ConnectButton/Connect.Commands'
+export function CommandMenuInnerContent() {
+ return (
+ <>
+ <CommandHeader>
+ <CommandInput />
+ </CommandHeader>
+ <CommandList />
+ </>
+ )
+}
+
export default function StudioCommandMenu() {
useCreateCommands()
useApiKeysCommands()
@@ -46,10 +57,7 @@ export default function StudioCommandMenu() {
return (
<CommandMenu>
- <CommandHeader>
- <CommandInput />
- </CommandHeader>
- <CommandList />
+ <CommandMenuInnerContent />
</CommandMenu>
)
}
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
index 2b6eb4d64c9..73f75cfe798 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewContext.tsx
@@ -124,6 +124,13 @@ export const useIsTableFilterBarEnabled = () => {
return flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_TABLE_FILTER_BAR]
}
+export const useIsFloatingMobileToolbarEnabled = () => {
+ const { flags } = useFeaturePreviewContext()
+ const showFloatingMobileToolbar = useFlag('enableFloatingMobileToolbar')
+
+ return showFloatingMobileToolbar && flags[LOCAL_STORAGE_KEYS.UI_PREVIEW_FLOATING_MOBILE_TOOLBAR]
+}
+
export const useFeaturePreviewModal = () => {
const featurePreviews = useFeaturePreviews()
const [featurePreviewModal, setFeaturePreviewModal] = useQueryState('featurePreviewModal')
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
index c4830f225fd..74fda3915a0 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FeaturePreviewModal.tsx
@@ -29,6 +29,7 @@ import { AdvisorRulesPreview } from './AdvisorRulesPreview'
import { Branching2Preview } from './Branching2Preview'
import { CLSPreview } from './CLSPreview'
import { useFeaturePreviewContext, useFeaturePreviewModal } from './FeaturePreviewContext'
+import { FloatingMobileToolbarPreview } from './FloatingMobileToolbarPreview'
import { PgDeltaDiffPreview } from './PgDeltaDiffPreview'
import { PlatformWebhooksPreview } from './PlatformWebhooksPreview'
import { QueueOperationsPreview } from './QueueOperationsPreview'
@@ -48,6 +49,7 @@ const FEATURE_PREVIEW_KEY_TO_CONTENT: {
[LOCAL_STORAGE_KEYS.UI_PREVIEW_QUEUE_OPERATIONS]: <QueueOperationsPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_TABLE_FILTER_BAR]: <TableFilterBarPreview />,
[LOCAL_STORAGE_KEYS.UI_PREVIEW_PLATFORM_WEBHOOKS]: <PlatformWebhooksPreview />,
+ [LOCAL_STORAGE_KEYS.UI_PREVIEW_FLOATING_MOBILE_TOOLBAR]: <FloatingMobileToolbarPreview />,
}
export const FeaturePreviewModal = () => {
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/FloatingMobileToolbarPreview.tsx b/apps/studio/components/interfaces/App/FeaturePreview/FloatingMobileToolbarPreview.tsx
new file mode 100644
index 00000000000..2f6158014bf
--- /dev/null
+++ b/apps/studio/components/interfaces/App/FeaturePreview/FloatingMobileToolbarPreview.tsx
@@ -0,0 +1,33 @@
+import { BASE_PATH } from 'lib/constants'
+import Image from 'next/image'
+
+export const FloatingMobileToolbarPreview = () => {
+ return (
+ <div className="flex flex-col gap-2">
+ <p className="text-foreground-light text-sm mb-4">
+ A floating toolbar conveniently positioned at the bottom of the screen on mobile viewports
+ to quickly access the Command Menu, Help, Advisor Panel, Editor Panel, and AI Assistant
+ buttons.
+ </p>
+ <p className="text-foreground-light text-sm mb-4">
+ It can be dragged to any position on the screen to move it if it gets in the way of
+ important content so you can keep working on your project.
+ </p>
+ <Image
+ src={`${BASE_PATH}/img/previews/floating-toolbar-preview.png`}
+ width={1296}
+ height={900}
+ quality={100}
+ alt="floating-mobile-toolbar-preview"
+ className="rounded border"
+ />
+ <div className="space-y-2 !mt-4">
+ <p className="text-sm">Enabling this preview will:</p>
+ <ul className="list-disc pl-6 text-sm text-foreground-light space-y-1">
+ <li>Show the floating toolbar at the bottom of the screen on mobile viewports</li>
+ <li>Hide the second row of mobile navigation bar</li>
+ </ul>
+ </div>
+ </div>
+ )
+}
diff --git a/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts b/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
index 84cc22c3f23..42491cca6ee 100644
--- a/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
+++ b/apps/studio/components/interfaces/App/FeaturePreview/useFeaturePreviews.ts
@@ -17,6 +17,7 @@ export const useFeaturePreviews = (): FeaturePreview[] => {
const isUnifiedLogsPreviewAvailable = useFlag('unifiedLogs')
const tableEditorNewFilterBar = useFlag('tableEditorNewFilterBar')
const pgDeltaDiffEnabled = useFlag('pgdeltaDiff')
+ const showFloatingMobileToolbar = useFlag('enableFloatingMobileToolbar')
const platformWebhooksEnabled = useFlag('platformWebhooks')
return [
@@ -102,5 +103,14 @@ export const useFeaturePreviews = (): FeaturePreview[] => {
isPlatformOnly: false,
isDefaultOptIn: tableEditorNewFilterBar,
},
+ {
+ key: LOCAL_STORAGE_KEYS.UI_PREVIEW_FLOATING_MOBILE_TOOLBAR,
+ name: 'Floating Mobile Toolbar',
+ discussionsUrl: 'https://github.com/orgs/supabase/discussions/43721',
+ enabled: showFloatingMobileToolbar,
+ isNew: true,
+ isPlatformOnly: false,
+ isDefaultOptIn: true,
+ },
].sort((a, b) => Number(b.isNew) - Number(a.isNew))
}
diff --git a/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx b/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx
index 16a4c9e8df3..a4350d92eb8 100644
--- a/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx
+++ b/apps/studio/components/interfaces/Home/ProjectList/EmptyStates.tsx
@@ -1,3 +1,4 @@
+import { HomeIcon } from 'components/layouts/Navigation/LayoutHeader/HomeIcon'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { BoxPlus } from 'icons'
import { Plus } from 'lucide-react'
@@ -16,7 +17,6 @@ import {
import { EmptyStatePresentational } from 'ui-patterns'
import { ShimmeringCard } from './ShimmeringCard'
-import { HomeIcon } from '@/components/layouts/ProjectLayout/LayoutHeader/HomeIcon'
export const Header = () => {
return (
diff --git a/apps/studio/components/interfaces/Organization/ProjectClaim/layout.tsx b/apps/studio/components/interfaces/Organization/ProjectClaim/layout.tsx
index 51856178540..b90a8e5344b 100644
--- a/apps/studio/components/interfaces/Organization/ProjectClaim/layout.tsx
+++ b/apps/studio/components/interfaces/Organization/ProjectClaim/layout.tsx
@@ -1,9 +1,8 @@
-import Image from 'next/image'
-import { PropsWithChildren, ReactNode } from 'react'
-
import { UserDropdown } from 'components/interfaces/UserDropdown'
-import { FeedbackDropdown } from 'components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackDropdown'
+import { FeedbackDropdown } from 'components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackDropdown'
import { BASE_PATH } from 'lib/constants'
+import Image from 'next/image'
+import { PropsWithChildren, ReactNode } from 'react'
import { cn, Separator } from 'ui'
export const ProjectClaimLayout = ({
diff --git a/apps/studio/components/interfaces/Sidebar.tsx b/apps/studio/components/interfaces/Sidebar.tsx
index ca399ff9a9a..59943dd552b 100644
--- a/apps/studio/components/interfaces/Sidebar.tsx
+++ b/apps/studio/components/interfaces/Sidebar.tsx
@@ -4,7 +4,7 @@ import {
generateProductRoutes,
generateSettingsRoutes,
generateToolRoutes,
-} from 'components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils'
+} from 'components/layouts/Navigation/NavigationBar/NavigationBar.utils'
import { ProjectIndexPageLink } from 'data/prefetchers/project.$ref'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import { AnimatePresence, motion, MotionProps } from 'framer-motion'
diff --git a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
index 7ddf9e57621..f760a804fb5 100644
--- a/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
+++ b/apps/studio/components/layouts/AccountLayout/AccountLayout.tsx
@@ -12,7 +12,7 @@ import { useEffect, useLayoutEffect, useMemo } from 'react'
import { useAppStateSnapshot } from 'state/app-state'
import { cn } from 'ui'
-import { useMobileSheet } from '../ProjectLayout/NavigationBar/MobileSheetContext'
+import { useMobileSheet } from '../Navigation/NavigationBar/MobileSheetContext'
import { AccountMenuContent } from './AccountMenuContent'
import { WithSidebar } from './WithSidebar'
diff --git a/apps/studio/components/layouts/DefaultLayout.tsx b/apps/studio/components/layouts/DefaultLayout.tsx
index e56dc27ac0b..a09175a8657 100644
--- a/apps/studio/components/layouts/DefaultLayout.tsx
+++ b/apps/studio/components/layouts/DefaultLayout.tsx
@@ -10,12 +10,12 @@ import { ResizablePanel, ResizablePanelGroup, SidebarProvider } from 'ui'
import { BannerStack } from '../ui/BannerStack/BannerStack'
import { BannerStackProvider } from '../ui/BannerStack/BannerStackProvider'
-import { LayoutHeader } from './ProjectLayout/LayoutHeader/LayoutHeader'
+import { LayoutHeader } from './Navigation/LayoutHeader/LayoutHeader'
+import MobileNavigationBar from './Navigation/NavigationBar/MobileNavigationBar'
+import { MobileSheetProvider } from './Navigation/NavigationBar/MobileSheetContext'
+import { StudioMobileSheetNav } from './Navigation/NavigationBar/StudioMobileSheetNav'
import { LayoutSidebar } from './ProjectLayout/LayoutSidebar'
import { LayoutSidebarProvider } from './ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
-import MobileNavigationBar from './ProjectLayout/NavigationBar/MobileNavigationBar'
-import { MobileSheetProvider } from './ProjectLayout/NavigationBar/MobileSheetContext'
-import { StudioMobileSheetNav } from './ProjectLayout/NavigationBar/StudioMobileSheetNav'
import { ProjectContextProvider } from './ProjectLayout/ProjectContext'
export interface DefaultLayoutProps {
@@ -41,19 +41,19 @@ export const DefaultLayout = ({
const { ref } = useParams()
const router = useRouter()
const appSnap = useAppStateSnapshot()
- const showProductMenu = !!ref && router.pathname !== '/project/[ref]'
const [lastVisitedOrganization] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.LAST_VISITED_ORGANIZATION,
''
)
- const backToDashboardURL =
- appSnap.lastRouteBeforeVisitingAccountPage.length > 0
+ const backToDashboardURL = router.pathname.startsWith('/account')
+ ? appSnap.lastRouteBeforeVisitingAccountPage.length > 0
? appSnap.lastRouteBeforeVisitingAccountPage
: !!lastVisitedOrganization
? `/org/${lastVisitedOrganization}`
: '/organizations'
+ : undefined
useCheckLatestDeploy()
@@ -82,14 +82,11 @@ export const DefaultLayout = ({
{/* Top Banner */}
<AppBannerWrapper />
<div className="flex-shrink-0">
- <MobileNavigationBar hideMobileMenu={hideMobileMenu} />
- <LayoutHeader
- showProductMenu={showProductMenu}
- headerTitle={headerTitle}
- backToDashboardURL={
- router.pathname.startsWith('/account') ? backToDashboardURL : undefined
- }
+ <MobileNavigationBar
+ hideMobileMenu={hideMobileMenu}
+ backToDashboardURL={backToDashboardURL}
/>
+ <LayoutHeader headerTitle={headerTitle} backToDashboardURL={backToDashboardURL} />
</div>
{/* Main Content Area */}
<div className="flex flex-1 w-full overflow-y-hidden">
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
new file mode 100644
index 00000000000..cffc4dd9365
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.tsx
@@ -0,0 +1,133 @@
+import { useParams, useViewport } from 'common'
+import { AdvisorButton } from 'components/layouts/AppLayout/AdvisorButton'
+import { AssistantButton } from 'components/layouts/AppLayout/AssistantButton'
+import { InlineEditorButton } from 'components/layouts/AppLayout/InlineEditorButton'
+import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
+import { ButtonTooltip } from 'components/ui/ButtonTooltip'
+import { HelpButton } from 'components/ui/HelpPanel/HelpButton'
+import { AnimatePresence } from 'framer-motion'
+import { Menu, Search, X } from 'lucide-react'
+import { useRef } from 'react'
+import { Button, cn, KeyboardShortcut } from 'ui'
+
+import { getToolbarStyle } from './FloatingMobileToolbar.utils'
+import { useFloatingToolbarDrag } from './useFloatingToolbarDrag'
+import { useFloatingToolbarNavSize } from './useFloatingToolbarNavSize'
+import { useFloatingToolbarSheet } from './useFloatingToolbarSheet'
+import { useFloatingToolbarSidebarClick } from './useFloatingToolbarSidebarClick'
+
+const FloatingMobileToolbar = ({ hideMobileMenu }: { hideMobileMenu?: boolean }) => {
+ const navRef = useRef<HTMLElement | null>(null)
+ const sheet = useFloatingToolbarSheet(hideMobileMenu)
+ const drag = useFloatingToolbarDrag(navRef)
+ const handleNavClickCapture = useFloatingToolbarSidebarClick()
+ const navSize = useFloatingToolbarNavSize(navRef, sheet.isSheetOpen)
+ const viewport = useViewport()
+ const { handleSearchClick, isSearchOpen } = sheet
+
+ const style = getToolbarStyle({
+ position: drag.position,
+ navSize,
+ isSheetOpen: sheet.isSheetOpen,
+ viewport,
+ isDragging: drag.dragStartRef.current !== null,
+ })
+
+ const { ref: projectRef } = useParams()
+
+ return (
+ <nav
+ ref={navRef}
+ aria-label="Floating toolbar"
+ className={cn(
+ 'flex pointer-events-auto cursor-grab active:cursor-grabbing flex-row items-centerw-auto',
+ 'gap-2',
+ 'fixed md:hidden'
+ )}
+ style={style}
+ onClickCapture={handleNavClickCapture}
+ onPointerDown={drag.handlePointerDown}
+ onPointerMove={drag.handlePointerMove}
+ >
+ <div
+ className={cn(
+ 'flex pointer-events-auto cursor-grab active:cursor-grabbing flex-row items-center justify-between w-auto rounded-full',
+ 'bg-overlay/80 backdrop-blur-md px-2.5 py-2 gap-2',
+ 'border border-strong shadow-[0px_3px_6px_-2px_rgba(0,0,0,0.07),0px_10px_30px_0px_rgba(0,0,0,0.10)]'
+ )}
+ >
+ <AnimatePresence initial={false}>
+ <ButtonTooltip
+ type={isSearchOpen ? 'secondary' : 'outline'}
+ size="tiny"
+ id="search-trigger"
+ className={cn(
+ 'rounded-full w-[32px] h-[32px] flex items-center justify-center p-0',
+ isSearchOpen && 'text-background'
+ )}
+ tooltip={{
+ content: {
+ className: 'p-1 pl-2.5',
+ text: (
+ <div className="flex items-center gap-2.5">
+ <span>Search</span>
+ <KeyboardShortcut keys={['Meta', 'K']} />
+ </div>
+ ),
+ },
+ }}
+ onClick={handleSearchClick}
+ >
+ <Search size={16} strokeWidth={1} />
+ </ButtonTooltip>
+ <span data-sidebar-id={SIDEBAR_KEYS.HELP_PANEL}>
+ <HelpButton />
+ </span>
+ <span data-sidebar-id={SIDEBAR_KEYS.ADVISOR_PANEL}>
+ <AdvisorButton projectRef={projectRef} />
+ </span>
+ {!!projectRef && (
+ <>
+ <span data-sidebar-id={SIDEBAR_KEYS.EDITOR_PANEL}>
+ <InlineEditorButton />
+ </span>
+ <span data-sidebar-id={SIDEBAR_KEYS.AI_ASSISTANT}>
+ <AssistantButton />
+ </span>
+ </>
+ )}
+ {sheet.showMenuButton && sheet.isSheetOpen && (
+ <Button
+ title="Menu dropdown button"
+ type={sheet.isMenuOpen ? 'secondary' : 'default'}
+ className={cn(
+ 'flex lg:hidden mr-1 rounded-md min-w-[30px] w-[30px] h-[30px] data-[state=open]:bg-overlay-hover/30',
+ !sheet.isMenuOpen && '!bg-surface-300'
+ )}
+ icon={<Menu />}
+ onClick={sheet.handleMenuClick}
+ />
+ )}
+ </AnimatePresence>
+ </div>
+ <AnimatePresence initial={false}>
+ <Button
+ title="close"
+ type="text"
+ className={cn(
+ 'flex flex-row items-center justify-center rounded-full',
+ 'bg-overlay/50 backdrop-blur-md my-auto !p-1 gap-2',
+ 'border border-strong shadow-[0px_3px_6px_-2px_rgba(0,0,0,0.07),0px_10px_30px_0px_rgba(0,0,0,0.10)]',
+ '!w-10 !h-10 !min-w-10 !min-h-10',
+ 'rounded-full',
+ !sheet.isSheetOpen && 'hidden'
+ )}
+ icon={<X />}
+ onClick={sheet.handleClose}
+ />
+ </AnimatePresence>
+ </nav>
+ )
+}
+
+export default FloatingMobileToolbar
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.utils.test.ts b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.utils.test.ts
new file mode 100644
index 00000000000..1ff0f776934
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.utils.test.ts
@@ -0,0 +1,98 @@
+import { describe, expect, it } from 'vitest'
+
+import {
+ clampPosition,
+ getToolbarStyle,
+ getNextPosition,
+ isMenuContent,
+ shouldShowMenuButton,
+} from './FloatingMobileToolbar.utils'
+
+describe('isMenuContent', () => {
+ it('returns false for null', () => {
+ expect(isMenuContent(null)).toBe(false)
+ })
+
+ it('returns false for sidebar id string', () => {
+ expect(isMenuContent('help-panel')).toBe(false)
+ })
+
+ it('returns true for non-string content', () => {
+ expect(isMenuContent({})).toBe(true)
+ expect(isMenuContent(0)).toBe(true)
+ })
+})
+
+describe('shouldShowMenuButton', () => {
+ it('returns true for project, org, account paths', () => {
+ expect(shouldShowMenuButton('/project/ref')).toBe(true)
+ expect(shouldShowMenuButton('/org/slug')).toBe(true)
+ expect(shouldShowMenuButton('/account/me')).toBe(true)
+ })
+
+ it('returns false for other paths', () => {
+ expect(shouldShowMenuButton('/organizations')).toBe(false)
+ expect(shouldShowMenuButton('/')).toBe(false)
+ })
+})
+
+describe('clampPosition', () => {
+ const viewport = { width: 400, height: 800 }
+ const navSize = { width: 100, height: 48 }
+
+ it('clamps to viewport bounds', () => {
+ const next = clampPosition({ x: 0, y: 0 }, { dx: 500, dy: 900 }, viewport, navSize)
+ expect(next.x).toBe(300)
+ expect(next.y).toBe(752)
+ })
+
+ it('does not go negative', () => {
+ const next = clampPosition({ x: 10, y: 10 }, { dx: -20, dy: -20 }, viewport, navSize)
+ expect(next.x).toBe(0)
+ expect(next.y).toBe(0)
+ })
+})
+
+describe('getNextPosition', () => {
+ const viewport = { width: 400, height: 800 }
+ const navSize = { width: 100, height: 48 }
+ const dragStart = { x: 50, y: 100, startX: 60, startY: 110 }
+
+ it('returns null when under threshold', () => {
+ expect(getNextPosition(dragStart, 62, 111, viewport, navSize, 8)).toBeNull()
+ })
+
+ it('returns clamped position when over threshold', () => {
+ const next = getNextPosition(dragStart, 80, 130, viewport, navSize, 5)
+ expect(next).toEqual({ x: 70, y: 120 })
+ })
+})
+
+describe('getToolbarStyle', () => {
+ const viewport = { width: 390, height: 844 }
+ const navSize = { width: 200, height: 48 }
+
+ it('returns style with transform and zIndex', () => {
+ const style = getToolbarStyle({
+ position: null,
+ navSize,
+ isSheetOpen: false,
+ viewport,
+ isDragging: false,
+ })
+ expect(style.zIndex).toBe(41)
+ expect(style.transform).toBeDefined()
+ expect(style.left).toBe('50%')
+ })
+
+ it('uses higher zIndex when sheet open', () => {
+ const style = getToolbarStyle({
+ position: null,
+ navSize,
+ isSheetOpen: true,
+ viewport,
+ isDragging: false,
+ })
+ expect(style.zIndex).toBe(101)
+ })
+})
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.utils.ts b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.utils.ts
new file mode 100644
index 00000000000..b91ccd2c98d
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar.utils.ts
@@ -0,0 +1,109 @@
+import type { CSSProperties } from 'react'
+
+export const DRAG_THRESHOLD_PX = 8
+export const GAP_FROM_BOTTOM = 50
+export const SHEET_OPEN_GAP_FRACTION = 0.15
+export const DEFAULT_NAV_HEIGHT = 56
+
+export function isMenuContent(content: unknown): boolean {
+ return content !== null && typeof content !== 'string'
+}
+
+export function shouldShowMenuButton(pathname: string): boolean {
+ return (
+ pathname.startsWith('/project/') ||
+ pathname.startsWith('/org/') ||
+ pathname.startsWith('/account')
+ )
+}
+
+export type Viewport = { width: number; height: number }
+export type NavSize = { width: number; height: number }
+export type Position = { x: number; y: number }
+
+export function clampPosition(
+ current: Position,
+ delta: { dx: number; dy: number },
+ viewport: Viewport,
+ navSize: NavSize
+): Position {
+ const maxX = Math.max(0, viewport.width - navSize.width)
+ const maxY = Math.max(0, viewport.height - navSize.height)
+ return {
+ x: Math.max(0, Math.min(maxX, current.x + delta.dx)),
+ y: Math.max(0, Math.min(maxY, current.y + delta.dy)),
+ }
+}
+
+export type DragStartState = {
+ x: number
+ y: number
+ startX: number
+ startY: number
+}
+
+export function getNextPosition(
+ dragStart: DragStartState,
+ clientX: number,
+ clientY: number,
+ viewport: Viewport,
+ navSize: NavSize,
+ threshold: number = DRAG_THRESHOLD_PX
+): Position | null {
+ const dist = Math.hypot(clientX - dragStart.startX, clientY - dragStart.startY)
+ if (dist < threshold) return null
+ const dx = clientX - dragStart.startX
+ const dy = clientY - dragStart.startY
+ return clampPosition({ x: dragStart.x, y: dragStart.y }, { dx, dy }, viewport, navSize)
+}
+
+export function getToolbarStyle(params: {
+ position: Position | null
+ navSize: NavSize
+ isSheetOpen: boolean
+ viewport: Viewport
+ isDragging: boolean
+}): CSSProperties {
+ const { position, navSize, isSheetOpen, viewport, isDragging } = params
+ const { width: navW, height: navH } = navSize
+ const vw = viewport.width
+ const vh = viewport.height
+ const transition = isDragging
+ ? 'transform 0ms, z-index 0s'
+ : 'transform 300ms cubic-bezier(0.4, 0, 0.2, 1), z-index 0s'
+ const base: CSSProperties = {
+ zIndex: isSheetOpen ? 101 : 41,
+ transition,
+ touchAction: 'none',
+ }
+
+ const centerX = vw > 0 && navW > 0 ? vw / 2 - navW / 2 : 0
+ const sheetOpenGapPx = vh * SHEET_OPEN_GAP_FRACTION
+ const topWhenSheetOpen = vh > 0 ? sheetOpenGapPx / 2 - navH / 2 : 0
+ const defaultYClosed = vh > 0 ? vh - GAP_FROM_BOTTOM - (navH > 0 ? navH : DEFAULT_NAV_HEIGHT) : 0
+
+ if (position === null) {
+ return {
+ ...base,
+ left: '50%',
+ top: 0,
+ transform: isSheetOpen
+ ? `translate(-50%, ${topWhenSheetOpen}px)`
+ : `translate(-50%, ${defaultYClosed}px)`,
+ }
+ }
+ if (isSheetOpen) {
+ return {
+ ...base,
+ left: 0,
+ top: 0,
+ transform: `translate(${centerX}px, ${topWhenSheetOpen}px)`,
+ }
+ }
+ return {
+ ...base,
+ left: 0,
+ top: 0,
+ transform: `translate(${position.x}px, ${position.y}px)`,
+ }
+}
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarDrag.ts b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarDrag.ts
new file mode 100644
index 00000000000..a0e579e4b04
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarDrag.ts
@@ -0,0 +1,97 @@
+import { useCallback, useRef, useState } from 'react'
+
+import {
+ DRAG_THRESHOLD_PX,
+ getNextPosition,
+ type NavSize,
+ type Position,
+ type Viewport,
+} from './FloatingMobileToolbar.utils'
+
+type DragStartState = {
+ x: number
+ y: number
+ startX: number
+ startY: number
+ pointerId: number
+}
+
+export function useFloatingToolbarDrag(navRef: React.RefObject<HTMLElement | null>) {
+ const [position, setPosition] = useState<Position | null>(null)
+ const dragStartRef = useRef<DragStartState | null>(null)
+
+ const applyMove = useCallback(
+ (clientX: number, clientY: number) => {
+ const state = dragStartRef.current
+ if (!state) return
+ const rect = navRef.current?.getBoundingClientRect()
+ const viewport: Viewport = {
+ width: typeof window !== 'undefined' ? window.innerWidth : 0,
+ height: typeof window !== 'undefined' ? window.innerHeight : 0,
+ }
+ const navSize: NavSize = {
+ width: rect?.width ?? 200,
+ height: rect?.height ?? 48,
+ }
+ const next = getNextPosition(state, clientX, clientY, viewport, navSize, DRAG_THRESHOLD_PX)
+ if (next) setPosition(next)
+ },
+ [navRef]
+ )
+
+ const handlePointerDown = useCallback(
+ (e: React.PointerEvent) => {
+ e.preventDefault()
+ e.stopPropagation()
+ const rect = navRef.current?.getBoundingClientRect()
+ if (!rect) return
+ const currentX = position?.x ?? rect.left
+ const currentY = position?.y ?? rect.top
+ dragStartRef.current = {
+ x: currentX,
+ y: currentY,
+ startX: e.clientX,
+ startY: e.clientY,
+ pointerId: e.pointerId,
+ }
+
+ const onMove = (moveEvent: PointerEvent) => {
+ if (dragStartRef.current?.pointerId !== moveEvent.pointerId) return
+ const dist = Math.hypot(
+ moveEvent.clientX - dragStartRef.current.startX,
+ moveEvent.clientY - dragStartRef.current.startY
+ )
+ if (dist >= DRAG_THRESHOLD_PX) {
+ navRef.current?.setPointerCapture?.(moveEvent.pointerId)
+ }
+ applyMove(moveEvent.clientX, moveEvent.clientY)
+ }
+ const onUpOrCancel = (upEvent: PointerEvent) => {
+ if (dragStartRef.current?.pointerId !== upEvent.pointerId) return
+ ;(upEvent.target as HTMLElement)?.releasePointerCapture?.(upEvent.pointerId)
+ window.removeEventListener('pointermove', onMove)
+ window.removeEventListener('pointerup', onUpOrCancel)
+ window.removeEventListener('pointercancel', onUpOrCancel)
+ dragStartRef.current = null
+ }
+ window.addEventListener('pointermove', onMove)
+ window.addEventListener('pointerup', onUpOrCancel)
+ window.addEventListener('pointercancel', onUpOrCancel)
+ },
+ [navRef, position, applyMove]
+ )
+
+ const handlePointerMove = useCallback(
+ (e: React.PointerEvent) => {
+ applyMove(e.clientX, e.clientY)
+ },
+ [applyMove]
+ )
+
+ return {
+ position,
+ dragStartRef,
+ handlePointerDown,
+ handlePointerMove,
+ }
+}
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarNavSize.ts b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarNavSize.ts
new file mode 100644
index 00000000000..3a5591ca5c6
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarNavSize.ts
@@ -0,0 +1,40 @@
+import { useLayoutEffect, useState } from 'react'
+
+import type { NavSize } from './FloatingMobileToolbar.utils'
+
+function measure(
+ el: HTMLElement | null,
+ setNavSize: React.Dispatch<React.SetStateAction<NavSize>>
+) {
+ if (!el) return
+ const rect = el.getBoundingClientRect()
+ setNavSize((prev) =>
+ prev.width !== rect.width || prev.height !== rect.height
+ ? { width: rect.width, height: rect.height }
+ : prev
+ )
+}
+
+export function useFloatingToolbarNavSize(
+ navRef: React.RefObject<HTMLElement | null>,
+ isSheetOpen: boolean
+): NavSize {
+ const [navSize, setNavSize] = useState<NavSize>({ width: 0, height: 0 })
+
+ useLayoutEffect(() => {
+ const el = navRef.current
+ if (!el) return
+ measure(el, setNavSize)
+ const ro = new ResizeObserver(() => measure(el, setNavSize))
+ ro.observe(el)
+ return () => ro.disconnect()
+ }, [navRef])
+
+ useLayoutEffect(() => {
+ if (!isSheetOpen) return
+ const raf = requestAnimationFrame(() => measure(navRef.current, setNavSize))
+ return () => cancelAnimationFrame(raf)
+ }, [isSheetOpen, navRef])
+
+ return navSize
+}
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarSheet.tsx b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarSheet.tsx
new file mode 100644
index 00000000000..57d4cce8a3b
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarSheet.tsx
@@ -0,0 +1,56 @@
+import { useRouter } from 'next/router'
+import { useCallback } from 'react'
+import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
+
+import { useMobileSheet } from '../NavigationBar/MobileSheetContext'
+import { isMenuContent, shouldShowMenuButton } from './FloatingMobileToolbar.utils'
+
+export function useFloatingToolbarSheet(hideMobileMenu?: boolean) {
+ const router = useRouter()
+ const pathname = router.asPath?.split('?')[0] ?? router.pathname
+ const { content: sheetContent, setContent: setSheetContent, openMenu } = useMobileSheet()
+ const { clearActiveSidebar, closeActive, activeSidebar } = useSidebarManagerSnapshot()
+
+ const isSheetOpen = sheetContent !== null
+ const isMenuOpen = isMenuContent(sheetContent)
+ const isSearchOpen = sheetContent === 'search'
+ const showMenuButton = shouldShowMenuButton(pathname) && !hideMobileMenu
+
+ const handleMenuClick = useCallback(() => {
+ if (isMenuOpen) {
+ clearActiveSidebar()
+ setSheetContent(null)
+ return
+ }
+ clearActiveSidebar()
+ openMenu()
+ }, [isMenuOpen, clearActiveSidebar, openMenu, setSheetContent])
+
+ const handleClose = useCallback(() => {
+ if (activeSidebar) {
+ closeActive()
+ } else {
+ setSheetContent(null)
+ }
+ }, [activeSidebar, closeActive, setSheetContent])
+
+ const handleSearchClick = useCallback(() => {
+ if (isSearchOpen) {
+ clearActiveSidebar()
+ setSheetContent(null)
+ return
+ }
+ clearActiveSidebar()
+ setSheetContent('search')
+ }, [isSearchOpen, clearActiveSidebar, setSheetContent])
+
+ return {
+ isSheetOpen,
+ isMenuOpen,
+ isSearchOpen,
+ showMenuButton,
+ handleMenuClick,
+ handleClose,
+ handleSearchClick,
+ }
+}
diff --git a/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarSidebarClick.ts b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarSidebarClick.ts
new file mode 100644
index 00000000000..d41d0caad88
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/FloatingMobileToolbar/useFloatingToolbarSidebarClick.ts
@@ -0,0 +1,23 @@
+import { useCallback } from 'react'
+import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
+
+import { useMobileSheet } from '../NavigationBar/MobileSheetContext'
+
+export function useFloatingToolbarSidebarClick() {
+ const { setContent: setSheetContent } = useMobileSheet()
+ const { activeSidebar, openSidebar } = useSidebarManagerSnapshot()
+
+ return useCallback(
+ (e: React.MouseEvent) => {
+ const target = (e.target as HTMLElement).closest?.('[data-sidebar-id]')
+ const sidebarId = target?.getAttribute('data-sidebar-id')
+ if (sidebarId && activeSidebar?.id !== sidebarId) {
+ e.preventDefault()
+ e.stopPropagation()
+ openSidebar(sidebarId)
+ setSheetContent(sidebarId)
+ }
+ },
+ [activeSidebar?.id, openSidebar, setSheetContent]
+ )
+}
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/BreadcrumbsView.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/BreadcrumbsView.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/BreadcrumbsView.tsx
rename to apps/studio/components/layouts/Navigation/LayoutHeader/BreadcrumbsView.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackDropdown.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackDropdown.tsx
similarity index 95%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackDropdown.tsx
rename to apps/studio/components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackDropdown.tsx
index 3c4579f01c9..664a1ec77dc 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackDropdown.tsx
+++ b/apps/studio/components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackDropdown.tsx
@@ -1,5 +1,8 @@
import { IS_PLATFORM } from 'common'
import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
+import { ASSISTANT_SUGGESTIONS } from 'components/ui/HelpPanel/HelpPanel.constants'
+import { getSupportLinkQueryParams } from 'components/ui/HelpPanel/HelpPanel.utils'
+import { HelpSection } from 'components/ui/HelpPanel/HelpSection'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
import { Lightbulb, TriangleAlert } from 'lucide-react'
@@ -15,9 +18,6 @@ import {
PopoverTrigger_Shadcn_,
} from 'ui'
-import { ASSISTANT_SUGGESTIONS } from '../HelpPanel/HelpPanel.constants'
-import { getSupportLinkQueryParams } from '../HelpPanel/HelpPanel.utils'
-import { HelpSection } from '../HelpPanel/HelpSection'
import { FeedbackWidget } from './FeedbackWidget'
export const FeedbackDropdown = ({ className }: { className?: string }) => {
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackDropdown.utils.ts b/apps/studio/components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackDropdown.utils.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackDropdown.utils.ts
rename to apps/studio/components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackDropdown.utils.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
rename to apps/studio/components/layouts/Navigation/LayoutHeader/FeedbackDropdown/FeedbackWidget.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HomeIcon.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/HomeIcon.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HomeIcon.tsx
rename to apps/studio/components/layouts/Navigation/LayoutHeader/HomeIcon.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx
similarity index 93%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
rename to apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx
index ba3dd0c3d69..a54930134f5 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx
+++ b/apps/studio/components/layouts/Navigation/LayoutHeader/LayoutHeader.tsx
@@ -1,5 +1,11 @@
import { LOCAL_STORAGE_KEYS, useParams } from 'common'
-import { useIsBranching2Enabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import {
+ useIsBranching2Enabled,
+ useIsFloatingMobileToolbarEnabled,
+} from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { Connect } from 'components/interfaces/Connect/Connect'
+import { ConnectButton } from 'components/interfaces/ConnectButton/ConnectButton'
+import { ConnectSheet } from 'components/interfaces/ConnectSheet/ConnectSheet'
import { LocalDropdown } from 'components/interfaces/LocalDropdown'
import { UserDropdown } from 'components/interfaces/UserDropdown'
import { AdvisorButton } from 'components/layouts/AppLayout/AdvisorButton'
@@ -8,6 +14,7 @@ import { BranchDropdown } from 'components/layouts/AppLayout/BranchDropdown'
import { InlineEditorButton } from 'components/layouts/AppLayout/InlineEditorButton'
import { OrganizationDropdown } from 'components/layouts/AppLayout/OrganizationDropdown'
import { ProjectDropdown } from 'components/layouts/AppLayout/ProjectDropdown'
+import { HelpButton } from 'components/ui/HelpPanel/HelpButton'
import { getResourcesExceededLimitsOrg } from 'components/ui/OveragesBanner/OveragesBanner.utils'
import { useOrgUsageQuery } from 'data/usage/org-usage-query'
import { DevToolbarTrigger } from 'dev-tools'
@@ -15,26 +22,21 @@ import { AnimatePresence, motion } from 'framer-motion'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
+import { usePHFlag } from 'hooks/ui/useFlag'
import { IS_PLATFORM } from 'lib/constants'
import { ChevronLeft } from 'lucide-react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import { ReactNode, useMemo } from 'react'
-import { useAppStateSnapshot } from 'state/app-state'
import { Badge, cn } from 'ui'
import { CommandMenuTriggerInput } from 'ui-patterns'
import { BreadcrumbsView } from './BreadcrumbsView'
import { FeedbackDropdown } from './FeedbackDropdown/FeedbackDropdown'
-import { HelpButton } from './HelpPanel/HelpButton'
import { HomeIcon } from './HomeIcon'
import { LocalVersionPopover } from './LocalVersionPopover'
import { MergeRequestButton } from './MergeRequestButton'
-import { Connect } from '@/components/interfaces/Connect/Connect'
-import { ConnectButton } from '@/components/interfaces/ConnectButton/ConnectButton'
-import { ConnectSheet } from '@/components/interfaces/ConnectSheet/ConnectSheet'
import type { ConnectSectionVariant } from '@/components/interfaces/ProjectHome/ConnectSection.config'
-import { usePHFlag } from '@/hooks/ui/useFlag'
const LayoutHeaderDivider = ({ className, ...props }: React.HTMLProps<HTMLSpanElement>) => (
<span className={cn('text-border-stronger pr-2', className)} {...props}>
@@ -59,7 +61,6 @@ interface LayoutHeaderProps {
customHeaderComponents?: ReactNode
breadcrumbs?: any[]
headerTitle?: string
- showProductMenu?: boolean
backToDashboardURL?: string
}
@@ -67,7 +68,6 @@ export const LayoutHeader = ({
customHeaderComponents,
breadcrumbs = [],
headerTitle,
- showProductMenu,
backToDashboardURL,
}: LayoutHeaderProps) => {
const router = useRouter()
@@ -76,6 +76,7 @@ export const LayoutHeader = ({
const { data: selectedOrganization } = useSelectedOrganizationQuery()
const gitlessBranching = useIsBranching2Enabled()
+ const showFloatingMobileToolbar = useIsFloatingMobileToolbarEnabled()
const connectSectionVariant = usePHFlag<ConnectSectionVariant | false>('connectSection')
const isConnectSheetEnabled = connectSectionVariant === 'connect'
@@ -102,7 +103,12 @@ export const LayoutHeader = ({
return (
<>
- <header className="flex h-11 md:h-12 items-center flex-shrink-0 border-b">
+ <header
+ className={cn(
+ 'flex h-11 md:h-12 items-center flex-shrink-0 border-b',
+ showFloatingMobileToolbar && 'hidden md:flex'
+ )}
+ >
{backToDashboardURL && isAccountPage && (
<div className="flex items-center justify-center border-r flex-0 md:hidden h-full aspect-square">
<Link
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LocalVersionPopover.test.ts b/apps/studio/components/layouts/Navigation/LayoutHeader/LocalVersionPopover.test.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/LocalVersionPopover.test.ts
rename to apps/studio/components/layouts/Navigation/LayoutHeader/LocalVersionPopover.test.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LocalVersionPopover.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/LocalVersionPopover.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/LocalVersionPopover.tsx
rename to apps/studio/components/layouts/Navigation/LayoutHeader/LocalVersionPopover.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/LocalVersionPopover.utils.ts b/apps/studio/components/layouts/Navigation/LayoutHeader/LocalVersionPopover.utils.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/LocalVersionPopover.utils.ts
rename to apps/studio/components/layouts/Navigation/LayoutHeader/LocalVersionPopover.utils.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MergeRequestButton.tsx b/apps/studio/components/layouts/Navigation/LayoutHeader/MergeRequestButton.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/MergeRequestButton.tsx
rename to apps/studio/components/layouts/Navigation/LayoutHeader/MergeRequestButton.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/CommandOption.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/CommandOption.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/CommandOption.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/CommandOption.tsx
diff --git a/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
new file mode 100644
index 00000000000..fde2b02f5df
--- /dev/null
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/MobileNavigationBar.tsx
@@ -0,0 +1,112 @@
+import { useParams } from 'common'
+import { useIsFloatingMobileToolbarEnabled } from 'components/interfaces/App/FeaturePreview/FeaturePreviewContext'
+import { ConnectButton } from 'components/interfaces/ConnectButton/ConnectButton'
+import { LocalDropdown } from 'components/interfaces/LocalDropdown'
+import { SidebarContent } from 'components/interfaces/Sidebar'
+import { UserDropdown } from 'components/interfaces/UserDropdown'
+import FloatingMobileToolbar from 'components/layouts/Navigation/FloatingMobileToolbar/FloatingMobileToolbar'
+import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
+import { IS_PLATFORM } from 'lib/constants'
+import { ChevronLeft, Menu, Search } from 'lucide-react'
+import Link from 'next/link'
+import { useState } from 'react'
+import { Button, cn } from 'ui'
+import { CommandMenuTrigger, MobileSheetNav } from 'ui-patterns'
+
+import { HomeIcon } from '../LayoutHeader/HomeIcon'
+import { useMobileSheet } from './MobileSheetContext'
+import { OrgSelector } from './OrgSelector'
+import { ProjectBranchSelector } from './ProjectBranchSelector'
+
+export const ICON_SIZE = 20
+export const ICON_STROKE_WIDTH = 1.5
+
+const MobileNavigationBar = ({
+ hideMobileMenu,
+ backToDashboardURL,
+}: {
+ hideMobileMenu?: boolean
+ backToDashboardURL?: string
+}) => {
+ const [isSheetOpen, setIsSheetOpen] = useState(false)
+ const showFloatingMobileToolbar = useIsFloatingMobileToolbarEnabled()
+ const { ref: projectRef, slug } = useParams()
+ const { data: selectedOrganization } = useSelectedOrganizationQuery()
+ const isProjectScope = !!projectRef
+ const showOrgSelection = slug || (selectedOrganization && projectRef)
+ const { openMenu } = useMobileSheet()
+
+ return (
+ <div className="w-full flex flex-row md:hidden">
+ <nav
+ className={cn(
+ 'group pr-3 pl-2 z-10 w-full h-12 gap-2',
+ 'border-b bg-dash-sidebar border-default shadow-[0_0_30px_0_rgba(0,0,0,0.07)]',
+ 'transition-width duration-200',
+ 'hide-scrollbar flex flex-row items-center justify-between overflow-x-auto'
+ )}
+ >
+ <div className={cn('flex min-w-0 flex-shrink items-center gap-2', !IS_PLATFORM && 'pl-2')}>
+ {showFloatingMobileToolbar && backToDashboardURL && (
+ <div className="flex items-center justify-center ml-1 flex-0 md:hidden h-full aspect-square">
+ <Link
+ href={backToDashboardURL}
+ className="flex items-center justify-center !bg-transparent rounded-md min-w-[30px] w-[30px] h-[30px] border text-foreground-lighter hover:text-foreground transition-colors"
+ >
+ <ChevronLeft strokeWidth={1.5} size={16} />
+ </Link>
+ </div>
+ )}
+ {!IS_PLATFORM && <HomeIcon />}
+ {isProjectScope ? (
+ <>
+ <ProjectBranchSelector />
+ <ConnectButton className="[&_span]:hidden h-8 w-8" />
+ </>
+ ) : IS_PLATFORM && showOrgSelection ? (
+ <OrgSelector />
+ ) : (
+ <HomeIcon className="ml-1" />
+ )}
+ </div>
+ <div className="flex flex-shrink-0 gap-2">
+ {!showFloatingMobileToolbar && (
+ <CommandMenuTrigger>
+ <button
+ type="button"
+ className={cn(
+ 'group',
+ 'flex-grow h-[30px] rounded-md',
+ 'p-2',
+ 'flex items-center justify-between',
+ 'bg-transparent border-none text-foreground-lighter',
+ 'hover:bg-opacity-100 hover:border-strong hover:text-foreground-light',
+ 'focus-visible:!outline-4 focus-visible:outline-offset-1 focus-visible:outline-brand-600',
+ 'transition'
+ )}
+ >
+ <Search size={18} strokeWidth={2} />
+ </button>
+ </CommandMenuTrigger>
+ )}
+ {IS_PLATFORM ? <UserDropdown /> : <LocalDropdown />}
+ {!hideMobileMenu && (
+ <Button
+ title="Menu dropdown button"
+ type="default"
+ className="flex lg:hidden border-default bg-surface-100/75 text-foreground-light rounded-md min-w-[30px] w-[30px] h-[30px] data-[state=open]:bg-overlay-hover/30"
+ icon={<Menu />}
+ onClick={() => openMenu()}
+ />
+ )}
+ </div>
+ </nav>
+ <MobileSheetNav open={isSheetOpen} onOpenChange={setIsSheetOpen} data-state="expanded">
+ <SidebarContent />
+ </MobileSheetNav>
+ {showFloatingMobileToolbar && <FloatingMobileToolbar hideMobileMenu={hideMobileMenu} />}
+ </div>
+ )
+}
+
+export default MobileNavigationBar
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileSheetContext.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/MobileSheetContext.tsx
similarity index 94%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileSheetContext.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/MobileSheetContext.tsx
index 336ae4b5a4a..52392aa2d97 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileSheetContext.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/MobileSheetContext.tsx
@@ -1,7 +1,7 @@
import type { PropsWithChildren, ReactNode } from 'react'
import { createContext, useCallback, useContext, useRef, useState } from 'react'
-import type { TYPEOF_SIDEBAR_KEYS } from '../LayoutSidebar/LayoutSidebarProvider'
+import type { TYPEOF_SIDEBAR_KEYS } from '../../ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
/**
* Sheet content: null = closed; sidebar id = one of SIDEBAR_KEYS; ReactNode = custom content (menu, search, etc.).
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileViewNav.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/MobileViewNav.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileViewNav.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/MobileViewNav.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/NavigationBar.utils.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationIconButton.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconButton.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/NavigationIconButton.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconLink.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/NavigationIconLink.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/NavigationIconLink.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/NavigationIconLink.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/OrgSelector.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/OrgSelector.tsx
similarity index 99%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/OrgSelector.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/OrgSelector.tsx
index 4537cec62d8..0cb34459ad7 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/OrgSelector.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/OrgSelector.tsx
@@ -1,4 +1,5 @@
import { useBreakpoint, useParams } from 'common'
+import { OrgCommandItem } from 'components/layouts/AppLayout/OrgCommandItem'
import { useOrganizationsQuery } from 'data/organizations/organizations-query'
import { useOrgProjectsInfiniteQuery } from 'data/projects/org-projects-infinite-query'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
@@ -25,8 +26,6 @@ import {
} from 'ui'
import { ShimmeringLoader } from 'ui-patterns/ShimmeringLoader'
-import { OrgCommandItem } from 'components/layouts/AppLayout/OrgCommandItem'
-
import { OrgSelectorSheet } from './OrgSelectorSheet'
export function OrgSelector() {
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/OrgSelectorSheet.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/OrgSelectorSheet.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/OrgSelectorSheet.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/OrgSelectorSheet.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelector.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelector.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelector.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelector.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelector.utils.test.ts b/apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelector.utils.test.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelector.utils.test.ts
rename to apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelector.utils.test.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelector.utils.ts b/apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelector.utils.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelector.utils.ts
rename to apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelector.utils.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorPopover.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorPopover.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorPopover.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorPopover.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorSheet.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorSheet.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorSheet.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorSheet.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorSheetTabTrigger.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorSheetTabTrigger.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorSheetTabTrigger.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorSheetTabTrigger.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorTrigger.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorTrigger.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/ProjectBranchSelectorTrigger.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/ProjectBranchSelectorTrigger.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/StudioMobileSheetNav.tsx b/apps/studio/components/layouts/Navigation/NavigationBar/StudioMobileSheetNav.tsx
similarity index 67%
rename from apps/studio/components/layouts/ProjectLayout/NavigationBar/StudioMobileSheetNav.tsx
rename to apps/studio/components/layouts/Navigation/NavigationBar/StudioMobileSheetNav.tsx
index d2f8f07e399..0b758db27bf 100644
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/StudioMobileSheetNav.tsx
+++ b/apps/studio/components/layouts/Navigation/NavigationBar/StudioMobileSheetNav.tsx
@@ -1,9 +1,12 @@
+import { CommandMenuInnerContent } from 'components/interfaces/App/CommandMenu/CommandMenu'
import type { ReactNode } from 'react'
import { sidebarManagerState, useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
-import { MobileSheetNav } from 'ui-patterns'
+import { CommandWrapper, MobileSheetNav } from 'ui-patterns'
-import { SIDEBAR_KEYS } from '../LayoutSidebar/LayoutSidebarProvider'
-import type { TYPEOF_SIDEBAR_KEYS } from '../LayoutSidebar/LayoutSidebarProvider'
+import {
+ SIDEBAR_KEYS,
+ type TYPEOF_SIDEBAR_KEYS,
+} from '../../ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
import type { MobileSheetContentType } from './MobileSheetContext'
import { useMobileSheet } from './MobileSheetContext'
@@ -19,6 +22,13 @@ function getSheetChildren(
activeSidebar: { id: string; component?: () => ReactNode } | null
): ReactNode {
if (content === null) return null
+ if (content === 'search') {
+ return (
+ <CommandWrapper className="h-full flex flex-col bg-background">
+ <CommandMenuInnerContent />
+ </CommandWrapper>
+ )
+ }
if (isSidebarId(content) && activeSidebar?.id === content) {
return activeSidebar.component?.() ?? null
}
@@ -39,7 +49,11 @@ const StudioMobileSheetNav = () => {
}
return (
- <MobileSheetNav open={content !== null} onOpenChange={handleOpenChange}>
+ <MobileSheetNav
+ open={content !== null}
+ onOpenChange={handleOpenChange}
+ shouldCloseOnViewportResize={!activeSidebar}
+ >
{sheetChildren}
</MobileSheetNav>
)
diff --git a/apps/studio/components/layouts/ProjectLayout/ProductMenuBar.tsx b/apps/studio/components/layouts/Navigation/ProductMenuBar.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/ProductMenuBar.tsx
rename to apps/studio/components/layouts/Navigation/ProductMenuBar.tsx
diff --git a/apps/studio/components/layouts/OrganizationLayout/useRegisterOrgMenu.tsx b/apps/studio/components/layouts/OrganizationLayout/useRegisterOrgMenu.tsx
index 4650986ed6b..7bd84bea29a 100644
--- a/apps/studio/components/layouts/OrganizationLayout/useRegisterOrgMenu.tsx
+++ b/apps/studio/components/layouts/OrganizationLayout/useRegisterOrgMenu.tsx
@@ -3,8 +3,8 @@
import { useRouter } from 'next/router'
import { useLayoutEffect } from 'react'
+import { useMobileSheet } from '../Navigation/NavigationBar/MobileSheetContext'
import { OrgMenuContent } from '../ProjectLayout/LayoutHeader/MobileMenuContent/OrgMenuContent'
-import { useMobileSheet } from '../ProjectLayout/NavigationBar/MobileSheetContext'
import { getPathnameWithoutQuery, isOrgMenuScope } from './OrganizationLayout.utils'
/**
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx
index 37cb8e129bb..d6bc1be057b 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutHeader/MobileMenuContent/MobileMenuContent.tsx
@@ -11,7 +11,7 @@ import {
generateProductRoutes,
generateSettingsRoutes,
generateToolRoutes,
-} from 'components/layouts/ProjectLayout/NavigationBar/NavigationBar.utils'
+} from 'components/layouts/Navigation/NavigationBar/NavigationBar.utils'
import type { Route } from 'components/ui/ui.types'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useSelectedProjectQuery } from 'hooks/misc/useSelectedProject'
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider.tsx
index a77795d82c4..63a0e5aad80 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider.tsx
@@ -1,4 +1,5 @@
import { LOCAL_STORAGE_KEYS } from 'common'
+import { getSupportLinkQueryParams } from 'components/ui/HelpPanel/HelpPanel.utils'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
import useLatest from 'hooks/misc/useLatest'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
@@ -10,8 +11,6 @@ import { parseAsString, useQueryState } from 'nuqs'
import { useEffect, type PropsWithChildren } from 'react'
import { useRegisterSidebar, useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
-import { getSupportLinkQueryParams } from '../LayoutHeader/HelpPanel/HelpPanel.utils'
-
const AdvisorPanel = dynamic(() =>
import('components/ui/AdvisorPanel/AdvisorPanel').then((m) => m.AdvisorPanel)
)
@@ -22,9 +21,7 @@ const EditorPanel = dynamic(() =>
import('components/ui/EditorPanel/EditorPanel').then((m) => m.EditorPanel)
)
const HelpPanel = dynamic(() =>
- import('components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel').then(
- (m) => m.HelpPanel
- )
+ import('components/ui/HelpPanel/HelpPanel').then((m) => m.HelpPanel)
)
export const SIDEBAR_KEYS = {
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.test.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.test.tsx
index 8872548186b..5c4e1924f2f 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.test.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.test.tsx
@@ -1,11 +1,11 @@
import { act, screen, waitFor } from '@testing-library/react'
+import { MobileSheetProvider } from 'components/layouts/Navigation/NavigationBar/MobileSheetContext'
import { sidebarManagerState } from 'state/sidebar-manager-state'
import { render } from 'tests/helpers'
import { routerMock } from 'tests/lib/route-mock'
import { ResizablePanel, ResizablePanelGroup } from 'ui'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
-import { MobileSheetProvider } from '../NavigationBar/MobileSheetContext'
import { LayoutSidebar } from './index'
import { LayoutSidebarProvider, SIDEBAR_KEYS } from './LayoutSidebarProvider'
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx
index 2f9ad556ac6..55f1e24eeb4 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/LayoutSidebar/index.tsx
@@ -1,12 +1,18 @@
import { useBreakpoint } from 'common'
+import { useMobileSheet } from 'components/layouts/Navigation/NavigationBar/MobileSheetContext'
import { useEffect } from 'react'
import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
import { cn, ResizableHandle, ResizablePanel } from 'ui'
-import { useMobileSheet } from '../NavigationBar/MobileSheetContext'
+import { SIDEBAR_KEYS, type TYPEOF_SIDEBAR_KEYS } from './LayoutSidebarProvider'
+
+function isSidebarId(content: unknown): content is TYPEOF_SIDEBAR_KEYS {
+ return (
+ typeof content === 'string' &&
+ Object.values(SIDEBAR_KEYS).includes(content as TYPEOF_SIDEBAR_KEYS)
+ )
+}
-// Having these params as props as otherwise it's quite hard to visually check the sizes in DefaultLayout
-// as react resizeable panels requires all these values to be valid to render correctly
interface LayoutSidebarProps {
minSize?: string | number
maxSize?: string | number
@@ -20,9 +26,8 @@ export const LayoutSidebar = ({
}: LayoutSidebarProps) => {
const { activeSidebar } = useSidebarManagerSnapshot()
const isMobile = useBreakpoint('md')
- const { setContent: setMobileSheetContent } = useMobileSheet()
+ const { content: sheetContent, setContent: setMobileSheetContent } = useMobileSheet()
- // On mobile, sidebar content is shown in the sheet. Sync sheet content with active sidebar; clear when none or when switching to desktop.
useEffect(() => {
if (!isMobile) {
setMobileSheetContent(null)
@@ -30,10 +35,10 @@ export const LayoutSidebar = ({
}
if (activeSidebar?.component) {
setMobileSheetContent(activeSidebar.id)
- } else {
+ } else if (isSidebarId(sheetContent)) {
setMobileSheetContent(null)
}
- }, [isMobile, activeSidebar, setMobileSheetContent])
+ }, [isMobile, activeSidebar, sheetContent, setMobileSheetContent])
if (!activeSidebar?.component) return null
if (isMobile) return null
diff --git a/apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileNavigationBar.tsx b/apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileNavigationBar.tsx
deleted file mode 100644
index 71baec35d12..00000000000
--- a/apps/studio/components/layouts/ProjectLayout/NavigationBar/MobileNavigationBar.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import { useParams } from 'common'
-import { ConnectButton } from 'components/interfaces/ConnectButton/ConnectButton'
-import { UserDropdown } from 'components/interfaces/UserDropdown'
-import { useSelectedOrganizationQuery } from 'hooks/misc/useSelectedOrganization'
-import { IS_PLATFORM } from 'lib/constants'
-import { Menu, Search } from 'lucide-react'
-import { Button, cn } from 'ui'
-import { CommandMenuTrigger } from 'ui-patterns'
-
-import { HomeIcon } from '../LayoutHeader/HomeIcon'
-import { useMobileSheet } from './MobileSheetContext'
-import { OrgSelector } from './OrgSelector'
-import { ProjectBranchSelector } from './ProjectBranchSelector'
-
-const MobileNavigationBar = ({ hideMobileMenu }: { hideMobileMenu?: boolean }) => {
- const { ref: projectRef, slug } = useParams()
- const { data: selectedOrganization } = useSelectedOrganizationQuery()
- const isProjectScope = !!projectRef
- const showOrgSelection = slug || (selectedOrganization && projectRef)
- const { openMenu } = useMobileSheet()
-
- return (
- <div className="w-full flex flex-row md:hidden">
- <nav
- className={cn(
- 'group pr-3 pl-2 z-10 w-full h-12 gap-2',
- 'border-b bg-dash-sidebar border-default shadow-xl',
- 'transition-width duration-200',
- 'hide-scrollbar flex flex-row items-center justify-between overflow-x-auto'
- )}
- >
- <div className={cn('flex min-w-0 flex-shrink items-center gap-2', !IS_PLATFORM && 'pl-2')}>
- {!IS_PLATFORM && <HomeIcon />}
- {isProjectScope ? (
- <>
- <ProjectBranchSelector />
- <ConnectButton className="[&_span]:hidden h-8 w-8" />
- </>
- ) : IS_PLATFORM && showOrgSelection ? (
- <OrgSelector />
- ) : (
- <HomeIcon className="ml-1" />
- )}
- </div>
- <div className="flex flex-shrink-0 gap-2">
- <CommandMenuTrigger>
- <button
- type="button"
- className={cn(
- 'group',
- 'flex-grow h-[30px] rounded-md',
- 'p-2',
- 'flex items-center justify-between',
- 'bg-transparent border-none text-foreground-lighter',
- 'hover:bg-opacity-100 hover:border-strong hover:text-foreground-light',
- 'focus-visible:!outline-4 focus-visible:outline-offset-1 focus-visible:outline-brand-600',
- 'transition'
- )}
- >
- <Search size={18} strokeWidth={2} />
- </button>
- </CommandMenuTrigger>
- <UserDropdown />
- {!hideMobileMenu && (
- <Button
- title="Menu dropdown button"
- type="default"
- className="flex lg:hidden border-default bg-surface-100/75 text-foreground-light rounded-md min-w-[30px] w-[30px] h-[30px] data-[state=open]:bg-overlay-hover/30"
- icon={<Menu />}
- onClick={() => openMenu()}
- />
- )}
- </div>
- </nav>
- </div>
- )
-}
-
-export default MobileNavigationBar
diff --git a/apps/studio/components/layouts/ProjectLayout/index.test.tsx b/apps/studio/components/layouts/ProjectLayout/index.test.tsx
index 588514e8b4f..8a65fa03165 100644
--- a/apps/studio/components/layouts/ProjectLayout/index.test.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/index.test.tsx
@@ -2,6 +2,8 @@ import { render, waitFor } from '@testing-library/react'
import type { ReactNode } from 'react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { MobileSheetProvider } from '../Navigation/NavigationBar/MobileSheetContext'
+import { ProjectLayout } from './index'
import { STUDIO_PAGE_TITLE_SEPARATOR } from '@/lib/page-title'
const { mockRouter, mockSetSelectedDatabaseId, mockSetMobileMenuOpen } = vi.hoisted(() => ({
@@ -158,9 +160,6 @@ vi.mock('@/state/database-selector', () => ({
}),
}))
-import { MobileSheetProvider } from './NavigationBar/MobileSheetContext'
-import { ProjectLayout } from './index'
-
describe('ProjectLayout title', () => {
beforeEach(() => {
mockRouter.pathname = '/project/[ref]/observability/query-performance'
diff --git a/apps/studio/components/layouts/ProjectLayout/index.tsx b/apps/studio/components/layouts/ProjectLayout/index.tsx
index adc3819fb7a..c2390a61933 100644
--- a/apps/studio/components/layouts/ProjectLayout/index.tsx
+++ b/apps/studio/components/layouts/ProjectLayout/index.tsx
@@ -22,17 +22,15 @@ import {
import { useEditorType } from '../editors/EditorsLayout.hooks'
import { useSetMainScrollContainer } from '../MainScrollContainerContext'
+import { useMobileSheet } from '../Navigation/NavigationBar/MobileSheetContext'
+import ProductMenuBar from '../Navigation/ProductMenuBar'
import BuildingState from './BuildingState'
import ConnectingState from './ConnectingState'
-import { getPathnameWithoutQuery } from '@/lib/pathname.utils'
-
import { getSectionKeyFromPathname, MobileMenuContent } from './LayoutHeader/MobileMenuContent'
import { LoadingState } from './LoadingState'
-import { useMobileSheet } from './NavigationBar/MobileSheetContext'
import { ProjectPausedState } from './PausedState/ProjectPausedState'
import { PauseFailedState } from './PauseFailedState'
import { PausingState } from './PausingState'
-import ProductMenuBar from './ProductMenuBar'
import { ResizingState } from './ResizingState'
import RestartingState from './RestartingState'
import { RestoreFailedState } from './RestoreFailedState'
@@ -47,6 +45,7 @@ import { useSelectedProjectQuery } from '@/hooks/misc/useSelectedProject'
import { withAuth } from '@/hooks/misc/withAuth'
import { PROJECT_STATUS } from '@/lib/constants'
import { buildStudioPageTitle } from '@/lib/page-title'
+import { getPathnameWithoutQuery } from '@/lib/pathname.utils'
import { useAppStateSnapshot } from '@/state/app-state'
import { useDatabaseSelectorStateSnapshot } from '@/state/database-selector'
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpButton.tsx b/apps/studio/components/ui/HelpPanel/HelpButton.tsx
similarity index 96%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpButton.tsx
rename to apps/studio/components/ui/HelpPanel/HelpButton.tsx
index c986e14a34c..fdab54fd2be 100644
--- a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpButton.tsx
+++ b/apps/studio/components/ui/HelpPanel/HelpButton.tsx
@@ -31,7 +31,7 @@ export const HelpButton = () => {
})
}
}}
- tooltip={{ content: { side: 'bottom', text: 'Help' } }}
+ tooltip={{ content: { text: 'Help' } }}
>
<HelpCircle
size={16}
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpOptionsList.tsx b/apps/studio/components/ui/HelpPanel/HelpOptionsList.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpOptionsList.tsx
rename to apps/studio/components/ui/HelpPanel/HelpOptionsList.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.constants.ts b/apps/studio/components/ui/HelpPanel/HelpPanel.constants.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.constants.ts
rename to apps/studio/components/ui/HelpPanel/HelpPanel.constants.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.tsx b/apps/studio/components/ui/HelpPanel/HelpPanel.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.tsx
rename to apps/studio/components/ui/HelpPanel/HelpPanel.tsx
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.utils.test.ts b/apps/studio/components/ui/HelpPanel/HelpPanel.utils.test.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.utils.test.ts
rename to apps/studio/components/ui/HelpPanel/HelpPanel.utils.test.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.utils.ts b/apps/studio/components/ui/HelpPanel/HelpPanel.utils.ts
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpPanel.utils.ts
rename to apps/studio/components/ui/HelpPanel/HelpPanel.utils.ts
diff --git a/apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpSection.tsx b/apps/studio/components/ui/HelpPanel/HelpSection.tsx
similarity index 100%
rename from apps/studio/components/layouts/ProjectLayout/LayoutHeader/HelpPanel/HelpSection.tsx
rename to apps/studio/components/ui/HelpPanel/HelpSection.tsx
diff --git a/apps/studio/public/img/previews/floating-toolbar-preview.png b/apps/studio/public/img/previews/floating-toolbar-preview.png
new file mode 100644
index 00000000000..c2563010b33
Binary files /dev/null and b/apps/studio/public/img/previews/floating-toolbar-preview.png differ
diff --git a/apps/studio/state/sidebar-manager-state.tsx b/apps/studio/state/sidebar-manager-state.tsx
index 2e88861e230..98bc39f188f 100644
--- a/apps/studio/state/sidebar-manager-state.tsx
+++ b/apps/studio/state/sidebar-manager-state.tsx
@@ -32,6 +32,7 @@ type SidebarManagerState = SidebarManagerData & {
closeSidebar: (id: string) => void
isSidebarOpen: (id: string) => boolean
closeActive: () => void
+ clearActiveSidebar: () => void
}
const INITIAL_SIDEBAR_MANAGER_DATA: SidebarManagerData = {
@@ -145,6 +146,10 @@ const createSidebarManagerState = () => {
state.activeSidebar?.onClose?.()
state.activeSidebar = undefined
},
+
+ clearActiveSidebar() {
+ state.activeSidebar = undefined
+ },
})
return state
diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.ts
index 98f168b4633..501365250c2 100644
--- a/packages/common/constants/local-storage.ts
+++ b/packages/common/constants/local-storage.ts
@@ -25,6 +25,7 @@ export const LOCAL_STORAGE_KEYS = {
UI_PREVIEW_QUEUE_OPERATIONS: 'supabase-ui-queue-operations',
UI_PREVIEW_TABLE_FILTER_BAR: 'supabase-ui-table-filter-bar',
UI_PREVIEW_PG_DELTA_DIFF: 'supabase-ui-pg-delta-diff',
+ UI_PREVIEW_FLOATING_MOBILE_TOOLBAR: 'supabase-ui-floating-mobile-toolbar',
UI_PREVIEW_PLATFORM_WEBHOOKS: 'supabase-ui-platform-webhooks',
NEW_LAYOUT_NOTICE_ACKNOWLEDGED: 'new-layout-notice-acknowledge',
diff --git a/packages/common/hooks/index.ts b/packages/common/hooks/index.ts
index 5f6e518e4ac..3d3b082f3d3 100644
--- a/packages/common/hooks/index.ts
+++ b/packages/common/hooks/index.ts
@@ -14,3 +14,4 @@ export * from './useParams'
export * from './useSearchParamsShallow'
export * from './useTelemetryCookie'
export * from './useThemeSandbox'
+export * from './useViewport'
diff --git a/packages/common/hooks/useViewport.ts b/packages/common/hooks/useViewport.ts
new file mode 100644
index 00000000000..42cd76f0f23
--- /dev/null
+++ b/packages/common/hooks/useViewport.ts
@@ -0,0 +1,22 @@
+'use client'
+
+import { useEffect, useState } from 'react'
+
+export type Viewport = { width: number; height: number }
+
+function getViewport(): Viewport {
+ if (typeof window === 'undefined') return { width: 0, height: 0 }
+ return { width: window.innerWidth, height: window.innerHeight }
+}
+
+export function useViewport(): Viewport {
+ const [viewport, setViewport] = useState<Viewport>(getViewport)
+
+ useEffect(() => {
+ const onResize = () => setViewport(getViewport())
+ window.addEventListener('resize', onResize)
+ return () => window.removeEventListener('resize', onResize)
+ }, [])
+
+ return viewport
+}
diff --git a/packages/ui-patterns/src/CommandMenu/api/CommandInput.tsx b/packages/ui-patterns/src/CommandMenu/api/CommandInput.tsx
index b6d0a68dea6..1eba66b280d 100644
--- a/packages/ui-patterns/src/CommandMenu/api/CommandInput.tsx
+++ b/packages/ui-patterns/src/CommandMenu/api/CommandInput.tsx
@@ -124,7 +124,7 @@ const CommandInput = forwardRef<
onCompositionStart={() => setImeComposing(true)}
onCompositionEnd={() => setImeComposing(false)}
className={cn(
- 'flex h-11 w-full rounded-md bg-transparent px-2 py-7 outline-none',
+ 'flex h-11 w-full rounded-md bg-transparent px-2 y-4 md:py-7 outline-none',
'focus:shadow-none focus:ring-transparent',
'text-base text-foreground-light placeholder:text-foreground-muted disabled:cursor-not-allowed disabled:opacity-50 border-0',
className
diff --git a/packages/ui-patterns/src/CommandMenu/internal/Command.tsx b/packages/ui-patterns/src/CommandMenu/internal/Command.tsx
index f7ce30bcb04..145a8f8f24f 100644
--- a/packages/ui-patterns/src/CommandMenu/internal/Command.tsx
+++ b/packages/ui-patterns/src/CommandMenu/internal/Command.tsx
@@ -20,7 +20,7 @@ const generateCommandClassNames = (isLink: boolean) =>
'rounded-md',
'text-sm',
'group',
- 'py-3',
+ 'py-2 md:py-3',
'text-foreground-light',
'relative',
'flex',