GithubHelp home page GithubHelp logo

rebecca-shoptaw / ask-oscar-wilde Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10.64 MB

Magic 8 ball style site where Oscar Wilde quotes appear in response to user predicaments. ๐Ÿฆโ€โฌ›๐Ÿฅ‚

Home Page: https://rebeccashoptaw.dev/ask-oscar-wilde/

License: MIT License

HTML 13.76% TypeScript 51.11% SCSS 35.14%

ask-oscar-wilde's Introduction

Ask Oscar Wilde ๐Ÿฆโ€โฌ›๐Ÿฅ‚

A Magic 8 ball style site where Oscar Wilde quotes appear in response to user predicaments.

Live Site

Ask Oscar interface

Background & Mission

The idea behind Ask Oscar Wilde was twofold: first, to bring back some of the fun, simple, carefree energy of the minigames of the early internet -- something I'm trying to do in a number of my projects -- and second, to bring the delightful work of Oscar Wilde to new audiences in a fun and surprising manner.

Built With

React Vite Typescript HTML CSS SASS GSAP

UI Walkthrough

The current version of the UI is very straightforward -- the user sees an empty autofocused input box where they are encouraged to enter a predicament, and when they click "Submit", a random Oscar Wilde quote is generated as a response.

Oscar Wilde UI Part 1

Oscar Wilde UI Part 2

If the user hits submit again, they will see a fresh quote, but if they try to hit submit without entering a predicament, Oscar will ask "Why won't you tell me what's troubling you??"

If they select "New Predicament", the input will clear, and Oscar will ask what else he can help with.

Implementation

The implementation is quite straightforward as well -- just about everything happens within the AskOscar component, and relies on two simple functions -- newQuote and clearInput -- and two state values, one to store the user input and one to store the current Oscar Wilde quote.

The newQuote function, which fires when the user hits "Submit," checks to determine that there is a user input, then selects a random quote from the oscarQuotes array, stored separately:

const newQuote = () =>
    input == ""
      ? setQuote("Why won't you tell me what ails you??")
      : setQuote(oscarQuotes[Math.floor(Math.random() * oscarQuotes.length)]);

The clearInput function, which fires when the user hits "New Predicament," resets the user input and Oscar quote, and refocuses on the input using a useRef hook:

 const clearInput = () => {
    setInput("");
    setQuote("With what else may I assist you?");
    inputRef.current?.focus();
  };

Next Steps

  • Redo styling using SASS
  • Replace remaining Bootstrap classes with SASS code
  • Use meta and Schema.org tags to improve SEO
  • Reorganize app using custom hooks and sub-components
  • Use GSAP to create a fun quote loading and reveal animation
  • Add a test suite via Jest

License

Distributed under the MIT License. See LICENSE.txt for more information.

Contact

Rebecca Shoptaw - email | linkedin

ask-oscar-wilde's People

Contributors

rebecca-shoptaw 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.