mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
* Initial commit. * Remove bunch of unneeded deps. * Fix the providers. * Minor fixes to make the themes work. * Fix prettier errors. * Add default constraint. * Midway styling * General styling improvements * More styling stuff * Bit more styling * Bit more pizzazz * Scaffold all threads modal * Small style fix * Ensure loading state persist in new page until redirect * Fix * Test'; * Add basic validation * Fix * Remove console logs * Hide show all threads button * chore: style the blocks * fix: stroke width * add some shadow * stroke width * Update TableNode.tsx * Swap hide chat for hide code * more sidebar styling * Resolve conflicts * Some style fixeds * Some style fixeds * mock profile * update user dorpdown * Update globals.css * Chore/db new layouts and url params (#19142) * chore: layouts * Fix + clean up --------- Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com> * Fix header * Scaffold profile and conversations * Some quick styling * Update apps/database-new/.env.local.example Co-authored-by: Greg Richardson <greg.nmr@gmail.com> --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com> Co-authored-by: Jonathan Summers-Muir <MildTomato@users.noreply.github.com> Co-authored-by: Greg Richardson <greg.nmr@gmail.com>
135 lines
4.5 KiB
TypeScript
135 lines
4.5 KiB
TypeScript
import { Diamond, DiamondIcon, Fingerprint, Hash, Key, Table, Table2 } from 'lucide-react'
|
|
import { IconHash, IconKey, cn } from 'ui'
|
|
import { Handle, NodeProps } from 'reactflow'
|
|
import { NODE_WIDTH } from './SchemaGraph.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 TableNode
|