Skip to content

Commit

Permalink
Use isPDF prop instead
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidRobertAnsart committed Dec 15, 2024
1 parent 2d9ba72 commit befdc28
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const DefiActivityView = ({ activity }: ActivityViewProps<DefiActivity>)
{activity.data.image && (
<Grid item xs={12} md={4}>
<div style={{ width: '100%', height: '100%', minHeight: '200px', position: 'relative' }}>
<LightBox url={activity.data.image} isImage={true}>
<LightBox url={activity.data.image}>
<Image layout="fill" objectFit="contain" alt="image du plat" unoptimized src={activity.data.image} />
</LightBox>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const MascotteActivityView = ({ activity }: ActivityViewProps<MascotteAct
</Grid>
<Grid item xs={12} md={4}>
<Box display="flex" justifyContent="center" m={4}>
<LightBox url={activity.data.mascotteImage} isImage={true}>
<LightBox url={activity.data.mascotteImage}>
<AvatarImg src={activity.data.mascotteImage} noLink />
</LightBox>
</Box>
Expand Down
8 changes: 4 additions & 4 deletions src/components/activities/ActivityView/StoryActivityView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const StoryActivityView = ({ activity }: ActivityViewProps<StoryActivity>
position: 'relative',
}}
>
<LightBox url={activity.data.tale.imageStory} isImage={true}>
<LightBox url={activity.data.tale.imageStory}>
<Image layout="fill" objectFit="contain" alt="image du plat" unoptimized src={activity.data.tale.imageStory} />
</LightBox>
</div>
Expand Down Expand Up @@ -112,7 +112,7 @@ export const StoryActivityView = ({ activity }: ActivityViewProps<StoryActivity>
>
{activity.data.odd.description}
</Typography>
<LightBox url={activity.data.odd.imageUrl} isImage={true}>
<LightBox url={activity.data.odd.imageUrl}>
<CardMedia
sx={{ borderRadius: '0.5rem', mt: 1 }}
component="img"
Expand Down Expand Up @@ -144,7 +144,7 @@ export const StoryActivityView = ({ activity }: ActivityViewProps<StoryActivity>
>
{activity.data.object.description}
</Typography>
<LightBox url={activity.data.object.imageUrl} isImage={true}>
<LightBox url={activity.data.object.imageUrl}>
<CardMedia
sx={{ borderRadius: '0.5rem', mt: 1 }}
component="img"
Expand Down Expand Up @@ -176,7 +176,7 @@ export const StoryActivityView = ({ activity }: ActivityViewProps<StoryActivity>
>
{activity.data.place.description}
</Typography>{' '}
<LightBox url={activity.data.place.imageUrl} isImage={true}>
<LightBox url={activity.data.place.imageUrl}>
<CardMedia
sx={{ borderRadius: '0.5rem', mt: 1 }}
component="img"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export const ImageModal = ({
position: 'relative',
}}
>
<LightBox url={preview.url} isImage={true}>
<LightBox url={preview.url}>
<Image layout="fill" objectFit="contain" src={preview.url} unoptimized />
</LightBox>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/activities/content/views/DocumentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { LightBox } from 'src/components/lightbox/Lightbox';
export const DocumentView = ({ value = '' }: ViewProps) => {
return (
<div style={{ width: '100%', display: 'flex', flexDirection: 'column', justifyContent: 'center', alignContent: 'center', alignItems: 'center' }}>
<LightBox url={value} isImage={false}>
<LightBox url={value} isPDF>
<PdfDisplay url={value} />
</LightBox>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/activities/content/views/ImageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ImageView = ({ value }: ViewProps) => {
<KeepRatio ratio={2 / 3} maxWidth="600px">
<div style={{ width: '100%', height: '100%', position: 'relative' }}>
{value && (
<LightBox url={value} isImage={true}>
<LightBox url={value}>
<Image layout="fill" objectFit="contain" src={value} unoptimized />
</LightBox>
)}
Expand Down
9 changes: 5 additions & 4 deletions src/components/lightbox/Lightbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import { Modal } from '../Modal';
type LightBoxProps = {
url: string;
children: JSX.Element;
isImage: boolean;
isPDF?: boolean;
};

export const LightBox = ({ url, children, isImage }: LightBoxProps) => {
export const LightBox = ({ url, children, isPDF }: LightBoxProps) => {
const [isModalOpen, setIsModalOpen] = React.useState(false);

const options = {
Expand All @@ -37,7 +37,7 @@ export const LightBox = ({ url, children, isImage }: LightBoxProps) => {
ariaLabelledBy="lightBox-modal-title"
ariaDescribedBy="lightBox-modal-description"
>
{isImage == false && (
{isPDF ? (
<Document options={options} file={url} onLoadSuccess={onDocumentLoadSuccess}>
{Array.from(Array(numPages).keys()).map((v) => (
<div
Expand All @@ -51,8 +51,9 @@ export const LightBox = ({ url, children, isImage }: LightBoxProps) => {
</div>
))}
</Document>
) : (
<Image layout="responsive" objectFit="contain" width="100%" height="70%" alt="" unoptimized src={url} />
)}
{isImage == true && <Image layout="responsive" objectFit="contain" width="100%" height="70%" alt="" unoptimized src={url} />}
</Modal>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/admin/newportal/contenulibre/2/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ const ContenuLibre = () => {
position: 'relative',
}}
>
<LightBox url={imageUrl} isImage={true}>
<LightBox url={imageUrl}>
<Image layout="fill" objectFit="contain" src={imageUrl} unoptimized />
</LightBox>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/contenu-libre/2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const ContenuLibre = () => {
position: 'relative',
}}
>
<LightBox url={imageUrl} isImage={true}>
<LightBox url={imageUrl}>
<Image layout="fill" objectFit="contain" src={imageUrl} unoptimized />
</LightBox>
</div>
Expand Down

0 comments on commit befdc28

Please sign in to comment.