Skip to content

Commit 4e65c89

Browse files
feat(file-tree): adjust shape restrictions, implement size property that manages font and icon dimensions
1 parent 47c3667 commit 4e65c89

2 files changed

Lines changed: 43 additions & 18 deletions

File tree

src/common/components/mock-components/front-rich-components/file-tree/file-tree.business.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,32 @@
11
import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes';
2-
import { ShapeSizeRestrictions, Size } from '@/core/model';
2+
import { ElementSize, ShapeSizeRestrictions, Size } from '@/core/model';
3+
import { FONT_SIZE_VALUES } from '../../front-components/shape.const';
4+
5+
export const getFileTreeSizeValues = (size?: ElementSize) => {
6+
switch (size) {
7+
case 'XS':
8+
return {
9+
fontSize: FONT_SIZE_VALUES.SMALLTEXT,
10+
iconWidth: 40,
11+
elementHeight: 55,
12+
size: 'XS',
13+
};
14+
case 'S':
15+
return {
16+
fontSize: FONT_SIZE_VALUES.NORMALTEXT,
17+
iconWidth: 50,
18+
elementHeight: 60,
19+
size: 'S',
20+
};
21+
default:
22+
return {
23+
fontSize: FONT_SIZE_VALUES.NORMALTEXT,
24+
iconWidth: 50,
25+
elementHeight: 60,
26+
size: 'S',
27+
};
28+
}
29+
};
330

431
export const joinTextContent = (text: string): string[] => {
532
return text.split(', ');

src/common/components/mock-components/front-rich-components/file-tree/file-tree.tsx

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import { BASIC_SHAPE } from '../../front-components/shape.const';
99
import {
1010
calculateFileTreeDynamicSize,
1111
FileTreeItem,
12+
getFileTreeSizeValues,
1213
parseFileTreeText,
1314
} from './file-tree.business';
1415

1516
const fileTreeShapeRestrictions: ShapeSizeRestrictions = {
16-
minWidth: 220,
17-
minHeight: 180,
17+
minWidth: 200,
18+
minHeight: 120,
1819
maxWidth: -1,
1920
maxHeight: -1,
20-
defaultWidth: 280,
21-
defaultHeight: 280,
21+
defaultWidth: 230,
22+
defaultHeight: 180,
2223
};
2324

2425
interface FileTreeShapeProps extends ShapeProps {
@@ -54,16 +55,17 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
5455
}
5556
);
5657

57-
const iconWidth = 50;
58-
const elementHeight = 60;
59-
const paddingX = 40;
60-
const paddingY = 30;
58+
const { fontSize, iconWidth, elementHeight, size } = getFileTreeSizeValues(
59+
otherProps?.size
60+
);
61+
62+
const paddingX = 30;
63+
const paddingY = 25;
6164
const iconTextSpacing = 10;
62-
const indentationStep = 10;
65+
const indentationStep = 25;
6366

6467
const restrictedSize = calculateFileTreeDynamicSize(treeItems, {
6568
width,
66-
height,
6769
elementHeight,
6870
paddingY,
6971
baseRestrictions: fileTreeShapeRestrictions,
@@ -83,11 +85,7 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
8385

8486
// Helper functions for position calculations
8587
const calculateIconX = (item: FileTreeItem) => {
86-
return (
87-
paddingX +
88-
item.level * indentationStep +
89-
(item.type === 'file' ? 40 : 0)
90-
);
88+
return paddingX + item.level * indentationStep;
9189
};
9290

9391
const calculateTextX = (item: FileTreeItem) => {
@@ -133,7 +131,7 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
133131
<Image
134132
image={icons[item.type]!}
135133
x={calculateIconX(item)}
136-
y={paddingY + elementHeight * index}
134+
y={paddingY + elementHeight * index + (size === 'XS' ? 5 : 0)}
137135
width={iconWidth}
138136
height={iconWidth}
139137
/>
@@ -145,7 +143,7 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
145143
width={calculateAvailableWidth(item)}
146144
height={elementHeight}
147145
fontFamily={BASIC_SHAPE.DEFAULT_FONT_FAMILY}
148-
fontSize={15}
146+
fontSize={fontSize}
149147
fill={textColor}
150148
wrap="none"
151149
ellipsis={true}

0 commit comments

Comments
 (0)