Skip to content

Commit ddd1dbc

Browse files
Studio: add CommandMenu trigger in top nav (supabase#40011)
* add CommandMenuTriggerInput in top nav in studio * uniform command trigger in top nav
1 parent be5e8b2 commit ddd1dbc

File tree

7 files changed

+41
-20
lines changed

7 files changed

+41
-20
lines changed

apps/studio/components/interfaces/UserDropdown.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,6 @@ export function UserDropdown() {
101101
<FlaskConical size={14} strokeWidth={1.5} className="text-foreground-lighter" />
102102
Feature previews
103103
</DropdownMenuItem>
104-
<DropdownMenuItem className="flex gap-2" onClick={handleCommandMenuOpen}>
105-
<Command size={14} strokeWidth={1.5} className="text-foreground-lighter" />
106-
Command menu
107-
</DropdownMenuItem>
108104
<DropdownMenuSeparator />
109105
</DropdownMenuGroup>
110106
</>

apps/studio/components/layouts/AppLayout/AssistantButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ export const AssistantButton = () => {
2929
}}
3030
tooltip={{
3131
content: {
32+
className: 'p-1 pl-2.5',
3233
text: (
33-
<div className="flex items-center gap-4">
34+
<div className="flex items-center gap-2.5">
3435
<span>AI Assistant</span>
35-
{isAIAssistantHotkeyEnabled && <KeyboardShortcut keys={['Meta', 'i']} />}
36+
{isAIAssistantHotkeyEnabled && <KeyboardShortcut keys={['Meta', 'I']} />}
3637
</div>
3738
),
3839
},

apps/studio/components/layouts/AppLayout/InlineEditorButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const InlineEditorKeyboardTooltip = () => {
1212
true
1313
)
1414

15-
return hotkeyEnabled ? <KeyboardShortcut keys={['Meta', 'e']} /> : null
15+
return hotkeyEnabled ? <KeyboardShortcut keys={['Meta', 'E']} /> : null
1616
}
1717

1818
export const InlineEditorButton = () => {
@@ -35,8 +35,9 @@ export const InlineEditorButton = () => {
3535
onClick={handleClick}
3636
tooltip={{
3737
content: {
38+
className: 'p-1 pl-2.5',
3839
text: (
39-
<div className="flex items-center gap-4">
40+
<div className="flex items-center gap-2.5">
4041
<span>SQL Editor</span>
4142
<InlineEditorKeyboardTooltip />
4243
</div>

apps/studio/components/layouts/ProjectLayout/LayoutHeader/LayoutHeader.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { HomeIcon } from './HomeIcon'
2828
import { LocalVersionPopover } from './LocalVersionPopover'
2929
import MergeRequestButton from './MergeRequestButton'
3030
import { AdvisorButton } from 'components/layouts/AppLayout/AdvisorButton'
31+
import { CommandMenuTriggerInput } from 'ui-patterns'
3132

3233
const LayoutHeaderDivider = ({ className, ...props }: React.HTMLProps<HTMLSpanElement>) => (
3334
<span className={cn('text-border-stronger pr-2', className)} {...props}>
@@ -208,7 +209,16 @@ export const LayoutHeader = ({
208209
<>
209210
<FeedbackDropdown />
210211

211-
<div className="overflow-hidden flex items-center gap-2">
212+
<div className="flex items-center gap-2">
213+
<CommandMenuTriggerInput
214+
placeholder="Search..."
215+
className="hidden md:flex md:min-w-32 xl:min-w-32 rounded-full bg-transparent
216+
[&_.command-shortcut>div]:border-none
217+
[&_.command-shortcut>div]:pr-2
218+
[&_.command-shortcut>div]:bg-transparent
219+
[&_.command-shortcut>div]:text-foreground-lighter
220+
"
221+
/>
212222
<HelpPopover />
213223
<AdvisorButton projectRef={projectRef} />
214224
<AnimatePresence initial={false}>
@@ -225,7 +235,16 @@ export const LayoutHeader = ({
225235
) : (
226236
<>
227237
<LocalVersionPopover />
228-
<div className="overflow-hidden flex items-center gap-2">
238+
<div className="flex items-center gap-2">
239+
<CommandMenuTriggerInput
240+
placeholder="Search..."
241+
className="hidden md:flex md:min-w-32 xl:min-w-32 rounded-full bg-transparent
242+
[&_.command-shortcut>div]:border-none
243+
[&_.command-shortcut>div]:pr-2
244+
[&_.command-shortcut>div]:bg-transparent
245+
[&_.command-shortcut>div]:text-foreground-lighter
246+
"
247+
/>
229248
<AdvisorButton projectRef={projectRef} />
230249
<AnimatePresence initial={false}>
231250
{!!projectRef && (

apps/studio/lib/profile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export function useProfileNameAndPicture(): {
130130
const { data: identitiesData, isLoading: isLoadingIdentities } = useProfileIdentitiesQuery()
131131

132132
const username = profile?.username
133-
const isGitHubProfile = profile?.auth0_id.startsWith('github')
133+
const isGitHubProfile = profile?.auth0_id?.startsWith('github')
134134

135135
const gitHubUsername = isGitHubProfile
136136
? identitiesData?.identities.find((x) => x.provider === 'github')?.identity_data?.user_name

packages/ui-patterns/src/CommandMenu/api/CommandMenu.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ function CommandMenuTrigger({ children }: PropsWithChildren) {
157157
'inline-flex items-center justify-center',
158158
'whitespace-nowrap',
159159
'rounded-md border border-input bg-background',
160-
'text-sm font-medium',
160+
'text-sm',
161161
'hover:bg-accent hover:text-accent-foreground',
162162
'ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2',
163163
'disabled:pointer-events-none disabled:opacity-50',
@@ -185,15 +185,19 @@ function CommandMenuTriggerInput({
185185
'pl-1.5 md:pl-2 pr-1',
186186
'flex items-center justify-between',
187187
'bg-surface-100/75 text-foreground-lighter border',
188-
'hover:bg-opacity-100 hover:border-strong',
189-
'focus-visible:!outline-4 focus-visible:outline-offset-1 focus-visible:outline-brand-600',
188+
'hover:bg-opacity-100 hover:border-stronger',
189+
'focus-visible:outline-none focus-visible:ring-4 focus-visible:ring-border-strong focus-visible:ring-offset-1 focus-visible:ring-offset-background',
190190
'transition',
191191
className
192192
)}
193193
>
194-
<div className="flex items-center space-x-2 text-foreground-muted">
195-
<Search size={18} strokeWidth={2} />
196-
<p className="flex text-sm pr-2">{placeholder}</p>
194+
<div className="flex items-center space-x-1.5 text-foreground-lighter">
195+
<Search
196+
size={16}
197+
strokeWidth={1.5}
198+
className="group-hover:text-foreground-light transition-colors"
199+
/>
200+
<p className="flex text-sm pr-2 text-foreground-muted">{placeholder}</p>
197201
</div>
198202
<div className="command-shortcut hidden md:flex items-center space-x-1">
199203
<div

packages/ui/src/components/KeyboardShortcut/KeyboardShortcut.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ export const KeyboardShortcut = ({ keys }: { keys: string[] }) => {
2323
{keysWithMetaAndShift.map((key) => (
2424
<span
2525
className={cn(
26-
['⌘', 'Shift', 'Ctrl'].includes(key) ? 'px-1.5 py-0.5' : 'w-[23px] h-[23px]',
27-
'border border-b-2 border-foreground-lightest',
28-
'rounded-sm flex items-center justify-center cursor-default'
26+
['Shift', 'Ctrl'].includes(key) ? 'px-1.5 py-0.5' : 'w-[23px] h-[23px]',
27+
'border border-foreground-lightest',
28+
'rounded flex items-center justify-center cursor-default'
2929
)}
3030
key={key}
3131
>

0 commit comments

Comments
 (0)