This repository has been archived by the owner on Nov 16, 2021. It is now read-only.
Component styling rules for layout containment #8
Labels
question
Further information is requested
Projects
Layout containment
We have two major layout containment styles:
Here, we'll focus on the layout containing components.
Styling needs
className
+ stylesheet, to inlinestyle
attribute, to CSS-in-JS solutions such as styled-components.An example of using a styled component
This will likely result in the following stylesheet and markup:
There some things here, both desirable and not:
position: relative
style. So if it were to placed naively on the component element's root, it'd come with the direct conflict withposition:fixed
defined by the user stylesheet.& > button[arrow-next]
above invites users to be as selective as possible, but creates backward compatibility problems.Implementation approaches
1. Merging styles (likely not good)
Naively, the component could simply look like this:
Notice, the same issues arise for both: the root element of the component and for each child (slide). We can overwrite the styles passed by the user. At best, the user styles are ignored; at worst we break the user styles, or they could even come into an unexpected conflict. Here, we change the user's
position:fixed
toposition:relative
and also changedheight
andwidth
. There are also a lot of assumptions go into this:width/height: 100%
relative to what? How can users changewidth
andheight
here? Only with a parent container? This is not obvious.2. Nesting.
This approach takes more nesting. It might have a minor performance impact, but it also brings the needed isolation.
These inline styles are really annoying
Yeah. See #7.
The text was updated successfully, but these errors were encountered: