MCPcopy Create free account
hub / github.com/callstack/react-native-paper / getLabelSizeWeb

Function getLabelSizeWeb

src/components/FAB/utils.ts:452–474  ·  view source on GitHub ↗
(ref: MutableRefObject<HTMLElement | null>)

Source from the content-addressed store, hash-verified

450};
451
452export const getLabelSizeWeb = (ref: MutableRefObject<HTMLElement | null>) => {
453 if (Platform.OS !== 'web' || ref.current === null) {
454 return null;
455 }
456
457 const canvasContext = getCanvasContext();
458
459 if (!canvasContext) {
460 return null;
461 }
462
463 const elementStyles = window.getComputedStyle(ref.current);
464 canvasContext.font = elementStyles.font;
465
466 const metrics = canvasContext.measureText(ref.current.innerText);
467
468 return {
469 width: metrics.width,
470 height:
471 (metrics.fontBoundingBoxAscent ?? 0) +
472 (metrics.fontBoundingBoxDescent ?? 0),
473 };
474};

Callers 2

AnimatedFABFunction · 0.90
updateTextSizeFunction · 0.90

Calls 1

getCanvasContextFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…