Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added merch gallery section #499

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/components/MerchSection/MerchGallery.styles.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

import styled from "styled-components";

export const MerchContainer = styled.div`
// mobile
column-count: 1;
column-gap: 24;
max-width: 1024px;
margin: auto;
// ipad
@media (min-width: 768px) {
column-count: 2;
}
// desktop
@media (min-width: 1024px) {
column-count: 3;
}
`;

export const Image = styled.img`
width: 100%;
height: auto;
margin-bottom: 24px;
background-color: white;
`;
59 changes: 59 additions & 0 deletions src/components/MerchSection/MerchGallery.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import axios from "axios";
import { useCallback, useEffect, useState } from "react";
import { PicturesContainer, PicturesHeader } from "components/PhotoGallery/PhotoGallery.styles";
import { LazyLoadImage } from "react-lazy-load-image-component";
import Loading from "components/Loading";

const MerchGallery = () => {
const [photosURL, setPhotosURL] = useState<string[]>([]);
const getAlbum = useCallback(async () => {
const galleryPicsURL = process.env.REACT_APP_PIC_API_URL;
try {
if (!galleryPicsURL) {
throw new Error("URL is not defined");
}
const { data } = await axios.get<string[]>(`${galleryPicsURL}/merchgallery`);

if (!data.length) {
throw new Error("No images found");
}
setPhotosURL(data);
} catch (error) {
console.error(
`Error fetching images from the server on ${galleryPicsURL}/merchgallery`,
error
);
}
}, []);

useEffect(() => {
getAlbum();
}, [getAlbum]);

return (
<>
{photosURL.length === 0 ? (
<Loading />
) : (
<PicturesHeader
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: 0.5 }}
>
<PicturesContainer>
{photosURL.map((photo, index) => (
<LazyLoadImage
height="auto"
key={index}
src={photo}
width="100%"
/>
))}
</PicturesContainer>
</PicturesHeader>
)}
</>
);
};

export default MerchGallery;
7 changes: 7 additions & 0 deletions src/components/MerchSection/MerchSection.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import React from "react";
import * as S from "./MerchSection.styles";
import MerchCollection from "./MerchCollection";
import Divider from "components/Divider";
import { merchList } from "./MerchData";
import MerchGallery from "components/MerchSection/MerchGallery";
import useViewport from "components/UseViewport";

const MerchSection = () => {
Expand All @@ -11,6 +13,11 @@ const MerchSection = () => {
return (
<S.MerchSection data-aos="fade-up" >
<MerchCollection merchItems={merchList} desktopView={defaultView} />
<h1 className="chonkyHeading chonkyHeading--black chonkyHeading--lessMargin">
Merch Gallery
</h1>
<Divider />
<MerchGallery/>
</S.MerchSection>
);
};
Expand Down