From cc31b1e995dc145794a95a180ba7d48f5a2550cf Mon Sep 17 00:00:00 2001 From: jajajadework <168697059+jajajadework@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:00:20 +1000 Subject: [PATCH] Add blue monotone plugin Testing GH workspace by adding blue monotones as plugin --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/jajajadework/plugin-samples-fork?shareId=XXXX-XXXX-XXXX-XXXX). --- blue-monotone/code.ts | 24 ++++++++++++++++++++++++ blue-monotone/manifest.json | 11 +++++++++++ blue-monotone/tsconfig.json | 11 +++++++++++ blue-monotone/ui.html | 17 +++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 blue-monotone/code.ts create mode 100644 blue-monotone/manifest.json create mode 100644 blue-monotone/tsconfig.json create mode 100644 blue-monotone/ui.html 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 @@ + + + + + + Blue Monotone Plugin + + +

Blue Monotone Plugin

+ + + +