diff --git a/blue-monotone/code.ts b/blue-monotone/code.ts new file mode 100644 index 0000000..8b8ef66 --- /dev/null +++ b/blue-monotone/code.ts @@ -0,0 +1,24 @@ +figma.showUI(__html__); + +figma.ui.onmessage = (msg) => { + if (msg.type === "convert-to-blue-monotone") { + const nodes = figma.currentPage.selection; + + for (const node of nodes) { + if ("fills" in node) { + const fills = node.fills.map((fill) => { + if (fill.type === "SOLID") { + return { + ...fill, + color: { r: 0, g: 0, b: fill.color.b }, + }; + } + return fill; + }); + node.fills = fills; + } + } + } + + figma.closePlugin(); +}; diff --git a/blue-monotone/manifest.json b/blue-monotone/manifest.json new file mode 100644 index 0000000..9e97545 --- /dev/null +++ b/blue-monotone/manifest.json @@ -0,0 +1,11 @@ +{ + "id": "blue-monotone-plugin", + "name": "Blue Monotone Plugin", + "api": "1.0.0", + "main": "code.js", + "editorType": ["figma", "figjam"], + "networkAccess": { + "allowedDomains": ["none"] + }, + "documentAccess": "dynamic-page" +} diff --git a/blue-monotone/tsconfig.json b/blue-monotone/tsconfig.json new file mode 100644 index 0000000..3a7b407 --- /dev/null +++ b/blue-monotone/tsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "target": "es6", + "lib": ["es6"], + "typeRoots": [ + "../node_modules/@types", + "../node_modules/@figma" + ] + }, + "include": ["**/*.ts"] +} diff --git a/blue-monotone/ui.html b/blue-monotone/ui.html new file mode 100644 index 0000000..709b963 --- /dev/null +++ b/blue-monotone/ui.html @@ -0,0 +1,17 @@ + + +
+ + +