GithubHelp home page GithubHelp logo

random-quote-machine's Introduction

Random-Quote-Machine toy project from FreeCodeCamp


Preview

image

image

Project goal

  • Build an app with frontend framework ( react ).
  • Understand React framework.
  • Understand and review HTML, CSS.

Tech Stack

  • HTML
  • JavaScript
  • CSS

Advanced Feature

  • React Hook( useState, useEffect )
  • animate CSS using document.getElementByID().animate( ) function
    const getRandomQuote = () =>{
        setRandomQuote( ()=>{ 
            return quotes[Math.floor(Math.random()*quotes.length)];
        });
        document.getElementById("text").animate([{opacity:0},{opacity:1}],{duration:1000,easing:"ease-in"});
        document.getElementById("author").animate([{opacity:0},{opacity:1}],{duration:1000,easing:"ease-in"});
    }
  • Using CSS variable --designated-color
/* src/App.css */ 
:root{
  --designated-color : #fff;
}

.App {
  text-align: center;
  display:flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width:100vw;
  height:100vh;
  background-color: var(--designated-color);
  transition: background-color 1s ease-in-out;
}
/* src/components/Quote.module.css */
.quoteText, .quoteAuthor{
    color : var(--designated-color);
}
  • Change style property using document.document.style.setProperty('--desingated-color',randomColor);
// src/components/QuoteBox.js
    const [randomColor, setRandomColor] = useState(colors[Math.floor(Math.random()*colors.length)]);

    useEffect(()=>{
        getRandomColor();
    },[]);
    const getRandomColor = ()=>{
        setRandomColor( ()=>{
            return colors[Math.floor(Math.random()*colors.length)];
        });
        console.log('getRandomColor',randomColor);
        document.documentElement.style.setProperty('--designated-color',randomColor);
    }

Improvements

  • Using redux

Module

├── @fortawesome/[email protected]

├── @fortawesome/[email protected]

├── @fortawesome/[email protected]

├── @fortawesome/[email protected]

├── @reduxjs/[email protected]

├── @testing-library/[email protected]

├── @testing-library/[email protected]

├── @testing-library/[email protected]

├── [email protected]

├── [email protected]

├── [email protected]

├── [email protected]

├── [email protected]

├── [email protected]

├── [email protected]

└── [email protected]

random-quote-machine's People

Contributors

seonmo-kang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.