Move gallery from homepage to seperate page, create tempoary homepage

This commit is contained in:
Ray 2024-01-14 12:29:22 +00:00 committed by GitHub
parent 7c4f64749b
commit 9a2212f93e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 59 additions and 41 deletions

View File

@ -20,6 +20,7 @@ import { About } from "./pages/About"
import { Home } from "./pages/Home" import { Home } from "./pages/Home"
import { Contact } from "./pages/Contact" import { Contact } from "./pages/Contact"
import { Detail } from "./pages/Detail"; import { Detail } from "./pages/Detail";
import { Gallery } from "./pages/Gallery";
// contexts // contexts
import { StorageContext } from "./contexts/StorageContext"; import { StorageContext } from "./contexts/StorageContext";
@ -92,16 +93,17 @@ function App() {
} }
// modify the navigation on line 101 to new home page (gallery is set for now)
return ( return (
<div className="App"> <div className="App">
<Header items={nav} user={auth} /> <Header items={nav} user={auth} />
<StorageContext.Provider value={FBstorage}> <StorageContext.Provider value={FBstorage}>
<Routes> <Routes>
<Route path="/" element={<Home items={data} />} /> <Route path="/" element={<Home/>} />
<Route path="/about" element={<About greeting="Hey you, this is about page!" handler={saySomething} />} /> <Route path="/about" element={<About greeting="Hey you, this is about page!" handler={saySomething} />} />
<Route path="/contact" element={<Contact greeting="Hey you, this is contact page!" />} /> <Route path="/contact" element={<Contact greeting="Hey you, this is contact page!" />} />
<Route path="/detail/:id" element={<Detail handler={getDocument} />} /> <Route path="/detail/:id" element={<Detail handler={getDocument} />} />
<Route path="/gallery" element={<Home items={data} />} /> <Route path="/gallery" element={<Gallery items={data} />} />
</Routes> </Routes>
</StorageContext.Provider> </StorageContext.Provider>
</div> </div>

View File

@ -0,0 +1,41 @@
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import Container from "react-bootstrap/Container";
import Card from "react-bootstrap/Card";
import { useState, useEffect } from "react"
import { ItemImage } from "../components/ItemImage"
export function Gallery(props) {
const [artworks,setArtworks] = useState([])
useEffect(() => {
console.log( props.items )
setArtworks( props.items )
}, [props.items])
const ItemCards = artworks.map( ( artwork, itemkey ) => {
const itemLink = `/detail/${artwork.id}`
return(
<Col md={4} className="mb-4" key={itemkey}>
<Card key={itemkey} className="position-relative">
<a href={itemLink} className="position-absolute" style={{top:0, left:0, right:0, bottom:0}}>
</a>
<ItemImage source={ artwork.artwork_image} />
<Card.Body>
<Card.Title>{ artwork.artwork_title }</Card.Title>
</Card.Body>
</Card>
</Col>
)
})
return (
<Container>
<Row>
{ItemCards}
</Row>
</Container>
)
}

View File

@ -1,41 +1,16 @@
import Row from 'react-bootstrap/Row'; // DEVELOP HOME PAGE HERE
import Col from 'react-bootstrap/Col';
import Container from "react-bootstrap/Container";
import Card from "react-bootstrap/Card"; //import required modules
import { useState, useEffect } from "react" import { Container } from "react-bootstrap"
import { ItemImage } from "../components/ItemImage"
export function Home(props) { export function Home(props) {
const [artworks,setArtworks] = useState([])
useEffect(() => {
console.log( props.items )
setArtworks( props.items )
}, [props.items])
const ItemCards = artworks.map( ( artwork, itemkey ) => {
const itemLink = `/detail/${artwork.id}`
return(
<Col md={4} className="mb-4" key={itemkey}>
<Card key={itemkey} className="position-relative">
<a href={itemLink} className="position-absolute" style={{top:0, left:0, right:0, bottom:0}}>
</a>
<ItemImage source={ artwork.artwork_image} />
<Card.Body>
<Card.Title>{ artwork.artwork_title }</Card.Title>
</Card.Body>
</Card>
</Col>
)
})
return ( return (
// temp home page
<Container> <Container>
<Row> <p>This is a tempoary home page</p>
{ItemCards}
</Row>
</Container> </Container>
) )
} }