Skip to content

Commit

Permalink
Correction of the text overlapping
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosApodaca committed Jan 19, 2024
1 parent e658905 commit 10f19c7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FieldVm, TableVm } from '@/core/providers/canvas-schema';
import classes from './database-table.module.css';
import { TABLE_CONST } from '@/core/providers/canvas-schema/canvas.const';
import { calculateDBColumnsWidth } from '@/pods/edit-table/edit-table.business';
import { TruncatedText } from './truncated-text.component';

interface Props {
tableInfo: TableVm;
Expand Down Expand Up @@ -43,13 +44,14 @@ export const DatabaseTableRow: React.FC<Props> = props => {
{isExpanded ? '▼' : '►'}
</text>
)}
<text
x={TABLE_CONST.FIELD_NAME_X_OFFSET + (isExpandable ? 15 : 0)}
y={TABLE_CONST.FONT_SIZE}
className={classes.tableTextRow}
>
{field.name}
</text>
<TruncatedText
id={field.id}
text={field.name}
x={TABLE_CONST.FONT_SIZE}
y={0}
width={columnWidths[0]}
height={TABLE_CONST.FONT_SIZE}
/>
</g>
<text
x={columnWidths[0] + columnWidths[1]}
Expand Down
32 changes: 32 additions & 0 deletions src/pods/canvas/components/table/truncated-text.component.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { GUID } from '@/core/model';
import classes from './database-table.module.css';

interface Props {
id: GUID;
text: string;
x: number;
y: number;
width: number;
height: number;
}

export const TruncatedText: React.FC<Props> = props => {
const { text, x, y, width, height, id } = props;

return (
<>
<clipPath id={`clip_${id}`}>
<rect x={x} y={y} width={width} height={height + 10}></rect>
</clipPath>

<text
x={x + 5}
y={y + height}
clip-path={`url(#clip_${id})`}
className={classes.tableTextRow}
>
{text}
</text>
</>
);
};

0 comments on commit 10f19c7

Please sign in to comment.