diff --git a/src/components/Img.tsx b/src/components/Img.tsx index 8723bbb..24861e5 100644 --- a/src/components/Img.tsx +++ b/src/components/Img.tsx @@ -50,7 +50,7 @@ export function getImgSizesByQuality( type ImgProps = { className?: string; - image: StrapiImage; + image?: StrapiImage; quality?: ImageQuality; alt?: ImageProps["alt"]; layout?: ImageProps["layout"]; @@ -60,42 +60,46 @@ type ImgProps = { }; export default function Img(props: ImgProps): JSX.Element { - const imgSize = getImgSizesByQuality( - props.image.width, - props.image.height, - props.quality ? props.quality : ImageQuality.Small - ); + if (props.image) { + const imgSize = getImgSizesByQuality( + props.image.width, + props.image.height, + props.quality ? props.quality : ImageQuality.Small + ); - if (props.rawImg) { - return ( - // eslint-disable-next-line @next/next/no-img-element - - ); + if (props.rawImg) { + return ( + // eslint-disable-next-line @next/next/no-img-element + + ); + } else { + return ( + + ); + } } else { - return ( - - ); + return <>>; } } diff --git a/src/components/LightBox.tsx b/src/components/LightBox.tsx new file mode 100644 index 0000000..a56551a --- /dev/null +++ b/src/components/LightBox.tsx @@ -0,0 +1,31 @@ +import { StrapiImage } from "graphql/operations-types"; +import { Dispatch, SetStateAction } from "react"; +import Img, { ImageQuality } from "./Img"; +import Popup from "./Popup"; + +export type LightBoxProps = { + setState: + | Dispatch> + | Dispatch>; + state: boolean; + image?: StrapiImage; +}; + +export default function LightBox(props: LightBoxProps): JSX.Element { + return ( + + + + ); +} diff --git a/src/components/Markdown/Markdawn.tsx b/src/components/Markdown/Markdawn.tsx index cd0dc14..9720884 100644 --- a/src/components/Markdown/Markdawn.tsx +++ b/src/components/Markdown/Markdawn.tsx @@ -1,4 +1,5 @@ import HorizontalLine from "components/HorizontalLine"; +import Img, { ImageQuality } from "components/Img"; import InsetBox from "components/InsetBox"; import ToolTip from "components/ToolTip"; import { useAppLayout } from "contexts/AppLayoutContext"; @@ -200,6 +201,43 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element { ); }, }, + img: { + component: (props: { + alt: string; + src: string; + width?: number; + height?: number; + caption?: string; + name?: string; + }) => { + return ( + <> + {props.src.startsWith("/uploads/") ? ( + + + + ) : ( + + + + )} + > + ); + }, + }, }, }} > diff --git a/src/components/Popup.tsx b/src/components/Popup.tsx index c9a30e1..7cd91b5 100644 --- a/src/components/Popup.tsx +++ b/src/components/Popup.tsx @@ -2,12 +2,17 @@ import { Dispatch, SetStateAction } from "react"; import Button from "./Button"; export type PopupProps = { - setState: Dispatch>; + setState: + | Dispatch> + | Dispatch>; state?: boolean; children: React.ReactNode; + fillViewport?: boolean; + hideBackground?: boolean; }; export default function Popup(props: PopupProps): JSX.Element { + return ( { + if (e.key.match("Escape")) props.setState(false); + }} + tabIndex={0} > (); + const subPanel = ( + + - + { + if (item.thumbnail.data) { + setLightboxImage(item.thumbnail.data.attributes); + setLightboxOpened(true); + } + }} + > {item.thumbnail.data ? ( { + setLightboxImage(galleryItem.attributes); + setLightboxOpened(true); + }} >