Skip to content
Snippets Groups Projects
Commit 6cbddd4b authored by Miłosz Grocholewski's avatar Miłosz Grocholewski
Browse files

fix(label): hide label when font size below cut-off font size

parent f2807878
No related branches found
No related tags found
1 merge request!432fix(label): hide label when font size below cut-off font size
Pipeline #102796 passed
......@@ -9,6 +9,7 @@ import getTextStyle from '@/components/Map/MapViewer/utils/shapes/text/getTextSt
import { MapSize } from '@/redux/map/map.types';
import { Stroke } from 'ol/style';
import getScaledStrokeStyle from '@/components/Map/MapViewer/utils/shapes/style/getScaledStrokeStyle';
import { TEXT_CUTOFF_FONTSIZE } from '@/components/Map/MapViewer/MapViewer.constants';
export default function getCoverStyles({
coverStyle,
......@@ -48,6 +49,9 @@ export default function getCoverStyles({
maxWidth: maxWidth * scale * 0.9,
maxHeight: maxHeight * scale * 0.9,
});
if (calculatedFontSize < TEXT_CUTOFF_FONTSIZE) {
return styles;
}
const center = getCenter(largestExtent);
const textGeometry = new Point([center[0], center[1]]);
......
......@@ -14,7 +14,7 @@ describe('getWrappedTextWithFontSize', () => {
});
expect(wrappedText.trim()).toEqual('Wrapped text\nwith font size\ntest');
expect(fontSize).toEqual(14);
expect(fontSize).toEqual(16);
});
it('should return a wrapped text and font size for this text when maxWidth is unlimited and maxHeight is limited', () => {
......
......@@ -3,8 +3,8 @@ export default function getWrappedTextWithFontSize({
text,
maxWidth,
maxHeight,
minFontSize = 1,
maxFontSize = 14,
minFontSize = 3,
maxFontSize = 16,
}: {
text: string;
maxWidth: number;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment