Skip to content

feat: Add RTL variant detection via Figma component property - #52

Merged
alexey1312 merged 3 commits into
mainfrom
alexey1312/add-rtl-as-property
Feb 10, 2026
Merged

feat: Add RTL variant detection via Figma component property#52
alexey1312 merged 3 commits into
mainfrom
alexey1312/add-rtl-as-property

Conversation

@alexey1312

Copy link
Copy Markdown
Collaborator

Description

Detect RTL (Right-to-Left) icons/images via structured Figma COMPONENT_SET variant property instead of relying solely on description text. The variant property name defaults to "RTL" and is configurable through PKL config (rtlProperty).

Changes

  • PKL schema: Add rtlProperty field to FrameSource (inherited by all platform entry types)
  • Figma API: Add ContainingComponentSet to ContainingFrame for variant component name resolution
  • RTL detection: Variant-based detection (RTL=On/RTL=Off) with description fallback
  • RTL=On filtering: Skip RTL=On variant components (iOS/Android mirror automatically)
  • Icon naming: Use containingComponentSet.name for variant components instead of raw variant name
  • Plugin API: Add rtlProperty to IconsSourceInput and ImagesSourceInput — flows through entire pipeline: PKL config → entry → SourceInput → Context → Loader
  • All platforms: Updated bridge methods in iOS, Android, Flutter, Web entry files and exporters
  • Tests: 23 new tests covering Component RTL extensions and rtlProperty passthrough
  • Docs: Updated CONFIG.md, api-reference.md, CLAUDE.md, example PKL config

How RTL detection works

  1. If component's COMPONENT_SET has RTL variant property → mark as RTL, skip RTL=On variants
  2. Fallback: check component description for "rtl" text (backward compatible)
  3. Set rtlProperty = null in PKL config to disable variant-based detection

🤖 Generated with Claude Code

Introduce the `rtlProperty` configuration to support RTL variant detection in
Figma components. This change updates the loaders to filter RTL=On variants
based on a customizable RTL property name, which defaults to "RTL". By setting
`rtlProperty`, components with this variant property are marked as RTL, and RTL=On
variants are automatically skipped (iOS/Android auto-mirror these variants).
This enhances platform support for RTL languages by ensuring icons and images
are properly processed without redundant RTL=On variants.
Add `rtlProperty` field to `ImagesSourceInput` and `IconsSourceInput` to enable
detection of right-to-left variants for Figma components. Ensure `rtlProperty` is
propagated correctly through the export process for all platforms (iOS, Android,
Flutter, Web) without modifying existing behaviors for left-to-right components.

Implement tests to validate the preservation of `rtlProperty` through the data
pipeline. Transition from default hardcoded RTL property `"RTL"` to configurable
approach, allowing per-entry customization or disabling (by setting it to `nil`).

This change enhances localization support by providing optional RTL variant support,
while maintaining backward compatibility with current workflows.
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @alexey1312, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the handling of Right-to-Left (RTL) assets by introducing a more structured and configurable detection method. It moves away from description-based RTL identification to leverage dedicated Figma component properties, enhancing accuracy and developer control. The changes ensure that RTL variants are correctly identified, filtered, and named across all supported platforms, streamlining the asset pipeline and providing greater flexibility for designers and developers.

Highlights

  • Enhanced RTL Detection: Implemented a new mechanism to detect Right-to-Left (RTL) icons and images using a structured Figma component property (defaulting to 'RTL') instead of relying solely on description text. This provides more robust and configurable RTL support.
  • Figma API Integration: Extended the Figma API response models to include ContainingComponentSet within ContainingFrame, enabling proper resolution of component names for variant components.
  • Variant Filtering and Naming: Introduced automatic filtering for RTL=On variant components (as iOS/Android handle mirroring automatically) and updated icon naming logic to use the containingComponentSet.name for variant components, ensuring consistent naming.
  • Configurability: Added a configurable rtlProperty field to FrameSource in the PKL schema, allowing users to specify the Figma property name for RTL variant detection or disable variant-based detection entirely.
  • Platform-wide Integration: Propagated the rtlProperty through the entire asset generation pipeline, from PKL config to SourceInput, Context, and Loader across iOS, Android, Flutter, and Web platforms.
  • Comprehensive Testing and Documentation: Added 23 new tests specifically covering Component RTL extensions and rtlProperty passthrough, and updated relevant documentation files (CONFIG.md, api-reference.md, CLAUDE.md, example PKL config) to reflect the new features.
Changelog
  • .claude/rules/api-reference.md
    • Documented new Figma API response key types, including ContainingComponentSet and its purpose for variant components.
  • CLAUDE.md
    • Added new code patterns for modifying loader configurations and FrameSource/SourceInput.
    • Updated troubleshooting section with a new entry for PKL FrameSource change.
  • CONFIG.md
    • Documented the new rtlProperty field in FrameSource with its default value and explanation of RTL detection logic.
    • Updated inherited fields for iOS.IconsEntry, iOS.ImagesEntry, Android.IconsEntry, Android.ImagesEntry, Flutter.IconsEntry, Flutter.ImagesEntry, Web.IconsEntry, and Web.ImagesEntry to include rtlProperty.
  • Sources/ExFig-Android/Config/AndroidIconsEntry.swift
    • Passed rtlProperty to the IconsSourceInput initializer.
  • Sources/ExFig-Android/Config/AndroidImagesEntry.swift
    • Passed rtlProperty to the ImagesSourceInput initializer.
  • Sources/ExFig-Android/Export/AndroidImagesExporter.swift
    • Passed rtlProperty when creating an ImagesSourceInput for SVG sources.
  • Sources/ExFig-Flutter/Config/FlutterIconsEntry.swift
    • Passed rtlProperty to the IconsSourceInput initializer.
  • Sources/ExFig-Flutter/Config/FlutterImagesEntry.swift
    • Passed rtlProperty to the ImagesSourceInput initializer in two locations.
  • Sources/ExFig-Web/Config/WebIconsEntry.swift
    • Passed rtlProperty to the IconsSourceInput initializer.
  • Sources/ExFig-Web/Config/WebImagesEntry.swift
    • Passed rtlProperty to the ImagesSourceInput initializer.
  • Sources/ExFig-iOS/Config/iOSIconsEntry.swift
    • Passed rtlProperty to the IconsSourceInput initializer.
  • Sources/ExFig-iOS/Config/iOSImagesEntry.swift
    • Passed rtlProperty to the ImagesSourceInput initializer.
  • Sources/ExFigCLI/Context/IconsExportContextImpl.swift
    • Updated IconsLoaderConfig initialization to include rtlProperty.
  • Sources/ExFigCLI/Context/ImagesExportContextImpl.swift
    • Updated ImagesLoaderConfig initialization to include rtlProperty.
  • Sources/ExFigCLI/Loaders/IconsLoader.swift
    • Added rtlProperty to the IconsLoaderConfig struct.
    • Updated IconsLoaderConfig factory methods (forIOS, forAndroid, forFlutter, forWeb, defaultConfig) to include rtlProperty.
    • Passed rtlProperty to ImageLoaderBase methods within IconsLoader.
  • Sources/ExFigCLI/Loaders/ImageLoaderBase.swift
    • Modified fetchImageComponents to filter out RTL=On variants based on rtlProperty.
    • Updated fetchImageComponents and related methods to accept rtlProperty as a parameter.
    • Changed asset filtering and metadata generation to use the new iconName property.
    • Added iconName computed property to Component to get the real icon name (component set name for variants).
    • Implemented rtlVariantValue(propertyName:) to extract variant property values from component names.
    • Added shouldSkipAsRTLVariant(propertyName:) to determine if a component should be skipped.
    • Updated useRTL(rtlProperty:) to prioritize variant-based detection over description-based fallback.
  • Sources/ExFigCLI/Loaders/ImagesLoader.swift
    • Added rtlProperty to the ImagesLoaderConfig struct.
    • Updated ImagesLoaderConfig factory methods (forIOS, forAndroid, forFlutter, forWeb, defaultConfig) to include rtlProperty.
    • Passed rtlProperty to ImageLoaderBase methods within ImagesLoader.
  • Sources/ExFigCLI/Resources/Schemas/Common.pkl
    • Added rtlProperty field with a default value of "RTL" to the FrameSource class.
  • Sources/ExFigCLI/Resources/Schemas/examples/exfig-ios.pkl
    • Added a commented-out example for configuring rtlProperty.
  • Sources/ExFigConfig/Generated/Android.pkl.swift
    • Added rtlProperty to Android.IconsEntry and Android.ImagesEntry structs.
    • Updated initializers for Android.IconsEntry and Android.ImagesEntry to accept rtlProperty.
  • Sources/ExFigConfig/Generated/Common.pkl.swift
    • Added rtlProperty to the Common_FrameSource protocol.
    • Added rtlProperty to the Common.FrameSource struct and its initializer.
  • Sources/ExFigConfig/Generated/Flutter.pkl.swift
    • Added rtlProperty to Flutter.IconsEntry and Flutter.ImagesEntry structs.
    • Updated initializers for Flutter.IconsEntry and Flutter.ImagesEntry to accept rtlProperty.
  • Sources/ExFigConfig/Generated/Web.pkl.swift
    • Added rtlProperty to Web.IconsEntry and Web.ImagesEntry structs.
    • Updated initializers for Web.IconsEntry and Web.ImagesEntry to accept rtlProperty.
  • Sources/ExFigConfig/Generated/iOS.pkl.swift
    • Added rtlProperty to iOS.IconsEntry and iOS.ImagesEntry structs.
    • Updated initializers for iOS.IconsEntry and iOS.ImagesEntry to accept rtlProperty.
  • Sources/ExFigCore/Protocol/IconsExportContext.swift
    • Added rtlProperty to the IconsSourceInput struct and its initializer.
  • Sources/ExFigCore/Protocol/ImagesExportContext.swift
    • Added rtlProperty to the ImagesSourceInput struct and its initializer.
  • Sources/FigmaAPI/Endpoint/ComponentsEndpoint.swift
    • Added containingComponentSet property to ContainingFrame.
    • Defined a new ContainingComponentSet struct to represent parent component sets.
  • Tests/ExFigTests/Input/EnumBridgingTests.swift
    • Updated initializers for various entry types to include the new rtlProperty field.
  • Tests/ExFigTests/Loaders/ComponentRTLTests.swift
    • Added a new test file ComponentRTLTests.swift to validate Component RTL detection logic.
    • Implemented tests for iconName, rtlVariantValue, shouldSkipAsRTLVariant, and useRTL.
  • Tests/ExFigTests/Loaders/IconsLoaderConfigTests.swift
    • Updated IconsLoaderConfig initializers in existing tests to include rtlProperty.
    • Added new tests to verify rtlProperty passthrough from entry to source to config.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces a robust mechanism for detecting RTL variants of icons and images directly from Figma component properties, which is a significant improvement over relying on description text. The changes are extensive, touching configuration, data models, loaders, and exporters across all platforms, and are well-executed. The documentation and tests have been thoroughly updated to reflect these new capabilities. I have one suggestion to improve the robustness of the variant property parsing.

Comment thread Sources/ExFigCLI/Loaders/ImageLoaderBase.swift
@alexey1312 alexey1312 changed the title Add RTL variant detection via Figma component property feat: Add RTL variant detection via Figma component property Feb 10, 2026
@alexey1312
alexey1312 merged commit 3a9aac4 into main Feb 10, 2026
3 checks passed
@alexey1312
alexey1312 deleted the alexey1312/add-rtl-as-property branch February 10, 2026 04:38
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.

1 participant