Hi guys,
I have a question regarding styling of web components. I know that it's probably too early to talk about best practices, but we probably don't have to talk about best practices at all, rather about some good advices with arguments behind it.
Imagine the following scenario:
Let's say we have a web component, that abstracts a very nice header element for your mobile UI away. We apply according styles and everything works fine.
Now we have another component, which is a button component. The button component get's its styling too, but we also want to be able to use the button
component within the header component. Actually all we wanna do is aligning the button in the header component.
With Shadow DOM CSS we're able to style down to "n" shadow doms from an outer document. On the other hand, we're able to define host context specific styles.
Now what does that mean? In case of our scenario, we have two options:
1. We could decide to style the alignment for our button, than **can** be used in our header, through Shadow DOM CSS. Kinda like the way we always do, but with shadow dom css.
2. We could define context specific styles to the button component. So it actually "knows" about a possible header context where its living in.
My question is, what is here the better way to go? The first option feels more appropriate since we do it in that way today. We define a CSS module and another one and a parent
module declares how a child module behaves within that parent module. But since we're using new technologies here that give us new possibilities, I wonder if it's over a long term
more convenient to define context specific rules for a component and let it know about it's possible contexts.
Any thoughts on that?