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

View File

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