MCPcopy Create free account
hub / github.com/FastLED/FastLED / calculateInputWidth

Function calculateInputWidth

src/platforms/wasm/compiler/modules/ui/ui_manager.ts:242–249  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

240
241 // Calculate dynamic width based on expected value range
242 const calculateInputWidth = () => {
243 const minDigits = String(Math.floor(element.min || 0)).length;
244 const maxDigits = String(Math.floor(element.max || 0)).length;
245 const valueDigits = String(Math.floor(element.value || 0)).length;
246 const maxLength = Math.max(minDigits, maxDigits, valueDigits, 5); // Minimum 5 digits
247 // ~8px per character + 20px for padding/controls
248 return `${maxLength * 8 + 20}px`;
249 };
250
251 numberInput.style.width = calculateInputWidth();
252 numberInput.style.minWidth = '70px'; // Ensure minimum usable width

Callers 1

createSingleNumberFieldFunction · 0.85

Calls 3

StringClass · 0.85
floorMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected