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

Cannot specify media query in different module - Invalid pseudo or at-rule. #241

Open
lotusjohn opened this issue Nov 28, 2024 · 1 comment
Labels
bug: stylex An issue that originates from StyleX bug Something isn't working

Comments

@lotusjohn
Copy link

lotusjohn commented Nov 28, 2024

Describe the issue

Im getting an error when I try to specify a helper for media queries to not have to write the string in every condition (or a const in every module I want to use it)
Invalid pseudo or at-rule.
If I specify the const in the same module, it works.
It doesn't matter if it is in a .stylex.ts file or .ts only.

// media.stylex.ts or media.ts
export const MEDIA = {
  md: "@media (min-width: 1024px)",
  lg: "@media (min-width: 1920px)",
};
//Component.tsx
const styles = css.create({
  comp: {
    width: {
      default: 100,
      [MEDIA.md]: 200
    }
  }
})

export const Comp = () => {
   return <html.div style={styles.comp} />
}

Expected behavior

Expect to be able to import media query helper from a different module.

Steps to reproduce

Basic setup.

  1. Create a basic RSD install
  2. Create a media.stylex.ts file
  3. Add this block to it
export const MEDIA = {
  md: "@media (min-width: 1024px)",
  lg: "@media (min-width: 1920px)",
};
  1. Create a Comp.tsx file
  2. Add a component using this media query and import the MEDIA const from the other module
const styles = css.create({
  comp: {
    width: {
      default: 100,
      [MEDIA.md]: 200
    }
  }
})

export const Comp = () => {
   return <html.div style={styles.comp}>Hello</html.div>
}

Test case

No response

Additional comments

strict-dom version 0.0.27

@lotusjohn lotusjohn added the bug Something isn't working label Nov 28, 2024
@necolas
Copy link
Contributor

necolas commented Nov 28, 2024

This is a shortcoming of StyleX. See facebook/stylex#724

@necolas necolas added the bug: stylex An issue that originates from StyleX label Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug: stylex An issue that originates from StyleX bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants