fix: radial gradient export alignment and positioning#3837
fix: radial gradient export alignment and positioning#3837akshay-gupta7 wants to merge 2 commits intomainfrom
Conversation
|
|
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Duplication | 10 |
TIP This summary will be updated as you push new changes. Give us feedback
There was a problem hiding this comment.
Pull request overview
Improves handling of radial gradients so exported/parsed gradients align more closely with Figma’s positioning behavior.
Changes:
- Updated radial gradient parsing to account for
at <position>and introduced transform adjustments for common positions. - Extended gradient parsing to accept repeating gradient function names and case-insensitive function names.
- Added radial-gradient transform test cases and added radial matching support for paint style comparisons.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| packages/tokens-studio-for-figma/src/plugin/setColorValuesOnTarget.ts | Adjusts gradient paint creation typing (non-null assertion on gradientTransform). |
| packages/tokens-studio-for-figma/src/plugin/figmaUtils/styleMatchers/paintStyleMatchesColorToken.ts | Adds matching support for GRADIENT_RADIAL paint styles. |
| packages/tokens-studio-for-figma/src/plugin/figmaTransforms/gradients.ts | Enhances radial gradient transform calculations; broadens supported gradient function names; normalizes function-name casing. |
| packages/tokens-studio-for-figma/src/plugin/figmaTransforms/gradients.test.ts | Adds tests for radial-gradient positioning/case-insensitivity behavior. |
...s/tokens-studio-for-figma/src/plugin/figmaUtils/styleMatchers/paintStyleMatchesColorToken.ts
Outdated
Show resolved
Hide resolved
packages/tokens-studio-for-figma/src/plugin/figmaTransforms/gradients.ts
Outdated
Show resolved
Hide resolved
packages/tokens-studio-for-figma/src/plugin/figmaTransforms/gradients.ts
Outdated
Show resolved
Hide resolved
packages/tokens-studio-for-figma/src/plugin/figmaTransforms/gradients.ts
Show resolved
Hide resolved
...s/tokens-studio-for-figma/src/plugin/figmaUtils/styleMatchers/paintStyleMatchesColorToken.ts
Outdated
Show resolved
Hide resolved
|
Commit SHA:d8423f2909030d49b9cc96677e3bc67d6ca4ff0e Test coverage results 🧪
|
|
Commit SHA:d8423f2909030d49b9cc96677e3bc67d6ca4ff0e |
Why does this PR exist?
This PR addresses inconsistencies and missing features in radial gradient handling between Tokens Studio and Figma. Previously, radial gradients were not accurately positioned or aligned during export, and the plugin lacked the ability to match radial gradient tokens against existing Figma paint styles.
What does this pull request do?
radial-gradientsyntax, including support for theat <position>keyword and shape/size declarations (circle,ellipse).GRADIENT_RADIALinpaintStyleMatchesColorToken.ts. This allows the plugin to correctly identify when a Figma style already matches a radial gradient token, preventing unnecessary style overrides.at,circle, etc.). This fixes a previous bug where modern color formats likeoklch()or named colors were sometimes misclassified as positioning metadata.gradients.tsandsetColorValuesOnTarget.ts.Testing this change
yarn workspace @tokens-studio/figma-plugin test src/plugin/figmaUtils/styleMatchers/paintStyleMatchesColorToken.test.tsto verify radial style matching.yarn workspace @tokens-studio/figma-plugin test src/plugin/figmaTransforms/gradients.test.tsto verify the transformation engine.radial-gradient(at top left, #fff, #000)) to a layer and verify it matches the expected visual output in Figma.Additional Notes (if any)
This PR also includes updates to the
PaintStyletest mock to align with the latest@figma/plugin-typings.