summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRishi-k-s <rishikrishna.sr@gmail.com>2025-02-28 20:25:48 +0530
committerRishi-k-s <rishikrishna.sr@gmail.com>2025-02-28 20:25:48 +0530
commita04f2fd180b84643874873b3a589269a63c43fc4 (patch)
tree5ff1e8156ca7f425608b5a49ea861514ee58ed4e
Add initial setup for Figma plugin "Batchly"
This commit introduces the initial project setup for the Batchly Figma plugin. It includes configuration files (.gitignore, tsconfig.json, and more), TypeScript and HTML source files for plugin functionality, and Node.js-based tooling with relevant package dependencies. A README is also added to guide development and setup.
-rw-r--r--.gitignore8
-rw-r--r--.idea/.gitignore8
-rw-r--r--.idea/Batchly.iml8
-rw-r--r--.idea/inspectionProfiles/profiles_settings.xml6
-rw-r--r--.idea/misc.xml4
-rw-r--r--.idea/modules.xml8
-rw-r--r--README.md40
-rw-r--r--code.ts37
-rw-r--r--manifest.json18
-rw-r--r--package.json44
-rw-r--r--tsconfig.json11
-rw-r--r--ui.html17
12 files changed, 209 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..f16fba9
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,8 @@
+# Node
+*.log
+*.log.*
+node_modules
+
+out/
+dist/
+code.js
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/Batchly.iml b/.idea/Batchly.iml
new file mode 100644
index 0000000..d8b3f6c
--- /dev/null
+++ b/.idea/Batchly.iml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="PYTHON_MODULE" version="4">
+ <component name="NewModuleRootManager">
+ <content url="file://$MODULE_DIR$" />
+ <orderEntry type="jdk" jdkName="Python 3.13" jdkType="Python SDK" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ </component>
+</module> \ No newline at end of file
diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
new file mode 100644
index 0000000..105ce2d
--- /dev/null
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -0,0 +1,6 @@
+<component name="InspectionProjectProfileManager">
+ <settings>
+ <option name="USE_PROJECT_PROFILE" value="false" />
+ <version value="1.0" />
+ </settings>
+</component> \ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..23231ce
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13" project-jdk-type="Python SDK" />
+</project> \ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..e8baca6
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectModuleManager">
+ <modules>
+ <module fileurl="file://$PROJECT_DIR$/.idea/Batchly.iml" filepath="$PROJECT_DIR$/.idea/Batchly.iml" />
+ </modules>
+ </component>
+</project> \ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..64bbc21
--- /dev/null
+++ b/README.md
@@ -0,0 +1,40 @@
+Below are the steps to get your plugin running. You can also find instructions at:
+
+ https://www.figma.com/plugin-docs/plugin-quickstart-guide/
+
+This plugin template uses Typescript and NPM, two standard tools in creating JavaScript applications.
+
+First, download Node.js which comes with NPM. This will allow you to install TypeScript and other
+libraries. You can find the download link here:
+
+ https://nodejs.org/en/download/
+
+Next, install TypeScript using the command:
+
+ npm install -g typescript
+
+Finally, in the directory of your plugin, get the latest type definitions for the plugin API by running:
+
+ npm install --save-dev @figma/plugin-typings
+
+If you are familiar with JavaScript, TypeScript will look very familiar. In fact, valid JavaScript code
+is already valid Typescript code.
+
+TypeScript adds type annotations to variables. This allows code editors such as Visual Studio Code
+to provide information about the Figma API while you are writing code, as well as help catch bugs
+you previously didn't notice.
+
+For more information, visit https://www.typescriptlang.org/
+
+Using TypeScript requires a compiler to convert TypeScript (code.ts) into JavaScript (code.js)
+for the browser to run.
+
+We recommend writing TypeScript code using Visual Studio code:
+
+1. Download Visual Studio Code if you haven't already: https://code.visualstudio.com/.
+2. Open this directory in Visual Studio Code.
+3. Compile TypeScript to JavaScript: Run the "Terminal > Run Build Task..." menu item,
+ then select "npm: watch". You will have to do this again every time
+ you reopen Visual Studio Code.
+
+That's it! Visual Studio Code will regenerate the JavaScript file every time you save.
diff --git a/code.ts b/code.ts
new file mode 100644
index 0000000..b1a0432
--- /dev/null
+++ b/code.ts
@@ -0,0 +1,37 @@
+// This plugin will open a window to prompt the user to enter a number, and
+// it will then create that many rectangles on the screen.
+
+// This file holds the main code for plugins. Code in this file has access to
+// the *figma document* via the figma global object.
+// You can access browser APIs in the <script> tag inside "ui.html" which has a
+// full browser environment (See https://www.figma.com/plugin-docs/how-plugins-run).
+
+// This shows the HTML page in "ui.html".
+figma.showUI(__html__);
+
+// Calls to "parent.postMessage" from within the HTML page will trigger this
+// callback. The callback will be passed the "pluginMessage" property of the
+// posted message.
+figma.ui.onmessage = (msg: {type: string, count: number}) => {
+ // One way of distinguishing between different types of messages sent from
+ // your HTML page is to use an object with a "type" property like this.
+ if (msg.type === 'create-shapes') {
+ // This plugin creates rectangles on the screen.
+ const numberOfRectangles = msg.count;
+
+ const nodes: SceneNode[] = [];
+ for (let i = 0; i < numberOfRectangles; i++) {
+ const rect = figma.createRectangle();
+ rect.x = i * 150;
+ rect.fills = [{ type: 'SOLID', color: { r: 1, g: 0.5, b: 0 } }];
+ figma.currentPage.appendChild(rect);
+ nodes.push(rect);
+ }
+ figma.currentPage.selection = nodes;
+ figma.viewport.scrollAndZoomIntoView(nodes);
+ }
+
+ // Make sure to close the plugin when you're done. Otherwise the plugin will
+ // keep running, which shows the cancel button at the bottom of the screen.
+ figma.closePlugin();
+};
diff --git a/manifest.json b/manifest.json
new file mode 100644
index 0000000..8c494b0
--- /dev/null
+++ b/manifest.json
@@ -0,0 +1,18 @@
+{
+ "name": "Batchly",
+ "id": "1477301699765765080",
+ "api": "1.0.0",
+ "main": "code.js",
+ "capabilities": [],
+ "enableProposedApi": false,
+ "documentAccess": "dynamic-page",
+ "editorType": [
+ "figma"
+ ],
+ "ui": "ui.html",
+ "networkAccess": {
+ "allowedDomains": [
+ "none"
+ ]
+ }
+} \ No newline at end of file
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..5ecfa49
--- /dev/null
+++ b/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "Batchly",
+ "version": "1.0.0",
+ "description": "Your Figma Plugin",
+ "main": "code.js",
+ "scripts": {
+ "build": "tsc -p tsconfig.json",
+ "lint": "eslint --ext .ts,.tsx --ignore-pattern node_modules .",
+ "lint:fix": "eslint --ext .ts,.tsx --ignore-pattern node_modules --fix .",
+ "watch": "npm run build -- --watch"
+ },
+ "author": "",
+ "license": "",
+ "devDependencies": {
+ "@figma/eslint-plugin-figma-plugins": "*",
+ "@figma/plugin-typings": "*",
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
+ "@typescript-eslint/parser": "^6.12.0",
+ "eslint": "^8.54.0",
+ "typescript": "^5.3.2"
+ },
+ "eslintConfig": {
+ "extends": [
+ "eslint:recommended",
+ "plugin:@typescript-eslint/recommended",
+ "plugin:@figma/figma-plugins/recommended"
+ ],
+ "parser": "@typescript-eslint/parser",
+ "parserOptions": {
+ "project": "./tsconfig.json"
+ },
+ "root": true,
+ "rules": {
+ "@typescript-eslint/no-unused-vars": [
+ "error",
+ {
+ "argsIgnorePattern": "^_",
+ "varsIgnorePattern": "^_",
+ "caughtErrorsIgnorePattern": "^_"
+ }
+ ]
+ }
+ }
+} \ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..5b20a2d
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,11 @@
+{
+ "compilerOptions": {
+ "target": "es6",
+ "lib": ["es6"],
+ "strict": true,
+ "typeRoots": [
+ "./node_modules/@types",
+ "./node_modules/@figma"
+ ]
+ }
+}
diff --git a/ui.html b/ui.html
new file mode 100644
index 0000000..20db7f7
--- /dev/null
+++ b/ui.html
@@ -0,0 +1,17 @@
+<h2>Rectangle Creator</h2>
+<p>Count: <input id="count" type="number" value="5"></p>
+<button id="create">Create</button>
+<button id="cancel">Cancel</button>
+<script>
+
+document.getElementById('create').onclick = () => {
+ const textbox = document.getElementById('count');
+ const count = parseInt(textbox.value, 10);
+ parent.postMessage({ pluginMessage: { type: 'create-shapes', count } }, '*')
+}
+
+document.getElementById('cancel').onclick = () => {
+ parent.postMessage({ pluginMessage: { type: 'cancel' } }, '*')
+}
+
+</script>