Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
origami-z committed Feb 19, 2024
1 parent 563fd6c commit 0f2009f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,18 @@ describe("generateCssFromJson", () => {
--prefix-c-withReferenceValue: var(--prefix-a-with6DigitHex);`
);
});

test("generates css with rgbaFormat when provided", () => {
const generatedCss = generateCssFromJson(
JSON.stringify(sampleValidColorToken),
{ rgbaFormat: true }
);
expect(generatedCss).toEqual(
`--a-with6DigitHex: rgb(18, 52, 86);
--b-withAlphaHex: rgba(18, 52, 86, 0.47);
--c-withReferenceValue: var(--a-with6DigitHex);`
);
});
});

describe("number tokens", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/export-variables-rest-api/src/tokenUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export function parseTokenObject(tokenObj: object) {
return parseResult;
}

type CssGenOption = { prefix?: string };
type CssGenOption = { prefix?: string; rgbaFormat?: boolean };
export function generateCssFromJson(
inputJson: string,
option: CssGenOption = {}
Expand All @@ -78,7 +78,7 @@ export function generateCssFromJson(
if ($type === "color") {
const css = formatCssLine(
formatCssVarDeclaration(keys, prefix),
formatCssVarColorValue($value, prefix, true)
formatCssVarColorValue($value, prefix, option.rgbaFormat)
);
// console.debug("new color css", keys, css);
allCss.push(css);
Expand Down

0 comments on commit 0f2009f

Please sign in to comment.