The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add tabs and key nav to the examples page
Terry Sutton093b4db48e2b
diff --git a/packages/ui/src/components/Command/AiCommand.tsx b/packages/ui/src/components/Command/AiCommand.tsxindex 5e816dd7d53..ec6a4638ab5 100644--- a/packages/ui/src/components/Command/AiCommand.tsx+++ b/packages/ui/src/components/Command/AiCommand.tsx@@ -1,3 +1,4 @@+import React from 'react'import type {ChatCompletionResponseMessage,CreateChatCompletionResponse,diff --git a/packages/ui/src/components/Command/Command.constants.ts b/packages/ui/src/components/Command/Command.constants.tsindex c2fcfee925a..0acab15843d 100644--- a/packages/ui/src/components/Command/Command.constants.ts+++ b/packages/ui/src/components/Command/Command.constants.ts@@ -17,7 +17,7 @@ type SampleQueries = QueryCategory[]export const SAMPLE_QUERIES: SampleQueries = [{- category: 'Create tables',+ category: 'Tables',queries: ['Create a table that stores a list of cities, and insert 10 rows of sample data into it','Create tables (with foreign key relationships) for blog posts and comments',@@ -25,7 +25,7 @@ export const SAMPLE_QUERIES: SampleQueries = [],},{- category: 'Create views',+ category: 'Views',queries: ['Create a view that shows the total revenue for each customer','Create a view that shows all orders that were placed in the last week',@@ -34,7 +34,7 @@ export const SAMPLE_QUERIES: SampleQueries = [],},{- category: 'Create indexes',+ category: 'Indexes',queries: ['Create an index on the primary key column of my orders table','Create a partial index on the orders table:',@@ -42,7 +42,7 @@ export const SAMPLE_QUERIES: SampleQueries = [],},{- category: 'Select data',+ category: 'Select',queries: ['Retrieve a list of employees from the employees table who have a salary greater than $50,000','Retrieve a list of all employees with the title "Manager" from the employees table',@@ -51,7 +51,7 @@ export const SAMPLE_QUERIES: SampleQueries = [],},{- category: 'Create triggers',+ category: 'Triggers',queries: ['Create a trigger that updates the updated_at column on the orders table with the current time when the row of the orders table is updated','Create a trigger to add a new user to the users table when someone new registers',@@ -60,7 +60,7 @@ export const SAMPLE_QUERIES: SampleQueries = [],},{- category: 'Row level security',+ category: 'Row Level Security',queries: ['Create an RLS policy that grants only authenticated access to the profiles table','Create an RLS policy that grants SELECT access to the sales_rep role for the customers table, but denies access to all other roles',@@ -68,7 +68,7 @@ export const SAMPLE_QUERIES: SampleQueries = [],},{- category: 'Postgres functions',+ category: 'Functions',queries: ["Create a function to add a new entry to a user's table when a new user signs up",'Create an a function to calculate the average price of a product in a given category',diff --git a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsxindex 0f50c348df9..7d89aba5bed 100644--- a/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx+++ b/packages/ui/src/components/Command/GenerateSQL/GenerateSQL.tsx@@ -12,6 +12,7 @@ import {MessageRole,MessageStatus,useAiChat,+ Tabs,} from 'ui'import { cn } from '../../../utils/cn'@@ -174,78 +175,47 @@ const GenerateSQL = () => {{messages.length === 0 && !hasError && (<div>- <div className="px-10">- <h3>+ <div className="px-4">+ <h3 className="text-base text-scale-1100">Describe what you need and Supabase AI will try to generate the relevant SQLstatements</h3><p className="text-sm mt-1 text-scale-1100">- Here are some example prompts to try out.+ Here are some example prompts to try out:</p></div>- <div className="flex mt-4 border-t pt-2">- <div className="w-1/3 py-4 px-6">- <ul className="space-y-2">- {SAMPLE_QUERIES.map((item, index) => (- <li key={index}>- <button- className={cn(- 'px-4 py-1 cursor-pointer text-sm hover:bg-slate-300 rounded-md block w-full text-left',- selectedCategory === item.category && 'bg-slate-400 '- )}- type="button"- onClick={() => setSelectedCategory(item.category)}- onKeyDown={(e) => handleKeypress(e, item.category)}- >- {item.category}- </button>- </li>- ))}- </ul>- </div>- <div className="w-2/3 py-4 px-6">- <ul>- {SAMPLE_QUERIES.find((item) => item.category === selectedCategory)?.queries.map(- (query, index) => (- <button- onClick={() => {- if (!search) {+ <div className="mt-4 border-t pt-4 ml-4">+ <Tabs type="rounded-pills" size="small">+ {SAMPLE_QUERIES.map((sample) => (+ <Tabs.Panel+ key={sample.category}+ id={sample.category}+ label={sample.category}+ className="mt-4"+ >+ {SAMPLE_QUERIES.find((item) => item.category === sample.category)?.queries.map(+ (query) => (+ <CommandItem+ type="command"+ onSelect={() => {handleSubmit(query)- }- }}- key={query.replace(/\s+/g, '_')}- type="button"- >- <div className="flex">- <div>- <AiIcon />+ }}+ onKeyDown={(e) => e.keyCode === 13 && handleSubmit(query)}+ forceMount+ key={query.replace(/\s+/g, '_')}+ >+ <div className="flex">+ <div>+ <AiIcon />+ </div>+ <p>{query}</p></div>- {query}- </div>- </button>- // <CommandItem- // type="command"- // onSelect={() => {- // if (!search) {- // handleSubmit(query)- // }- // }}- // forceMount- // key={query.replace(/\s+/g, '_')}- // >- // <div className="flex">- // <div>- // <AiIcon />- // </div>- // <p>- // <button type="button">{query}</button>- // </p>- // </div>- // </CommandItem>- )- )}- </ul>- </div>+ </CommandItem>+ )+ )}+ </Tabs.Panel>+ ))}+ </Tabs></div></div>)}