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

feat: Add breakpoints option to support toggling classes based on player width. #5471

Merged
merged 7 commits into from
Oct 10, 2018

Conversation

misteroneill
Copy link
Member

@misteroneill misteroneill commented Oct 2, 2018

Closes #4371

Description

This adds a breakpoints option. By default, this option is false meaning this is an opt-in feature.

When passing true, it will use a default set of breakpoints. Or custom breakpoints can be passed if users do not like our breakpoints (or previously-existing style decisions).

Specific Changes proposed

  • Add breakpoints option.
  • Adds some new (currently unused) classes: vjs-layout-medium, vjs-layout-large, vjs-layout-x-large, and vjs-layout-huge.
  • Add updateCurrentBreakpoint and currentBreakpoint methods to the player.
  • Update css/components/_adaptive.scss
  • In cleaning up sandbox a bit, I noticed several appearances of vjs-default-skin which was no longer used anywhere. Removed it everywhere.
  • Add sandbox/responsive.html.example

Requirements Checklist

  • Feature implemented / Bug fixed
  • If necessary, more likely in a feature request than a bug fix
    • Change has been verified in an actual browser (Chome, Firefox, IE)
    • Unit Tests updated or fixed
    • Docs/guides updated
  • Reviewed by Two Core Contributors

@gkatsev
Copy link
Member

gkatsev commented Oct 2, 2018

@misteroneill
Copy link
Member Author

Updating that now. I had local changes that were not reflected there yet.

@gkatsev
Copy link
Member

gkatsev commented Oct 3, 2018

Looks like stuff like caption buttons get removed in vjs-layout-small, I think it may be better to hide those buttons in x-small and less but still hide the time displays.

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

Would be good to add unit tests as well. Otherwise, this is great!

`vjs-layout-x-large` | 1441-2560
`vjs-layout-huge` | 2561+

These can be overridden by passing an **ordered** array that looks like this:
Copy link
Member

Choose a reason for hiding this comment

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

would it be better to just have an object?

{
  tiny: 210,
  xmall: 320,
  small: 425,
  medium: 768.
  large: 1140,
  xlarge: 2560
}

Copy link
Member

Choose a reason for hiding this comment

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

That is, instead of having custom class names as an option, only have the main ones we support

Copy link
Member Author

Choose a reason for hiding this comment

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

Gotcha, that could make sense. We define the order by class name and then it can be configured via an object where ordering does not matter. I like it. 👍

<link href="../dist/video-js.css" rel="stylesheet" type="text/css">
<script src="../dist/video.js"></script>
<script src="../node_modules/videojs-flash/dist/videojs-flash.js"></script>
Copy link
Member

Choose a reason for hiding this comment

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

We should leave flash here as it makes it easier to test with since it's already set up. At least for a bit longer still.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well, my thought was that we have a flash.html.example so it would be confusing as to why it was identical to index.html.example.

sandbox/index.html.example Show resolved Hide resolved
src/js/player.js Outdated
*
* @private
*/
updateCurrentBreakpoint() {
Copy link
Member

Choose a reason for hiding this comment

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

if this should be a private method, it should get a postfixed _

@gkatsev
Copy link
Member

gkatsev commented Oct 3, 2018

Also, the fullscreen button in x-tiny moves right next to the play toggle, I'd expect it to stay pinned to the right

@misteroneill
Copy link
Member Author

Pffft, tests. 😛

(Yeah, I'll do that, got sidetracked)

@gkatsev
Copy link
Member

gkatsev commented Oct 9, 2018

Some things I noticed:

  • The fullscreen button should stay pinned to the right in tiny
  • looks like when going from tiny to small, the progress control doesn't show up immediately, at least according to the example page. At the top, it has already changed to x-small, but the control bar still looks like tiny. This may be an issue with small->medium as well.
  • x-small and small seem identical at the moment. Probably worth keeping caption buttons in small.

@misteroneill
Copy link
Member Author

misteroneill commented Oct 9, 2018

looks like when going from tiny to small, the progress control doesn't show up immediately

This is a consequence of the class name highlighting being based on CSS media queries and the playerresize event being throttled.

@gkatsev
Copy link
Member

gkatsev commented Oct 10, 2018

Looks like the issue with the second one was that of expectations and there's been an update to better explain it on the page.

@@ -12,7 +12,7 @@

// Video has started playing
.vjs-has-started .vjs-control-bar {
@include display-flex;
@include display-flex(flex-start, space-between);
Copy link
Member Author

Choose a reason for hiding this comment

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

This change to the justification should be fine. For all sizes except tiny, the progress bar fills all available space, making the justification pretty much irrelevant. This seems like the right value for other use-cases (without a progress bar).

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if the issue is that the spacer has different settings applied to it in tiny mode:

   .vjs-custom-control-spacer { @include flex(auto); }
   &.vjs-no-flex .vjs-custom-control-spacer { width: auto; }

I'd be more comfortable fiddling with those properties over this one, at first at least.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, sure.

Copy link
Member

@gkatsev gkatsev left a comment

Choose a reason for hiding this comment

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

Awesome, glad we finally have this!

@gkatsev gkatsev merged commit 51bd49f into master Oct 10, 2018
@gkatsev gkatsev deleted the feat/breakpoints branch October 10, 2018 20:53
gkatsev pushed a commit that referenced this pull request Oct 11, 2018
Follow-up for #5471

This makes the breakpoints option and `breakpoints()` method clearer and introduces the responsive option and `responsive()` method, which will turn on the breakpoints.

The return value of `currentBreakpoint()` was simplified to only ever return a string (empty if none).

Also, added convenience methods: `responsive()`, `getBreakpointClass()`, and `currentBreakpointClass()`.
gkatsev pushed a commit that referenced this pull request Oct 31, 2018
…yer width. (#5471)

This adds a breakpoints option. By default, this option is false meaning this is an opt-in feature.

When passing true, it will use a default set of breakpoints. Or custom breakpoints can be passed if users do not like our breakpoints (or previously-existing style decisions).

- Add breakpoints option.
- Adds some new (currently unused) classes: vjs-layout-medium, vjs-layout-large, vjs-layout-x-large, and vjs-layout-huge.
- Add updateCurrentBreakpoint and currentBreakpoint methods to the player.
- Update css/components/_adaptive.scss
- Add sandbox/responsive.html.example

Closes #4371
gkatsev pushed a commit that referenced this pull request Oct 31, 2018
Follow-up for #5471

This makes the breakpoints option and `breakpoints()` method clearer and introduces the responsive option and `responsive()` method, which will turn on the breakpoints.

The return value of `currentBreakpoint()` was simplified to only ever return a string (empty if none).

Also, added convenience methods: `responsive()`, `getBreakpointClass()`, and `currentBreakpointClass()`.
@axten
Copy link
Contributor

axten commented Nov 26, 2018

Hey, great feature!
Is it possible to make a new 6.x release? I need this :)
thanks

@gkatsev
Copy link
Member

gkatsev commented Nov 26, 2018

@axten yes, I've just been lazy and not releasing 6.x. I'll make sure to get to it this week.

@axten
Copy link
Contributor

axten commented Nov 26, 2018

@gkatsev cool, many thanks!

@axten
Copy link
Contributor

axten commented Dec 5, 2018

It would be cool to have it this week :)

@gkatsev
Copy link
Member

gkatsev commented Dec 5, 2018

Oops, totally forgot. I'll be working on this right now.

@gkatsev
Copy link
Member

gkatsev commented Dec 5, 2018

@axten 6.13.0 is now out as pre-release with this feature. Please check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants