The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Chore/schema visualizer styles (#21614)
Terry Sutton53fa2a89976f
diff --git a/apps/database-new/components/SchemaFlowHandler/SchemaFlow.utils.ts b/apps/database-new/components/SchemaFlowHandler/SchemaFlow.utils.tsindex 4b43c6287b9..ae276cfe01f 100644--- a/apps/database-new/components/SchemaFlowHandler/SchemaFlow.utils.ts+++ b/apps/database-new/components/SchemaFlowHandler/SchemaFlow.utils.ts@@ -2,8 +2,9 @@ import { PostgresTable } from '@/lib/types'import dagre from '@dagrejs/dagre'import { uniqBy } from 'lodash'import { Edge, Node, Position } from 'reactflow'+import { TableNodeData } from 'ui-patterns/SchemaTableNode'+import { NODE_ROW_HEIGHT, NODE_WIDTH } from './SchemaFlow.constants'-import { TableNodeData } from './TableNode'export async function getGraphDataFromTables(tables: PostgresTable[]): Promise<{nodes: Node<TableNodeData>[]diff --git a/apps/database-new/components/SchemaFlowHandler/TableNode.tsx b/apps/database-new/components/SchemaFlowHandler/TableNode.tsxdeleted file mode 100644index 3b5073cc15e..00000000000--- a/apps/database-new/components/SchemaFlowHandler/TableNode.tsx+++ /dev/null@@ -1,134 +0,0 @@-import { DiamondIcon, Fingerprint, Hash, Key, Table2 } from 'lucide-react'-import { Handle, NodeProps } from 'reactflow'-import { cn } from 'ui'-import { NODE_WIDTH } from './SchemaFlow.constants'--export type TableNodeData = {- name: string- isForeign: boolean- columns: {- id: string- isPrimary: boolean- isNullable: boolean- isUnique: boolean- isIdentity: boolean- name: string- format: string- }[]-}--const TableNode = ({ data, targetPosition, sourcePosition }: NodeProps<TableNodeData>) => {- // Important styles is a nasty hack to use Handles (required for edges calculations), but do not show them in the UI.- // ref: https://github.com/wbkd/react-flow/discussions/2698- const hiddenNodeConnector = '!h-px !w-px !min-w-0 !min-h-0 !cursor-grab !border-0 !opacity-0'-- const itemHeight = 'h-[22px]'-- return (- <>- {data.isForeign ? (- <div className="rounded-lg">- <header className="text-[0.5rem] leading-5 font-bold px-2 text-center bg-brand text-gray-300">- {data.name}- {targetPosition && (- <Handle- type="target"- id={data.name}- position={targetPosition}- className={cn(hiddenNodeConnector, '!left-0')}- />- )}- </header>- </div>- ) : (- <div- className="border border-[0.5px] overflow-hidden rounded-[4px] shadow-sm"- style={{ width: NODE_WIDTH / 2 }}- >- <header- className={cn(- 'text-[0.55rem] px-2 bg-alternative text-default flex gap-1 items-center',- itemHeight- )}- >- <Table2 strokeWidth={1} size={12} className="text-light" />- {data.name}- </header>-- {data.columns.map((column) => (- <div- className={cn(- 'text-[8px] leading-5 relative flex flex-row justify-items-start',- 'bg-surface-100',- 'border-t',- 'border-t-[0.5px]',- // 'odd:bg-scale-300',- // 'even:bg-scale-400',- 'hover:bg-scale-500 transition cursor-default',- itemHeight- )}- key={column.id}- >- <div className="gap-[0.24rem] flex mx-2 align-middle basis-1/5 items-center justify-start">- {column.isPrimary && (- <Key- size={8}- strokeWidth={1}- className={cn(- // 'sb-grid-column-header__inner__primary-key'- 'flex-shrink-0',- 'text-light'- )}- />- )}- {column.isNullable && (- <DiamondIcon size={8} strokeWidth={1} className="flex-shrink-0 text-light" />- )}- {!column.isNullable && (- <DiamondIcon- size={8}- strokeWidth={1}- fill="currentColor"- className="flex-shrink-0 text-light"- />- )}- {column.isUnique && (- <Fingerprint size={8} strokeWidth={1} className="flex-shrink-0 text-light" />- )}- {column.isIdentity && (- <Hash size={8} strokeWidth={1} className="flex-shrink-0 text-light" />- )}- </div>- <div className="flex w-full justify-between">- <span className="text-ellipsis overflow-hidden whitespace-nowrap">- {column.name}- </span>- <span className="px-2 inline-flex justify-end font-mono text-lighter text-[0.4rem]">- {column.format}- </span>- </div>- {targetPosition && (- <Handle- type="target"- id={column.id}- position={targetPosition}- className={cn(hiddenNodeConnector, '!left-0')}- />- )}- {sourcePosition && (- <Handle- type="source"- id={column.id}- position={sourcePosition}- className={cn(hiddenNodeConnector, '!right-0')}- />- )}- </div>- ))}- </div>- )}- </>- )-}--export default TableNodediff --git a/apps/database-new/components/SchemaFlowHandler/index.tsx b/apps/database-new/components/SchemaFlowHandler/index.tsxindex f9d96b516b7..04c013eeec6 100644--- a/apps/database-new/components/SchemaFlowHandler/index.tsx+++ b/apps/database-new/components/SchemaFlowHandler/index.tsx@@ -13,7 +13,7 @@ import 'reactflow/dist/style.css'import { PostgresTable } from '@/lib/types'import { parseTables } from '@/lib/utils'import { getGraphDataFromTables } from './SchemaFlow.utils'-import TableNode from './TableNode'+import { TableNode } from 'ui-patterns'interface SchemaGraphProps {tables?: PostgresTable[]diff --git a/packages/ui-patterns/SchemaTableNode.tsx b/packages/ui-patterns/SchemaTableNode.tsxindex 0d6810e4dbc..76424665157 100644--- a/packages/ui-patterns/SchemaTableNode.tsx+++ b/packages/ui-patterns/SchemaTableNode.tsx@@ -70,7 +70,12 @@ const TableNode = ({ data, targetPosition, sourcePosition }: NodeProps<TableNode)}key={column.id}>- <div className="gap-[0.24rem] flex mx-2 align-middle basis-1/5 items-center justify-start">+ <div+ className={cn(+ 'gap-[0.24rem] flex mx-2 align-middle items-center justify-start',+ column.isPrimary && 'basis-1/5'+ )}+ >{column.isPrimary && (<Keysize={8}@@ -101,7 +106,7 @@ const TableNode = ({ data, targetPosition, sourcePosition }: NodeProps<TableNode)}</div><div className="flex w-full justify-between">- <span className="text-ellipsis overflow-hidden whitespace-nowrap">+ <span className="text-ellipsis overflow-hidden whitespace-nowrap max-w-[85px]">{column.name}</span><span className="px-2 inline-flex justify-end font-mono text-lighter text-[0.4rem]">