@@ -14,8 +14,7 @@ import {
1414 className ?: string ;
1515 autoPlay ?: boolean ;
1616 controls ?: boolean ;
17- width ?: string | number ;
18- height ?: string | number ;
17+ aspectRatio ?: '16:9' | '4:3' | '1:1' | 'auto' ;
1918 }
2019
2120 const VideoPlayerWrapper : React . FC < VideoPlayerProps > = ( {
@@ -26,9 +25,23 @@ import {
2625 className,
2726 autoPlay = false ,
2827 controls = true ,
29- width = "100%" ,
30- height = "auto" ,
28+ aspectRatio = '16:9' ,
3129 } ) => {
30+ // Get aspect ratio styles
31+ const getAspectRatioStyle = ( ) => {
32+ switch ( aspectRatio ) {
33+ case '16:9' :
34+ return { paddingBottom : '56.25%' } ;
35+ case '4:3' :
36+ return { paddingBottom : '75%' } ;
37+ case '1:1' :
38+ return { paddingBottom : '100%' } ;
39+ case 'auto' :
40+ default :
41+ return { } ;
42+ }
43+ } ;
44+
3245 // Extract video ID from YouTube URL for embedding
3346 const getYouTubeEmbedUrl = ( url : string ) => {
3447 // Match various YouTube URL formats
@@ -66,12 +79,9 @@ import {
6679 < div
6780 style = { {
6881 position : 'relative' ,
69- paddingBottom : '56.25%' , // 16:9 aspect ratio
70- height : 0 ,
71- overflow : 'hidden' ,
72- maxWidth : '100%' ,
73- background : '#000' ,
74- borderRadius : 'var(--pf-global--BorderRadius--sm)'
82+ height : aspectRatio === 'auto' ? 'auto' : 0 ,
83+ overflow : 'hidden' ,
84+ ...getAspectRatioStyle ( )
7585 } }
7686 >
7787 < iframe
@@ -98,12 +108,6 @@ import {
98108 src = { video }
99109 controls = { controls }
100110 autoPlay = { autoPlay }
101- style = { {
102- width,
103- height,
104- maxWidth : '100%' ,
105- borderRadius : 'var(--pf-global--BorderRadius--sm)'
106- } }
107111 title = { title }
108112 >
109113 Your browser does not support the video tag.
@@ -113,32 +117,16 @@ import {
113117 } else if ( video_img ) {
114118 // Show poster image when no video URL is provided
115119 return (
116- < div style = { { textAlign : 'center' } } >
117- < img
118- src = { video_img }
119- alt = { title }
120- style = { {
121- maxWidth : '100%' ,
122- height : 'auto' ,
123- borderRadius : 'var(--pf-global--BorderRadius--sm)' ,
124- objectFit : 'cover' ,
125- } }
126- />
127- </ div >
120+ < img
121+ src = { video_img }
122+ alt = { title }
123+ />
128124 ) ;
129125 }
130126
131127 // Fallback when neither video nor poster image is available
132128 return (
133- < div
134- style = { {
135- textAlign : 'center' ,
136- padding : '2rem' ,
137- backgroundColor : 'var(--pf-global--BackgroundColor--200)' ,
138- borderRadius : 'var(--pf-global--BorderRadius--sm)' ,
139- color : 'var(--pf-global--Color--200)'
140- } }
141- >
129+ < div >
142130 No video content available
143131 </ div >
144132 ) ;
@@ -148,11 +136,6 @@ import {
148136 < Card
149137 id = { id }
150138 className = { className }
151- style = { {
152- maxWidth : "1440px" ,
153- margin : "0 auto" ,
154- width : "100%"
155- } }
156139 >
157140 < CardTitle >
158141 < Title headingLevel = "h4" size = "lg" >
0 commit comments