feat: aperçu Youtube dans les popup de la carte

proto-module-actu-react
Jalil Arfaoui 2023-09-08 15:35:41 +02:00
parent 906cfb32e7
commit 3f3d735f3c
2 changed files with 30 additions and 12 deletions

View File

@ -1,10 +1,11 @@
import { ReactNode } from "react";
import { IframeHTMLAttributes } from "react";
interface Props {
youtubeId: string;
width: string;
height: string;
onClick: () => void;
style: IframeHTMLAttributes<HTMLIFrameElement>["style"];
}
export const EmbeddedYoutube = ({
@ -12,6 +13,7 @@ export const EmbeddedYoutube = ({
width,
height,
onClick,
style,
}: Props) => (
<div onClick={onClick}>
<iframe
@ -22,7 +24,7 @@ export const EmbeddedYoutube = ({
frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowFullScreen
style={{ pointerEvents: "none" }}
style={{ pointerEvents: "none", ...style }}
></iframe>
</div>
);

View File

@ -5,6 +5,7 @@ import { getResistantPhotoUrl } from "../../../getResistantPhotoUrl";
import { HomeContext } from "../../../context/HomeContext";
import { getResistantPageUrl } from "../../../getResistantPageUrl";
import { getResistantGrayscaleRule } from "../../../style/getResistantGrayscaleRule";
import { EmbeddedYoutube } from "../../../components/EmbeddedYoutube";
export const PopupContent = ({ resistant }: { resistant: Resistant }) => {
const navigate = useNavigate();
@ -19,16 +20,31 @@ export const PopupContent = ({ resistant }: { resistant: Resistant }) => {
: navigate(resistant.id)
}
>
<img
src={getResistantPhotoUrl(resistant)}
style={{
...getResistantGrayscaleRule(resistant),
float: "left",
maxHeight: "15em",
marginRight: "1em",
}}
alt={resistant.noms}
/>
{resistant.video ? (
<EmbeddedYoutube
youtubeId={resistant.video}
width={"220"}
height={"120"}
onClick={() => {}}
style={{
float: "left",
maxHeight: "15em",
marginRight: "1em",
paddingBottom: "3em",
}}
/>
) : (
<img
src={getResistantPhotoUrl(resistant)}
style={{
...getResistantGrayscaleRule(resistant),
float: "left",
maxHeight: "15em",
marginRight: "1em",
}}
alt={resistant.noms}
/>
)}
<strong style={{ overflow: "hidden" }}>{resistant.noms}</strong>
<br />
👨👩👧👦 Parent(s) de {resistant.enfants} <br />