Skip to content

Commit e7b91ae

Browse files
ChucKN0risKAMoreaux
authored andcommitted
fix(to-flutter): Add height property on text styles
1 parent e96f557 commit e7b91ae

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

parsers/to-flutter/__snapshots__/to-flutter.spec.ts.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class SpecifyTextStyle {
4444
fontWeight: FontWeight.w500,
4545
letterSpacing: 10.00,
4646
color: Color(0xFF1E212B),
47+
height: 20.00,
4748
);
4849
static const TextStyle bodyWithOpacity = TextStyle(
4950
fontFamily: _inter,
@@ -52,19 +53,22 @@ class SpecifyTextStyle {
5253
fontWeight: FontWeight.w500,
5354
letterSpacing: 10.00,
5455
color: Color(0x4D1E212B),
56+
height: 20.00,
5557
);
5658
static const TextStyle code = TextStyle(
5759
fontFamily: _firaCode,
5860
fontSize: 13.00,
5961
fontStyle: FontStyle.normal,
6062
fontWeight: FontWeight.w500,
6163
color: Color(0xFFFF8E05),
64+
height: 20.00,
6265
);
6366
static const TextStyle list = TextStyle(
6467
fontFamily: _roboto,
6568
fontSize: 14.00,
6669
fontStyle: FontStyle.normal,
6770
fontWeight: FontWeight.w400,
71+
height: 20.00,
6872
);
6973
static const TextStyle title = TextStyle(
7074
fontFamily: _inter,
@@ -73,6 +77,7 @@ class SpecifyTextStyle {
7377
fontWeight: FontWeight.w600,
7478
decoration: TextDecoration.underline,
7579
color: Color(0xFF1E212B),
80+
height: 40.00,
7681
);
7782
}",
7883
},
@@ -176,6 +181,7 @@ class CustomTheme {
176181
fontWeight: FontWeight.w500,
177182
letterSpacing: 10.00,
178183
color: Color(0xFF1E212B),
184+
height: 20.00,
179185
);
180186
static const TextStyle bodyWithOpacity = TextStyle(
181187
fontFamily: _inter,
@@ -184,19 +190,22 @@ class CustomTheme {
184190
fontWeight: FontWeight.w500,
185191
letterSpacing: 10.00,
186192
color: Color(0x4D1E212B),
193+
height: 20.00,
187194
);
188195
static const TextStyle code = TextStyle(
189196
fontFamily: _firaCode,
190197
fontSize: 13.00,
191198
fontStyle: FontStyle.normal,
192199
fontWeight: FontWeight.w500,
193200
color: Color(0xFFFF8E05),
201+
height: 20.00,
194202
);
195203
static const TextStyle list = TextStyle(
196204
fontFamily: _roboto,
197205
fontSize: 14.00,
198206
fontStyle: FontStyle.normal,
199207
fontWeight: FontWeight.w400,
208+
height: 20.00,
200209
);
201210
static const TextStyle title = TextStyle(
202211
fontFamily: _inter,
@@ -205,6 +214,7 @@ class CustomTheme {
205214
fontWeight: FontWeight.w600,
206215
decoration: TextDecoration.underline,
207216
color: Color(0xFF1E212B),
217+
height: 40.00,
208218
);
209219
}",
210220
},

parsers/to-flutter/tokens/textStyle.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class {{textStyleClass}} {
2020
fontFamily: {{fontFamily}},
2121
fontSize: {{fontSize}},
2222
fontStyle: {{fontStyle}},
23-
fontWeight: FontWeight.w{{fontWeight}},{{#decoration}}\n decoration: {{decoration}},{{/decoration}}{{#letterSpacing}}\n letterSpacing: {{letterSpacing}},{{/letterSpacing}}{{#color}}\n color: Color({{color}}),{{/color}}
23+
fontWeight: FontWeight.w{{fontWeight}},{{#decoration}}\n decoration: {{decoration}},{{/decoration}}{{#letterSpacing}}\n letterSpacing: {{letterSpacing}},{{/letterSpacing}}{{#color}}\n color: Color({{color}}),{{/color}}{{#height}}\n height: {{height}},{{/height}}
2424
);
2525
{{/textStyles}}
2626
}`);
@@ -59,6 +59,11 @@ export function generateTextStyleFile(
5959
fontSize: textStyle.value.fontSize.value.measure.toFixed(2),
6060
fontStyle: `FontStyle.${!!textStyle.value.font.value.isItalic ? 'italic' : 'normal'}`,
6161
fontWeight: textStyle.value.font.value.fontWeight,
62+
height: pipe(
63+
O.fromNullable(textStyle.value.lineHeight),
64+
O.map(v => v.value.measure.toFixed(2)),
65+
O.toUndefined,
66+
),
6267
decoration: pipe(
6368
// Flutter only accept 1 text decoration
6469
O.fromNullable(textStyle.value.textDecoration?.[0]),

0 commit comments

Comments
 (0)