Skip to content

Commit 83e67d1

Browse files
committed
feat(VVideo): add aspect-ratio prop
1 parent 22b828f commit 83e67d1

File tree

6 files changed

+13
-1
lines changed

6 files changed

+13
-1
lines changed

packages/api-generator/src/locale/en/VVideo.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"props": {
3+
"aspectRatio": "Sets the aspect ratio for the playback, calculated as width/height.",
34
"src": "Media file URL",
45
"type": "Media file type (optional)",
56
"image": "Apply a specific image as cover before the video is loaded.",

packages/docs/src/examples/v-video/misc-in-card.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
<template>
22
<div class="d-flex justify-center">
3-
<v-card elevation="4" rounded="xl">
3+
<v-card elevation="4" rounded="xl" width="400">
44
<v-card-item class="py-4">
55
<v-skeleton-loader type="list-item-avatar-two-line"></v-skeleton-loader>
66
</v-card-item>
77
<v-card-text class="pb-4 px-6">
88
<v-video
99
:volume="50"
10+
aspect-ratio="4 / 3"
1011
background-color="transparent"
1112
color="orange"
1213
controls-transition="slide-y-transition"
1314
elevation="0"
1415
image="https://jsek.work/vt-video-poster.jpg"
1516
rounded="xl"
1617
src="https://jsek.work/vt-video.mp4"
18+
width="100%"
1719
detached
1820
eager
1921
floating

packages/docs/src/examples/v-video/usage.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<v-select v-model="theme" :items="['light', 'dark']" label="Theme" clearable></v-select>
1414
<v-select v-model="color" :items="colorOptions" label="Color" clearable></v-select>
1515
<v-select v-model="elevation" :items="[4, 8, 12]" label="Elevation" clearable></v-select>
16+
<v-select v-model="aspectRatio" :items="['16/9', '3/2', '1']" label="Aspect ratio" clearable></v-select>
1617
<v-checkbox v-if="!isHidden" v-model="hidePlay" label="Hide play"></v-checkbox>
1718
<v-checkbox v-if="!isHidden" v-model="hideVolume" label="Hide volume"></v-checkbox>
1819
<v-checkbox v-if="!isHidden" v-model="noFullscreen" label="No fullscreen"></v-checkbox>
@@ -31,6 +32,7 @@
3132
const theme = shallowRef(null)
3233
const color = shallowRef(null)
3334
const elevation = shallowRef(null)
35+
const aspectRatio = shallowRef('16/9')
3436
3537
const isHidden = toRef(() => model.value === 'hidden')
3638
@@ -46,6 +48,7 @@
4648
theme: theme.value || undefined,
4749
color: color.value || undefined,
4850
elevation: elevation.value || undefined,
51+
'aspect-ratio': aspectRatio.value || undefined,
4952
'hide-play': (!isHidden.value && hidePlay.value) || undefined,
5053
'hide-volume': (!isHidden.value && hideVolume.value) || undefined,
5154
noFullscreen: (!isHidden.value && noFullscreen.value) || undefined,

packages/vuetify/src/labs/VVideo/VVideo.sass

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
flex-direction: column
99
align-items: center
1010
position: relative
11+
--v-video-aspect-ratio: #{$video-aspect-ratio}
1112
--v-video-controls-height: #{$video-controls-height}
1213
--v-video-controls-pill-border-radius: #{$video-controls-pill-border-radius}
1314

@@ -138,6 +139,7 @@
138139
> .v-video__content
139140
width: 100%
140141
height: $video-player-height
142+
aspect-ratio: var(--v-video-aspect-ratio)
141143

142144
&--variant-background
143145
outline: none

packages/vuetify/src/labs/VVideo/VVideo.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const allowedVariants = ['background', 'player'] as const
4444
type Variant = typeof allowedVariants[number]
4545

4646
export const makeVVideoProps = propsFactory({
47+
aspectRatio: [String, Number],
4748
autoplay: Boolean,
4849
muted: Boolean,
4950
eager: Boolean,
@@ -392,6 +393,7 @@ export const VVideo = genericComponent<VVideoSlots>()({
392393
props.class,
393394
]}
394395
style={[
396+
{ '--v-video-aspect-ratio': props.aspectRatio },
395397
props.variant === 'background' ? [] : pick(dimensionStyles.value, ['width', 'min-width', 'max-width']),
396398
props.style,
397399
]}

packages/vuetify/src/labs/VVideo/_variables.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
@use 'sass:math';
12
@use '../../styles/settings';
23

34
// Defaults
45
$video-player-width: 480px !default;
56
$video-player-height: 270px !default;
7+
$video-aspect-ratio: math.div(16, 9) !default;
68

79
$video-elevation: 4 !default;
810
$video-padding: 0px !default;

0 commit comments

Comments
 (0)