Skip to content

Commit c2a4d32

Browse files
committed
feat: AdjustLabelWidth, remove maxfontWidth as max is defined by default
1 parent 6cab9cc commit c2a4d32

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

packages/webui/src/client/ui/util/AdjustLabelFit.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ export interface AdjustLabelFitProps {
3939
*/
4040
minFontWidth?: number
4141

42-
/**
43-
* Maximum font size in percentage relative to normal (for auto-scaling)
44-
* Default is 120
45-
*/
46-
maxFontWidth?: number
47-
4842
/**
4943
* Enable letter spacing adjustment to fit text
5044
* Default is false
@@ -89,7 +83,6 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
8983
fontFamily,
9084
fontSize,
9185
minFontWidth = 30,
92-
maxFontWidth = 100,
9386
defaultOpticalSize = 100,
9487
defaultWidth = 100,
9588
useLetterSpacing = false,
@@ -181,7 +174,6 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
181174

182175
// Use a reasonable range for width variation
183176
currentWidth = Math.max(currentWidth, minFontWidth)
184-
currentWidth = Math.min(currentWidth, maxFontWidth)
185177

186178
//labelElement.style.fontVariationSettings = `'opsz' ${defaultOpticalSize}, 'wdth' ${currentWidth}`
187179
labelElement.style.fontVariationSettings = `'GRAD' 0, 'XOPQ' 96, 'XTRA' 468, 'YOPQ' 79, 'YTAS' 750, 'YTDE' -203, 'YTFI' 738, 'YTLC' 514, 'YTUC' 712, 'opsz' ${defaultOpticalSize}, 'slnt' 0, 'wdth' ${currentWidth}, 'wght' 550`
@@ -265,7 +257,7 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
265257
window.addEventListener('resize', handleResize)
266258

267259
// Run adjustment when width or font settings change
268-
if (width || fontFamily || fontSize || minFontWidth || maxFontWidth || minLetterSpacing) {
260+
if (width || fontFamily || fontSize || minFontWidth || minLetterSpacing) {
269261
handlePropsChange()
270262
}
271263

@@ -274,7 +266,7 @@ export const AdjustLabelFit: React.FC<AdjustLabelFitProps> = ({
274266
cancelAnimationFrame(adjustmentTimer)
275267
if (resizeTimer) cancelAnimationFrame(resizeTimer)
276268
}
277-
}, [label, width, fontFamily, fontSize, minFontWidth, maxFontWidth, minLetterSpacing])
269+
}, [label, width, fontFamily, fontSize, minFontWidth, minLetterSpacing])
278270

279271
return (
280272
<div ref={containerRef} className={`adjust-label-fit ${className}`} style={finalContainerStyle}>

0 commit comments

Comments
 (0)