Further code commenting for future reference
This commit is contained in:
parent
41aceb7814
commit
6d3d2556b1
|
@ -1,3 +1,4 @@
|
||||||
|
// import modules required
|
||||||
import Container from "react-bootstrap/Container"
|
import Container from "react-bootstrap/Container"
|
||||||
import Navbar from "react-bootstrap/Navbar"
|
import Navbar from "react-bootstrap/Navbar"
|
||||||
import Nav from "react-bootstrap/Nav"
|
import Nav from "react-bootstrap/Nav"
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
|
// import modules required
|
||||||
import { useState, useEffect, useContext } from 'react'
|
import { useState, useEffect, useContext } from 'react'
|
||||||
import { StorageContext } from '../contexts/StorageContext'
|
import { StorageContext } from '../contexts/StorageContext'
|
||||||
import { ref, getDownloadURL } from 'firebase/storage'
|
import { ref, getDownloadURL } from 'firebase/storage'
|
||||||
import Card from 'react-bootstrap/Card'
|
import Card from 'react-bootstrap/Card'
|
||||||
|
|
||||||
export function ItemImage ( props ) {
|
export function ItemImage ( props ) {
|
||||||
|
// declare variables
|
||||||
const [image,setImage] = useState()
|
const [image,setImage] = useState()
|
||||||
|
|
||||||
const storage = useContext( StorageContext)
|
const storage = useContext( StorageContext)
|
||||||
|
|
||||||
|
// useEffect to get image from Google Firebase Storage via the URL given in Google Firebase Firestore
|
||||||
useEffect( () => {
|
useEffect( () => {
|
||||||
if( props.source ) {
|
if( props.source ) {
|
||||||
const imgref = ref( storage, `artworks/${props.source}`)
|
const imgref = ref( storage, `artworks/${props.source}`)
|
||||||
|
@ -17,6 +19,7 @@ export function ItemImage ( props ) {
|
||||||
}
|
}
|
||||||
}, [props.source] )
|
}, [props.source] )
|
||||||
|
|
||||||
|
// if image cannot be loaded, display a grey box as placeholder
|
||||||
if(!image) {
|
if(!image) {
|
||||||
const defstyle={
|
const defstyle={
|
||||||
backgroundColor: "#cccccc",
|
backgroundColor: "#cccccc",
|
||||||
|
@ -29,6 +32,7 @@ export function ItemImage ( props ) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (
|
return (
|
||||||
|
// if all works out, display the image, title and author of the artwork in the gallery boxes with the correct scaling
|
||||||
<Card.Img style={{aspectRatio: "3/4"}} variant='top' src={image} />
|
<Card.Img style={{aspectRatio: "3/4"}} variant='top' src={image} />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ export function Home(props) {
|
||||||
return (
|
return (
|
||||||
// temp home page
|
// temp home page
|
||||||
<Container>
|
<Container>
|
||||||
<p>This is a tempoary home page</p>
|
<p>This is a tempoary home page further work will be done later on.</p>
|
||||||
</Container>
|
</Container>
|
||||||
)
|
)
|
||||||
}
|
}
|
Loading…
Reference in New Issue