Files
supabase/apps/studio/components/layouts/AppLayout/InlineEditorButton.tsx
T
Francesco Sansalvadore 9145470ff6 feat(studio): mobile sheet nav (#43184)
- use `MobileSheetNav` for all `LayoutSidebar` panels on mobile viewport
- move `Help` to LayoutSidepanel for a more cohesive experience
- enables opening the help panel using params `?sidebar=help-panel`

https://github.com/user-attachments/assets/a84e56f0-f2e2-4217-89a2-ba895bb7d352
2026-02-27 12:06:27 +00:00

52 lines
1.6 KiB
TypeScript

import { LOCAL_STORAGE_KEYS } from 'common'
import { SIDEBAR_KEYS } from 'components/layouts/ProjectLayout/LayoutSidebar/LayoutSidebarProvider'
import { ButtonTooltip } from 'components/ui/ButtonTooltip'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
import { SqlEditor } from 'icons'
import { useSidebarManagerSnapshot } from 'state/sidebar-manager-state'
import { cn, KeyboardShortcut } from 'ui'
const InlineEditorKeyboardTooltip = () => {
const [hotkeyEnabled] = useLocalStorageQuery(
LOCAL_STORAGE_KEYS.HOTKEY_SIDEBAR(SIDEBAR_KEYS.EDITOR_PANEL),
true
)
return hotkeyEnabled ? <KeyboardShortcut keys={['Meta', 'E']} /> : null
}
export const InlineEditorButton = () => {
const { activeSidebar, toggleSidebar } = useSidebarManagerSnapshot()
const isOpen = activeSidebar?.id === SIDEBAR_KEYS.EDITOR_PANEL
const handleClick = () => {
toggleSidebar(SIDEBAR_KEYS.EDITOR_PANEL)
}
return (
<ButtonTooltip
type="outline"
size="tiny"
id="editor-trigger"
className={cn(
'rounded-full w-[32px] h-[32px] flex items-center justify-center p-0 text-foreground-light hover:text-foreground',
isOpen && 'bg-foreground text-background hover:text-background'
)}
onClick={handleClick}
tooltip={{
content: {
className: 'p-1 pl-2.5',
text: (
<div className="flex items-center gap-2.5">
<span>SQL Editor</span>
<InlineEditorKeyboardTooltip />
</div>
),
},
}}
>
<SqlEditor size={16} strokeWidth={1.5} />
</ButtonTooltip>
)
}