Skip to content

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

Merge branch 'feat/cmdk-2' of github.com:supabase/supabase into feat/cmdk-2

Terry Sutton2e10e678f50a
diff --cc packages/ui/src/components/Command/AiCommand.tsx
index 0863698bd6f,c8dfcdf1e67..8b7a30769fd
--- a/packages/ui/src/components/Command/AiCommand.tsx
+++ b/packages/ui/src/components/Command/AiCommand.tsx
@@@ -119,9 -104,9 +104,9 @@@ function promptDataReducer
throw Error('Unknown action.')
}
- interface IAiCommand {
+ export interface AiCommandProps {
query?: string
- setQuery?: () => void
+ setQuery?: (query: string) => void
page?: string
}
diff --cc packages/ui/src/components/Command/CommandMenu.tsx
index 2afb72f19f9,a1b0d65b22f..e08b0f00095
--- a/packages/ui/src/components/Command/CommandMenu.tsx
+++ b/packages/ui/src/components/Command/CommandMenu.tsx
@@@ -10,30 -14,30 +14,19 @@@ import
CommandGroup,
CommandInput,
CommandItem,
- CommandItemStale,
CommandLabel,
CommandList,
- CommandSeparator,
CommandShortcut,
} from './Command.utils'
- import { IconCloudDrizzle } from '../Icon/icons/IconCloudDrizzle'
- import { IconBook } from '../Icon/icons/IconBook'
- import { IconInbox } from '../Icon/icons/IconInbox'
- import { IconMonitor } from '../Icon/icons/IconMonitor'
- import { Input } from '../Input'
- import { AiCommand } from './AiCommand'
- import { IconSun } from '../Icon/icons/IconSun'
- import { IconMoon } from '../Icon/icons/IconMoon'
- import { IconCopy } from '../Icon/icons/IconCopy'
- import DocsSearch from './DocsSearch'
import { useCommandMenu } from './CommandMenuProvider'
+// import { SearchProvider } from './SearchProvider'
+import navItems from './command-nav-items.json'
+import { NavItem } from './Command.types'
+import { AiIcon } from './Command.icons'
+import { IconArrowRight } from '../Icon/icons/IconArrowRight'
+import { IconLifeBuoy } from '../Icon/icons/IconLifeBuoy'
+ import DocsSearch from './DocsSearch'
-export const AiIcon = () => (
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 24 24"
- strokeWidth="1.5"
- stroke="currentColor"
- className="w-6 h-6 text-purple-900"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"
- />
- </svg>
-)
-
export const COMMAND_ROUTES = {
AI_HOME: 'Supabase AI',
AI_ASK_ANYTHING: 'Ask me anything',
@@@ -43,43 -47,43 +36,42 @@@
const AI_CHAT_ROUTES = [COMMAND_ROUTES.AI_ASK_ANYTHING, COMMAND_ROUTES.AI_RLS_POLICY]
-export const AiIconChat = () => (
- <div
- className="w-7 h-7
- bg-gradient-to-r from-purple-900 to-purple-800
-
- ring-purple-600
- ring-1
+interface IActions {
+ toggleTheme: () => void
+}
- rounded-md border border-purple-400 flex items-center justify-center
- shadow-sm
- "
- >
- <svg
- xmlns="http://www.w3.org/2000/svg"
- fill="none"
- viewBox="0 0 24 24"
- strokeWidth="1.5"
- stroke="currentColor"
- className="w-4 h-4 text-white"
- >
- <path
- strokeLinecap="round"
- strokeLinejoin="round"
- d="M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z"
- />
- </svg>
- </div>
-)
+const iconComponents = {
+ book: <IconBook />,
+}
-const ItemHandler = (props: any) => {
+const SearchOnlyItem = (props: any) => {
+ const icon = iconComponents[props.icon]
+ console.log('props', props)
const search = useCommandState((state) => state.search)
+ // if search is empty & items is marked as a subItem, don't show it
+ // ie: only show these items in search results, not top level
if (!search && props.isSubItem) return null
- return <CommandItem {...props} />
+ return <CommandItem>{props.label}</CommandItem>
+}
+
+// <CommandItem onSelect={() => handleSetPages([...pages, 'Docs Search'], true)} forceMount>
+// <IconBook className="" />
+
+// <span>
+// Search the docs...
+// <span className="text-scale-1200 font-semibold">{search}</span>
+// </span>
+// </CommandItem>
+
+{
+ /* <CommandItem>
+ <IconInbox className="text-scale-900" />
+ <CommandLabel>See what's new</CommandLabel>
+</CommandItem> */
}
- function CommandMenu({ actions }: { actions: IActions }) {
+ const CommandMenu = () => {
const [search, setSearch] = React.useState('')
- const [aiSearch, setAiSearch] = React.useState('')
const [pages, setPages] = React.useState([])
const page = pages[pages.length - 1]
const router = useRouter()
@@@ -88,19 -92,19 +80,19 @@@
const ThemeOptions = ({ isSubItem = false }) => {
return (
<CommandGroup>
- <ItemHandler
+ <SearchOnlyItem
isSubItem={isSubItem}
onSelect={() => {
- actions.toggleTheme()
+ actions.toggleTheme(true)
setIsOpen(false)
}}
>
Change Theme to dark
- </ItemHandler>
- <ItemHandler
+ </SearchOnlyItem>
+ <SearchOnlyItem
isSubItem={isSubItem}
onSelect={() => {
- actions.toggleTheme()
+ actions.toggleTheme(false)
setIsOpen(false)
}}
>