Skip to content

Commit fb60fa5

Browse files
committed
Button bar component add Font Size property
1 parent 57e487d commit fb60fa5

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/common/components/mock-components/front-rich-components/buttonBar/buttonBar.tsx

Lines changed: 8 additions & 8 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 buttonBarShapeSizeRestrictions: ShapeSizeRestrictions = {
1516
minWidth: 200,
@@ -49,13 +50,11 @@ export const ButtonBarShape = forwardRef<any, ShapeProps>((props, ref) => {
4950
const csvData = splitCSVContentIntoRows(text);
5051
const headers = extractCSVHeaders(csvData[0]);
5152
const tabLabels = headers.map(header => header.text);
52-
53+
const verticalPadding = 8;
5354
const dynamicTabWidth = restrictedWidth / tabLabels.length;
5455

55-
const { stroke, strokeStyle, fill, textColor } = useShapeProps(
56-
otherProps,
57-
BASIC_SHAPE
58-
);
56+
const { stroke, strokeStyle, fill, textColor, fontSize, fontVariant } =
57+
useShapeProps(otherProps, BASIC_SHAPE);
5958

6059
const activeTab = otherProps?.activeElement ?? 0;
6160

@@ -65,29 +64,30 @@ export const ButtonBarShape = forwardRef<any, ShapeProps>((props, ref) => {
6564
shapeType,
6665
ref
6766
);
67+
useResizeOnFontSizeChange(id, { x, y }, text, fontSize, fontVariant);
6868

6969
return (
7070
<Group {...commonGroupProps} {...shapeProps}>
7171
{tabLabels.map((header, index) => (
7272
<Group key={index} x={index * dynamicTabWidth}>
7373
<Rect
7474
width={dynamicTabWidth}
75-
height={restrictedHeight}
75+
height={restrictedHeight - verticalPadding}
7676
fill={index === activeTab ? 'lightblue' : fill}
7777
stroke={stroke}
7878
strokeWidth={1}
7979
dash={strokeStyle}
8080
/>
8181
<Text
8282
x={0}
83-
y={18}
83+
y={restrictedHeight / 2 - fontSize / 2}
8484
width={dynamicTabWidth - 20}
8585
height={restrictedHeight - 20}
8686
ellipsis={true}
8787
wrap="none"
8888
text={header} // Use the header text
8989
fontFamily="Arial"
90-
fontSize={16}
90+
fontSize={fontSize}
9191
fill={textColor}
9292
align="center"
9393
/>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ export const generateDefaultOtherProps = (
104104
textColor: BASIC_SHAPE.DEFAULT_FILL_TEXT,
105105
strokeStyle: [],
106106
activeElement: 0,
107+
fontSize: FONT_SIZE_VALUES.NORMALTEXT,
108+
fontVariant: `${INPUT_SHAPE.DEFAULT_FONT_VARIANT}`,
107109
};
108110
case 'largeArrow':
109111
return {

0 commit comments

Comments
 (0)