Skip to content

Commit 288385e

Browse files
🐛 fix video (#3814)
1 parent 2324b5f commit 288385e

8 files changed

Lines changed: 57 additions & 126 deletions

File tree

web/app/globals.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import "tailwindcss" source("../");
22
@import '@energyvision/shared/brand.css';
33
/* @source '../styles/components/imagezoom.css'; */
4-
@source '../styles/components/videojs.css';
54
@source '../styles/components/cookiebot.css';
65

76
/* Custom theme for web, not common brand */
@@ -316,6 +315,7 @@ data-ui="checked active" class="data-checked:underline">
316315
}
317316

318317
/************** Video js **********/
318+
319319
.video-js.vjs-fill .vjs-control-bar {
320320
@apply bg-transparent!;
321321
}

web/core/Carousel/Carousel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ export const Carousel = forwardRef<HTMLElement, CarouselProps>(
360360
src: video?.src,
361361
aspectRatio: displayMode === 'scroll' ? '9:16' : '16:9',
362362
figureCaption: title,
363-
className: 'min-w-[24rem] h-full',
363+
className: 'min-w-[24rem] h-full overflow-hidden rounded-card',
364364
}
365365
//@ts-ignore: TODO
366366
const element = <VideoPlayer {...props} />
@@ -371,7 +371,6 @@ export const Carousel = forwardRef<HTMLElement, CarouselProps>(
371371
aria-label={getTranslatedItemCountLabel(index + 1)}
372372
displayMode={displayMode}
373373
active={index === currentIndex}
374-
/* className={`${displayMode === 'scroll' ? 'h-full w-[260px] md:w-[372px] lg:w-[405px]' : ''}`} */
375374
{...(displayMode === 'single' && {
376375
style: {
377376
transform: `translate3d(${itemsXPositions[index]}px, 0px, 0px)`,

web/core/Carousel/CarouselImageItem.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,23 @@ export const CarouselImageItem = forwardRef<
9595
grid='sm'
9696
image={image}
9797
fill
98-
className={`relative aspect-4/3 h-full w-full rounded-md md:aspect-video`}
99-
imageClassName='rounded-md'
98+
className={`relative aspect-4/3 h-full w-full rounded-card md:aspect-video`}
99+
imageClassName='rounded-card'
100100
/>
101101
)
102102
}
103103
if (isImageWithSimpleCaption && image) {
104104
return (
105-
<figure className='flex aspect-4/3 h-full w-full items-end rounded-md md:aspect-video'>
105+
<figure className='flex aspect-4/3 h-full w-full items-end rounded-card md:aspect-video'>
106106
<Image
107107
grid='sm'
108108
image={image}
109109
fill
110110
className='absolute'
111-
imageClassName={`rounded-md`}
111+
imageClassName={`rounded-card`}
112112
/>
113113
<figcaption
114-
className={`fade-in-black-gradient z-1 w-full rounded-b-md ${
114+
className={`fade-in-black-gradient z-1 w-full rounded-b-card ${
115115
displayMode === 'single'
116116
? active
117117
? 'opacity-100'
@@ -147,9 +147,9 @@ export const CarouselImageItem = forwardRef<
147147
image={image}
148148
fill
149149
className='absolute'
150-
imageClassName={`aspect-4/3 rounded-md md:aspect-video`}
150+
imageClassName={`aspect-4/3 rounded-card md:aspect-video`}
151151
/>
152-
<div className='fade-in-black-gradient flex h-full w-full items-end rounded-b-md pt-10 lg:pt-20'>
152+
<div className='fade-in-black-gradient flex h-full w-full items-end rounded-b-card pt-10 lg:pt-20'>
153153
<BaseLink
154154
href={url as string}
155155
{...(action.link?.lang && {
@@ -170,7 +170,7 @@ export const CarouselImageItem = forwardRef<
170170
if (isImageWithOverlay) {
171171
return (
172172
<ImageWithOverlay
173-
className={`aspect-4/3 rounded-md md:aspect-video`}
173+
className={`aspect-4/3 rounded-card md:aspect-video`}
174174
teaserTitle={captionTeaserTitle}
175175
//@ts-ignore:TODO
176176
title={captionTitle as PortableTextBlock[]}
@@ -188,8 +188,8 @@ export const CarouselImageItem = forwardRef<
188188
grid='sm'
189189
image={image}
190190
fill
191-
className={`min-h-single-carousel-card-h-sm w-full rounded-md md:min-h-single-carousel-card-h-md lg:min-h-single-carousel-card-h-lg`}
192-
imageClassName='aspect-4/3 rounded-md md:aspect-video'
191+
className={`min-h-single-carousel-card-h-sm w-full rounded-card md:min-h-single-carousel-card-h-md lg:min-h-single-carousel-card-h-lg`}
192+
imageClassName='aspect-4/3 rounded-card md:aspect-video'
193193
/>
194194
<figcaption
195195
className={twMerge(

web/core/ImageWithOverlay/ImageWithOverlay.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ export const ImageWithOverlay = forwardRef<
5858
return (
5959
<figure
6060
ref={ref}
61-
className={twMerge(`h-full w-full rounded-md`, className)}
61+
className={twMerge(`h-full w-full rounded-card`, className)}
6262
>
6363
<Image
6464
grid='sm'
6565
image={image}
6666
fill
6767
className='absolute'
68-
imageClassName={`aspect-4/3 rounded-md md:aspect-video`}
68+
imageClassName={`aspect-4/3 rounded-card md:aspect-video`}
6969
/>
7070
<figcaption
7171
className={twMerge(
@@ -74,12 +74,12 @@ export const ImageWithOverlay = forwardRef<
7474
)}
7575
>
7676
<div
77-
className={`absolute inset-0 z-1 rounded-md transition-colors duration-250 ${
77+
className={`absolute inset-0 z-1 rounded-card transition-colors duration-250 ${
7878
showOverlay ? 'bg-slate-blue-95' : ''
79-
} flex flex-col-reverse rounded-b-md`}
79+
} flex flex-col-reverse rounded-b-card`}
8080
>
8181
<div
82-
className={`h-fit rounded-b-md ${
82+
className={`h-fit rounded-b-card ${
8383
showOverlay
8484
? 'justify-end'
8585
: 'fade-in-black-gradient justify-between'

web/core/VideoJsPlayer/Video.tsx

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
'use client'
2-
import { type HTMLProps, useEffect, useRef, useState } from 'react'
2+
import { type HTMLProps, useEffect, useRef } from 'react'
33
import videojs from 'video.js'
44
import 'video.js/dist/video-js.css'
55
import type Player from 'video.js/dist/types/player'
6+
import { twMerge } from '@/lib/twMerge/twMerge'
67
import useVideojsAnalytics from './useVideojsAnalytics'
78

89
//Needed?
@@ -46,15 +47,15 @@ export const Video: React.FC<VideoProps> = ({
4647
options,
4748
onReady,
4849
useBrandTheme = false,
49-
containVideo = false,
50+
// containVideo = false,
51+
className = '',
5052
}) => {
5153
const videoRef = useRef<HTMLDivElement>(null)
5254
const playerRef = useRef<Player>(null)
5355
const videoElementRef = useRef<HTMLElement | null>(null)
5456
const onReadyRef = useRef<VideoProps['onReady']>(onReady)
5557
const sourceKeyRef = useRef('')
56-
const [isReady, setIsReady] = useState(false)
57-
const { src, title, autoplay = false, fill, aspectRatio } = options
58+
const { src, title, autoplay = false } = options
5859

5960
const getSourceKey = (source: unknown): string => {
6061
if (typeof source === 'string') {
@@ -107,29 +108,24 @@ export const Video: React.FC<VideoProps> = ({
107108
videoElement.classList.add('vjs-envis-brand')
108109
}
109110
if (variant === 'fullwidth') {
110-
videoElement.classList.add('vjs-fullwidth')
111-
}
112-
if (
113-
!containVideo &&
114-
(fill || aspectRatio === '10:3' || aspectRatio === '21:9')
115-
) {
116-
videoElement.classList.add('vjs-fill', 'lg:[&>video]:object-cover')
117-
}
118-
if (aspectRatio === '16:9') {
119-
videoElement.classList.add('vjs-16-9')
120-
}
121-
if (aspectRatio === '4:3') {
122-
videoElement.classList.add('vjs-4-3')
123-
}
124-
if (aspectRatio === '9:16') {
125-
videoElement.classList.add('vjs-9-16')
111+
videoElement.classList.add(
112+
'vjs-fullwidth',
113+
'vjs-fill',
114+
'lg:[&>video]:object-cover',
115+
)
116+
} else {
117+
videoElement.classList.add(
118+
'pt-0!',
119+
'w-full!',
120+
'h-full!',
121+
'[&>video]:object-contain',
122+
'[&>video]:relative!',
123+
)
126124
}
127125

128126
videoRef.current?.appendChild(videoElement)
129-
setIsReady(false)
130127

131128
const markReady = () => {
132-
setIsReady(true)
133129
videoElement.classList.add('vjs-ready')
134130
}
135131

@@ -150,17 +146,7 @@ export const Video: React.FC<VideoProps> = ({
150146
return () => {
151147
window.clearTimeout(readyTimeout)
152148
}
153-
}, [
154-
aspectRatio,
155-
autoplay,
156-
containVideo,
157-
fill,
158-
options,
159-
sourceKey,
160-
src,
161-
useBrandTheme,
162-
variant,
163-
])
149+
}, [autoplay, options, sourceKey, src, useBrandTheme, variant])
164150

165151
useEffect(() => {
166152
const player = playerRef.current
@@ -171,11 +157,9 @@ export const Video: React.FC<VideoProps> = ({
171157
player.autoplay(autoplay)
172158

173159
if (sourceKey && sourceKeyRef.current !== sourceKey) {
174-
setIsReady(false)
175160
videoElementRef.current?.classList.remove('vjs-ready')
176161

177162
const markReady = () => {
178-
setIsReady(true)
179163
videoElementRef.current?.classList.add('vjs-ready')
180164
}
181165
const readyTimeout = window.setTimeout(markReady, 350)
@@ -202,14 +186,7 @@ export const Video: React.FC<VideoProps> = ({
202186
}
203187
}, [])
204188

205-
return (
206-
<div
207-
className={`video-player h-full w-full transition-opacity duration-300 ${isReady ? 'video-player--ready opacity-100' : 'opacity-0'}`}
208-
data-vjs-player
209-
>
210-
<div ref={videoRef} className={`h-full w-full`} />
211-
</div>
212-
)
189+
return <div ref={videoRef} className={twMerge(`h-full w-full`, className)} />
213190
}
214191

215192
export default Video

web/core/VideoJsPlayer/VideoPlayer.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export type VideoPlayerProps = Omit<
3131
src: string
3232
figureCaption?: string | PortableTextBlock[]
3333
captionClassName?: string
34+
figureClassName?: string
3435
/* setting this will sett fluid mode to video player */
3536
aspectRatio?: AspectRatioVariants | undefined
3637
/** Ignores aspect ratio to enable fill mode */
@@ -48,6 +49,7 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({
4849
loop = false,
4950
figureCaption,
5051
captionClassName = '',
52+
figureClassName = '',
5153
autoPlay = false,
5254
title,
5355
src,
@@ -135,7 +137,7 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({
135137
const aspectRatioClassName: Record<AspectRatioVariants, string> = {
136138
'10:3': 'aspect-16/9 md:aspect-10/3',
137139
'16:9': 'aspect-video',
138-
'21:9': 'aspect-16/9 md: aspect-21/9',
140+
'21:9': 'aspect-16/9 md:aspect-21/9',
139141
'9:16': 'aspect-9/16',
140142
'2:1': 'aspect-2/1',
141143
'4:3': 'aspect-4/3',
@@ -162,19 +164,18 @@ export const VideoPlayer: React.FC<VideoPlayerProps> = ({
162164
{...(id && { id })}
163165
className={twMerge(
164166
`relative flex flex-col ${variantClassName[variant]}`,
165-
className,
167+
figureClassName,
166168
)}
167169
>
168-
<div className={`${aspectRatioClassName[aspectRatio]}`}>
169-
<Video
170-
//@ts-ignore: TODO
171-
options={videoJsOptions}
172-
onReady={handlePlayerReady}
173-
useBrandTheme={useBrandTheme}
174-
containVideo={containVideo}
175-
variant={variant}
176-
/>
177-
</div>
170+
<Video
171+
//@ts-ignore: TODO
172+
options={videoJsOptions}
173+
onReady={handlePlayerReady}
174+
useBrandTheme={useBrandTheme}
175+
containVideo={containVideo}
176+
variant={variant}
177+
className={twMerge(aspectRatioClassName[aspectRatio], className)}
178+
/>
178179
{figureCaption && (
179180
<figcaption
180181
className={twMerge(

web/sections/VideoPlayerBlock/VideoPlayerBlock.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,14 @@ const VideoPlayerBlock = ({
5252
const { width = 'normal', ...videoPlayerDesignOptions } = designOptions
5353
const actionUrl = action ? getUrlFromAction(action) : ''
5454
const { bg, dark } = getBgAndDarkFromBackground(designOptions)
55+
5556
const isNarrowFeature =
5657
width === 'narrow' || videoPlayerDesignOptions?.aspectRatio === '9:16'
5758

5859
return (
5960
<section
6061
className={twMerge(
61-
`mx-auto max-w-content ${bg} ${dark ? 'dark' : ''} ${width === 'extraWide' ? 'px-layout-md' : 'px-layout-lg'}`,
62+
`mx-auto h-auto w-full max-w-content ${bg} ${dark ? 'dark' : ''} px-layout-sm ${width === 'extraWide' ? 'lg:px-layout-md' : 'lg:px-layout-lg'}`,
6263
className,
6364
)}
6465
id={anchor}
@@ -94,18 +95,20 @@ const VideoPlayerBlock = ({
9495
</div>
9596
)}
9697
{/*@ts-ignore: TODO*/}
98+
9799
<div
98100
className={twMerge(
101+
'h-auto w-full overflow-hidden rounded-card',
99102
isNarrowFeature && 'mx-auto',
100103
isNarrowFeature &&
101104
videoPlayerDesignOptions?.aspectRatio === '9:16' &&
102-
'aspect-9/16 w-101.5 overflow-hidden rounded-card',
105+
'w-101.5',
103106
isNarrowFeature &&
104107
videoPlayerDesignOptions?.aspectRatio === '16:9' &&
105-
'aspect-video w-200 overflow-hidden rounded-card',
108+
'w-200',
106109
isNarrowFeature &&
107110
videoPlayerDesignOptions?.aspectRatio === '1:1' &&
108-
'aspect-square w-150 overflow-hidden rounded-card',
111+
'w-150',
109112
)}
110113
>
111114
<VideoPlayer

web/styles/components/videojs.css

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)