-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ Use JSS for video #30298
♻️ Use JSS for video #30298
Conversation
return [1, 2, 3, 4].map((i) => ( | ||
<div className={`${classes.eqCol} amp-video-eq-col`} key={i}> | ||
<div className={`amp-video-eq-filler ${classes[`eq-${i}-1`]}`}></div> | ||
<div className={`amp-video-eq-filler ${classes[`eq-${i}-2`]}`}></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@samouri Do I need to unwrap this loop since the member access for classes
is dynamic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Current compiled output seems ok btw. In the future we could optimize this away as to not read classes
, which would then break this.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Context: I have a PR coming up that converts the classes
object to an enum.
You don't need to unroll the loop, but if you don't it'll deopt. I just tested it via the appspot closure compiler.
// Source file
/** @enum {string} */
const a = { cx1: 'hello', cx2: 'world'};
console.log(a.cx1);
console.log(a.cx2)
// Compiled output
console.log("hello");
console.log("world");
// Source file
/** @enum {string} */
const a = { cx1: 'hello', cx2: 'world'};
[1,2].forEach(i => {
console.log(a[`cx${i}`]);
})
// Compiled output
var a = {a:"hello", b:"world"};
[1, 2].forEach(function(b) {
console.log(a["cx" + b]);
});
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we wanted to make it fully enumerable so that it can be fully DCE'd to constants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of unrolling, I wrote a compound selector. I believe it can be DCE'd now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or... the current solution to map only those classes one level above :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or... just nth-child(x):before, :after
:)
animationTimingFunction: 'linear', | ||
animationIterationCount: 'infinite', | ||
animationDirection: 'alternate', | ||
backgroundColor: '#FAFAFA', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i like the sound of this color 🎵
height: '100%', | ||
position: 'absolute', | ||
width: '100%', | ||
willChange: 'transform', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FMI, do we have any data on the performance impact of using will-change
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No actual data. It does have an impact, since it definitely prevents some browsers from re-rendering when changing other CSS props.
const AutoplayIconContent = once(() => { | ||
const classes = useAutoplayStyles(); | ||
return [1, 2, 3, 4].map((i) => ( | ||
<div className={`${classes.eqCol} amp-video-eq-col`} key={i}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whats the point of keeping amp-video-eq-col
? Should probably just use eqCol
instead right (can also update the eqPlaying
rule above)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically this element's style is overridable via this class. Though I'm not sure any author has gone that deep 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok cool! Just making sure theres a reason. Do you know if this will live in the shadow or light dom? If lightdom then it is worth keeping as-is, if shadow then I'm not sure they can customize it via classname anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's using ['children']
, so it's rendered in ShadowDOM. Though its children are cloned into VNodes, so we could move it to the light DOM. In any case, I think it's fine to remove access to amp-video-eq-col
, but maybe not to amp-video-eq
since that may be used to hide the equalizer...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this looks very clean.
This is a port of video-autoplay.css. No CSS def in an AMP component since there's not a PreactBaseElement that uses VideoWrapper yet (see ampproject#30280)
This is a port of
video-autoplay.css
.No CSS def in an AMP component since there's not a
PreactBaseElement
that usesVideoWrapper
yet.