Skip to content

Commit ac87418

Browse files
feat(file-tree): refine sizing system for both available sizes
1 parent 4e65c89 commit ac87418

2 files changed

Lines changed: 50 additions & 23 deletions

File tree

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

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,53 @@ import { fitSizeToShapeSizeRestrictions } from '@/common/utils/shapes';
22
import { ElementSize, ShapeSizeRestrictions, Size } from '@/core/model';
33
import { FONT_SIZE_VALUES } from '../../front-components/shape.const';
44

5-
export const getFileTreeSizeValues = (size?: ElementSize) => {
5+
interface FileTreeSizeValues {
6+
fontSize: number;
7+
iconDimension: number;
8+
elementHeight: number;
9+
paddingX: number;
10+
paddingY: number;
11+
extraTextTopPadding: number;
12+
iconTextSpacing: number;
13+
indentationStep: number;
14+
}
15+
16+
export const getFileTreeSizeValues = (
17+
size?: ElementSize
18+
): FileTreeSizeValues => {
619
switch (size) {
720
case 'XS':
821
return {
9-
fontSize: FONT_SIZE_VALUES.SMALLTEXT,
10-
iconWidth: 40,
11-
elementHeight: 55,
12-
size: 'XS',
22+
fontSize: 12,
23+
iconDimension: 25,
24+
elementHeight: 30,
25+
paddingX: 25,
26+
paddingY: 15,
27+
extraTextTopPadding: 9,
28+
iconTextSpacing: 8,
29+
indentationStep: 15,
1330
};
1431
case 'S':
1532
return {
1633
fontSize: FONT_SIZE_VALUES.NORMALTEXT,
17-
iconWidth: 50,
34+
iconDimension: 50,
1835
elementHeight: 60,
19-
size: 'S',
36+
paddingX: 30,
37+
paddingY: 20,
38+
extraTextTopPadding: 20,
39+
iconTextSpacing: 10,
40+
indentationStep: 27,
2041
};
2142
default:
2243
return {
2344
fontSize: FONT_SIZE_VALUES.NORMALTEXT,
24-
iconWidth: 50,
45+
iconDimension: 50,
2546
elementHeight: 60,
26-
size: 'S',
47+
paddingX: 30,
48+
paddingY: 20,
49+
extraTextTopPadding: 20,
50+
iconTextSpacing: 10,
51+
indentationStep: 25,
2752
};
2853
}
2954
};

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from './file-tree.business';
1515

1616
const fileTreeShapeRestrictions: ShapeSizeRestrictions = {
17-
minWidth: 200,
17+
minWidth: 150,
1818
minHeight: 120,
1919
maxWidth: -1,
2020
maxHeight: -1,
@@ -55,14 +55,16 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
5555
}
5656
);
5757

58-
const { fontSize, iconWidth, elementHeight, size } = getFileTreeSizeValues(
59-
otherProps?.size
60-
);
61-
62-
const paddingX = 30;
63-
const paddingY = 25;
64-
const iconTextSpacing = 10;
65-
const indentationStep = 25;
58+
const {
59+
fontSize,
60+
iconDimension,
61+
elementHeight,
62+
extraTextTopPadding,
63+
paddingX,
64+
paddingY,
65+
iconTextSpacing,
66+
indentationStep,
67+
} = getFileTreeSizeValues(otherProps?.size);
6668

6769
const restrictedSize = calculateFileTreeDynamicSize(treeItems, {
6870
width,
@@ -89,7 +91,7 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
8991
};
9092

9193
const calculateTextX = (item: FileTreeItem) => {
92-
return calculateIconX(item) + iconWidth + iconTextSpacing;
94+
return calculateIconX(item) + iconDimension + iconTextSpacing;
9395
};
9496

9597
const calculateAvailableWidth = (item: FileTreeItem) => {
@@ -131,14 +133,14 @@ export const FileTreeShape = forwardRef<any, FileTreeShapeProps>(
131133
<Image
132134
image={icons[item.type]!}
133135
x={calculateIconX(item)}
134-
y={paddingY + elementHeight * index + (size === 'XS' ? 5 : 0)}
135-
width={iconWidth}
136-
height={iconWidth}
136+
y={paddingY + elementHeight * index}
137+
width={iconDimension}
138+
height={iconDimension}
137139
/>
138140
)}
139141
<Text
140142
x={calculateTextX(item)}
141-
y={paddingY + elementHeight * index + 20}
143+
y={paddingY + elementHeight * index + extraTextTopPadding}
142144
text={item.text}
143145
width={calculateAvailableWidth(item)}
144146
height={elementHeight}

0 commit comments

Comments
 (0)