Skip to content

Commit

Permalink
trying to put part of the code in ImageSelector.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Anum1608 committed Jul 22, 2024
1 parent 09f1b3d commit 5f8cf67
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
3 changes: 1 addition & 2 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@
width: 150px; /* Set a small width */
}

thumbnail:hover {
img.thumbnail:hover {
box-shadow: 0 0 20px 10px rgba(0, 140, 186, 0.5);
border: #000000;
border-radius: 4px;
}
15 changes: 4 additions & 11 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import {PhotoViewer} from './photoViewer/PhotoViewer.tsx'
import { ImageSelector } from './photoViewer/ImageSelector.tsx'
import { ImageSelector, currentImage } from './photoViewer/ImageSelector.tsx'
import { GetImageUrls } from './photoViewer/ImageSelector.tsx'



function App() {
const [count, setCount] = useState(0)
const imagesID = [1, 24, 32, 36, 44, 47];
const url = GetImageUrls(imagesID);

const [currentImage, setCurrentImage] = useState('https://picsum.photos/id/250/600/300.jpg')

//console.log(url)

Expand All @@ -33,16 +34,8 @@ function App() {
<PhotoViewer photoUrl={currentImage} />

<ImageSelector urlList={url}/>


{/* <button onClick={() => setCurrentImage((currentImage) => Math.min(currentImage + 1,url.length))}></button> */}

<div>
{url.map(imageUrl => {
return <div>
{imageUrl}
<img className='thumbnail' onClick={() => setCurrentImage(imageUrl)} src={imageUrl} alt="image" />
</div> })}
</div>

</>
)
Expand Down
11 changes: 11 additions & 0 deletions src/photoViewer/ImageSelector.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.thumbnail{
border: 1px solid #ddd; /* Gray border */
border-radius: 4px; /* Rounded border */
padding: 5px; /* Some padding */
width: 150px; /* Set a small width */
}

img.thumbnail:hover {
box-shadow: 0 0 20px 10px rgba(0, 140, 186, 0.5);
border-radius: 4px;
}
17 changes: 14 additions & 3 deletions src/photoViewer/ImageSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
import React from "react"; // import React (to provide access to TSX)
import { useState } from 'react'
import './ImageSelector.css'


export function ImageSelector(props) { // declare and export new function called 'PhotoViewer'
export const [currentImage, setCurrentImage] = useState('https://picsum.photos/id/250/600/300.jpg')



export function ImageSelector({urlList}: {urlList: string[]}) {

return (
<div>
Hello World ! in ImageSelector

<div>
{urlList.map(imageUrl => {
return <div>
<img className='thumbnail' onClick={() => setCurrentImage(imageUrl)} src={imageUrl} />
</div> })}
</div>
);
}
Expand Down

0 comments on commit 5f8cf67

Please sign in to comment.