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 keyframes order #167

Merged
merged 7 commits into from
Oct 8, 2024
Merged

fix keyframes order #167

merged 7 commits into from
Oct 8, 2024

Conversation

jantimon
Copy link
Owner

@jantimon jantimon commented Oct 7, 2024

This pull request addresses issue #166, where keyframe animations defined after their usage in styled components cause an "Unsupported template literal in css expression" error. The solution involves the following key changes:

  • Introduced ScopedVariableReference to manage JavaScript variable references more effectively, ensuring that both simple and complex references (e.g., foo and foo.bar) are handled consistently
  • Updated the handling of keyframe animations and nested CSS expressions to resolve references correctly, even when keyframes are defined after their usage

The solution is to link keyframe references with its declaration even before it was declared and reuse this name later during the actual declaration. This ensures that animations work seamlessly regardless of their order in the file

@jantimon jantimon changed the title Features/keyframe order fix keyframes order Oct 7, 2024
@jantimon jantimon requested a review from Mad-Kat October 8, 2024 06:11
@jantimon
Copy link
Owner Author

jantimon commented Oct 8, 2024

This PR added support for keyframes in objects e.g.:

  • const foo = { bar: keyframes`...` }

The first version supported only identifiers so the following versions were ignored:

  • const foo = { "bar": keyframes`...` }
  • const foo = { 123: keyframes`...` }

So in this update I enhanced visit_mut_object_lit function to support more types of the PropName:

  • Ident: Uses the sym field directly
  • Str: Uses the value field
  • Num: Converts to string
  • BigInt: Converts to string
  • Computed: Skipped (cannot be statically analyzed)

I also added an additional test

@jantimon jantimon requested a review from Tyderion October 8, 2024 07:12
@jantimon jantimon requested a review from Tyderion October 8, 2024 07:35
Copy link
Collaborator

@Tyderion Tyderion left a comment

Choose a reason for hiding this comment

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

lgtm

@jantimon jantimon merged commit 403f392 into main Oct 8, 2024
3 checks passed
@jantimon jantimon deleted the features/keyframe-order branch October 8, 2024 07:56
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.

2 participants