Merge pull request #33 from gractwo/1-develop-a-masonry-grid-for-the-index-pages-gallery

infamous Griddy
This commit is contained in:
Adam Cała
2024-02-06 12:40:32 +01:00
committed by GitHub
4 changed files with 1438 additions and 119 deletions

View File

@@ -1,70 +1,14 @@
.gallerycontainer { .image:hover {
display: flex; cursor: pointer;
flex-direction: row; }
flex-wrap: wrap; .title {
// justify-content: space-between; overflow: hidden;
@media screen and (max-width: 800px) { text-overflow: ellipsis;
flex-direction: column; white-space: nowrap;
align-items: center; }
}
gap: 2rem; .subtitle {
.galleryimg { overflow: hidden;
--mheight: 18rem; text-overflow: ellipsis;
position: relative; white-space: nowrap;
display: block;
margin: 0;
padding: 0;
max-height: var(--mheight);
animation-name: goIn;
animation-duration: 350ms;
@media screen and (max-width: 800px) {
text-decoration: none;
max-height: none;
text-align: center;
}
@keyframes goIn {
from {
opacity: 0;
transform: translate(0, 8px);
}
}
img {
max-height: var(--mheight);
border-radius: 8px;
@media screen and (max-width: 800px) {
max-width: 280px;
}
}
article {
position: absolute;
backdrop-filter: blur(8px);
background: rgba(#fff, 0.4);
color: var(--backdrop);
left: 0;
bottom: 0;
width: 100%;
padding: 0.25rem 0.5rem;
border-radius: 8px;
border-top-left-radius: 0;
border-top-right-radius: 0;
transition-duration: 100ms;
opacity: 0;
p {
margin-bottom: 4px;
}
@media screen and (max-width: 800px) {
display: block;
position: relative;
background: unset;
color: var(--white0);
padding: 0;
opacity: 1;
}
}
&:hover {
article {
opacity: 1;
}
}
}
} }

View File

@@ -1,6 +1,11 @@
import styles from "./IndexGallery.module.scss"; import styles from "./IndexGallery.module.scss";
import Link from "next/link"; import Link from "next/link";
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import ImageList from "@mui/material/ImageList";
import ImageListItem from "@mui/material/ImageListItem";
import ImageListItemBar from "@mui/material/ImageListItemBar";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
const IndexGallery = () => { const IndexGallery = () => {
type apiResType = { type apiResType = {
@@ -24,39 +29,40 @@ const IndexGallery = () => {
console.log(err); console.log(err);
}); });
}, []); }, []);
function redirect(
Link: string
): import("react").MouseEventHandler<HTMLImageElement> {
return (event: React.MouseEvent<HTMLImageElement>) => {
window.open(Link, "_blank");
};
}
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
return ( return (
<> <>
<main> <main>
<h2>galeria zdjęć idących mocno</h2> <h2>galeria zdjęć idących mocno</h2>
</main> </main>
<main className={styles.gallerycontainer}> <main>
{data.map((el: apiResType) => { <ImageList variant="masonry" cols={isMobile ? 1 : 3} gap={8}>
return ( {data.map((el: apiResType) => (
<Link key={el.Id} href={el.Link} className={styles.galleryimg}> <>
<img src={el.Link} alt={el.Description || el.Title} /> <ImageListItem key={el.Id}>
<article> <img
<h3>{el.Title}</h3> src={el.Link}
<p> alt={el.Description || el.Title}
{el.Place || ""} loading="lazy"
{el.Place && el.Date ? ", " : ""} onClick={redirect(el.Link)}
{el.Date className={styles.image}
? new Date(el.Date).getDate().toString().length == 2 ></img>
? new Date(el.Date).getDate() <ImageListItemBar
: "0" + new Date(el.Date).getDate() title={el.Title}
: ""} subtitle={el.Place}
{"."} ></ImageListItemBar>
{el.Date </ImageListItem>
? (new Date(el.Date).getMonth() + 1).toString().length == 2 </>
? new Date(el.Date).getMonth() + 1 ))}
: "0" + (new Date(el.Date).getMonth() + 1) </ImageList>
: ""}
{"."}
{el.Date ? new Date(el.Date).getFullYear() : ""}
</p>
</article>
</Link>
);
})}
</main> </main>
</> </>
); );

1409
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,6 +10,10 @@
}, },
"dependencies": { "dependencies": {
"@auth0/nextjs-auth0": "^2.0.1", "@auth0/nextjs-auth0": "^2.0.1",
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/lab": "^5.0.0-alpha.163",
"@mui/material": "^5.15.7",
"@types/node": "18.11.12", "@types/node": "18.11.12",
"@types/react": "18.0.26", "@types/react": "18.0.26",
"@types/react-dom": "18.0.9", "@types/react-dom": "18.0.9",