Open jviereck opened 9 years ago
For that specific I would think you would just use the state of the component to determine is it disabled or not and render different style. Similar to react native styles: https://facebook.github.io/react-native/docs/style.html
<div style={[styles.base, this.state.active && styles.active]} />
The current draft of VirtualCSS in PR #4 allows to use inheritance, for example:
The idea to use inheritance seems appealing when thinking about states like having a base definition for a button and then define what the button looks like when it is disabled. However, as soon as you start inheriting the styles for
disabled
from the basebutton
it becomes less obvious what the behavior ofbutton::disabled
is like when thebutton
style gets extended using composition later on.Therefore, instead of using inheritance, I plan to allow only one level of nesting for style definitions and then use composition to define what a "disabled" button should look like. However, this raises a problem: The way the styles are defined at the moment within one stylesheet makes it impossible to reference the
button
definition when thedisabled
definition want to componse on it. In fact, the usage ofStyleSheet.create
to define a bunch of styles felt strange to me for some time now, which is why I also intend to get rid ofStyleSheet.create
and instead useStyleSheet.defineStyle
to define a single style. With this, the above example becomes:This is more verbose at this point but for now as I want to focus on the functionality okay from my perspective.