Skip to content

Commit

Permalink
Android: force em values to use the X.em format by always dding a…
Browse files Browse the repository at this point in the history
… decimal place
  • Loading branch information
jmartinesp committed Jul 31, 2024
1 parent 465d232 commit 0f15b23
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
32 changes: 16 additions & 16 deletions assets/android/src/TypographyTokens.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object TypographyTokens {
fontWeight = FontWeight.W500,
lineHeight = 22.sp,
fontSize = 16.sp,
letterSpacing = 0.015625.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -49,7 +49,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 22.sp,
fontSize = 16.sp,
letterSpacing = 0.015625.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -58,7 +58,7 @@ object TypographyTokens {
fontWeight = FontWeight.W500,
lineHeight = 20.sp,
fontSize = 14.sp,
letterSpacing = 0.017857.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -67,7 +67,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 20.sp,
fontSize = 14.sp,
letterSpacing = 0.017857.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -76,7 +76,7 @@ object TypographyTokens {
fontWeight = FontWeight.W500,
lineHeight = 17.sp,
fontSize = 12.sp,
letterSpacing = 0.033333.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -85,7 +85,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 17.sp,
fontSize = 12.sp,
letterSpacing = 0.033333.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -94,7 +94,7 @@ object TypographyTokens {
fontWeight = FontWeight.W500,
lineHeight = 15.sp,
fontSize = 11.sp,
letterSpacing = 0.045454.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -103,7 +103,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 15.sp,
fontSize = 11.sp,
letterSpacing = 0.045454.em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -112,7 +112,7 @@ object TypographyTokens {
fontWeight = FontWeight.W700,
lineHeight = 34.sp,
fontSize = 28.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -121,7 +121,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 34.sp,
fontSize = 28.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -130,7 +130,7 @@ object TypographyTokens {
fontWeight = FontWeight.W700,
lineHeight = 27.sp,
fontSize = 22.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -139,7 +139,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 27.sp,
fontSize = 22.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -148,7 +148,7 @@ object TypographyTokens {
fontWeight = FontWeight.W500,
lineHeight = 25.sp,
fontSize = 20.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -157,7 +157,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 25.sp,
fontSize = 20.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -166,7 +166,7 @@ object TypographyTokens {
fontWeight = FontWeight.W700,
lineHeight = 41.sp,
fontSize = 34.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand All @@ -175,7 +175,7 @@ object TypographyTokens {
fontWeight = FontWeight.W400,
lineHeight = 41.sp,
fontSize = 34.sp,
letterSpacing = 0em,
letterSpacing = 0.0.em,
platformStyle = PlatformTextStyle(includeFontPadding = false),
lineHeightStyle = LineHeightStyle(LineHeightStyle.Alignment.Center, LineHeightStyle.Trim.None)
)
Expand Down
2 changes: 1 addition & 1 deletion src/transforms/kotlin/percentageToEm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export default {
},
transform: (token: TransformedToken): string => {
const val = Number.parseFloat(token.value.replace("%", ""));
return `${val / 100}.em`;
return `${(val / 100).toFixed(1)}.em`;
},
} satisfies Transform;
2 changes: 1 addition & 1 deletion src/transforms/kotlin/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default {
output += `${ARG_INDENT_LEVEL + textStylePropertiesMapping[propName]} = `;
if (propName === "fontFamily") {
output += "FontFamily.Default";
} else {
} else {
output += val;
}
output += ",\n";
Expand Down

0 comments on commit 0f15b23

Please sign in to comment.