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

Add support for @starting-style at-rule **when not nested** #1788

Open
michaelabrahamian opened this issue Jan 28, 2025 · 0 comments
Open

Add support for @starting-style at-rule **when not nested** #1788

michaelabrahamian opened this issue Jan 28, 2025 · 0 comments

Comments

@michaelabrahamian
Copy link
Collaborator

michaelabrahamian commented Jan 28, 2025

Is your feature request related to a problem? Please describe.

In this PR, support for the @starting-style at-rule was added. However, as mentioned in this comment, it only currently works when nested under another rule, e.g.

const styles = cssMap({
  flyoutOpen: {
    '@media (prefers-reduced-motion: no-preference)': {
      '@starting-style': {
         transform: 'translateX(-100%)',
      },
    },
  },
});

will correctly output:

 @media (prefers-reduced-motion: no-preference) {
    @starting-style {
      ._oyeijq3t {
        transform: translateX(-100%);
      }
    }
  }

However, when it is added as a top-level property (not nested under another property), the extracted CSS does not include a class name. Example:

const styles = cssMap({
  flyoutOpen: {
    '@starting-style': {
        transform: 'translateX(-100%)',
    },
  },
});

will output:

@starting-style transform: translateX(-100%){}

Also, the package's types do not seem to support top-level @starting-style. There seems to be an assumption that at-rules have two "halves" (e.g. like @media (min-width: 64rem)).

Image

This happens for other similar at-rules like @font-face that only have one "term".

Image

Adding a second "term" resolves the type issue:

Image

I believe the types are defined here: https://github.com/atlassian-labs/compiled/blob/BLU-6338-starting-style-reproduction/packages/react/src/css-map/index.ts#L13-L16

Describe the solution you'd like

@starting-style should work as a top level property. Types should also work.

Describe alternatives you've considered

N/A

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

No branches or pull requests

1 participant