Skip to content

Refactor library - New Penpot Export Format #254

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: main
Choose a base branch
from

Conversation

Cenadros
Copy link
Collaborator

@Cenadros Cenadros commented May 23, 2025

This pull request introduces several updates to the codebase, focusing on improving the handling of shape transformations, simplifying path translation logic, and enhancing stroke and effect translations. Additionally, it includes dependency updates and cleanup of unused imports. Below is a categorized summary of the most important changes:

Fill Image and Stroke Image Enhancements

  • Refactored how fill images and stroke properties are handled.
  • Updated stroke handling to ensure strokeColor is always set, defaulting to #000000 if not provided.
  • Changed the export file extension for downloads from .zip to .penpot.
  • Enhanced the PenpotContext interface with new methods for managing media (e.g., addFileMedia, getMediaAsImage) and returning UUIDs for color and media additions.
  • Added a new Media type for handling media metadata.
  • Modified the handling of fills and strokes in various shape and library creator functions to require the context parameter, making their behavior more consistent and context-aware.

Shape Transformation Enhancements:

  • Added rx and ry properties to corner radius transformations for better compatibility with Penpot's shape representation. (plugin-src/transformers/partials/transformCornerRadius.ts) [1] [2]
  • Modified transformRotationAndPosition to accept SceneNode instead of LayoutMixin, aligning the function with broader node compatibility. (plugin-src/transformers/partials/transformRotationAndPosition.ts)
  • Updated transformGroupNodeLike function to use SceneNode directly, simplifying node handling. (plugin-src/transformers/transformGroupNode.ts)

Path Translation Simplifications:

  • Replaced Segment type with direct Command usage in path translation logic, and introduced functions to generate SVG path strings (translateCommandsToPathString). (plugin-src/translators/vectors/translateNonRotatedCommands.ts, plugin-src/translators/vectors/translateRotatedCommands.ts) [1] [2] [3]
  • Removed unused Segment imports across files to clean up dependencies. (plugin-src/transformers/transformLineNode.ts, plugin-src/transformers/transformPathNode.ts, plugin-src/utils/applyRotation.ts) [1] [2] [3]

Stroke and Effect Translation Improvements:

  • Enhanced stroke translation by introducing default stroke color (#000000) and supporting StrokeImage for image-based strokes. (plugin-src/translators/translateStrokes.ts) [1] [2]
  • Added id property to shadow effect translations for better identification. (plugin-src/translators/translateShadowEffects.ts)
  • Specified BlurEffectBase type in blur effect translation for stricter type safety. (plugin-src/translators/translateBlurEffects.ts)

Dependency Updates:

  • Added @penpot/library dependency to package.json for Penpot integration support. (package.json)

Other Changes:

  • Simplified syncAttributes by removing unnecessary colons in attribute group names. (plugin-src/translators/translateTouched.ts)

Cenadros added 3 commits May 29, 2025 15:15
feat: enhance ExporterProgress component to display current export item

fix: modify useFigma hook to capture and display progress messages during export
…transformGroupNodeLike functions to SceneNode for consistency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant