Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
24 changes: 24 additions & 0 deletions blue-monotone/code.ts
Original file line number Diff line number Diff line change
@@ -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();
};
11 changes: 11 additions & 0 deletions blue-monotone/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}
11 changes: 11 additions & 0 deletions blue-monotone/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"target": "es6",
"lib": ["es6"],
"typeRoots": [
"../node_modules/@types",
"../node_modules/@figma"
]
},
"include": ["**/*.ts"]
}
17 changes: 17 additions & 0 deletions blue-monotone/ui.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Blue Monotone Plugin</title>
</head>
<body>
<h1>Blue Monotone Plugin</h1>
<button id="convert-button">Convert to Blue Monotone</button>
<script>
document.getElementById('convert-button').onclick = () => {
parent.postMessage({ pluginMessage: { type: 'convert-to-blue-monotone' } }, '*');
};
</script>
</body>
</html>