Skip to content

NathanielDaniels/capstone-project-react

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

//===================================================================

Added localStorage for Favorites and Cart Items.

//===================================================================

Challenge

  1. Only render the "Place Order" button if there are items in the cart

  2. Change the trash icon to a filled-in trash icon when hovering over it

Filled trash icon to use when hovering:

Empty trash icon to use when NOT hovering:

//===================================================================

Place Order Challenge

Let our user place their order!

Clicking the "Place Order" button should:

  1. Change the text to "Ordering..."
  2. Timeout for 3 seconds (to simulate an order being placed)
  3. Log "Order placed!" to the console
  4. Empty out the cart

//===================================================================

Challenge

Calculate the total cost of the items in the cart and display it on the Cart page

  1. Usually the item in the database will have it's own cost saved, but we're assuming every item we sell costs $5.99, so you can just hard code that cost in
  2. To very easily display the total cost in US dollars (or whatever currency you want), use the following:

<number>.toLocaleString("en-US", {style: "currency", currency: "USD"})

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString

//===================================================================

Cart Icon Challenge

Change the cart icon in the header to display the full cart icon if there are any items in the cart

Full class name to use WHEN ITEMS IN CART: "ri-shopping-cart-fill ri-fw ri-2x"

Full class name to use WHEN CART IS EMPTY: "ri-shopping-cart-line ri-fw ri-2x"

//===================================================================

Change Cart Icon Challenge

Change the plus icon to a full shopping cart icon when an image is already in the cart. This should display whether the image is being hovered or not (like the favorite icon).

Icon to use when item already in cart:

Hints: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some https://stackoverflow.com/a/8217584

//===================================================================

CartItem Context Challenge

Setup context to manage items in an array called cartItems. This will be an array of image objects.

  1. Add the cartItems state to context. (Array)
  2. Add function to add an image to the cart. (Takes the full image object as parameter)
  3. Make it so clicking the plus icon on the image adds the item to the cart. (Console.log the cart items array to see that it's working)

//===================================================================

PropTypes Challenge

Add propTypes to the Image component

  1. className should be a string
  2. img should be an object, specifically an object with id, url, and isFavorite properties a. Hint: Specifying the properties of an object is called and object's "shape"

https://reactjs.org/docs/typechecking-with-proptypes.html#proptypes

//===================================================================

Display Favorites Challenge

Make the image display the filled heart icon when it's already favorited

Logic to follow:

  • If the image is favorited, display the filled heart icon always
  • Otherwise, if the image being hovered on, display the heart outline instead
  • If it isn't favorited OR hovered on, don't display anything

Remember to make it so clicking the filled heart icon ALSO runs the toggleFavorite function!

Filled heart icon:

//===================================================================

Getting Started with Create React App

This project was bootstrapped with Create React App.

Available Scripts

In the project directory, you can run:

npm start

Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.

The page will reload if you make edits.
You will also see any lint errors in the console.

npm test

Launches the test runner in the interactive watch mode.
See the section about running tests for more information.

npm run build

Builds the app for production to the build folder.
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.
Your app is ready to be deployed!

See the section about deployment for more information.

npm run eject

Note: this is a one-way operation. Once you eject, you can’t go back!

If you aren’t satisfied with the build tool and configuration choices, you can eject at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use eject. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

Learn More

You can learn more in the Create React App documentation.

To learn React, check out the React documentation.

Code Splitting

This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting

Analyzing the Bundle Size

This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size

Making a Progressive Web App

This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app

Advanced Configuration

This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration

Deployment

This section has moved here: https://facebook.github.io/create-react-app/docs/deployment

npm run build fails to minify

This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published