|
1 | | -Below are the steps to get your plugin running. You can also find instructions at: |
| 1 | +# Devup Figma Plugin |
| 2 | +<p align="center"> |
| 3 | + <a href="LICENSE"> |
| 4 | + <img src="https://img.shields.io/badge/license-Apache--2.0-blue.svg" alt="License: Apache-2.0" /> |
| 5 | + </a> |
| 6 | + <a href="https://github.com/dev-five-git/devup-figma-plugin/actions"> |
| 7 | + <img src="https://img.shields.io/github/actions/workflow/status/dev-five-git/devup-figma-plugin/CI.yml?branch=main&label=CI" alt="Build Status" /> |
| 8 | + </a> |
| 9 | + <a href="https://codecov.io/gh/dev-five-git/devup-figma-plugin"> |
| 10 | + <img src="https://img.shields.io/codecov/c/github/dev-five-git/devup-figma-plugin" alt="Codecov Coverage" /> |
| 11 | + </a> |
| 12 | + <a href="https://github.com/dev-five-git/devup-figma-plugin"> |
| 13 | + <img src="https://img.shields.io/github/stars/dev-five-git/devup-figma-plugin.svg?style=social&label=Star" alt="GitHub stars" /> |
| 14 | + </a> |
| 15 | + <a href="https://github.com/dev-five-git/devup-figma-plugin/fork"> |
| 16 | + <img src="https://img.shields.io/github/forks/dev-five-git/devup-figma-plugin.svg?style=social&label=Fork" alt="GitHub forks" /> |
| 17 | + </a> |
| 18 | + <a href="https://github.com/dev-five-git/devup-figma-plugin/issues"> |
| 19 | + <img src="https://img.shields.io/github/issues/dev-five-git/devup-figma-plugin.svg" alt="GitHub issues" /> |
| 20 | + </a> |
| 21 | + <a href="https://github.com/dev-five-git/devup-figma-plugin/pulls"> |
| 22 | + <img src="https://img.shields.io/github/issues-pr/dev-five-git/devup-figma-plugin.svg" alt="GitHub pull requests" /> |
| 23 | + </a> |
| 24 | + <a href="https://github.com/dev-five-git/devup-figma-plugin/commits/main"> |
| 25 | + <img src="https://img.shields.io/github/last-commit/dev-five-git/devup-figma-plugin.svg" alt="GitHub last commit" /> |
| 26 | + </a> |
| 27 | +</p> |
2 | 28 |
|
3 | | -https://www.figma.com/plugin-docs/plugin-quickstart-guide/ |
| 29 | +A powerful Figma plugin that generates React/TypeScript code from Figma designs and manages Devup design system configurations. This plugin enables seamless conversion of Figma components to production-ready React code and facilitates design system synchronization. |
4 | 30 |
|
5 | | -This plugin template uses Typescript and NPM, two standard tools in creating JavaScript applications. |
| 31 | +## Features |
6 | 32 |
|
7 | | -First, download Node.js which comes with NPM. This will allow you to install TypeScript and other |
8 | | -libraries. You can find the download link here: |
| 33 | +### 🎨 Code Generation |
| 34 | +- **React Component Generation**: Automatically converts Figma designs to React/TypeScript components using the Devup-UI format |
| 35 | +- **Codegen Support**: Works with Figma's Dev Mode codegen feature for real-time code preview |
| 36 | +- **Component Extraction**: Extracts and generates code for nested components |
| 37 | +- **CLI Export**: Generates bash commands for easy file creation |
9 | 38 |
|
10 | | -https://nodejs.org/en/download/ |
| 39 | +### 📦 Design System Management |
| 40 | +- **Export Devup Config**: Export your design system (colors, typography, components) in JSON or Excel format |
| 41 | +- **Import Devup Config**: Import design system configurations back into Figma |
| 42 | +- **Treeshaking Support**: Optimize exports by removing unused design tokens |
| 43 | +- **Variable Support**: Handles Figma variables and color collections with multiple modes |
11 | 44 |
|
12 | | -Next, install TypeScript using the command: |
| 45 | +### 🚀 Component & Asset Export |
| 46 | +- **Component Export**: Export selected components as a ZIP file containing individual component files |
| 47 | +- **Asset Export**: Export design assets (currently in development) |
13 | 48 |
|
14 | | -npm install -g typescript |
| 49 | +## Installation |
15 | 50 |
|
16 | | -Finally, in the directory of your plugin, get the latest type definitions for the plugin API by running: |
| 51 | +### Prerequisites |
| 52 | +- [Bun](https://bun.sh/) (recommended) or Node.js |
| 53 | +- Figma Desktop App (for plugin development) |
17 | 54 |
|
18 | | -npm install --save-dev @figma/plugin-typings |
| 55 | +### Setup |
19 | 56 |
|
20 | | -If you are familiar with JavaScript, TypeScript will look very familiar. In fact, valid JavaScript code |
21 | | -is already valid Typescript code. |
| 57 | +1. Clone the repository: |
| 58 | +```bash |
| 59 | +git clone <repository-url> |
| 60 | +cd devup-figma-plugin |
| 61 | +``` |
22 | 62 |
|
23 | | -TypeScript adds type annotations to variables. This allows code editors such as Visual Studio Code |
24 | | -to provide information about the Figma API while you are writing code, as well as help catch bugs |
25 | | -you previously didn't notice. |
| 63 | +2. Install dependencies: |
| 64 | +```bash |
| 65 | +bun install |
| 66 | +``` |
26 | 67 |
|
27 | | -For more information, visit https://www.typescriptlang.org/ |
| 68 | +3. Build the plugin: |
| 69 | +```bash |
| 70 | +bun run build |
| 71 | +``` |
28 | 72 |
|
29 | | -Using TypeScript requires a compiler to convert TypeScript (code.ts) into JavaScript (code.js) |
30 | | -for the browser to run. |
| 73 | +4. Load the plugin in Figma: |
| 74 | + - Open Figma Desktop |
| 75 | + - Go to `Plugins` → `Development` → `Import plugin from manifest...` |
| 76 | + - Select the `manifest.json` file from this project |
31 | 77 |
|
32 | | -We recommend writing TypeScript code using Visual Studio code: |
| 78 | +## Development |
33 | 79 |
|
34 | | -1. Download Visual Studio Code if you haven't already: https://code.visualstudio.com/. |
35 | | -2. Open this directory in Visual Studio Code. |
36 | | -3. Compile TypeScript to JavaScript: Run the "Terminal > Run Build Task..." menu item, |
37 | | - then select "npm: watch". You will have to do this again every time |
38 | | - you reopen Visual Studio Code. |
| 80 | +### Available Scripts |
39 | 81 |
|
40 | | -That's it! Visual Studio Code will regenerate the JavaScript file every time you save. |
| 82 | +- `bun run dev` - Start development server with hot reload |
| 83 | +- `bun run build` - Build the plugin for production |
| 84 | +- `bun run watch` - Build the plugin in watch mode |
| 85 | +- `bun run test` - Run tests with coverage |
| 86 | +- `bun run lint` - Check code for linting errors |
| 87 | +- `bun run lint:fix` - Fix linting errors automatically |
| 88 | + |
| 89 | +### Project Structure |
| 90 | + |
| 91 | +``` |
| 92 | +src/ |
| 93 | +├── code.ts # Main plugin entry point |
| 94 | +├── codegen/ # Code generation logic |
| 95 | +│ ├── Codegen.ts # Main codegen class |
| 96 | +│ ├── props/ # Property generators (layout, colors, etc.) |
| 97 | +│ ├── render/ # Component rendering logic |
| 98 | +│ └── utils/ # Codegen utilities |
| 99 | +├── commands/ # Plugin commands |
| 100 | +│ ├── devup/ # Devup export/import functionality |
| 101 | +│ ├── exportAssets.ts # Asset export command |
| 102 | +│ └── exportComponents.ts # Component export command |
| 103 | +└── utils/ # Shared utilities |
| 104 | +``` |
| 105 | + |
| 106 | +## Usage |
| 107 | + |
| 108 | +### Code Generation (Dev Mode) |
| 109 | + |
| 110 | +1. Open Figma in Dev Mode |
| 111 | +2. Select a design element (frame, component, etc.) |
| 112 | +3. The plugin will automatically generate React/TypeScript code in the code panel |
| 113 | +4. You can copy the generated code or use the provided CLI commands |
| 114 | + |
| 115 | +### Export Devup Configuration |
| 116 | + |
| 117 | +1. Select elements in your Figma file |
| 118 | +2. Go to `Plugins` → `Devup` → `Export Devup` (or `Export Devup Excel`) |
| 119 | +3. Choose whether to use treeshaking (removes unused tokens) |
| 120 | +4. The configuration file will be downloaded |
| 121 | + |
| 122 | +### Import Devup Configuration |
| 123 | + |
| 124 | +1. Go to `Plugins` → `Devup` → `Import Devup` (or `Import Devup Excel`) |
| 125 | +2. Select your Devup configuration file |
| 126 | +3. The design system will be imported into Figma |
| 127 | + |
| 128 | +### Export Components |
| 129 | + |
| 130 | +1. Select the components you want to export |
| 131 | +2. Go to `Plugins` → `Devup` → `Export Components` |
| 132 | +3. A ZIP file containing all component files will be downloaded |
| 133 | + |
| 134 | +## Technical Details |
| 135 | + |
| 136 | +### Code Generation |
| 137 | + |
| 138 | +The plugin converts Figma nodes to React components by: |
| 139 | +- Analyzing layout properties (auto-layout, padding, spacing) |
| 140 | +- Converting styles (colors, typography, effects) |
| 141 | +- Handling component variants and instances |
| 142 | +- Generating proper TypeScript types |
| 143 | +- Optimizing CSS properties |
| 144 | + |
| 145 | +### Supported Figma Features |
| 146 | + |
| 147 | +- ✅ Auto Layout |
| 148 | +- ✅ Components & Variants |
| 149 | +- ✅ Text Styles & Typography |
| 150 | +- ✅ Color Variables & Collections |
| 151 | +- ✅ Effects (shadows, blurs) |
| 152 | +- ✅ Borders & Strokes |
| 153 | +- ✅ Grid Layouts |
| 154 | +- ✅ Transform properties |
| 155 | + |
| 156 | +### Build Configuration |
| 157 | + |
| 158 | +- **Bundler**: Rspack |
| 159 | +- **Language**: TypeScript |
| 160 | +- **Linter**: Biome |
| 161 | +- **Test Runner**: Bun |
| 162 | +- **Package Manager**: Bun |
| 163 | + |
| 164 | +## Testing |
| 165 | + |
| 166 | +Run tests with coverage: |
| 167 | +```bash |
| 168 | +bun run test |
| 169 | +``` |
| 170 | + |
| 171 | +Test coverage reports are generated in the `coverage/` directory. |
| 172 | + |
| 173 | +## Contributing |
| 174 | + |
| 175 | +1. Follow the existing code style (enforced by Biome) |
| 176 | +2. Write tests for new features |
| 177 | +3. Ensure all tests pass and linting checks succeed |
| 178 | +4. Update documentation as needed |
| 179 | + |
| 180 | +## License |
| 181 | + |
| 182 | +[Add your license information here] |
| 183 | + |
| 184 | +## Support |
| 185 | + |
| 186 | +For issues, questions, or contributions, please [open an issue](link-to-issues) or contact the maintainers. |
0 commit comments