Skip to content

Commit

Permalink
Merge branch '738-better-youtube-thumbnail-quality' of https://github…
Browse files Browse the repository at this point in the history
….com/SSWConsulting/SSW.Website into 738-better-youtube-thumbnail-quality
  • Loading branch information
Jord-Gui committed Jul 13, 2023
2 parents c344e3a + ac0888c commit 5d2ca57
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .tina/__generated__/_graphql.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .tina/__generated__/_schema.json

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions components/blocks/videoEmbed.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React from "react";
import classNames from "classnames";
import type { Template } from "tinacms";
import { VideoModal } from "../videoModal";
import classNames from "classnames";

export const VideoEmbed = ({ data }) => {
const width = data.videoWidth || "w-3/4";
const margin = data.removeMargin ? "" : "m-8";

return (
<div className={classNames("relative mx-auto aspect-video", width, margin)}>
<VideoModal url={data.url} />
<VideoModal url={data.url} duration={data.videoDuration} />
</div>
);
};
Expand Down Expand Up @@ -58,5 +57,11 @@ export const videoEmbedBlockSchema: Template = {
name: "removeMargin",
required: false,
},
{
type: "string",
label: "Video duration",
name: "videoDuration",
required: false,
},
],
};
8 changes: 7 additions & 1 deletion components/videoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const YouTubeEmbed = dynamic(
}
);

export const VideoModal = ({ children = null, url }) => {
export const VideoModal = ({ children = null, url, duration = null }) => {
const id = url ? getYouTubeId(url) : null;
console.log(duration);

const [clicked, setClicked] = useState<boolean>(false);
const [imageSrc, setImageSrc] = useState<string>(
Expand Down Expand Up @@ -41,6 +42,11 @@ export const VideoModal = ({ children = null, url }) => {
}}
/>
<PlayArrow />
{duration && (
<div className="absolute bottom-3 left-3 rounded-lg border-1 bg-sswRed px-4 py-1 text-white">
{duration}
</div>
)}
</div>
) : (
<YouTubeEmbed
Expand Down
2 changes: 1 addition & 1 deletion content/consulting/react.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ seo:

# The benefits of building your **UI in React** with SSW

<VideoEmbed url="https://www.youtube.com/watch?v=3K4Gb54BFMo" />
<VideoEmbed url="https://www.youtube.com/watch?v=3K4Gb54BFMo" videoDuration="28:22" />

React is a JavaScript library that combines the speed of JavaScript with new ways of rendering web pages, making them highly dynamic and responsive to user input. This technology significantly changed Facebook approach to development. After the library was released as an open-source tool, it became extremely popular due to its revolutionary approach to programming user interfaces.

Expand Down

0 comments on commit 5d2ca57

Please sign in to comment.