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

Understanding "composes" peer classes #398

Open
douglasjunior opened this issue Oct 9, 2023 · 2 comments
Open

Understanding "composes" peer classes #398

douglasjunior opened this issue Oct 9, 2023 · 2 comments

Comments

@douglasjunior
Copy link

douglasjunior commented Oct 9, 2023

I'm trying to use composes with multiple class levels, but it's working for part of my need.

My project is configured with vite and lightningcss.

I have the following scenario:

component.module.css

.classA {
  composes: fontSizes--headingMedium from global;
  background-color: magenta;
}

.classB {
  composes: classA from '.';
  text-align: center;
}

.myComponentClass {
  composes: classB from '.';
  border: solid 1px red;
}

theme.css (imported globally in my App.tsx)

.fontWeights--bold {
  font-family: Arial, sans-serif, NunitoSans-Bold;
  font-weight: bold;
}

.fontSizes--headingMedium {
  composes: fontWeights--bold from '.';
  font-size: 24px;
  line-height: 24px;
  letter-spacing: 0;
}

Result appearance

image

Result HTML

image

Result CSS

image

So, note that the composes: fontWeights--bold from '.'; was ignored by the css-modules transpilation.

What I'm doing wrong?

Reproducible example: https://codesandbox.io/p/sandbox/lightningcss-css-modules-composition-demo-6k9x67

@douglasjunior
Copy link
Author

douglasjunior commented Oct 9, 2023

The most strange part, is that if I remove from '.'; from the local classes, the result is even worse:

component.module.css

.classA {
  composes: fontSizes--headingMedium from global;
  background-color: magenta;
}

.classB {
  composes: classA;
  text-align: center;
}

.myComponentClass {
  composes: classB;
  border: solid 1px red;
}

Result appearance

image

Result HTML

image

Result CSS

image

Note that the classA was completely ignored.

@douglasjunior
Copy link
Author

Sorry, I think that I need to open this issue in the lightningcss GitHub, right?

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