Skip to content

Nkwor-Jane/randomn-joke-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of contents

Overview

I created a Random Joke generator with ReactJS and a JokeAPI. When the Dice button is clicked, a new random joke is displayed. Time intervals of at least 5 seconds should be given between jokes.

Screenshot

  • Light Mode screenshot1
  • Dark Mode screenshot2

Links

My process

  • Installed React.
  • Added neccessary files and a folder.
  • Wrote necessary code and CSS.
  • I used Axios to fetch data from the JokeApi Documentation.
  • I added an extra feature: Dark/Light Mode feature.

Built with

  • Semantic HTML5 markup
  • CSS custom properties
  • Flexbox
  • Mobile-first workflow
  • React - JS library

What I learned

I learnt how to fetch data with React Hooks and Axios.

Code Snippet:

function App() {
  const [theme, setTheme] = useState("dark")
  const toggleTheme = () =>{
    setTheme((curr) => (
      curr ==="dark" ? "light":"dark"
    ))
  }
  return (
    <ThemeContext.Provider value={{theme, toggleTheme}}>
      <div id={theme}>
      <Generator/>

      {/* switch slider for light/dark mode */}
      <div className="switch-checkbox">
              <span id="mode-text">{theme === "light" ? "Light Mode" : "Dark Mode"}</span>
                <label className="switch">
                    <input type="checkbox" onChange={toggleTheme}/>
                    <span className="slider round"> </span>
                </label>
                </div>
    </div>
    </ThemeContext.Provider>
  );
}

Continued development

I will focus on bulding projects from Frontend Mentor challenges and personal projects for personal development.

Useful resources

Author

Acknowledgments

I would like to thank Frontend Mentor.

About

Used the Joke to create a random advice generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published