MCPcopy
hub / github.com/tomkp/react-split-pane / convertToPixels

Function convertToPixels

src/utils/calculations.ts:9–26  ·  view source on GitHub ↗
(size: Size, containerSize: number)

Source from the content-addressed store, hash-verified

7 * @returns Size in pixels
8 */
9export function convertToPixels(size: Size, containerSize: number): number {
10 if (typeof size === 'number') {
11 return size;
12 }
13
14 if (size.endsWith('%')) {
15 const percentage = parseFloat(size);
16 return (percentage / 100) * containerSize;
17 }
18
19 if (size.endsWith('px')) {
20 return parseFloat(size);
21 }
22
23 // Try to parse as number
24 const parsed = parseFloat(size);
25 return isNaN(parsed) ? 0 : parsed;
26}
27
28/**
29 * Constrain a value between min and max

Callers 2

SplitPaneFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…