typestyle: Theming can break due to deduping
This is wrong http://typestyle.io/#/core/-classes- :
If a dom element has two classes applied to it, the second class gets to override any first class properties
It only works if the second class is written to the generated CSS after the first class. This is not necessarily true in the presence of freestyle deduping.
HotFix workaround is of course using &&
like we recommended for ordering pseudo classes http://typestyle.io/#/advanced/concept-ordering-pseudo-classes:
const messageClass = style({
color: 'grey',
fontSize: '24px',
width: '100%'
});
const Message = (props:{className?:string,text:string}) => {
return (
<p className={classes(messageClass,props.className)}>{props.text}</p>
);
};
<div>
{/** Without customization */}
<Message text="Hello"/>
{/** With customization */}
<Message text="World"
className={style({
$nest:
{'&&':{color:'red'}}
})/>
</div>
But it is verbose. Open for a better idea.
// cc @blakeembrey for FreeStyle users 🌹
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (13 by maintainers)
Commits related to this issue
- kill $priority as people can just use `important` for a 1 level override :rose: refs https://github.com/typestyle/typestyle/issues/95#issuecomment-271449550 — committed to typestyle/typestyle by deleted user 7 years ago
@Frikki If you really don’t want to see the any, csx has a helper for important that should type-check your code properly.
It uses a trick with type inference to return the same type back even if ’ !important’ is appended.
http://typestyle.io/#/utilities
I’ve updated the docs
I didn’t actually look at your implementation 😨