Skip to content

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

Add nav items

Terry Sutton0fa2fb115f6d
diff --git a/packages/ui/src/components/Command/Command.icons.tsx b/packages/ui/src/components/Command/Command.icons.tsx
new file mode 100644
index 00000000000..ccb75965b32
--- /dev/null
+++ b/packages/ui/src/components/Command/Command.icons.tsx
@@ -0,0 +1,46 @@
+import React from 'react'
+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 AiIconChat = () => (
+ <div
+ className="w-7 h-7
+ bg-gradient-to-r from-purple-900 to-purple-800
+
+ ring-purple-600
+ ring-1
+
+ 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>
+)
diff --git a/packages/ui/src/components/Command/Command.tsx b/packages/ui/src/components/Command/Command.tsx
index 121b3b55a33..29c7ea7ce28 100644
--- a/packages/ui/src/components/Command/Command.tsx
+++ b/packages/ui/src/components/Command/Command.tsx
@@ -28,23 +28,9 @@ import { IconCopy } from '../Icon/icons/IconCopy'
import DocsSearch from './DocsSearch'
import { useCommandMenu } from './CommandMenuProvider'
// import { SearchProvider } from './SearchProvider'
-
-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>
-)
+import navItems from './command-nav-items.json'
+import { NavItem } from './Command.types'
+import { AiIcon } from './Command.icons'
export const COMMAND_ROUTES = {
AI_HOME: 'Supabase AI',
@@ -55,43 +41,38 @@ export const COMMAND_ROUTES = {
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
-
- 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>
-)
-
interface IActions {
toggleTheme: () => void
}
-const ItemHandler = (props: any) => {
+const iconComponents = {
+ book: <IconBook />,
+}
+
+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 }) {
@@ -105,7 +86,7 @@ function CommandMenu({ actions }: { actions: IActions }) {
const ThemeOptions = ({ isSubItem = false }) => {
return (
<CommandGroup>
- <ItemHandler
+ <SearchOnlyItem
isSubItem={isSubItem}
onSelect={() => {
actions.toggleTheme()
@@ -113,8 +94,8 @@ function CommandMenu({ actions }: { actions: IActions }) {
}}
>
Change Theme to dark
- </ItemHandler>
- <ItemHandler
+ </SearchOnlyItem>
+ <SearchOnlyItem
isSubItem={isSubItem}
onSelect={() => {
actions.toggleTheme()
@@ -122,7 +103,28 @@ function CommandMenu({ actions }: { actions: IActions }) {
}}
>
Change Theme to light
- </ItemHandler>
+ </SearchOnlyItem>
+ </CommandGroup>
+ )
+ }
+
+ const SearchableChildItems = ({ isSubItem = false }) => {
+ return (
+ <CommandGroup>
+ {/* output only subItems */}
+ {navItems.items
+ .filter((item) => item.sites.includes('docs'))
+ .flatMap((item) => item.subItems)
+ .map((item) => (
+ <SearchOnlyItem
+ icon={item.icon}
+ label={item.label}
+ isSubItem={isSubItem}
+ onSelect={() => {
+ console.log('hay')
+ }}
+ />
+ ))}
</CommandGroup>
)
}
@@ -289,6 +291,7 @@ function CommandMenu({ actions }: { actions: IActions }) {
</CommandGroup>
<ThemeOptions isSubItem />
+ <SearchableChildItems isSubItem />
</>
)}
{page === 'docs-search' && (
diff --git a/packages/ui/src/components/Command/Command.types.ts b/packages/ui/src/components/Command/Command.types.ts
new file mode 100644
index 00000000000..476ebc3c504
--- /dev/null
+++ b/packages/ui/src/components/Command/Command.types.ts
@@ -0,0 +1,14 @@
+
+export interface NavItem {
+ label: string;
+ icon: string;
+ url: string;
+ sites: Site[];
+ subItems?: NavItem[];
+}
+
+export type Site = "docs" | "dashboard";
+
+export interface NavItems {
+ navItems: NavItem[];
+}
diff --git a/packages/ui/src/components/Command/command-nav-items.json b/packages/ui/src/components/Command/command-nav-items.json
new file mode 100644
index 00000000000..514dac78116
--- /dev/null
+++ b/packages/ui/src/components/Command/command-nav-items.json
@@ -0,0 +1,48 @@
+{
+ "items": [
+ {
+ "label": "Home",
+ "icon": "home",
+ "url": "http://www.example.com/home",
+ "sites": ["docs", "dashboard"],
+ "subItems": [
+ {
+ "label": "About",
+ "icon": "book",
+ "url": "http://www.example.com/about",
+ "sites": ["docs", "dashboard"]
+ },
+ {
+ "label": "Services",
+ "icon": "services",
+ "url": "http://www.example.com/services",
+ "sites": ["docs", "dashboard"]
+ },
+ {
+ "label": "Contact",
+ "icon": "contact",
+ "url": "http://www.example.com/contact",
+ "sites": ["docs", "dashboard"]
+ }
+ ]
+ },
+ {
+ "label": "Products",
+ "icon": "products",
+ "url": "http://www.example.com/products",
+ "sites": ["dashboard"],
+ "subItems": [
+ {
+ "label": "Mobile",
+ "icon": "mobile",
+ "url": "http://www.example.com/products/mobile"
+ },
+ {
+ "label": "In person",
+ "icon": "person",
+ "url": "http://www.example.com/products/in-person"
+ }
+ ]
+ }
+ ]
+}