Skip to content

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

Show dropdown caret on SQL Snippets on hover instead of having to click on them first

Terry Sutton6199c56372b7
diff --git a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx b/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
index a655aff998a..c8539c5e9b3 100644
--- a/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
+++ b/studio/components/layouts/SQLEditorLayout/QueryItem.tsx
@@ -38,7 +38,7 @@ const QueryItem = ({ tabInfo }: QueryItemProps) => {
key={id}
className={clsx(
'flex items-center justify-between rounded-md group',
- isActive && 'text-scale-1200 bg-scale-400 dark:bg-scale-300 -active'
+ isActive && 'text-scale-1200 bg-scale-400 dark:bg-scale-600 -active'
)}
ref={isActive ? (activeItemRef as React.RefObject<HTMLDivElement>) : null}
>
@@ -52,14 +52,20 @@ const QueryItem = ({ tabInfo }: QueryItemProps) => {
</p>
</a>
</Link>
- <div className="pr-3">{isActive && <QueryItemActions tabInfo={tabInfo} />}</div>
+ <div className="pr-3">{<QueryItemActions tabInfo={tabInfo} activeId={activeId} />}</div>
</div>
)
}
export default QueryItem
-const QueryItemActions = observer(({ tabInfo }: { tabInfo: SqlSnippet }) => {
+interface QueryItemActionsProps {
+ tabInfo: SqlSnippet
+ activeId: string | undefined
+}
+
+const QueryItemActions = observer(({ tabInfo, activeId }: QueryItemActionsProps) => {
+ console.log('activeId', activeId)
const { ui } = useStore()
const { ref } = useParams()
const router = useRouter()
@@ -75,6 +81,7 @@ const QueryItemActions = observer(({ tabInfo }: { tabInfo: SqlSnippet }) => {
const { id, name } = tabInfo || {}
const [renameModalOpen, setRenameModalOpen] = useState(false)
const [deleteModalOpen, setDeleteModalOpen] = useState(false)
+ const isActive = id === activeId
const onCloseRenameModal = () => {
setRenameModalOpen(false)
@@ -112,7 +119,7 @@ const QueryItemActions = observer(({ tabInfo }: { tabInfo: SqlSnippet }) => {
}
return (
- <div>
+ <div className="group sql-snippet-queryitem-dropdown">
{IS_PLATFORM ? (
<Dropdown
side="bottom"
@@ -129,12 +136,16 @@ const QueryItemActions = observer(({ tabInfo }: { tabInfo: SqlSnippet }) => {
</>
}
>
- <Button
- as="span"
- type="text"
- icon={<IconChevronDown size="tiny" strokeWidth={2} className="text-scale-1100" />}
- style={{ padding: '3px' }}
- />
+ <span
+ className={clsx(
+ 'p-0.5 rounded-md ',
+ isActive
+ ? 'text-scale-1100 hover:bg-scale-800'
+ : 'text-scale-300 dark:text-scale-200 hover:bg-scale-500 group-hover:text-scale-1100'
+ )}
+ >
+ <IconChevronDown size="tiny" strokeWidth={2} />
+ </span>
</Dropdown>
) : (
<Button as="span" type="text" style={{ padding: '3px' }} />
diff --git a/studio/styles/main.scss b/studio/styles/main.scss
index 70970273ab4..9464d86687c 100644
--- a/studio/styles/main.scss
+++ b/studio/styles/main.scss
@@ -238,3 +238,15 @@ div[data-radix-portal]:not(.portal--toast) {
[data-radix-popper-content-wrapper] {
@apply z-50 #{!important};
}
+
+// Dropdowns on SQL Snippets
+// can't quite target this properly with Tailwind
+.sql-snippet-queryitem-dropdown {
+ button[data-state='open'] {
+ @apply bg-scale-400 text-scale-900;
+
+ svg {
+ @apply stroke-scale-900;
+ }
+ }
+}