Skip to content

Commit 83ae5bd

Browse files
committed
Fix padding issue
1 parent b9453e0 commit 83ae5bd

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/codegen/__tests__/__snapshots__/codegen.test.ts.snap

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,10 +3184,9 @@ exports[`render real world component real world $ 91`] = `
31843184
maskPos="center"
31853185
maskRepeat="no-repeat"
31863186
maskSize="contain"
3187-
pb="5px"
31883187
pl="9px"
31893188
pr="7px"
3190-
pt="5px"
3189+
py="5px"
31913190
transform="rotate(180deg)"
31923191
/>
31933192
</Center>
@@ -3207,10 +3206,7 @@ exports[`render real world component real world $ 92`] = `
32073206
maskPos="center"
32083207
maskRepeat="no-repeat"
32093208
maskSize="contain"
3210-
pb="2.29px"
3211-
pl="2.29px"
3212-
pr="2.29px"
3213-
pt="2.29px"
3209+
p="2.29px"
32143210
/>
32153211
</Center>
32163212
)
@@ -3239,10 +3235,8 @@ exports[`render real world component real world $ 94`] = `
32393235
maskPos="center"
32403236
maskRepeat="no-repeat"
32413237
maskSize="contain"
3242-
pb="2.33px"
3243-
pl="2.65px"
3244-
pr="2.65px"
3245-
pt="2.33px"
3238+
px="2.65px"
3239+
py="2.33px"
32463240
/>
32473241
</Center>
32483242
)
@@ -3271,10 +3265,8 @@ exports[`render real world component real world $ 96`] = `
32713265
maskPos="center"
32723266
maskRepeat="no-repeat"
32733267
maskSize="contain"
3274-
pb="2.33px"
3275-
pl="2.65px"
3276-
pr="2.65px"
3277-
pt="2.33px"
3268+
px="2.65px"
3269+
py="2.33px"
32783270
/>
32793271
</Center>
32803272
)

src/codegen/utils/optimize-space.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ export function optimizeSpace(
77
b: number,
88
l: number,
99
): Record<string, string | undefined> {
10+
// Round to 2 decimal places to handle Figma floating-point imprecision
11+
// (e.g. 1.5 vs 1.5000009536743164). Matches formatNumber's rounding.
12+
t = Math.round(t * 100) / 100
13+
r = Math.round(r * 100) / 100
14+
b = Math.round(b * 100) / 100
15+
l = Math.round(l * 100) / 100
16+
1017
if (t === r && r === b && b === l) {
1118
return { [type]: addPx(t) }
1219
}

0 commit comments

Comments
 (0)