Skip to content

Commit 5b79a15

Browse files
committed
fix: correct dimension handler for borderRadius
Modified the dimension handler to use borderRadiusLookup instead of dimensionsLookup in builder.ts. Updated corresponding references in config.ts to ensure correct handling of border radii.
1 parent 037cf30 commit 5b79a15

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/code/src/builder/builder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Builder implements IBuilder {
101101

102102
if (cornerRadius !== figma.mixed) {
103103
if (cornerRadius !== 0) {
104-
const dimensionHandler = createDimensionHandler(this.config.dimensionsLookup, this.config.nearestInference, this.config.unit)
104+
const dimensionHandler = createDimensionHandler(this.config.borderRadiusLookup, this.config.nearestInference, this.config.unit)
105105
this.attributes.add(`rounded-${translateUtilityValue(dimensionHandler(cornerRadius))}`)
106106
}
107107
}

packages/code/src/config/config.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { createDimensionLookup } from './dimension'
99
interface LookupCache {
1010
color: InferenceColorMap | null
1111
dimensions: InferenceDimensionMap | null
12-
borderDimensions: InferenceDimensionMap | null
12+
borderRadiusDimensions: InferenceDimensionMap | null
1313
}
1414

1515
const defaultConfig: IConfiguration = {
@@ -45,7 +45,7 @@ export class Configuration implements IConfiguration {
4545
private lookupCache: LookupCache = {
4646
color: null,
4747
dimensions: null,
48-
borderDimensions: null,
48+
borderRadiusDimensions: null,
4949
}
5050

5151
constructor(
@@ -102,4 +102,20 @@ export class Configuration implements IConfiguration {
102102

103103
return lookup
104104
}
105+
106+
/**
107+
* Retrieves the border radius lookup for the component.
108+
* If the lookup cache already contains the border dimensions, it returns the cached value.
109+
* Otherwise, it creates and caches the border dimensions using the theme's border radius.
110+
* @return {InferenceDimensionMap} - The border radius lookup
111+
*/
112+
public get borderRadiusLookup(): InferenceDimensionMap {
113+
if (this.lookupCache.borderRadiusDimensions)
114+
return this.lookupCache.borderRadiusDimensions
115+
116+
const lookup = createDimensionLookup(this.theme.borderRadius || {})
117+
this.lookupCache.borderRadiusDimensions = lookup
118+
119+
return lookup
120+
}
105121
}

0 commit comments

Comments
 (0)