Skip to content

Commit e96f557

Browse files
committed
fix(to-flutter): fix filename option for textStyle
1 parent afec879 commit e96f557

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,13 +157,13 @@ class CustomTheme {
157157
exports[`To Flutter Should generate the text styles theme with custom file name, class name and type 1`] = `
158158
[
159159
{
160-
"name": "text-styles.dart",
160+
"name": "custom-text-styles-file-name.dart",
161161
"value": {
162162
"content": "
163163
import 'dart:ui';
164164
165-
class SpecifyTextStyle {
166-
SpecifyTextStyle._();
165+
class CustomTheme {
166+
CustomTheme._();
167167
168168
static const String _inter = 'Inter';
169169
static const String _firaCode = 'Fira Code';

parsers/to-flutter/tokens/textStyle.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ import 'dart:ui';
1111
class {{textStyleClass}} {
1212
{{textStyleClass}}._();
1313
14-
{{#fontFamillies}}
14+
{{#fontFamilies}}
1515
static const String {{varName}} = '{{fontName}}';
16-
{{/fontFamillies}}
16+
{{/fontFamilies}}
1717
1818
{{#textStyles}}
1919
static const {{#type}}{{type}} {{/type}}{{name}} = TextStyle(
20-
fontFamily: {{fontFamilly}},
20+
fontFamily: {{fontFamily}},
2121
fontSize: {{fontSize}},
2222
fontStyle: {{fontStyle}},
2323
fontWeight: FontWeight.w{{fontWeight}},{{#decoration}}\n decoration: {{decoration}},{{/decoration}}{{#letterSpacing}}\n letterSpacing: {{letterSpacing}},{{/letterSpacing}}{{#color}}\n color: Color({{color}}),{{/color}}
@@ -42,11 +42,11 @@ export function generateTextStyleFile(
4242
options: OptionsType,
4343
): DownloadableFile {
4444
return {
45-
name: options?.formatByType?.color?.fileName ?? 'text-styles.dart',
45+
name: options?.formatByType?.textStyle?.fileName ?? 'text-styles.dart',
4646
value: {
4747
content: templateContent.render({
48-
textStyleClass: options?.formatByType?.color?.className ?? 'SpecifyTextStyle',
49-
fontFamillies: [...new Set(textStyles.map(v => v.value.font.value.fontFamily))].map(
48+
textStyleClass: options?.formatByType?.textStyle?.className ?? 'SpecifyTextStyle',
49+
fontFamilies: [...new Set(textStyles.map(v => v.value.font.value.fontFamily))].map(
5050
fontName => ({
5151
fontName,
5252
varName: `_${camelCase(fontName)}`,
@@ -55,7 +55,7 @@ export function generateTextStyleFile(
5555
textStyles: textStyles.map(textStyle => ({
5656
name: camelCase(textStyle.name),
5757
type: options?.formatByType?.textStyle?.classType ?? 'TextStyle',
58-
fontFamilly: `_${camelCase(textStyle.value.font.value.fontFamily)}`,
58+
fontFamily: `_${camelCase(textStyle.value.font.value.fontFamily)}`,
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,

0 commit comments

Comments
 (0)