Skip to content

Commit e5b64f7

Browse files
authored
Merge pull request #800 from Lemoncode/dev
font siza
2 parents 7bc30de + 57e487d commit e5b64f7

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

src/common/components/mock-components/front-rich-components/horizontal-menu/horizontal-menu.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
splitCSVContentIntoRows,
1111
} from '@/common/utils/active-element-selector.utils';
1212
import { useGroupShapeProps } from '../../mock-components.utils';
13+
import { useResizeOnFontSizeChange } from '../../front-text-components/front-text-hooks/resize-fontsize-change.hook';
1314

1415
const horizontalMenuShapeSizeRestrictions: ShapeSizeRestrictions = {
1516
minWidth: 200,
@@ -41,7 +42,7 @@ export const HorizontalMenu = forwardRef<any, ShapeProps>((props, ref) => {
4142
const csvData = splitCSVContentIntoRows(text);
4243
const headers = extractCSVHeaders(csvData[0]);
4344
const itemLabels = headers.map(header => header.text);
44-
45+
const verticalPadding = 8;
4546
const numberOfItems = itemLabels.length;
4647
const itemSpacing = 10;
4748

@@ -54,10 +55,15 @@ export const HorizontalMenu = forwardRef<any, ShapeProps>((props, ref) => {
5455
const totalMargins = restrictedWidth - itemSpacing * (numberOfItems + 1);
5556
const itemWidth = totalMargins / numberOfItems;
5657

57-
const { stroke, strokeStyle, fill, textColor, borderRadius } = useShapeProps(
58-
otherProps,
59-
BASIC_SHAPE
60-
);
58+
const {
59+
stroke,
60+
strokeStyle,
61+
fill,
62+
textColor,
63+
borderRadius,
64+
fontSize,
65+
fontVariant,
66+
} = useShapeProps(otherProps, BASIC_SHAPE);
6167

6268
const itemVerticalPadding = 4;
6369

@@ -69,7 +75,7 @@ export const HorizontalMenu = forwardRef<any, ShapeProps>((props, ref) => {
6975
shapeType,
7076
ref
7177
);
72-
78+
useResizeOnFontSizeChange(id, { x, y }, text, fontSize, fontVariant);
7379
return (
7480
<Group {...commonGroupProps} {...shapeProps}>
7581
<Rect
@@ -90,20 +96,21 @@ export const HorizontalMenu = forwardRef<any, ShapeProps>((props, ref) => {
9096
x={itemSpacing * (index + 1) + itemWidth * index}
9197
y={itemVerticalPadding}
9298
width={itemWidth}
93-
height={restrictedHeight - 2 * itemVerticalPadding}
99+
height={restrictedHeight - verticalPadding}
94100
fill={index === activeSelected ? 'lightblue' : fill}
95101
/>
96102
<Text
97103
x={itemSpacing * (index + 1) + itemWidth * index}
98-
y={restrictedHeight / 2 - 8}
104+
y={restrictedHeight / 2 - fontSize / 2}
99105
text={header}
100106
fontFamily="Arial"
101-
fontSize={16}
107+
fontSize={fontSize}
102108
fill={textColor}
103109
width={itemWidth}
104110
align="center"
105111
wrap="none"
106112
ellipsis={true}
113+
fontVariant={fontVariant}
107114
/>
108115
</Group>
109116
))}

src/pods/canvas/model/shape-other-props.utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ export const generateDefaultOtherProps = (
4848
strokeStyle: [],
4949
borderRadius: `${BASIC_SHAPE.DEFAULT_CORNER_RADIUS}`,
5050
activeElement: 0,
51+
fontSize: FONT_SIZE_VALUES.NORMALTEXT,
52+
fontVariant: `${INPUT_SHAPE.DEFAULT_FONT_VARIANT}`,
5153
};
5254
case 'datepickerinput':
5355
case 'timepickerinput':

0 commit comments

Comments
 (0)