In our amp template design the sidebar mask is fully transparent. However adding custom styles to this element causes the validator to fail as it's targeting i-amphtml-sidebar-mask
.
It would be useful to customize the mask such as changing the background colour, the opacity and other properties like margins.
A simple solution to this would be to add an amp-sidebar-mask
class to it to allow developers to add styles or override default styles.
Thanks
@WillDonohoe That is working as intended. Any i-amphtml-
css class will be prohibited as that's an internal css class for amp runtime. There may be another way to target the mask, adding @camelburrito for that possibility.
/to @camelburrito. Maybe @tiendt can take this?
yes @tiendt - do you wanna take this?
@camelburrito yeah sure!
I found simple solution for this issue. It not causes the validator to fail.
For example to change the opacity of .i-amphtml-sidebar-mask add to your style:
footer.center + div{
opacity: 0.8;
}
Where footer.center is a last element in <body>
.
This might not work as you are relying on the mask being the last element. Other components or the runtime could change this behavior
Yes of course this is not a universal solution. But in some cases it works.
other solution is:
[class*="amphtml-sidebar-mask"] {
background: none;
}
@josegustavo I came to the same solution and ended up here trying to find out if there are any negative consequences to doing it. It seems like "cheating." As far as you know, is this okay to do?
I ended up using this:
body ~ div:last-child {
background: none;
}
I prefer not targeting the mask directly since it can be changed without notice.
ping @ampproject/wg-ui-and-a11y
We're doing some work (polish + upgrade) on sidebar that will likely resolve this, the current target launch date is mid November. We're having a design review on the new version of sidebar tomorrow (links incoming).
/cc @nainar @leafsy
This has now been addressed with #31999. The mask is a styleable using the amp-sidebar-mask
classname.
Most helpful comment
other solution is: