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

Fix custom linear gradient angles #3109

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

Conversation

macintoshhelper
Copy link
Contributor

@macintoshhelper macintoshhelper commented Aug 30, 2024

Why does this PR exist?

Partial fix for #2331

What does this pull request do?

Before

image

After

image

Testing this change

Additional Notes (if any)

Copy link

changeset-bot bot commented Aug 30, 2024

🦋 Changeset detected

Latest commit: a7c5661

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Aug 30, 2024

⤵️ 📦 ✨ The artifact was successfully created! Want to test it? Download it here 👀 🎁

const normalisedCos = Math.cos(normalizedAngleRad);
scale = normalisedCos;
} else {
// FIXME: fallback, but might break paintStyleMatchesColorToken
Copy link
Contributor

Choose a reason for hiding this comment

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

Might break? Is there another safe fallback for this case, or a test to doublecheck?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Node type check removed, so this is not relevant now. paintStyleMatchesColorToken might fail until the nodes are updated (apply to selection/page is run), but the previous gradient should be treated as broken/incorrect I think until updated.


let scale = 1;

if (['RECTANGLE', 'FRAME'].includes(node?.type || '')) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be saved as a constant above, easier to find if there's other types that need to be added later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have removed this as it seems to be unnecessary. Vector linear gradient scales were breaking because of this check.


const gradientTransformMatrix = inverse(transformationMatrix).to2DArray();
Copy link
Contributor

Choose a reason for hiding this comment

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

inverse(...) is not needed anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, since new Matrix([...]) is being called inline now.

Copy link
Contributor

github-actions bot commented Sep 4, 2024

Commit SHA:11c54b5bb79d231532c8a89e6a162b368c8cc4de

Test coverage results 🧪

Code coverage diff between base branch:main and head branch: fix/2331-custom-angle-linear-gradients 
Status File % Stmts % Branch % Funcs % Lines
🟢 total 67.1 (0.02) 57.73 (-0.01) 63.87 (0.01) 67.44 (0.02)
🟢 packages/tokens-studio-for-figma/src/plugin/figmaTransforms/gradients.ts 75 (5) 55 (-2.89) 100 (0) 74.6 (5.22)

Copy link
Contributor

github-actions bot commented Sep 4, 2024

Commit SHA:11c54b5bb79d231532c8a89e6a162b368c8cc4de
Current PR reduces the test coverage percentage by 1 for some tests

@macintoshhelper macintoshhelper marked this pull request as ready for review September 5, 2024 10:54
@six7
Copy link
Collaborator

six7 commented Oct 15, 2024

@macintoshhelper linting seems to have failed here

@macintoshhelper
Copy link
Contributor Author

Fixed the ESLint errors

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.

3 participants