What if there was a kind of uninline project that meant that projects using inline styles could use a component that expected only classes?
As an author I write a component like this:
export default props => {
let {theme, children} = props
return <header className={theme.header}>
<h1 className={theme.title}>{children}</h1>
</header>
}
As a user on a project that uses inline styles, I could be doing something like this:
export default () => {
let inlineStyles = {
header: {
margin: 40
},
title: {
lineHeight: 1,
fontSize: '4rem'
}
}
<MyComponent theme={uninline(inlineStyles)}>Sneaky Class Times!</MyComponent>
}
The automatically generated classnames would have lower specificity than inline styles but we could mitigate that by either adding !important to every rule 😱 or asking the user to add an ID of #uninlined somewhere to their project and generating CSS that looks like this:
:export {
header: 204a1c693ef27e;
title: 1aafe63c034927;
}
#uninlined .204a1c693ef27e {
margin: 40px;
}
#uninlined .1aafe63c034927 {
line-height: 1;
font-size: 4rem;
}
Adding the #uninlined id could be optional but if it's mandatory it will mean much fewer specificity surprises down the track.
Basically an inline styles to ICSS compiler. Thoughts?
What if there was a kind of
uninlineproject that meant that projects using inline styles could use a component that expected only classes?As an author I write a component like this:
As a user on a project that uses inline styles, I could be doing something like this:
The automatically generated classnames would have lower specificity than inline styles but we could mitigate that by either adding
!importantto every rule 😱 or asking the user to add an ID of#uninlinedsomewhere to their project and generating CSS that looks like this:Adding the
#uninlinedid could be optional but if it's mandatory it will mean much fewer specificity surprises down the track.Basically an inline styles to ICSS compiler. Thoughts?