( value: number, conversionMap: Record<number, string>, )
| 72 | }; |
| 73 | |
| 74 | const pxToTailwind = ( |
| 75 | value: number, |
| 76 | conversionMap: Record<number, string>, |
| 77 | ): string | null => { |
| 78 | const keys = Object.keys(conversionMap).map((d) => +d); |
| 79 | const convertedValue = exactValue(value, keys); |
| 80 | |
| 81 | if (convertedValue) { |
| 82 | return conversionMap[convertedValue]; |
| 83 | } else if (localTailwindSettings.roundTailwindValues) { |
| 84 | // Only round if the nearest value is within acceptable threshold |
| 85 | const thresholdValue = nearestValueWithThreshold(value, keys); |
| 86 | |
| 87 | if (thresholdValue !== null) { |
| 88 | return conversionMap[thresholdValue]; |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | return `[${numberToFixedString(value)}px]`; |
| 93 | }; |
| 94 | |
| 95 | export const pxToLetterSpacing = (value: number): string => { |
| 96 | return pxToRemToTailwind(value, config.letterSpacing); |
no test coverage detected