You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was thinking more about the whole !important debate, and why it's there in the first place. Wouldn't another way to raise the presence of Aphrodite styles be to simply prefix styles with an ID?
It could easily go on the body or a wrapping element around a component, and I suspect it would magically make the precedence problems go away in a way that has none of the downsides of !important
It is also friendlier to component authors (I'm thinking about react-select here), where users providing inline styles is a really important feature, pun not intended.
... and hey presto, the text is green like it should be.
For something like React Select I can ship that library with stylesheets that prefix the ReactSelect ID, and just wrap the component in a <div id="ReactSelect"> container, and it's highly unlikely any user styles will interfere with the stylesheet in the component.
Technically I'm not complying with the HTML spec if I have more than one ReactSelect ID in my page, so that's kind of ugly. But it will work, and I think it's a trade-off worth discussing.
The text was updated successfully, but these errors were encountered:
Once we have a variant that does not use !important, then component authors will be free to use that, regardless of whether or not it's default.
If you make it bounded on some ID, then when I'm reading the component code, I have to wonder "is this ID sometimes on the page and sometimes not?" Right now, when I look at Aphrodite component code, I know "this is definitely the style it's going to hold, regardless of what context on the page it's in".
I was thinking more about the whole
!important
debate, and why it's there in the first place. Wouldn't another way to raise the presence of Aphrodite styles be to simply prefix styles with an ID?It could easily go on the
body
or a wrapping element around a component, and I suspect it would magically make the precedence problems go away in a way that has none of the downsides of!important
It is also friendlier to component authors (I'm thinking about react-select here), where users providing inline styles is a really important feature, pun not intended.
The old problem:
Legacy stylesheet
New component
The browser sees:
... and the text goes red. Bad.
But with an ID, render your React app inside a
<body id="my-id">
tag then prefix all the classes with#my-id
:The browser sees:
... and hey presto, the text is green like it should be.
For something like React Select I can ship that library with stylesheets that prefix the
ReactSelect
ID, and just wrap the component in a<div id="ReactSelect">
container, and it's highly unlikely any user styles will interfere with the stylesheet in the component.Technically I'm not complying with the HTML spec if I have more than one
ReactSelect
ID in my page, so that's kind of ugly. But it will work, and I think it's a trade-off worth discussing.The text was updated successfully, but these errors were encountered: