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

Mm 49 large image #22

Open
wants to merge 12 commits into
base: staging
Choose a base branch
from
13 changes: 13 additions & 0 deletions src/components/photoGallery/LargeImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
DishaDarpan marked this conversation as resolved.
Show resolved Hide resolved

interface Props {
DishaDarpan marked this conversation as resolved.
Show resolved Hide resolved
largeImageUrl: string
DishaDarpan marked this conversation as resolved.
Show resolved Hide resolved
}

export const LargeImage: React.FunctionComponent<Props> = ({ largeImageUrl }) => {
return (
<div>
<img className="large-picture" src={largeImageUrl} alt="lorem picsum" width="90%" />
DishaDarpan marked this conversation as resolved.
Show resolved Hide resolved
</div>
);
}
11 changes: 10 additions & 1 deletion src/components/photoGallery/PhotoGallery.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.image-container {
display: flex;
flex-direction: column;
}

.image-gallery {
display: flex;
flex-wrap: wrap;
Expand All @@ -9,5 +14,9 @@
.space-image {
width: 200px;
height: 200px;
object-fit: cover;
object-fit: cover;
}

.large-picture {
padding: 5%;
}
17 changes: 11 additions & 6 deletions src/components/photoGallery/PhotoGallery.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, { useState, useEffect } from "react";
import "./PhotoGallery.scss";
import { LargeImage } from "./LargeImage";

export const PhotoGallery: React.FunctionComponent = () => {
const [imageUrls, setImageUrls] = useState<string[]>();
const [largeImageUrl, setLargeImageUrl] = useState<string>("https://apod.nasa.gov/apod/image/0201/earthrise_apollo8.jpg");
DishaDarpan marked this conversation as resolved.
Show resolved Hide resolved

useEffect(() => {
const url = `https://api.nasa.gov/planetary/apod?count=50&api_key=DEMO_KEY`;
Expand All @@ -17,12 +19,15 @@ export const PhotoGallery: React.FunctionComponent = () => {
}, []);

return (
<div className="image-gallery">
{imageUrls === undefined ? (
<p>Loading....</p>
) : (
imageUrls.map((url) => <img className="space-image" src={url} alt="" />)
)}
<div className="image-container">
<LargeImage largeImageUrl={largeImageUrl} />
<div className="image-gallery">
{imageUrls === undefined ? (
<p>Loading....</p>
) : (
imageUrls.map((url) => <img className="space-image" src={url} alt="" />)
)}
</div>
</div>
);
};