From e87b6f609e078d095c273cc73af37ebab8e6d8ea Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Fri, 6 May 2022 10:12:16 +0200 Subject: [PATCH 1/7] [Fix] Fix publish beta release --- .github/workflows/npm-publish-beta.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/npm-publish-beta.yml b/.github/workflows/npm-publish-beta.yml index 7b29e512..d03b58cb 100644 --- a/.github/workflows/npm-publish-beta.yml +++ b/.github/workflows/npm-publish-beta.yml @@ -1,9 +1,7 @@ name: Publish NPM Beta Package on: - pull_request: - types: - - closed + push: branches: - master From 6f0aadee2cf4194055ef4966fbac6f96eda261d8 Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Fri, 6 May 2022 10:12:47 +0200 Subject: [PATCH 2/7] [New] Add prop to hide overlay of link icon --- src/components/LinkIcon.jsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/LinkIcon.jsx b/src/components/LinkIcon.jsx index d3169e60..84189017 100644 --- a/src/components/LinkIcon.jsx +++ b/src/components/LinkIcon.jsx @@ -4,7 +4,7 @@ import ExternalLink from "../styles/icons/ExternalLink"; import IconOverlay from "./IconOverlay"; const LinkIcon = (props) => { - return ( + return props.showOverlay ? ( { + ) : ( + + + ); }; @@ -30,12 +38,14 @@ LinkIcon.propTypes = { iconClass: PropTypes.string, overlayPlacement: PropTypes.string, absolutePosition: PropTypes.bool, + showOverlay: PropTypes.bool, }; LinkIcon.defaultProps = { iconClassContainer: "", iconClass: "", absolutePosition: true, + showOverlay: true, }; export default LinkIcon; From 5ed4bd1b080df44917ef629d80348ce92d1ad420 Mon Sep 17 00:00:00 2001 From: Max Chopart Date: Fri, 6 May 2022 11:14:52 +0200 Subject: [PATCH 3/7] [New #149] Add support of images for media content --- src/components/MediaContent.tsx | 83 +++++++++++++++++++++++++-------- src/styles/s-forms.css | 41 ++++++++++++++++ 2 files changed, 105 insertions(+), 19 deletions(-) diff --git a/src/components/MediaContent.tsx b/src/components/MediaContent.tsx index 18391823..45d7f368 100644 --- a/src/components/MediaContent.tsx +++ b/src/components/MediaContent.tsx @@ -1,48 +1,93 @@ import React from "react"; import Constants from "../constants/Constants"; +import LinkIcon from "./LinkIcon"; interface Props { question: object; } +const YOUTUBE_URL = "https://www.youtube.com/"; +const GOOGLE_DRIVE_URL = "https://drive.google.com/"; + const MediaContent = ({ question }: Props) => { - const renderMedia = () => { + const isGoogleDriveImage = (mediaContentUrl: string) => { + return ( + mediaContentUrl.includes("/file/d/") && + mediaContentUrl.includes(GOOGLE_DRIVE_URL) + ); + }; + + const isYoutubeVideo = (mediaContentUrl: string) => { + return ( + mediaContentUrl.includes("watch?v=") && + mediaContentUrl.includes(YOUTUBE_URL) + ); + }; + + const getMediaId = (mediaContentUrl: string) => { + if (isGoogleDriveImage(mediaContentUrl)) { + return mediaContentUrl.substring( + mediaContentUrl.indexOf("/file/d/") + 8, + mediaContentUrl.lastIndexOf("/") + ); + } + if (isYoutubeVideo(mediaContentUrl)) { + return mediaContentUrl.substring(mediaContentUrl.indexOf("watch?v=") + 8); + } + }; + + const getEmbedLink = (mediaContentUrl: string) => { + if (isGoogleDriveImage(mediaContentUrl)) { + return ( + GOOGLE_DRIVE_URL + "uc?export=view&id=" + getMediaId(mediaContentUrl) + ); + } + if (isYoutubeVideo(mediaContentUrl)) { + return YOUTUBE_URL + "embed/" + getMediaId(mediaContentUrl); + } + return mediaContentUrl; + }; + + const getMediaType = (mediaContentUrl: string) => { + if (mediaContentUrl.includes(YOUTUBE_URL)) { + return