From 2247a679f405fc42f6a2a559f61fd0de71578e85 Mon Sep 17 00:00:00 2001 From: Drina_Rincon Date: Thu, 12 May 2022 10:30:41 -0300 Subject: [PATCH 1/2] Modificar videoBackground para que reciba url de youtube --- .../videoBackground/VideoBackground.js | 72 ++++++++++++++----- .../videoBackground/videoBackground.scss | 17 +++-- 2 files changed, 67 insertions(+), 22 deletions(-) diff --git a/src/components/videoBackground/VideoBackground.js b/src/components/videoBackground/VideoBackground.js index 40dc0401..75aa9a03 100644 --- a/src/components/videoBackground/VideoBackground.js +++ b/src/components/videoBackground/VideoBackground.js @@ -1,8 +1,9 @@ import React, { useEffect, useRef, useState } from "react" import ButtonLink from "../ButtonLink/ButtonLink" import "./videoBackground.scss" + const VideoBackground = ({ - data: { video, description, button, strapi_component, id, backgroundImage }, + data: { video, description, button, strapi_component, id, backgroundImage, videoUrl }, }) => { const [isVideoPause, setIsVideoPause] = useState(false) const videoRef = useRef(null) @@ -32,6 +33,14 @@ const VideoBackground = ({ localStorage.setItem("videoPaused", isVideoPause) }, [isVideoPause]) + const url = videoUrl?.replace("watch?v=", "embed/") + let code = url?.substring(url.lastIndexOf("/") + 1, url.length) + const codeIndex = code?.indexOf("?") + + if (codeIndex !== -1 && code !== undefined) { + code = code.substring(0, code.indexOf("?")) + } + return (
-
diff --git a/src/components/videoBackground/videoBackground.scss b/src/components/videoBackground/videoBackground.scss index 2919513c..7017e18b 100644 --- a/src/components/videoBackground/videoBackground.scss +++ b/src/components/videoBackground/videoBackground.scss @@ -5,9 +5,10 @@ margin-top: 50px; margin-bottom: 50px; } - video { + video, + iframe { width: 100%; - height: 250px; + height: 195px; object-fit: cover; display: block; border-radius: 5px; @@ -37,7 +38,7 @@ @media screen and (min-width: $breakpoint-md) { .videoBackground { // width: calc(100% - 6em); - height: 550px; + height: 400px; position: relative; z-index: 3; display: flex; @@ -46,7 +47,7 @@ margin-top: 80px; margin-bottom: 80px; } - video { + .video { top: 0; position: absolute; width: 100%; @@ -81,13 +82,19 @@ @media screen and (min-width: $breakpoint-lg) { .videoBackground { - height: 80vh; + height: 520px; &-container { margin-bottom: 80px; } } } +@media screen and (min-width: $breakpoint-xl) { + .videoBackground { + height: 720px; + } +} + // @media screen and (max-width: $breakpoint-md) { // .videoBackground { // height: 500px; From 91b3b8dd396c394f68666adb82b2d38c0d766f9f Mon Sep 17 00:00:00 2001 From: Drina_Rincon Date: Thu, 12 May 2022 14:36:49 -0300 Subject: [PATCH 2/2] Arreglar medida en mobile del iframe --- src/components/videoBackground/videoBackground.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/videoBackground/videoBackground.scss b/src/components/videoBackground/videoBackground.scss index 7017e18b..e97512dc 100644 --- a/src/components/videoBackground/videoBackground.scss +++ b/src/components/videoBackground/videoBackground.scss @@ -8,7 +8,7 @@ video, iframe { width: 100%; - height: 195px; + height: 220px; object-fit: cover; display: block; border-radius: 5px;