Skip to content

Figma test system and micro conversion system #8674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 44 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
a8564d4
Extract json from getLocalVariableCollectionsAsync()
NigelBreslaw Jun 6, 2025
f450cbf
Add 'dev:testdata' with download test data button
NigelBreslaw Jun 6, 2025
0eee1ca
Simplify
NigelBreslaw Jun 6, 2025
8c2dcdb
Optomise with figma.variables.getLocalVariablesAsync
NigelBreslaw Jun 7, 2025
c2c2d2b
Simplify as TypeScript can infer the types itself.
NigelBreslaw Jun 7, 2025
1a3ff7b
Make zip file saving more generic
NigelBreslaw Jun 7, 2025
a48baa7
Add Simple export button
NigelBreslaw Jun 7, 2025
0ec54c4
Sanitise property names and add tests
NigelBreslaw Jun 7, 2025
814ccde
Save as example.slint
NigelBreslaw Jun 7, 2025
44e8d11
Typo
NigelBreslaw Jun 7, 2025
9bc4c0d
Create one struct per collection
NigelBreslaw Jun 7, 2025
6695dd2
Remove consecutive duplicate words in names
NigelBreslaw Jun 7, 2025
6b0c30f
Sanitize names without using regex
NigelBreslaw Jun 7, 2025
9f7e676
Stop multiple running of export
NigelBreslaw Jun 7, 2025
28d0a89
Add variable references to data
NigelBreslaw Jun 8, 2025
59ecfa3
DRY
NigelBreslaw Jun 8, 2025
362e1e3
Add test for names starting with a hypen
NigelBreslaw Jun 8, 2025
95af996
Support more slint types via variable scopes
NigelBreslaw Jun 8, 2025
8962350
Tweak tests
NigelBreslaw Jun 8, 2025
201e835
Support slint hex color values
NigelBreslaw Jun 8, 2025
9d625a4
Fix issue when only one mode value is shared across all modes
NigelBreslaw Jun 8, 2025
59fd753
bug: Make collections with one mode have an 'out' property
NigelBreslaw Jun 8, 2025
4e2e0be
bug: Handle Figma file with deleted variables
NigelBreslaw Jun 8, 2025
da4a720
Handle case of variable-alias to an item in the same collection
NigelBreslaw Jun 8, 2025
24b1aad
Save the whole variable in the map for fast lookup
NigelBreslaw Jun 8, 2025
97ef530
Resolve self referencing figma variables
NigelBreslaw Jun 9, 2025
724a47f
Simplify export by reducing the number of levels you can use variable…
NigelBreslaw Jun 9, 2025
48cd9ee
Fix converstion issue
NigelBreslaw Jun 9, 2025
0747b44
Slight tweak
NigelBreslaw Jun 9, 2025
90dab3b
Tidy
NigelBreslaw Jun 9, 2025
9df556c
Use some Figma types directly
NigelBreslaw Jun 9, 2025
65e351c
Tidy
NigelBreslaw Jun 10, 2025
689f4fd
[autofix.ci] apply automated fixes
autofix-ci[bot] Jun 11, 2025
bd1cfe8
Support the recovery of deleted variables and collections
NigelBreslaw Jun 12, 2025
008d3c9
Updated tests
NigelBreslaw Jun 12, 2025
a6fbd47
[autofix.ci] apply automated fixes
autofix-ci[bot] Jun 12, 2025
6dcb91b
test-data now creates ALL data upfront
NigelBreslaw Jun 14, 2025
c291692
Simplify
NigelBreslaw Jun 14, 2025
d85505c
Flatten tests - no 'describe'
NigelBreslaw Jun 15, 2025
769ebc5
Small tidy
NigelBreslaw Jun 15, 2025
82ff1ea
Refactor converter based on simpler upfront system
NigelBreslaw Jun 15, 2025
3a7fe41
Stricter typescript with less 'any'
NigelBreslaw Jun 15, 2025
02244f8
[autofix.ci] apply automated fixes
autofix-ci[bot] Jun 16, 2025
b43bb1a
No need for 2 maps
NigelBreslaw Jun 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions tools/figma-inspector/backend/code.ts
Original file line number Diff line number Diff line change
@@ -5,6 +5,10 @@
import { listenTS, dispatchTS } from "./utils/code-utils.js";
import { generateSlintSnippet } from "./utils/property-parsing.js";
import { exportFigmaVariablesToSeparateFiles } from "./utils/export-variables.js";
import {
saveVariableCollectionsToFile,
createSlintExport,
} from "./utils/experimental-export.js";

if (figma.editorType === "dev" && figma.mode === "codegen") {
figma.codegen.on("generate", async ({ node }: { node: SceneNode }) => {
@@ -95,8 +99,8 @@ listenTS("exportToFiles", async (message) => {
);

// Send to UI for downloading
figma.ui.postMessage({
type: "exportedFiles",
dispatchTS("exportedFiles", {
zipFilename: "figma-variables",
files: files,
});

@@ -230,3 +234,29 @@ async function checkVariableChanges(isInitialRun = false) {
});
}
}

listenTS("getTestData", async () => {
try {
const testData = await saveVariableCollectionsToFile();

dispatchTS("saveTextFile", {
filename: "figma-test-data.json",
content: testData,
});

figma.notify("Test data ready for download!");
} catch (error) {
console.error("Error getting test data:", error);
figma.notify("Failed to get test data", { error: true });
}
});

listenTS("createSlintExport", async () => {
try {
await createSlintExport();
figma.notify("Slint export ready!");
} catch (error) {
console.error("Error creating Slint export:", error);
figma.notify("Failed to create Slint export", { error: true });
}
});
Loading