Skip to content

Commit

Permalink
feat: add checkmark icon to listboxes
Browse files Browse the repository at this point in the history
  • Loading branch information
luwes committed Jul 27, 2023
1 parent 7253a3a commit 861a9bc
Show file tree
Hide file tree
Showing 16 changed files with 444 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ <h1>Captions Listbox</h1>
<media-seek-backward-button seekoffset="15"></media-seek-backward-button>
<media-seek-forward-button seekoffset="15"></media-seek-forward-button>
<media-mute-button></media-mute-button>
<media-volume-range></media-volume-range>
<media-time-range></media-time-range>
<media-time-display showduration remaining></media-time-display>
<media-captions-button></media-captions-button>
Expand Down
56 changes: 56 additions & 0 deletions examples/vanilla/control-elements/media-playback-rate-listbox.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width">
<title>Media Chrome Playback Rate Listbox</title>
<script type="module" src="../../../dist/index.js"></script>
<script type="module" src="../../../../dist/experimental/media-playback-rate-listbox.js"></script>
<style>
/** add styles to prevent CLS (Cumulative Layout Shift) */
media-controller:not([audio]) {
display: block; /* expands the container if preload=none */
max-width: 540px; /* allows the container to shrink if small */
aspect-ratio: 16 / 9; /* set container aspect ratio if preload=none */
}

video {
width: 100%; /* prevents video to expand beyond its container */
}

.examples {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Playback Rate Listbox</h1>

<media-controller id="mc">
<video
id="video"
slot="media"
src="https://stream.mux.com/O6LdRc0112FEJXH00bGsN9Q31yu5EIVHTgjTKRkKtEq1k/high.mp4"
poster="https://image.mux.com/O6LdRc0112FEJXH00bGsN9Q31yu5EIVHTgjTKRkKtEq1k/thumbnail.webp"
preload="metadata"
muted
crossorigin
></video>
<media-control-bar>
<media-play-button></media-play-button>
<media-time-display showduration></media-time-display>
<media-time-range></media-time-range>
<media-mute-button></media-mute-button>
<media-pip-button></media-pip-button>
<media-fullscreen-button></media-fullscreen-button>
</media-control-bar>
</media-controller>
<br>

<media-playback-rate-listbox mediacontroller="mc"></media-playback-rate-listbox>


<div class="examples">
<a href="../">View more examples</a>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width">
<title>Media Chrome Playback Rate Selectmenu</title>
<script type="module" src="../../../dist/index.js"></script>
<script type="module" src="../../../../dist/experimental/media-playback-rate-selectmenu.js"></script>
<style>
/** add styles to prevent CLS (Cumulative Layout Shift) */
media-controller:not([audio]) {
display: block; /* expands the container if preload=none */
max-width: 540px; /* allows the container to shrink if small */
aspect-ratio: 16 / 9; /* set container aspect ratio if preload=none */
}

video {
width: 100%; /* prevents video to expand beyond its container */
}

.examples {
margin-top: 20px;
}
</style>
</head>
<body>
<h1>Playback Rate Selectmenu</h1>

<media-controller id="mc">
<video
id="video"
slot="media"
src="https://stream.mux.com/O6LdRc0112FEJXH00bGsN9Q31yu5EIVHTgjTKRkKtEq1k/high.mp4"
poster="https://image.mux.com/O6LdRc0112FEJXH00bGsN9Q31yu5EIVHTgjTKRkKtEq1k/thumbnail.webp"
preload="metadata"
muted
crossorigin
></video>
<media-control-bar>
<media-play-button></media-play-button>
<media-time-display showduration></media-time-display>
<media-time-range></media-time-range>
<media-mute-button></media-mute-button>
<media-playback-rate-selectmenu></media-playback-rate-selectmenu>
<media-pip-button></media-pip-button>
<media-fullscreen-button></media-fullscreen-button>
</media-control-bar>
</media-controller>

<div class="examples">
<a href="../">View more examples</a>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ <h1>Rendition Listbox</h1>
Quality: <span id="renditionactive">N/A</span>
</p>

<script>
<script type="module">
const RenditionListbox = await customElements.whenDefined('media-rendition-listbox');

RenditionListbox.formatOptionText = (text) => {
console.log(text);
return text.replace('720p', '720p (HD)');
}

video.addEventListener('resize', () => {
renditionactive.textContent = `${Math.min(video.videoWidth, video.videoHeight)}p`;
});
Expand Down
2 changes: 2 additions & 0 deletions examples/vanilla/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ <h3>Experimental</h3>
<li><a href="control-elements/media-chrome-listbox.html">Listbox</a></li>
<li><a href="control-elements/media-captions-listbox.html">Captions listbox</a></li>
<li><a href="control-elements/media-captions-selectmenu.html">Captions selectmenu</a></li>
<li><a href="control-elements/media-playback-rate-listbox.html">Playback rate listbox</a></li>
<li><a href="control-elements/media-playback-rate-selectmenu.html">Playback rate selectmenu</a></li>
<li><a href="control-elements/media-rendition-listbox.html">Rendition listbox</a></li>
<li><a href="control-elements/media-rendition-selectmenu.html">Rendition selectmenu</a></li>
</ul>
Expand Down
9 changes: 9 additions & 0 deletions src/js/experimental/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export { MediaChromeListbox } from './media-chrome-listbox.js';
export { MediaChromeOption } from './media-chrome-option.js';
export { MediaChromeSelectMenu } from './media-chrome-selectmenu.js';
export { MediaCaptionsListbox } from './media-captions-listbox.js';
export { MediaCaptionsSelectMenu } from './media-captions-selectmenu.js';
export { MediaPlaybackRateListbox } from './media-playback-rate-listbox.js';
export { MediaPlaybackRateSelectMenu } from './media-playback-rate-selectmenu.js';
export { MediaRenditionListbox } from './media-rendition-listbox.js';
export { MediaRenditionSelectMenu } from './media-rendition-selectmenu.js';
Loading

0 comments on commit 861a9bc

Please sign in to comment.