Add portafolio page

This commit is contained in:
Alexander Navarro 2023-11-18 14:02:51 -03:00
parent 0c10c3fa77
commit 318a647147
8 changed files with 166 additions and 23 deletions

View file

@ -0,0 +1,44 @@
import React from 'react';
import { MediaType, type Media } from './types';
interface Props {
items: Media[];
}
// TODO: transform this component in a lightbox
export default function Gallery({ items }: Props): JSX.Element {
const renderItem = (item: Media): JSX.Element => {
// get the file id from the "share" link of google drive
const googleFileId = item.url.split('/').at(5);
let url;
switch (item.type) {
case MediaType.Image:
url =
googleFileId !== undefined
? `https://drive.google.com/uc?export=preview&id=${googleFileId}`
: item.url;
return <img src={url} alt={item.alt} />;
case MediaType.Video:
url =
googleFileId !== undefined
? `https://drive.google.com/file/d/${googleFileId}/preview`
: item.url;
return (
<iframe src={url} width="600" height="500" allow="autoplay"></iframe>
);
default:
break;
}
return <></>;
};
return (
<ul className="list-unstyle">
{items.map((item, idx) => (
<li key={idx}>{renderItem(item)}</li>
))}
</ul>
);
}