diff --git a/public/images/dolphin.jpg b/public/images/dolphin.jpg new file mode 100644 index 0000000..ec5fe63 Binary files /dev/null and b/public/images/dolphin.jpg differ diff --git a/public/images/lobster.jpg b/public/images/lobster.jpg new file mode 100644 index 0000000..15b7671 Binary files /dev/null and b/public/images/lobster.jpg differ diff --git a/public/images/ocean.jpg b/public/images/ocean.jpg new file mode 100644 index 0000000..8330232 Binary files /dev/null and b/public/images/ocean.jpg differ diff --git a/public/images/starfish.jpg b/public/images/starfish.jpg new file mode 100644 index 0000000..51d675e Binary files /dev/null and b/public/images/starfish.jpg differ diff --git a/src/components/animalFacts.js b/src/components/animalFacts.js new file mode 100644 index 0000000..5f35a15 --- /dev/null +++ b/src/components/animalFacts.js @@ -0,0 +1,51 @@ +import { animals } from '../js/animals' +import React from 'react'; + +const title = ''; +const showBackground = true; +const background = ( + ocean +); +const images = []; + +for (const animal in animals) { + images.push( + {animal} + ); +} + +function displayFact(e) { + const animalName = e.target.alt; + const facts = animals[animalName].facts; + const randomIndex = Math.floor(Math.random() * facts.length); + const funFact = facts[randomIndex]; + + const factElement = document.getElementById('fact'); + factElement.innerHTML = funFact; +} + +const animalFacts = ( +
+

{title || 'Click an animal for a fun fact'}

+ {showBackground && background} +
+ {images} +
+

+
+); + + +export default animalFacts; diff --git a/src/css/styles.css b/src/css/styles.css new file mode 100644 index 0000000..a8a3318 --- /dev/null +++ b/src/css/styles.css @@ -0,0 +1,63 @@ +div { + display: flex; + align-items: center; + flex-direction: column; +} + +.background { + position: absolute; + margin-top: 80px; + width: 95%; + z-index: 1 +} + +#fact { + display: flex; + justify-content: center; + position: fixed; + margin-top: 100px; + width: 90%; + font-size: 3vw; + z-index: 2; +} + +.animals { + display: flex; + flex-direction: row; + position: fixed; + width: 85%; + margin-top: 240px; + z-index: 2 +} + +.animal { + width: 33.3%; +} + +@media only screen and (max-width: 670px) { + .animals { + margin-top: 180px; + } + + h1 { + font-size: 24px; + } +} + +@media only screen and (max-width: 390px) { + .animals { + margin-top: 150px; + } +} + +@media only screen and (max-width: 300px) { + .animals { + margin-top: 130px; + } +} + +@media only screen and (max-width: 200px) { + .animals { + margin-top: 120px; + } +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index d563c0f..87e58b6 100644 --- a/src/index.js +++ b/src/index.js @@ -1,17 +1,18 @@ import React from 'react'; import ReactDOM from 'react-dom/client'; import './index.css'; -import App from './App'; +import './css/styles.css'; +import animalFacts from './components/animalFacts'; import reportWebVitals from './reportWebVitals'; const root = ReactDOM.createRoot(document.getElementById('root')); root.render( - + {animalFacts} ); // If you want to start measuring performance in your app, pass a function // to log results (for example: reportWebVitals(console.log)) // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals -reportWebVitals(); +reportWebVitals(); \ No newline at end of file diff --git a/src/js/animals.js b/src/js/animals.js new file mode 100644 index 0000000..e81c345 --- /dev/null +++ b/src/js/animals.js @@ -0,0 +1,14 @@ +export const animals = { + dolphin: { + image: '/images/dolphin.jpg', + facts: ['Dolphins have been shown to give distinct names to each other!', 'Dolphins are known to display their own culture!', 'Dolphins have two stomachs!'] + }, + lobster: { + image: '/images/lobster.jpg', + facts: ['Lobsters taste with their legs!', 'Lobsters chew with their stomachs!', 'Lobsters can live as long as 100 years.'] + }, + starfish: { + image: '/images/starfish.jpg', + facts: ['Starfish can have up to 40 arms!', 'Starfish have no brain and no blood!', 'Starfish can regenerate their own arms!'] + } +}; \ No newline at end of file