Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/******************************************
/* CSS
/*******************************************/

/* Box Model Hack */
*{
box-sizing: border-box;
}

/******************************************
/* LAYOUT
/*******************************************/
img{
display: block;
margin: 0 auto;
}


/******************************************
/* ADDITIONAL STYLES
/*******************************************/
html {
box-sizing: border-box;
}

*,
*::before,
*::after {
box-sizing: inherit;
margin: 0;
padding: 0;
}

body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
background-color: lightcyan;
}

.app {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 600px;
background-color: white;
border-radius: 5px;
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, .14), 0 3px 1px -2px rgba(0, 0, 0, .2), 0 1px 5px 0 rgba(0, 0, 0, .12);
}

header {
width: 100%;
font-size: 30px;
text-align: center;
padding: 10px;
border-bottom: 1px solid #ebebeb;
}

.quotes {
padding: 20px 50px;
min-height: 200px;
}

.quote-text {
padding-bottom: 20px;
font-size: 25px;
color: black;
}

.controls {
width: 100%;
padding: 20px 50px;
}

.button {
display: block;
color: black;
border-radius: 4px;
border: none;
padding: 10px 20px;
margin: 20px;
cursor: pointer;
text-align: center;
width: 100%;
font-size: 20px;
}

input {
border: 2px solid #eee
padding: 20px;
margin: 10px 0;
border-radius:2px;
justify-content: center
}


@media screen and (max-width: 600px) {
.app {
width: 100%;
}

.quote-text {
font-size: 18px;
}
}
40 changes: 40 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="Gives a random or personalized trump quote.">
<meta name="keywords" content="one, two, three">

<title>Trump Quotes</title>

<!-- external CSS link -->
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class='app'>
<header>
Donald Trump Quotes
</header>
<section class = 'controls'>
<button type="button" id="js-new-quote" class="new-quote button">
Generate a random quote
</button>

<input type="text" placeholder="Name">

<button type="button" id="js-personal-quote" class="personal-quote button">
Generate a personalized quote
</button>
</section>

<h2 id="quote-text" class="quotes"></h2>
</div>





<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
37 changes: 37 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Selects the js-new-quote class to generate a new quote

const newQuoteButton = document.querySelector('#js-new-quote')
const personalQuoteButton = document.querySelector('#js-personal-quote')

newQuoteButton.addEventListener('click', getQuote);
personalQuoteButton.addEventListener('click', getPersonal);

function getQuote() {
const url = 'https://api.whatdoestrumpthink.com/api/v1/quotes/random'

fetch(url)
.then(res => res.json()) // parse response as JSON
.then(data => {
console.log(data)
document.querySelector('h2').innerText = data.message
})
.catch(err => {
console.log(`error ${err}`)
});

}

function getPersonal() {
const choice = document.querySelector('input').value
const url = 'https://api.whatdoestrumpthink.com/api/v1/quotes/personalized?q=' + choice

fetch(url)
.then(res => res.json()) // parse response as JSON
.then(data => {
console.log(data);
document.querySelector('h2').innerText = data.message
})
.catch(err => {
console.log(`error ${err}`)
});
}