<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script src="https://kit.fontawesome.com/93f9f9ade9.js" crossorigin="anonymous"></script>
    <link rel="stylesheet" href="style.css">
    <title>Random Quote Generator</title>
</head>
<body id="quote-box">
    <div class="container row mx-auto justify-content-center h-100 align-content-center">
        <div id="quote-area">
            <div id="text" class="d-flex h-100 w-100 justify-content-center align-items-center text-center p-5"></div>
            <div id="author-box" class="py-3 px-4">
                <p id="author" class="m-0">John Kennedy</p>
            </div>
            <div class="quote-tri" id="tri-1"></div>
            <div class="quote-tri" id="tri-2"></div>
        </div>
    </div>
    <div class="d-flex align-items-center justify-content-between" id="btn-group">
        <button class="btn btn-lg" id="new-quote">New Quote</button>
        <a href="twitter.com/intent/tweet" id="tweet-quote"><i class="fab fa-twitter-square fa-2x" ></i></a>
    </div>
    
    <script
  src="https://code.jquery.com/jquery-3.4.1.js"
  integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU="
  crossorigin="anonymous"></script>
    <script src="app.js"></script>
</body>
</html>
@import url('https://fonts.googleapis.com/css?family=Libre+Baskerville|Quicksand&display=swap');

:root {
   --main-color : #ADD8E6;
   --secondary-color: #ffc0cb; 
   --btn-color: #cff0cc;
   --tweet-color: #fed8b1;    
}

i, i:hover {
    color: black;
}

html, body {
    height: 100%; 
    width: 100%;
    font-size: 16px; 
}

body {
    font-family: 'Quicksand', 'sans-serif';
}
/* quote styings */
#quote-area {
    position: relative; 
    border-radius: 10px;
    background-color: var(--main-color); 
    margin-bottom: 6rem; 
    height: 352px;
    width: 590px;
    
}

.quote-tri {
    position: absolute; 
    width: 0;
    height: 0; 
    border: 40px solid; 
    border-color: var(--main-color)  var(--main-color)   transparent transparent; 
    right: 100px; 
    bottom: -13%;
    z-index: 1; 
    display: inline-block; 
}

#tri-2 { 
    right: 410px; 
    opacity: 0; 
    border-color: var(--main-color) transparent transparent var(--main-color)
}
#text {
    line-height: 2.5rem !important;
    font-style: italic; 
    font-size: 1.5rem; 
}

/* author stylings  */
#author-box {
    position: absolute;
    background-color: var(--secondary-color);
    border-radius: 10px;
    width: auto !important; 
    white-space: nowrap; 
    bottom : -110px;
    right : 38px;
    z-index : -1; 
}

/* btn stylings */
.btn {
    background-color: var(--btn-color);
    margin-right: 2rem !important;
    font-size: 1.3rem; 
    font-weight: lighter; 
    text-transform: uppercase;
}

#btn-group {
    position: absolute; 
    top: 550px; 
    left: 60px; 
    margin-bottom: 15px; 
}

/* twitter quote */
#btn-group.special:before {
    content: 'Tweet Quote!'; 
    position: absolute; 
    right: -70px; 
    top: -40px; 
    background-color: var(--tweet-color); 
    padding: .5rem; 
    font-size: .75rem; 
    border-radius: 10px;
    
}

#btn-group.special:after {
    content: ''; 
    width: 0; 
    height: 0; 
    border: 5px solid; 
    border-color: var(--tweet-color) transparent transparent var(--tweet-color);
    position: absolute;
    right: -18px; 
    top: -7px; 
     
}

// Make object with all the quotes 

const quotes = [
    {
        quote : "I have no special talent. I am only passionately curious.",
        author : "Albert Einstein"
    },
    {
        quote : "Doubt can motivate you, so don’t be afraid of it. Confidence and doubt are at two ends of the scale, and you need both. They balance each other out.",
        author : "Barbra Steisand"
    },
    {
        quote : "Be thankful for what you have; you’ll end up having more. If you concentrate on what you don’t have, you will never, ever have enough.",
        author : "Oprah Winfrey"
    },
    {
        quote : "To be successful you have to be selfish, or else you never achieve. And once you get to your highest level, then you have to be unselfish. Stay reachable. Stay in touch. Don’t isolate.",
        author : "Michael Jordan"
    },
    {
        quote : "Ceaseless work, analysis, reflection, writing much, endless self-correction, that is my secret.",
        author : "Johann Sebastian Bach"
    },
    {
        quote : "Vulnerability is the essence of romance. It’s the art of being uncalculated, the willingness to look foolish, the courage to say, ‘This is me, and I’m interested in you enough to show you my flaws with the hope that you may embrace me for all that I am but, more important, all that I am not.",
        author : "Ashton Kutcher"
    },
    {
        quote : "Dost thou love life? Then do not squander time, for that is the stuff life is made of.",
        author : "Benjamin Franklin"
    },
    {
        quote : "Curious that we spend more time congratulating people who have succeeded than encouraging people who have not.",
        author : "Neil DeGrasse Tyson"
    },
    {
        quote : "Wisely, and slow. They stumble that run fast.",
        author : "William Shakespeare"
    },
    {
        quote : "If you judge people, you have no time to love them.",
        author : "Mother Theresa"
    },
    {
        quote : "Imperfection is beauty, madness is genius and it’s better to be absolutely ridiculous than absolutely boring.",
        author : "Marilyn Monroe"
    },
    {
        quote : "The future belongs to those who believe in the beauty of their dreams.",
        author : "Eleanor Roosevelt"
    },
    {
        quote : "The future belongs to those who prepare for it today.",
        author : "Malcolm X"
    },
    {
        quote : "The successful warrior is the average man, with laser-like focus. ",
        author : "Bruce Lee"
    },
    {
        quote : "No matter who you are or what you look like, how you started off, or how and who you love, America is a place where you can write your own destiny.",
        author : "Barack Obama"
    },
    {
        quote : "I don’t think of all the misery but of the beauty that still remains. ",
        author : "Anne Frank"
    },
    {
        quote : "You have power over your mind – not outside events. Realize this, and you will find strength. ",
        author : "Marcus Aurelius"
    },
    {
        quote : "By failing to prepare, you are preparing to fail.",
        author : "Benjamin Franklin"
    },
    {
        quote : "Ask not what your country can do for you, but what you can do for your country.",
        author : "John F. Kennedy"
    },
    {
        quote : "Good artists copy, great artists steal.",
        author : "Pablo Picasso"
    },
    {
        quote : "Ask not what your country can do for you, but what you can do for your country.",
        author : "John F. Kennedy"
    },
    {
        quote : "For beautiful eyes, look for the good in others; for beautiful lips, speak only words of kindness; and for poise, walk with the knowledge that you are never alone.",
        author : "Audrey Hepburn"
    },
    {
        quote : "Everybody wants to be famous, but nobody wants to do the work. I live by that. You grind hard so you can play hard. At the end of the day, you put all the work in, and eventually it’ll pay off. It could be in a year, it could be in 30 years. Eventually, your hard work will pay off.",
        author : "Kevin Hart"
    },
    {
        quote : "Impossible is just a big word thrown around by small men who find it easier to live in the world they’ve been given than to explore the power they have to change it. Impossible is not a fact. It’s an opinion. Impossible is not a declaration. It’s a dare. Impossible is potential. Impossible is temporary. Impossible is nothing. ",
        author : "Muhammad Ali"
    },
    {
        quote : "I have learned over the years that when one’s mind is made up, this diminishes fear; knowing what must be done does away with fear.",
        author : "Rosa Parks"
    }
];

// get quote

function getNewQuote(){
    $('#text, #author').animate({
        opacity : 0
    }, 500, function() {
        displayNewQuote(); 
        $(this).animate({
            opacity : 1
        }, 500)
    })
}

// add quote to UI
function displayNewQuote() {
    const qIndex = Math.floor(Math.random() * quotes.length); 
    const newQuote = quotes[qIndex].quote; 
    const newAuthor = quotes[qIndex].author; 
    $('#text').text(newQuote); 
    $('#author').text(newAuthor)
}

// quote box animation 
var i = 1, left, right, top, bottom;
function quoteAnimation() { 
    switch (i) {
        case 1: 
            // speech bubble animation
            $("#tri-1").animate({
                opacity : 0
            }, 500, function(){
                $("#tri-2").animate({
                    opacity : 1
                }, 500)
            });
            //author box animation
            $("#author-box").animate({
                right: '397px', 
                bottom: '-110px',
            });
            i++; 
            break;
           
        case 2:
            // speech bubble animation
            $("#tri-2").animate({
                opacity : 0
            }, 500, function(){
                $("#tri-1").animate({
                    opacity : 1
                }, 500)
            });
            //author box animation
            $("#author-box").animate({
                right: '38px', 
                bottom: '-110px',
            
            });
            i--;    
    }
}


// event -- click
$(document).ready(function(){
    displayNewQuote(); 
    $('#new-quote').click(function() {
        quoteAnimation(); 
        getNewQuote(); 
    }); 
    //event -- mouse over tweet quote
    $('#tweet-quote').hover(function(){
        $('#btn-group').toggleClass('special'); 
        $(this).animate({
            'marginBottom' : '+=10px',
        }, 'fast', function(){
            $(this).animate({
                'marginBottom' : '-=10px'
            }, 'fast')
        })
    }, function(){
        $('#btn-group').toggleClass('special');
    }); 
    
}
)

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js