MCPcopy Index your code
hub / github.com/bernaferrari/FigmaToCode / formatWithJSX

Function formatWithJSX

packages/backend/src/common/parseJSX.ts:4–26  ·  view source on GitHub ↗
(
  property: string,
  isJsx: boolean,
  value: number | string,
)

Source from the content-addressed store, hash-verified

2import { numberToFixedString } from "./numToAutoFixed";
3
4export const formatWithJSX = (
5 property: string,
6 isJsx: boolean,
7 value: number | string,
8): string => {
9 // convert font-size to fontSize.
10 const jsx_property = property
11 .split("-")
12 .map((d, i) => (i > 0 ? d.charAt(0).toUpperCase() + d.slice(1) : d))
13 .join("");
14
15 if (typeof value === "number") {
16 if (isJsx) {
17 return `${jsx_property}: ${numberToFixedString(value)}`;
18 } else {
19 return `${property}: ${numberToFixedString(value)}px`;
20 }
21 } else if (isJsx) {
22 return `${jsx_property}: '${value}'`;
23 } else {
24 return `${property}: ${value}`;
25 }
26};
27
28export const formatMultipleJSXArray = (
29 styles: Record<string, string | number>,

Callers 15

htmlContainerFunction · 0.90
fontSizeMethod · 0.90
textTrimMethod · 0.90
textAlignHorizontalMethod · 0.90
textAlignVerticalMethod · 0.90
borderMethod · 0.90
positionMethod · 0.90
applyFillsToStyleMethod · 0.90
shadowMethod · 0.90
blurMethod · 0.90
htmlBlendModeFunction · 0.90
htmlVisibilityFunction · 0.90

Calls 1

numberToFixedStringFunction · 0.90

Tested by

no test coverage detected