Skip to content
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

fix: Audio only mode styling conflicts with fluid mode #7724

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions src/css/components/_layout.scss
Expand Up @@ -77,26 +77,33 @@
.video-js.vjs-1-1 {
width: 100%;
max-width: 100%;
}

.video-js.vjs-fluid:not(.vjs-audio-only-mode),
.video-js.vjs-16-9:not(.vjs-audio-only-mode),
.video-js.vjs-4-3:not(.vjs-audio-only-mode),
.video-js.vjs-9-16:not(.vjs-audio-only-mode),
.video-js.vjs-1-1:not(.vjs-audio-only-mode) {
height: 0;
}

.video-js.vjs-16-9 {
.video-js.vjs-16-9:not(.vjs-audio-only-mode) {
@include apply-aspect-ratio(16, 9);
}

.video-js.vjs-4-3 {
.video-js.vjs-4-3:not(.vjs-audio-only-mode) {
@include apply-aspect-ratio(4, 3);
}

.video-js.vjs-9-16 {
.video-js.vjs-9-16:not(.vjs-audio-only-mode) {
@include apply-aspect-ratio(9, 16);
}

.video-js.vjs-1-1 {
.video-js.vjs-1-1:not(.vjs-audio-only-mode) {
@include apply-aspect-ratio(1, 1);
}

.video-js.vjs-fill {
.video-js.vjs-fill:not(.vjs-audio-only-mode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we wouldn't be able to add a rule with a target like .video-js.vjs-audio-only-mode after these rules? That would be of equal hierarchy as the .video-js.<ratio-class-name> targets and should override them just because it's further down in the stylesheet. That way you wouldn't need to specify :not().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And same thought for the targeting on line 82. It might just be easier a bit more terse to have a small .video-js.vjs-audio-only-mode rule after the ones modified here. That way it's more declarative and less conditional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary following offline discussion:

This is a good suggestion and it would probably be ideal to do it this way, but overriding the player's height via CSS in these places disables the player.height() setter method, on which audioOnlyMode() currently depends. So I think we should leave this as is for now, and if we decide to rework audioOnlyMode() later not to use player.height() we can do that, but it's out of scope for this PR.

width: 100%;
height: 100%;
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/player.js
Expand Up @@ -1112,7 +1112,7 @@ class Player extends Component {
height: ${height}px;
}

.${idClass}.vjs-fluid {
.${idClass}.vjs-fluid:not(.vjs-audio-only-mode) {
padding-top: ${ratioMultiplier * 100}%;
}
`);
Expand Down
2 changes: 1 addition & 1 deletion src/js/video.js
Expand Up @@ -207,7 +207,7 @@ if (window.VIDEOJS_NO_DYNAMIC_STYLE !== true && Dom.isReal()) {
height: 150px;
}

.vjs-fluid {
.vjs-fluid:not(.vjs-audio-only-mode) {
padding-top: 56.25%
}
`);
Expand Down