Skip to content
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

RFC: Component Instance Handling #10

Open
MiguelFranken opened this issue Apr 17, 2024 · 0 comments
Open

RFC: Component Instance Handling #10

MiguelFranken opened this issue Apr 17, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request rfc: wip

Comments

@MiguelFranken
Copy link
Collaborator

MiguelFranken commented Apr 17, 2024

Status: Work in Progress

RFC: Efficient Handling of Figma Component Instances for Vue Code Generation

Summary

This RFC outlines a proposed method for converting Figma designs into Vue code, focusing specifically on the treatment of Figma component instances. Figma's design system is component-based, mirroring the modular architecture of modern web frameworks such as Vue. Our approach involves recognizing and appropriately structuring these Figma component instances within the generated Vue codebase, ensuring each Figma component (and its instances) translates into distinct Vue components.

Background

Figma operates on a component-instance model where the main component acts as a template, and instances are copies that inherit its attributes but can also override them. This model is beneficial for maintaining consistency across designs while allowing variations. Our goal is to replicate this model in Vue to maintain design integrity, enhance code maintainability, and simplify project scalability.

Objectives

  • Preserve Component Hierarchies: Maintain the structured hierarchy of Figma components in the Vue code to keep the component logic and relationships clear.
  • Facilitate Code Maintenance: Automatically generate separate Vue files for each component and instance to make updates more manageable.
  • Promote Reusability: Enable components to be reused across the application without code duplication.
  • Synchronize Updates: Automatically propagate changes from master components to instances, mirroring Figma's update flow.

Proposed Solution

Step-by-Step Process:

  1. Component and Instance Identification:

    • Upon selection of a Figma node, scan its entire node tree to identify any component instances.
    • Generate Vue components for the selected node and for each identified instance. The main Vue file for the selected node will import its child components as needed.
  2. Example of Generated File Structure:

    • ButtonGroup.vue: Represents the selected main component, which includes Button.vue as a child component (imported instance).
    • Button.vue: Stands as a reusable component instance.
  3. Customization Options:

    • Provide settings to customize the naming conventions and other generation parameters through the plugin's user interface. This flexibility helps adapt the output to various project standards or personal preferences.

Alternatives Considered

  • Single File Approach: Generate one Vue file containing all component definitions. While this might simplify initial setup, it could complicate future maintenance and reduce modularity, which are critical for larger projects.
@MiguelFranken MiguelFranken self-assigned this Apr 17, 2024
@MiguelFranken MiguelFranken changed the title RFC: Component Instance Handling Draft: RFC: Component Instance Handling Apr 19, 2024
@MiguelFranken MiguelFranken moved this to Backlog in Onyx Board Apr 20, 2024
@MiguelFranken MiguelFranken changed the title Draft: RFC: Component Instance Handling RFC: Component Instance Handling Apr 22, 2024
@MiguelFranken MiguelFranken added rfc: wip enhancement New feature or request and removed pending triage labels Apr 22, 2024
@MiguelFranken MiguelFranken linked a pull request Apr 23, 2024 that will close this issue
@MiguelFranken MiguelFranken moved this from Backlog to In progress in Onyx Board Apr 23, 2024
@MiguelFranken MiguelFranken removed a link to a pull request Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request rfc: wip
Projects
Status: In progress
Development

No branches or pull requests

1 participant