Skip to content

Refactor Plugin - #184

Merged
bernaferrari merged 98 commits into
mainfrom
refactor
Mar 19, 2025
Merged

bernaferrari merged 98 commits into
mainfrom
refactor

Conversation

@bernaferrari

Copy link
Copy Markdown
Owner

I improved the design and started using Figma REST API so plugin is as faster as ever. The REST API might cause some bugs, so need to check if everything is as best as possible.

image

@bernaferrari
bernaferrari force-pushed the refactor branch 2 times, most recently from 4e20a43 to 599a994 Compare March 4, 2025 22:56
@bernaferrari
bernaferrari requested a review from Copilot March 7, 2025 15:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR refactors the plugin to improve design, incorporate the Figma REST API, and add extensive debug logging while updating various conversion and rendering flows. Key changes include:

  • Exporting additional helper functions and adjusting existing utility functions.
  • Updating UI rendering and code generation logic in the plugin.
  • Modifying conversion logic for Figma nodes, including changes in flattening and cloning behavior.

Reviewed Changes

File Description
packages/backend/src/common/lowercaseFirstLetter.ts Now exports the helper function explicitly.
apps/plugin/ui-src/main.tsx Updates ReactDOM usage with createRoot.
packages/backend/src/altNodes/altNodeUtils.ts Refines children type-checking and error handling in SVG export.
packages/backend/src/common/color.ts Adds new functions for converting colors and gradients.
packages/backend/src/common/nodeWidthHeight.ts Revises logic to check explicit layout sizing properties.
packages/backend/src/common/nodeVisibility.ts Updates filtering logic for visible nodes.
packages/backend/src/code.ts Adds extensive debug logging and refactors settings management.
packages/backend/src/tailwind.config.js Removes unused theme extensions and plugins.
packages/backend/src/common/exportAsyncProxy.ts Adjusts export logic using figma.getNodeByIdAsync.
packages/backend/src/altNodes/altConversion.ts Simplifies node conversion and adjusts cloning behavior.
packages/backend/src/common/retrieveUI/convertToCode.ts Refines conversion to code for HTML mode.
packages/backend/src/common/commonFormatAttributes.ts Modifies attribute formatting to use lowercase first letters.
packages/backend/src/common/commonPosition.ts Adds a defensive check on layoutPositioning.
packages/backend/src/common/images.ts Adjusts image export logic by using the node directly.

Copilot reviewed 69 out of 69 changed files in this pull request and generated 2 comments.

Comment on lines +36 to +42
if (!result) {
// If any child is not of the specified types, return false
return false;
}
}
// all children are true
return true;
// All children are valid types
return node.children.length > 0; // Only return true if there are children

Copilot AI Mar 7, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The revised logic in isTypeOrGroupOfTypes now returns false if any child node does not match. Please confirm that this behavior is intended, as it changes the previous iteration over all children.

Copilot uses AI. Check for mistakes.
Comment thread packages/backend/src/altNodes/altConversion.ts Outdated
@mimshwright

Copy link
Copy Markdown
Contributor

The idea of a pull request and separate branch is to protect the main branch from unvalidated new code. But since the released version is the refactored version, and all new work is happening on this branch, there is no point in keeping it separate anymore. So it should be merged into main.

@bernaferrari

Copy link
Copy Markdown
Owner Author

Yeah, I agree. I was waiting for 2 consecutive days without big changes.

@bernaferrari
bernaferrari merged commit effebaa into main Mar 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants