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 checkmark icon to listboxes #694

Merged
merged 6 commits into from
Jul 28, 2023
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<!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">
<!-- Custom select indicator icon -->
<span slot="select-indicator" class="select-icon">
<style>
.select-icon {
box-sizing: border-box;
display: inline-flex;
justify-content: center;
align-items: center;
border: 1.5px solid currentcolor;
width: 9px;
height: 9px;
margin-top: -.14em;
vertical-align: middle;
border-radius: 50%;
visibility: visible;
}

[aria-selected="true"] .select-icon::after {
content: '';
display: block;
width: 4px;
height: 4px;
border-radius: 8px;
background: currentcolor;
}
</style>
</span>
</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 @@ -54,6 +54,13 @@ <h1>Rendition Listbox</h1>
</p>

<script>
const renditionListbox = document.querySelector('media-rendition-listbox');

renditionListbox.formatOptionText = (text) => {
console.log(text);
return text.replace('720p', '720p (HD)');
}
luwes marked this conversation as resolved.
Show resolved Hide resolved

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