@@ -10,6 +10,7 @@ import {
1010 splitCSVContentIntoRows ,
1111} from '@/common/utils/active-element-selector.utils' ;
1212import { useGroupShapeProps } from '../../mock-components.utils' ;
13+ import { useResizeOnFontSizeChange } from '../../front-text-components/front-text-hooks/resize-fontsize-change.hook' ;
1314
1415const 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 ) ) }
0 commit comments