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

Separate explicitly ordered stylesheets for reliable override behavior #26

Open
lewisl9029 opened this issue Dec 3, 2021 · 0 comments

Comments

@lewisl9029
Copy link
Owner

lewisl9029 commented Dec 3, 2021

At the very least we'll need separate stylesheets for media queries to override other styles, as they have 0 extra specificity. May also want a separate stylesheet for shorthands so that we can place non-shorthands after and have them always override.

As a last resort we can ask users to apply !important which isn't the end of the world as it's easy enough to reason about because we'd still only have 2 levels of specificity.

Can also add some api to apply some vanity class to raise specificity of certain selectors for overriding:

className={useStyles({ padding: '8px' }) + useStyles({ 'padding-top': '16px' }, { increaseSpecificityBy: 1 })}

Can translate to:

className={"r_somehash r_s r_someotherhash"}

With the following css injected:

.r_somehash {
  padding: 8px;
}

.r_s.r_someotherhash {
  padding: 16px;
}

(With specificity of 2+, we can chain more .r_s classes like .r_s.r_s.r_s.r_someotherhash)

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