Skip to content

Commit

Permalink
Update export plugin to handle strings
Browse files Browse the repository at this point in the history
  • Loading branch information
jessiehuff committed May 14, 2024
1 parent e521f74 commit 93ae558
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 14 deletions.
8 changes: 6 additions & 2 deletions packages/module/build/css/tokens-charts-dark.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@

// Do not edit directly
// Generated on Thu, 09 May 2024 17:55:04 GMT
// Generated on Tue, 14 May 2024 15:28:40 GMT

@mixin pf-v6-tokens {
--pf-t--chart--global--stroke-line-join: "round";
--pf-t--chart--global--layout--width: 450;
--pf-t--chart--global--layout--height: 300;
--pf-t--chart--global--layout--padding: 50;
--pf-t--chart--global--label--stroke--width: 0;
--pf-t--chart--global--label--text-anchor: "middle";
--pf-t--chart--global--label--stroke: "transparent";
--pf-t--chart--global--label--margin: 8;
--pf-t--chart--global--label--padding: 10;
--pf-t--chart--global--stroke-line-cap: "round";
--pf-t--chart--global--letter-spacing: "normal";
--pf-t--chart--global--FontSize--2xl: 22;
--pf-t--chart--global--FontSize--lg: 18;
--pf-t--chart--global--FontSize--sm: 14;
Expand Down
8 changes: 6 additions & 2 deletions packages/module/build/css/tokens-charts.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@

// Do not edit directly
// Generated on Thu, 09 May 2024 17:55:04 GMT
// Generated on Tue, 14 May 2024 15:28:40 GMT

@mixin pf-v6-tokens {
--pf-t--chart--global--stroke-line-join: "round";
--pf-t--chart--global--layout--width: 450;
--pf-t--chart--global--layout--height: 300;
--pf-t--chart--global--layout--padding: 50;
--pf-t--chart--global--label--stroke--width: 0;
--pf-t--chart--global--label--text-anchor: "middle";
--pf-t--chart--global--label--stroke: "transparent";
--pf-t--chart--global--label--margin: 8;
--pf-t--chart--global--label--padding: 10;
--pf-t--chart--global--stroke-line-cap: "round";
--pf-t--chart--global--letter-spacing: "normal";
--pf-t--chart--global--FontSize--2xl: 22;
--pf-t--chart--global--FontSize--lg: 18;
--pf-t--chart--global--FontSize--sm: 14;
Expand Down
2 changes: 1 addition & 1 deletion packages/module/build/css/tokens-dark.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Do not edit directly
// Generated on Thu, 09 May 2024 17:55:04 GMT
// Generated on Tue, 14 May 2024 15:28:40 GMT

@mixin pf-v6-tokens {
--pf-t--global--background--color--action--plain--default: rgba(0, 0, 0, 0.0000);
Expand Down
2 changes: 1 addition & 1 deletion packages/module/build/css/tokens-default.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Do not edit directly
// Generated on Thu, 09 May 2024 17:55:04 GMT
// Generated on Tue, 14 May 2024 15:28:40 GMT

@mixin pf-v6-tokens {
--pf-t--global--background--color--action--plain--default: rgba(255, 255, 255, 0.0000);
Expand Down
2 changes: 1 addition & 1 deletion packages/module/build/css/tokens-palette.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

// Do not edit directly
// Generated on Thu, 09 May 2024 17:55:04 GMT
// Generated on Tue, 14 May 2024 15:28:40 GMT

@mixin pf-v6-tokens {
--pf-t--color--red--70: #5f0000;
Expand Down
18 changes: 13 additions & 5 deletions packages/module/plugins/export-patternfly-tokens/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,28 @@ function processCollection({ name, modes, variableIds }) {
figma.variables.getVariableById(variableId);
const value = valuesByMode[mode.modeId];

if (value !== undefined && ["COLOR", "FLOAT"].includes(resolvedType)) {
if (value !== undefined && ["COLOR", "FLOAT", "STRING"].includes(resolvedType)) {
let obj = file.body;
name.split("/").forEach((groupName) => {
obj[groupName] = obj[groupName] || {};
obj = obj[groupName];
});
obj.$type = resolvedType === "COLOR" ? "color" : "number";


if (value.type === "VARIABLE_ALIAS") {
obj.$type = resolvedType === "COLOR" ? "color" : "number";
obj.$value = `{${figma.variables
.getVariableById(value.id)
.name.replace(/\//g, ".")}}`;
} else {
obj.$value = resolvedType === "COLOR" ? rgbToHex(value) : value;
} else if (resolvedType === "COLOR") {
obj.$type = "color"
obj.$value = rgbToHex(value);
} else if (resolvedType === "FLOAT") {
obj.$type = "number";
obj.$value = value
} else if (resolvedType === "STRING") {
obj.$type = "string";
obj.$value = value
}
}
});
Expand Down
20 changes: 19 additions & 1 deletion packages/module/tokens/dark/charts.dark.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@
"value": 22
}
},
"letter-spacing": {
"type": "string",
"value": "\"normal\""
},
"stroke-line-cap": {
"type": "string",
"value": "\"round\""
},
"label": {
"padding": {
"type": "number",
Expand All @@ -301,7 +309,13 @@
"width": {
"type": "number",
"value": 0
}
},
"type": "string",
"value": "\"transparent\""
},
"text-anchor": {
"type": "string",
"value": "\"middle\""
},
"fill": {
"type": "color",
Expand All @@ -321,6 +335,10 @@
"type": "number",
"value": 450
}
},
"stroke-line-join": {
"type": "string",
"value": "\"round\""
}
},
"theme": {
Expand Down
20 changes: 19 additions & 1 deletion packages/module/tokens/default/charts.json
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@
"value": 22
}
},
"letter-spacing": {
"type": "string",
"value": "\"normal\""
},
"stroke-line-cap": {
"type": "string",
"value": "\"round\""
},
"label": {
"padding": {
"type": "number",
Expand All @@ -301,7 +309,13 @@
"width": {
"type": "number",
"value": 0
}
},
"type": "string",
"value": "\"transparent\""
},
"text-anchor": {
"type": "string",
"value": "\"middle\""
},
"fill": {
"type": "color",
Expand All @@ -321,6 +335,10 @@
"type": "number",
"value": 450
}
},
"stroke-line-join": {
"type": "string",
"value": "\"round\""
}
},
"theme": {
Expand Down

0 comments on commit 93ae558

Please sign in to comment.