Skip to content

Database diagrams editor that allows you to visualize and design your DB with a single query.

layouts fixes

Guy Ben-Aharon545ff77467ea
diff --git a/package-lock.json b/package-lock.json
index 20a14341..1440a3cd 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -42,6 +42,7 @@
"react-code-blocks": "^0.1.6",
"react-dom": "^18.3.1",
"react-resizable-panels": "^2.0.22",
+ "react-responsive": "^10.0.0",
"react-router-dom": "^6.26.0",
"react-use": "^17.5.1",
"tailwind-merge": "^2.4.0",
@@ -4340,6 +4341,12 @@
"hyphenate-style-name": "^1.0.3"
}
},
+ "node_modules/css-mediaquery": {
+ "version": "0.1.2",
+ "resolved": "https://registry.npmjs.org/css-mediaquery/-/css-mediaquery-0.1.2.tgz",
+ "integrity": "sha512-COtn4EROW5dBGlE/4PiKnh6rZpAPxDeFLaEEwt4i10jpDMFt2EhQGS79QmmrO+iKCHv0PU/HrOWEhijFd1x99Q==",
+ "license": "BSD"
+ },
"node_modules/css-to-react-native": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/css-to-react-native/-/css-to-react-native-3.2.0.tgz",
@@ -7054,6 +7061,15 @@
"@jridgewell/sourcemap-codec": "^1.5.0"
}
},
+ "node_modules/matchmediaquery": {
+ "version": "0.4.2",
+ "resolved": "https://registry.npmjs.org/matchmediaquery/-/matchmediaquery-0.4.2.tgz",
+ "integrity": "sha512-wrZpoT50ehYOudhDjt/YvUJc6eUzcdFPdmbizfgvswCKNHD1/OBOHYJpHie+HXpu6bSkEGieFMYk6VuutaiRfA==",
+ "license": "MIT",
+ "dependencies": {
+ "css-mediaquery": "^0.1.2"
+ }
+ },
"node_modules/mdn-data": {
"version": "2.0.14",
"resolved": "https://registry.npmjs.org/mdn-data/-/mdn-data-2.0.14.tgz",
@@ -7775,7 +7791,6 @@
"version": "15.8.1",
"resolved": "https://registry.npmjs.org/prop-types/-/prop-types-15.8.1.tgz",
"integrity": "sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"loose-envify": "^1.4.0",
@@ -7872,7 +7887,6 @@
"version": "16.13.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz",
"integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==",
- "dev": true,
"license": "MIT"
},
"node_modules/react-refresh": {
@@ -7942,6 +7956,24 @@
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0"
}
},
+ "node_modules/react-responsive": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/react-responsive/-/react-responsive-10.0.0.tgz",
+ "integrity": "sha512-N6/UiRLGQyGUqrarhBZmrSmHi2FXSD++N5VbSKsBBvWfG0ZV7asvUBluSv5lSzdMyEVjzZ6Y8DL4OHABiztDOg==",
+ "license": "MIT",
+ "dependencies": {
+ "hyphenate-style-name": "^1.0.0",
+ "matchmediaquery": "^0.4.2",
+ "prop-types": "^15.6.1",
+ "shallow-equal": "^3.1.0"
+ },
+ "engines": {
+ "node": ">=14"
+ },
+ "peerDependencies": {
+ "react": ">=16.8.0"
+ }
+ },
"node_modules/react-router": {
"version": "6.26.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.26.0.tgz",
@@ -8379,6 +8411,12 @@
"node": ">=6.9"
}
},
+ "node_modules/shallow-equal": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/shallow-equal/-/shallow-equal-3.1.0.tgz",
+ "integrity": "sha512-pfVOw8QZIXpMbhBWvzBISicvToTiM5WBF1EeAUZDDSb5Dt29yl4AYbyywbJFSEsRUMr7gJaxqCdr4L3tQf9wVg==",
+ "license": "MIT"
+ },
"node_modules/shallowequal": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz",
diff --git a/package.json b/package.json
index c2660adf..81f5a980 100644
--- a/package.json
+++ b/package.json
@@ -45,6 +45,7 @@
"react-code-blocks": "^0.1.6",
"react-dom": "^18.3.1",
"react-resizable-panels": "^2.0.22",
+ "react-responsive": "^10.0.0",
"react-router-dom": "^6.26.0",
"react-use": "^17.5.1",
"tailwind-merge": "^2.4.0",
diff --git a/src/components/combobox/combobox.tsx b/src/components/combobox/combobox.tsx
index 2a443407..2a5fc17f 100644
--- a/src/components/combobox/combobox.tsx
+++ b/src/components/combobox/combobox.tsx
@@ -65,7 +65,7 @@ export function Combobox({
>
{selected && selected.length > 0 ? (
<div className="relative mr-auto flex flex-grow flex-wrap items-center overflow-hidden">
- <span>
+ <span className="overflow-hidden whitespace-nowrap text-ellipsis">
{mode === 'multiple' &&
Array.isArray(selected)
? selected
diff --git a/src/hooks/use-breakpoint.ts b/src/hooks/use-breakpoint.ts
new file mode 100644
index 00000000..a927d61d
--- /dev/null
+++ b/src/hooks/use-breakpoint.ts
@@ -0,0 +1,32 @@
+import { useMediaQuery } from 'react-responsive';
+
+const breakpoints = {
+ sm: '640px',
+ // => @media (min-width: 640px) { ... }
+
+ md: '768px',
+ // => @media (min-width: 768px) { ... }
+
+ lg: '1024px',
+ // => @media (min-width: 1024px) { ... }
+
+ xl: '1280px',
+ // => @media (min-width: 1280px) { ... }
+
+ '2xl': '1400px',
+ // => @media (min-width: 1400px) { ... }
+};
+
+type BreakpointKey = keyof typeof breakpoints;
+
+export function useBreakpoint<K extends BreakpointKey>(breakpointKey: K) {
+ const bool = useMediaQuery({
+ query: `(min-width: ${breakpoints[breakpointKey]})`,
+ });
+ const capitalizedKey =
+ breakpointKey[0].toUpperCase() + breakpointKey.substring(1);
+ type Key = `is${Capitalize<K>}`;
+ return {
+ [`is${capitalizedKey}`]: bool,
+ } as Record<Key, boolean>;
+}
diff --git a/src/pages/editor-page/editor-page.tsx b/src/pages/editor-page/editor-page.tsx
index 008ed2f1..65f6c62a 100644
--- a/src/pages/editor-page/editor-page.tsx
+++ b/src/pages/editor-page/editor-page.tsx
@@ -13,14 +13,19 @@ import { useChartDB } from '@/hooks/use-chartdb';
import { useDialog } from '@/hooks/use-dialog';
import { useRedoUndoStack } from '@/hooks/use-redo-undo-stack';
import { Toaster } from '@/components/toast/toaster';
+import { useFullScreenLoader } from '@/hooks/use-full-screen-spinner';
+import { useBreakpoint } from '@/hooks/use-breakpoint';
export const EditorPage: React.FC = () => {
const { loadDiagram } = useChartDB();
const { resetRedoStack, resetUndoStack } = useRedoUndoStack();
+ const { showLoader, hideLoader } = useFullScreenLoader();
const { openCreateDiagramDialog } = useDialog();
const { diagramId } = useParams<{ diagramId: string }>();
const { config } = useConfig();
const navigate = useNavigate();
+ const { isLg } = useBreakpoint('lg');
+ const { isXl } = useBreakpoint('xl');
useEffect(() => {
if (!config) {
@@ -29,12 +34,14 @@ export const EditorPage: React.FC = () => {
const loadDefaultDiagram = async () => {
if (diagramId) {
+ showLoader();
resetRedoStack();
resetUndoStack();
const diagram = await loadDiagram(diagramId);
if (!diagram) {
navigate('/');
}
+ hideLoader();
} else if (!diagramId && config.defaultDiagramId) {
navigate(`/diagrams/${config.defaultDiagramId}`);
} else {
@@ -50,6 +57,8 @@ export const EditorPage: React.FC = () => {
loadDiagram,
resetRedoStack,
resetUndoStack,
+ hideLoader,
+ showLoader,
]);
return (
@@ -57,11 +66,15 @@ export const EditorPage: React.FC = () => {
<section className="bg-background h-screen w-screen flex flex-col">
<TopNavbar />
<ResizablePanelGroup direction="horizontal">
- <ResizablePanel defaultSize={25} minSize={25} maxSize={99}>
+ <ResizablePanel
+ defaultSize={isXl ? 25 : isLg ? 35 : 50}
+ minSize={isXl ? 25 : isLg ? 35 : 50}
+ maxSize={99}
+ >
<SidePanel />
</ResizablePanel>
<ResizableHandle />
- <ResizablePanel defaultSize={75}>
+ <ResizablePanel defaultSize={isXl ? 75 : isLg ? 65 : 50}>
<Canvas />
</ResizablePanel>
</ResizablePanelGroup>
diff --git a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-content/relationship-list-item-content.tsx b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-content/relationship-list-item-content.tsx
index 21ef7998..9eb80727 100644
--- a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-content/relationship-list-item-content.tsx
+++ b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list-item/relationship-list-item-content/relationship-list-item-content.tsx
@@ -7,6 +7,11 @@ import {
SelectTrigger,
SelectValue,
} from '@/components/select/select';
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from '@/components/tooltip/tooltip';
import { useChartDB } from '@/hooks/use-chartdb';
import { DBRelationship, RelationshipType } from '@/lib/domain/db-relationship';
import { useReactFlow } from '@xyflow/react';
@@ -47,27 +52,41 @@ export const RelationshipListItemContent: React.FC<
<div className="rounded-b-md px-1 flex flex-col my-1">
<div className="flex flex-col gap-6">
<div className="flex justify-between items-center gap-1 text-xs">
- <div className="flex flex-col gap-2 text-xs">
+ <div className="flex flex-col gap-2 text-xs overflow-hidden">
<div className="flex flex-row items-center gap-1">
<FileMinus2 className="h-4 w-4 text-slate-700" />
<div className="font-bold text-slate-700">
Primary
</div>
</div>
- <div className="text-sm">
- {targetTable?.name}({targetField?.name})
- </div>
+ <Tooltip>
+ <TooltipTrigger>
+ <div className="text-sm overflow-hidden whitespace-nowrap text-ellipsis ">
+ {targetTable?.name}({targetField?.name})
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>
+ {targetTable?.name}({targetField?.name})
+ </TooltipContent>
+ </Tooltip>
</div>
- <div className="flex flex-col gap-2 text-xs">
+ <div className="flex flex-col gap-2 text-xs overflow-hidden">
<div className="flex flex-row items-center gap-1">
<FileOutput className="h-4 w-4 text-slate-700" />
<div className="font-bold text-slate-700">
Foreign
</div>
</div>
- <div className="text-sm">
- {sourceTable?.name}({sourceField?.name})
- </div>
+ <Tooltip>
+ <TooltipTrigger>
+ <div className="text-sm overflow-hidden whitespace-nowrap text-ellipsis ">
+ {sourceTable?.name}({sourceField?.name})
+ </div>
+ </TooltipTrigger>
+ <TooltipContent>
+ {sourceTable?.name}({sourceField?.name})
+ </TooltipContent>
+ </Tooltip>
</div>
</div>
<div className="flex flex-col gap-2 text-xs">
diff --git a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list.tsx b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list.tsx
index 3aa8b7ab..05341c4f 100644
--- a/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list.tsx
+++ b/src/pages/editor-page/side-panel/relationships-section/relationship-list/relationship-list.tsx
@@ -24,7 +24,7 @@ export const RelationshipList: React.FC<TableListProps> = ({
const scrollToRelationship = useCallback(
(id: string) =>
- refs[id].current?.scrollIntoView({
+ refs[id]?.current?.scrollIntoView({
behavior: 'smooth',
block: 'center',
}),
diff --git a/src/pages/editor-page/side-panel/relationships-section/relationships-section.tsx b/src/pages/editor-page/side-panel/relationships-section/relationships-section.tsx
index a937f46a..613bba7d 100644
--- a/src/pages/editor-page/side-panel/relationships-section/relationships-section.tsx
+++ b/src/pages/editor-page/side-panel/relationships-section/relationships-section.tsx
@@ -1,7 +1,6 @@
import React, { useMemo } from 'react';
import { Button } from '@/components/button/button';
import { ListCollapse } from 'lucide-react';
-import { ScrollArea } from '@/components/scroll-area/scroll-area';
import { Input } from '@/components/input/input';
import { RelationshipList } from './relationship-list/relationship-list';
import { useChartDB } from '@/hooks/use-chartdb';
@@ -41,10 +40,10 @@ export const RelationshipsSection: React.FC<RelationshipsSectionProps> = () => {
/>
</div>
</div>
- <div className="flex flex-col flex-1 overflow-hidden">
- <ScrollArea className="h-full">
- <RelationshipList relationships={filteredRelationships} />
- </ScrollArea>
+ <div className="flex flex-col flex-1 overflow-scroll">
+ {/* <ScrollArea className="h-full"> */}
+ <RelationshipList relationships={filteredRelationships} />
+ {/* </ScrollArea> */}
</div>
</section>
);
diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsx
index d5166a89..6691bd42 100644
--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsx
+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-field/table-field.tsx
@@ -43,9 +43,9 @@ export const TableField: React.FC<TableFieldProps> = ({
return (
<div className="flex flex-row p-1 justify-between flex-1">
- <div className="flex basis-8/12 gap-1">
+ <div className="flex w-8/12 gap-1 justify-start overflow-hidden">
<Input
- className="h-8 focus-visible:ring-0 basis-8/12"
+ className="h-8 focus-visible:ring-0 w-7/12 !overflow-hidden !whitespace-nowrap !text-ellipsis"
type="text"
placeholder="Name"
value={field.name}
@@ -56,7 +56,7 @@ export const TableField: React.FC<TableFieldProps> = ({
}
/>
<Combobox
- className="flex h-8 basis-4/12"
+ className="flex h-8 !w-5/12"
mode="single"
options={dataFieldOptions}
placeholder="Type"
@@ -69,7 +69,7 @@ export const TableField: React.FC<TableFieldProps> = ({
emptyText="No types found."
/>
</div>
- <div className="flex gap-1">
+ <div className="flex w-4/12 gap-1 justify-end overflow-hidden">
<Tooltip>
<TooltipTrigger>
<Toggle
diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsx
index 88bd51f7..e859cefa 100644
--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsx
+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list-item/table-list-item-content/table-list-item-content.tsx
@@ -90,7 +90,7 @@ export const TableListItemContent: React.FC<TableListItemContentProps> = ({
</div>
</div>
</AccordionTrigger>
- <AccordionContent className="pb-0 pt-1">
+ <AccordionContent className="flex flex-col pb-0 pt-1">
{table.fields.map((field) => (
<TableField
key={field.id}
diff --git a/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx b/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx
index b1fb129b..72c8ea3d 100644
--- a/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx
+++ b/src/pages/editor-page/side-panel/tables-section/table-list/table-list.tsx
@@ -20,7 +20,7 @@ export const TableList: React.FC<TableListProps> = ({ tables }) => {
const scrollToTable = useCallback(
(id: string) =>
- refs[id].current?.scrollIntoView({
+ refs[id]?.current?.scrollIntoView({
behavior: 'smooth',
block: 'center',
}),
diff --git a/src/pages/editor-page/side-panel/tables-section/tables-section.tsx b/src/pages/editor-page/side-panel/tables-section/tables-section.tsx
index a7515ecb..39093fef 100644
--- a/src/pages/editor-page/side-panel/tables-section/tables-section.tsx
+++ b/src/pages/editor-page/side-panel/tables-section/tables-section.tsx
@@ -2,7 +2,6 @@ import React, { useMemo } from 'react';
import { TableList } from './table-list/table-list';
import { Button } from '@/components/button/button';
import { Table, ListCollapse } from 'lucide-react';
-import { ScrollArea } from '@/components/scroll-area/scroll-area';
import { Input } from '@/components/input/input';
import { DBTable } from '@/lib/domain/db-table';
@@ -48,10 +47,10 @@ export const TablesSection: React.FC<TablesSectionProps> = () => {
Add Table
</Button>
</div>
- <div className="flex flex-col flex-1 overflow-hidden">
- <ScrollArea className="h-full">
- <TableList tables={filteredTables} />
- </ScrollArea>
+ <div className="flex flex-col flex-1 overflow-scroll">
+ {/* <ScrollArea className="h-full !max-w-full"> */}
+ <TableList tables={filteredTables} />
+ {/* </ScrollArea> */}
</div>
</section>
);