Skip to content

Commit b74667e

Browse files
committed
Write script and test to generate typography ts code
1 parent 15e3eb1 commit b74667e

File tree

3 files changed

+602
-4
lines changed

3 files changed

+602
-4
lines changed

src/bin/css_to_ts/css_to_ts.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { generateBreakpointsTsCode } from "./breakpoints";
22
import { generateGetColorDecisionsTsCode } from "./colorDecisions";
33
import { generateGetColorOptionsTsCode } from "./colorOptions";
44
import { getProjectRoot } from "../tools/getProjectRoot";
5+
import { generateTypographyTsCode } from "./typography";
56
import * as fs from "fs";
67
import { join as pathJoin, basename as pathBasename, relative as pathRelative } from "path";
78

@@ -60,3 +61,8 @@ fs.writeFileSync(
6061
pathJoin(generatedDirPath, "breakpoints.ts"),
6162
Buffer.from([warningMessage, ``, generateBreakpointsTsCode(rawCssCode)].join("\n"), "utf8")
6263
);
64+
65+
fs.writeFileSync(
66+
pathJoin(generatedDirPath, "typography.ts"),
67+
Buffer.from([warningMessage, ``, generateTypographyTsCode(rawCssCode)].join("\n"), "utf8")
68+
);

src/bin/css_to_ts/typography.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ function matchSelector(selector: string): boolean {
106106
}
107107

108108
export function generateTypographyTsCode(rawCssCode: string): string {
109-
const typographyVariants = parseBreakpointsValues(rawCssCode);
109+
const typographyVariants = parseTypographyVariants(rawCssCode);
110110

111-
//TODO
112-
return "const typography= " + JSON.stringify(typographyVariants, null, 2);
111+
return `export const typography = ${JSON.stringify(typographyVariants, null, 4)} as const;`;
113112
}

0 commit comments

Comments
 (0)