Giter Club home page Giter Club logo

advanced-ecommerce-2's Introduction

Intro

Let's practice compoment communication by adding a little complexity to a simple ecommerce site. Intead of just looking at all products, we now want to look at products that are in a certain category. The user needs to be able to click on a button in one component that then changes what happens in another component. This application is based on an existing website that does not use React. If you worked for this company, they might ask you to update their site to use React. https://p.w3layouts.com/demos/spareparts/web/index.html

Setup

Fork, Clone, npm install, npm start

Do

  • Take the html out of the App component and put in separate components

    • Header

      • look for div with a className of "top-header" (in App.js)
      • take that content and place it in the Header component
    • Footer _ look for div with a className of "footer" (in App.js) _ take that content and place it in the Footer component _ ...the component may not exist yet )()()()()()()()()()()(_)

    • ImageSlider

      • look for div with className of "image-slider" (in App.js)
      • take that content and place it in the ImageSlider component )()()()()()()()()()()()()(* )
    • ProductDetail

      • look for div with className of "grid_1_of_5" (in App.js)
      • take that content and place it in the ProductDetail component
      • Use PropTypes to require a prop "product"
      • Use product prop to populate the UI instead of hard coded

      // map by id from state.js

  • SubHeader

    • look for div with className of "sub-header" (in App.js)
    • take that content and place it in the SubHeader component
  • TopNav

    • look for div with className of "top-nav" (in App.js)
    • take that content and place it in the TopNav component
  • Make sure to import and use all these components back in App

  • Create a variable in index.js called currentCategory and set it to "tires"

  • Create a function in index.js called changeCategory thats takes a parameter category. It will assign category to currentCategory and call render()

  • Send the changeCategory function to App and then to the TopNav component by way of props

  • Send the currentCategory to App by way of props

  • App should use the currentCategory value to filter the array of products by category and then map over them to create ProductDetail components

  • Modify TopNav

    • Remove existing href and replace with "#"
    • Register onClick for the links, make sure to use arrow function. Make sure to preventDefault.
    • In the arrow function call props.changeCategory("tires"). Send in the category that is appropriate for the link

advanced-ecommerce-2's People

Contributors

jw56578 avatar konarie1990 avatar matt-viteri-volusion 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.