How imnotashrimp/copythat-airtable-figma works
Main components
• Figma Environment & Plugin Integration:
• manifest.json: This file defines the plugin’s metadata and is how Figma integrates and registers the plugin.
• UI files: src/ui.html and src/ui.ts are responsible for rendering and handling interactions in the plugin’s user interface.
• Core Plugin Logic:
• Entry point and main logic: src/code.ts – orchestrates how the plugin operates once it’s invoked in Figma.
• Utility modules: Files like src/date-time.ts, src/fonts.ts, src/format-text.ts, src/replace-text.ts, and src/var-test.ts provide helper functions and variable processing.
• External Service Integration (Airtable):
• Airtable Service Layer: Modules under src/airtable (get-airtable-records.ts and get-set-airtable-config.ts) are dedicated to fetching records from Airtable, configuring the connection, and potentially managing the data flow from Airtable.
• Build and Deployment Tools:
• Bundler & Transpilers: webpack.config.js (for bundling) and babel.config.js are used to prepare the code for execution, ensuring it complies with the required specifications for Figma.
• TypeScript configuration: tsconfig.json ensures the TypeScript code is compiled correctly.
• Package Management: package.json, package-lock.json, and the related npm dependencies.
• Testing Environment:
• Test cases: Files in the __tests__ directory (e.g., dateTime.spec.js, varTest.spec.js) using Jest to validate the functionality.
Relationships and data flow
• The developer builds the plugin using the provided build tools (Webpack, Babel, TypeScript) and manages dependencies via npm.
• The plugin is loaded into Figma via manifest.json.
• Within Figma:
• When triggered (via the Figma menu), the plugin’s UI (src/ui.html & src/ui.ts) is rendered, offering configuration options for Airtable (like specifying field names, etc.).
• The core logic (src/code.ts) listens for user actions, such as syncing text.
• The core logic calls the Airtable modules to fetch the required records.
• Once records are fetched and processed (using utility modules to format/replace text), the plugin updates the Figma document text nodes that match the placeholders.
• Testing components ensure that functions, particularly those that process variables and dates, behave as expected. Jest tests in __tests__ lend confidence to module interactions.
Architectural patterns and design principles
• Modularization: The project is split into distinct modules for Airtable integration, UI management, and general utility functions. This aligns with modular development best practices.
• Separation of Concerns: The clear separation between UI, core processing, and external service (Airtable) calls.
• Plugin architecture standard for Figma: Leveraging manifest.json for registration and appropriate signaling to Figma’s runtime environment.
• Build and deployment pipeline: Maintaining configuration files (tsconfig.json, webpack.config.js, babel.config.js) and CI workflows (in .github/workflows) that run tests.
• Frontend (Figma plugin UI)
• Backend / core logic
• External API integration
• Build environment and testing infrastructure.