Database diagrams editor that allows you to visualize and design your DB with a single query.
TypeScript databasedbdb-migrationeditorerdmariadbmssqlmysqlpostgresqlreactreact-flowschema-migrationssqlsqlitetypescriptvisualizationxyflow
add expand animation
johnnyfishf70bd3f76cc5
diff --git a/src/pages/editor-page/canvas/table-node-field.tsx b/src/pages/editor-page/canvas/table-node-field.tsxindex 9c12c61c..4b714216 100644--- a/src/pages/editor-page/canvas/table-node-field.tsx+++ b/src/pages/editor-page/canvas/table-node-field.tsx@@ -16,14 +16,15 @@ export const RIGHT_HANDLE_ID_PREFIX = 'right_';export const TARGET_ID_PREFIX = 'target_';export interface TableNodeFieldProps {- tableNodeId: string;field: DBField;focused: boolean;+ tableNodeId: string;highlighted: boolean;+ visible: boolean;}export const TableNodeField: React.FC<TableNodeFieldProps> = React.memo(- ({ field, focused, tableNodeId, highlighted }) => {+ ({ field, focused, tableNodeId, highlighted, visible }) => {const { removeField, relationships } = useChartDB();const updateNodeInternals = useUpdateNodeInternals();const connection = useConnection();@@ -41,7 +42,13 @@ export const TableNodeField: React.FC<TableNodeFieldProps> = React.memo(return (<div- className={`group relative flex h-8 items-center justify-between gap-1 border-t px-3 text-sm last:rounded-b-[6px] hover:bg-slate-100 dark:hover:bg-slate-800 ${highlighted ? 'bg-pink-100 dark:bg-pink-900' : ''} transition-colors`}+ className={`group relative flex h-8 items-center justify-between gap-1 border-t px-3 text-sm last:rounded-b-[6px] hover:bg-slate-100 dark:hover:bg-slate-800 ${+ highlighted ? 'bg-pink-100 dark:bg-pink-900' : ''+ } transition-all duration-300 ease-in-out ${+ visible+ ? 'max-h-8 opacity-100'+ : 'max-h-0 overflow-hidden opacity-0'+ }`}>{!connection.inProgress && (<>diff --git a/src/pages/editor-page/canvas/table-node.tsx b/src/pages/editor-page/canvas/table-node.tsxindex c50347d6..162ac79a 100644--- a/src/pages/editor-page/canvas/table-node.tsx+++ b/src/pages/editor-page/canvas/table-node.tsx@@ -6,6 +6,8 @@ import {ChevronsRightLeft,Pencil,Table2,+ ChevronDown,+ ChevronUp,} from 'lucide-react';import { Label } from '@/components/label/label';import { DBTable } from '@/lib/domain/db-table';@@ -136,26 +138,47 @@ export const TableNode: React.FC<NodeProps<TableNodeType>> = ({</Button></div></div>- {visibleFields.map((field) => (- <TableNodeField- key={field.id}- focused={focused}- tableNodeId={id}- field={field}- highlighted={selectedEdges.some(- (edge) =>- edge.data?.relationship.sourceFieldId ===- field.id ||- edge.data?.relationship.targetFieldId === field.id- )}- />- ))}+ <div+ className="overflow-hidden transition-[max-height] duration-300 ease-in-out"+ style={{+ maxHeight: expanded+ ? `${table.fields.length * 32}px`+ : '320px',+ }}+ >+ {table.fields.map((field) => (+ <TableNodeField+ key={field.id}+ focused={focused}+ tableNodeId={id}+ field={field}+ highlighted={selectedEdges.some(+ (edge) =>+ edge.data?.relationship.sourceFieldId ===+ field.id ||+ edge.data?.relationship.targetFieldId ===+ field.id+ )}+ visible={visibleFields.includes(field)}+ />+ ))}+ </div>{table.fields.length > 10 && (<div- className="flex cursor-pointer items-center justify-center py-2 hover:bg-slate-100 dark:hover:bg-slate-800"+ className="flex cursor-pointer items-center justify-center py-2 transition-colors duration-200 hover:bg-slate-100 dark:hover:bg-slate-800"onClick={toggleExpand}>- {expanded ? 'Show Less' : 'Show More'}+ {expanded ? (+ <>+ <ChevronUp className="mr-1 size-4" />+ Show Less+ </>+ ) : (+ <>+ <ChevronDown className="mr-1 size-4" />+ Show More+ </>+ )}</div>)}</div>