-
Notifications
You must be signed in to change notification settings - Fork 14
Discussion: style override #12
Comments
In @ampproject/wg-ui-and-a11y past discussions, we have often preferred some way to do (2). The underlying principle is that for every component that comes with default functionally crucial and visually enhancing styles, the visually enhancing styles should follow an "all or none" opt-in model. The reasoning is publishers should not rely on some combination of our styles and their styles to achieve the look on the page -- if so, we become locked into our non-critical styling because changes to these will break publishers in unanticipated ways. This is one of the points discussed in the CSS in Bento AMP document. |
In this case, we may also need to reclassify all styles into two categories: "essential structure" vs "pure styling". E.g. if an element must have |
Yes that's right, the document linked earlier discusses this:
|
Do we have an issue on wg-bento that lists the document and some key points from it? If not, could we create it and link it here? |
Created #15 |
Related Web proposal: w3c/csswg-drafts#3890 |
Related issues: #7.
A reusable component may need to set a style that it wants to be overridable. For instance,
Structurally it may be important for the component to have an outline. At the same time, provided it's substituted safely, it should be overridable. The example above allows override by passing the
style
prop. But that would only work with inline styling. A styled-components, for instance, would be unable to override it because it works via stylesheet.Some possible options:
className={
${props.className || ''} amp-component}
. So far, however, we didn't find a non-fragile way to deploy stylesheets.<AmpComponent disableDefaultStyles>
. This is a very rough flag however. The user may want to override only some of the styles.<AmpComponent className="myclass" style={{outline: ''}}>
. This will work, but a bit cryptic and also fragile. E.g. for now styles may useoutline
and tomorrow decide to switch tooutline-color
. CSS is smart enough to override it all. Butstyle
map may or may not work well for this. And even then, this is not very ergonomic. Basically, the component user must cancel the same styles on every use.The text was updated successfully, but these errors were encountered: