diff --git a/src/core/client/stream/common/Media/GiphyMedia.css b/src/core/client/stream/common/Media/GiphyMedia.css new file mode 100644 index 000000000..dd1520932 --- /dev/null +++ b/src/core/client/stream/common/Media/GiphyMedia.css @@ -0,0 +1,15 @@ +.responsiveVideo { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + border: 0; +} + +.responsiveContainer { + position: relative; + height: 0; + overflow: hidden; + max-width: 100%; +} diff --git a/src/core/client/stream/common/Media/GiphyMedia.tsx b/src/core/client/stream/common/Media/GiphyMedia.tsx index f2bbf93fa..40e47ef2c 100644 --- a/src/core/client/stream/common/Media/GiphyMedia.tsx +++ b/src/core/client/stream/common/Media/GiphyMedia.tsx @@ -1,5 +1,8 @@ +import cn from "classnames"; import React, { FunctionComponent } from "react"; +import styles from "./GiphyMedia.css"; + interface Props { url: string; width?: number | null; @@ -8,6 +11,10 @@ interface Props { title?: string | null; } +function calculateBottomPadding(width: number, height: number) { + return `${(height / width) * 100}%`; +} + const GiphyMedia: FunctionComponent = ({ url, title, @@ -15,15 +22,30 @@ const GiphyMedia: FunctionComponent = ({ width, height, }) => { + const paddingBottom = + width && height ? calculateBottomPadding(width, height) : null; return video ? ( - +
+
+ +
+
) : ( {title );