Skip to content

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

feat(sql-editor): styled ai input

Greg Richardsone1e70fc75a12
diff --git a/packages/ui/src/components/Command/Command.icons.tsx b/packages/ui/src/components/Command/Command.icons.tsx
index 9d0914765b0..c8b179552ac 100644
--- a/packages/ui/src/components/Command/Command.icons.tsx
+++ b/packages/ui/src/components/Command/Command.icons.tsx
@@ -4,9 +4,9 @@ interface AiIconProps {
className?: string
}
-export const AiIcon = ({ className = 'text-brand-900' }: AiIconProps) => (
+export const AiIcon = ({ className = 'text-brand-900 w-6 h-6' }: AiIconProps) => (
<svg
- className={`w-6 h-6 ${className}`}
+ className={className}
width="16"
height="16"
viewBox="0 0 16 16"
@@ -15,14 +15,14 @@ export const AiIcon = ({ className = 'text-brand-900' }: AiIconProps) => (
>
<path
d="M9.7003 13.379L8.33022 14.9739C7.99629 15.3626 7.35899 15.1265 7.35899 14.614V10.2188L2.13597 10.2188C1.20712 10.2189 0.693015 9.14211 1.277 8.4198L7.24456 1.03867C7.5719 0.633801 8.22633 0.865262 8.22633 1.3859V5.71008H13.7967C14.7348 5.71008 15.2458 6.80561 14.6431 7.52442L14.1628 8.09707"
- stroke="#4CC38A"
+ stroke="currentColor"
stroke-miterlimit="10"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M12.2534 14.3848L12.5765 13.4148C12.7202 12.9836 12.9624 12.5917 13.2839 12.2702C13.6053 11.9488 13.9972 11.7066 14.4285 11.5628L15.3984 11.2398C15.5808 11.179 15.5808 10.921 15.3984 10.8603L14.4285 10.5372C13.9972 10.3935 13.6053 10.1513 13.2839 9.8298C12.9624 9.50834 12.7202 9.11646 12.5765 8.68518L12.2534 7.71525C12.1927 7.53285 11.9347 7.53285 11.8739 7.71525L11.5509 8.68518C11.4071 9.11646 11.1649 9.50834 10.8435 9.8298C10.522 10.1513 10.1301 10.3935 9.69885 10.5372L8.72892 10.8603C8.54652 10.921 8.54652 11.179 8.72892 11.2398L9.69885 11.5628C10.1301 11.7066 10.522 11.9488 10.8435 12.2702C11.1649 12.5917 11.4071 12.9836 11.5509 13.4148L11.8739 14.3848C11.9347 14.5672 12.1927 14.5672 12.2534 14.3848Z"
- fill="#4CC38A"
+ fill="currentColor"
/>
</svg>
)
diff --git a/packages/ui/src/components/Input/Input.tsx b/packages/ui/src/components/Input/Input.tsx
index 93a5b0fbd60..afeab84387e 100644
--- a/packages/ui/src/components/Input/Input.tsx
+++ b/packages/ui/src/components/Input/Input.tsx
@@ -14,6 +14,8 @@ import { useFormContext } from '../Form/FormContext'
export interface Props
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'size' | 'onCopy'> {
+ inputClassName?: string
+ iconContainerClassName?: string
copy?: boolean
onCopy?: () => void
defaultValue?: string | number
@@ -38,6 +40,8 @@ function Input({
autoComplete,
autoFocus,
className,
+ inputClassName,
+ iconContainerClassName,
copy,
defaultValue,
descriptionText,
@@ -124,13 +128,14 @@ function Input({
setHidden(false)
}
- let inputClasses = [__styles.base]
+ let inputClasses = ['peer/input', __styles.base]
if (error) inputClasses.push(__styles.variants.error)
if (!error) inputClasses.push(__styles.variants.standard)
if (icon) inputClasses.push(__styles.with_icon)
if (size) inputClasses.push(__styles.size[size])
if (disabled) inputClasses.push(__styles.disabled)
+ if (inputClassName) inputClasses.push(inputClassName)
return (
<FormLayout
@@ -164,7 +169,7 @@ function Input({
className={inputClasses.join(' ')}
{...props}
/>
- {icon && <InputIconContainer icon={icon} />}
+ {icon && <InputIconContainer icon={icon} className={iconContainerClassName} />}
{copy || error || actions ? (
<div className={__styles.actions_container}>
{error && <InputErrorIcon size={size} />}
diff --git a/packages/ui/src/lib/Layout/InputIconContainer.tsx b/packages/ui/src/lib/Layout/InputIconContainer.tsx
index 8d28954e605..93c36d0f8fd 100644
--- a/packages/ui/src/lib/Layout/InputIconContainer.tsx
+++ b/packages/ui/src/lib/Layout/InputIconContainer.tsx
@@ -1,7 +1,8 @@
import React from 'react'
import styleHandler from '../theme/styleHandler'
+import { cn } from '../utils'
-export default function InputIconContainer({ icon }: any) {
+export default function InputIconContainer({ icon, className }: any) {
const __styles = styleHandler('inputIconContainer')
- return <div className={__styles.base}>{icon}</div>
+ return <div className={cn(__styles.base, className)}>{icon}</div>
}
diff --git a/studio/components/interfaces/SQLEditor/SQLEditor.tsx b/studio/components/interfaces/SQLEditor/SQLEditor.tsx
index a5485343771..9525ed25b5a 100644
--- a/studio/components/interfaces/SQLEditor/SQLEditor.tsx
+++ b/studio/components/interfaces/SQLEditor/SQLEditor.tsx
@@ -1,13 +1,15 @@
import { useParams } from 'common'
import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'
+import { useExecuteSqlMutation } from 'data/sql/execute-sql-mutation'
+import { useLocalStorage } from 'hooks'
+import useLatest from 'hooks/misc/useLatest'
+import { detectOS } from 'lib/helpers'
import { useCallback, useRef } from 'react'
import Split from 'react-split'
import { getSqlEditorStateSnapshot, useSqlEditorStateSnapshot } from 'state/sql-editor'
-import { useExecuteSqlMutation } from 'data/sql/execute-sql-mutation'
-import useLatest from 'hooks/misc/useLatest'
+import { AiIcon, IconCornerDownLeft, Input } from 'ui'
import MonacoEditor, { IStandaloneCodeEditor } from './MonacoEditor'
import UtilityPanel from './UtilityPanel/UtilityPanel'
-import { useLocalStorage } from 'hooks'
const SQLEditor = () => {
const { ref, id } = useParams()
@@ -66,8 +68,41 @@ const SQLEditor = () => {
}
}, [isExecuting, project])
+ const os = detectOS()
+
return (
<div className="flex h-full flex-col">
+ <Input
+ size="xlarge"
+ icon={<AiIcon className="w-4 h-4 ml-1" />}
+ inputClassName="bg-transparent rounded-none focus:border-brand-900"
+ iconContainerClassName="transition text-scale-800 peer-focus/input:text-brand-900"
+ placeholder="Generate & edit SQL using Supabase AI..."
+ actions={
+ <div className="flex items-center space-x-1 mr-6">
+ {os === 'macos' ? (
+ <svg
+ width="16"
+ height="16"
+ viewBox="0 0 24 24"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M3 5H7.76472L16.2353 19H21M16.2353 5H21"
+ stroke="currentColor"
+ stroke-width="1.5"
+ stroke-linecap="square"
+ stroke-linejoin="round"
+ />
+ </svg>
+ ) : (
+ <p className="text-xs text-scale-1100">ALT</p>
+ )}
+ <IconCornerDownLeft size={16} strokeWidth={1.5} />
+ </div>
+ }
+ />
<Split
style={{ height: '100%' }}
direction="vertical"
@@ -91,7 +126,6 @@ const SQLEditor = () => {
/>
)}
</div>
-
<div className="flex flex-col">
{isLoading ? (
<div className="flex h-full w-full items-center justify-center">Loading...</div>