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

Disallow composed atoms or electrons to override the same CSS rule #15

Open
axyz opened this issue Oct 9, 2019 · 0 comments
Open

Disallow composed atoms or electrons to override the same CSS rule #15

axyz opened this issue Oct 9, 2019 · 0 comments

Comments

@axyz
Copy link
Member

axyz commented Oct 9, 2019

Feature Summary

We should avoid that 2 classes define the same CSS rule, as by design we cannot make assumption on CSS specificity and order.

Rationale

If an element has tho classes operating on the same rule we cannot predict which one will be applied e.g.

.myClass {
  electrons: (margin_s, margin_l);
}

if the margin will be s or l is not predictable and it shouldn't be as we are breaking the concept of composition here in favor of the one of overrides.

.scrollableRoot {
  electrons: (margin_s);
}
.myClass {
  composes: scrollableRoot;
  electrons: (margin_l);
}

in this case scrollableRoot is already defining some margin and we do not know if .myClass will result in an s or l margin.

Proposed Changes

Ideally we should spot these issues during the atom build. But could also be a separate visitor to avoid performance bottlenecks, and can be run only on the production build.

We could use a visitor to go through the exported atoms and check using postcss and the generated bundle if any exported class string is applying the same css rule twice or more.

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