diff --git a/README.md b/README.md index 788ab5a..cf4f73b 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,17 @@ -# 📊 Project: Simple API 2 - -### Goal: Display data returned from an api - -### How to submit your code for review: - -- Fork and clone this repo -- Create a new branch called answer -- Checkout answer branch -- Push to your fork -- Issue a pull request -- Your pull request description should contain the following: - - (1 to 5 no 3) I completed the challenge - - (1 to 5 no 3) I feel good about my code - - Anything specific on which you want feedback! - -Example: -``` -I completed the challenge: 5 -I feel good about my code: 4 -I'm not sure if my constructors are setup cleanly... -``` +# Simple API 2 Project + +This project fetches a joke from a jokes API and display that joke on the UI! + +## How It's Made: + +**Tech used:** HTML, CSS, and JavaScript + +I used html for the markup, css for the styling, andI used Javascript for the logic of this project. + +## Lessons Learned: + +I learned how to run javascript code in HTML strings, and turn the output into a number via the eval function. + +## Image of Project: + +![dadjokes image](dadjokesapiimg.png) diff --git a/dadjokesapiimg.png b/dadjokesapiimg.png new file mode 100644 index 0000000..e69b0fe Binary files /dev/null and b/dadjokesapiimg.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..d77f6d6 --- /dev/null +++ b/index.html @@ -0,0 +1,18 @@ + + + + + + + Document + + + +
+

+ +
+ + + + \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..df40737 --- /dev/null +++ b/script.js @@ -0,0 +1,18 @@ +// Get a Joke API PROJECT! + + +let button = document.querySelector('button') + +button.addEventListener("click", getJoke) + +function getJoke(){ + let joke = document.querySelector('h2') + let API_URL = ' https://v2.jokeapi.dev/joke/Any?blacklistFlags=nsfw,religious,political,racist,sexist&type=single' + fetch(API_URL) + .then(res => res.json()) + .then(data => { + console.log(data) + joke.innerText = data.joke + }) + +} diff --git a/style.css b/style.css new file mode 100644 index 0000000..7ffb887 --- /dev/null +++ b/style.css @@ -0,0 +1,53 @@ +/* box shadow citation https://developer.mozilla.org/en-US/docs/Web/CSS/box-shadow */ +/* https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_transitions/Using_CSS_transitions */ + + +* { + box-sizing: border-box; + padding: 0; + margin: 0; +} + +body { + height: 100vh; + display: flex; + justify-content: center; + align-items: center; + background: #abc5ec; + font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; +} + +main { + background: #fff; + padding: 2rem; + border-radius: 10px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); + display: flex; + flex-direction: column; + align-items: center; + gap: 20px; + max-width: 500px; + width: 90%; + text-align: center; +} + +h2 { + min-height: 2em; + font-size: 1.3rem; + color: #333; +} + +button { + padding: 10px 20px; + font-size: 1rem; + background: #4caf50; + color: #fff; + border: none; + border-radius: 5px; + cursor: pointer; + transition: background 0.2s ease; +} + +button:hover { + background: #45a049; +}