GithubHelp home page GithubHelp logo

react-products-gallery's Introduction

react-products-gallery

This library allows developers to easily integrate online shopping component into their React applications. It uses Rollup as a bundler and Material-UI for rendering major parts of its UI.

See this component in action.

Installation

npm install react-products-gallery

Usage

import ProductsGallery from 'react-products-gallery'

const products = [
  {
    id: 1,
    name: 'Antarctic Star Space Heater',
    currency: '$',
    price: 16.7,
    image: 'https://m.media-amazon.com/images/I/random-product-image-167.jpg',
    specs: [
      { property: 'Color', value: 'Black' },
      { property: 'Power Source', value: 'Corded Electric' },
      //...
    ],
    description: 'Lorem ipsum dolor sit amet',
  },
  //...
];

// ...
render() {
  return(
    <ProductsGallery
      products={products}
      callbacks={{ onAddToCart: (product) => {} }}
      options={{ mobileWidth: 600 }}
    />
  )
}

Component Props

Name Type Description
products array Check out the payload example from above. image, specs, and description are optional
options object Check out the list of available options from the table below
callbacks object Check out the list of available callbacks from the table below

Options

Name Type Default Description
wrapperStyles object {} Inline style object for the top-level wrapper element
autoSelectProduct boolean true If true, the first product will be selected by default upon data load and search.
searchInputAutoFocus boolean false If true, search field will be focused by default upon initialization of the component.
searchInputPlaceholder string "Find the product of your dreams" Placeholder text for the search field.
mobileWidth number 768 The boundary width of the component (in pixels) where it turns into mobile-friendly UI.
debounceDelay number 350 The debounce delay for the search result (in milliseconds) to become effective.

Callbacks

Name Type Parameters Description
onSelectProduct function (product: object) Fired when a product is selected from the left-hand list
onUpdateSearch function (keyword: string) Fired when the search keyword is changed. (Debounced)
onClearSearch function None Fired when the clear button of search field is clicked.
onAddToCart function (product: object) Fired when the cart button of the product detail section is clicked.

react-products-gallery's People

Contributors

nicky-song avatar

Watchers

Eran Sandler avatar  avatar

Forkers

laymans-ltd

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.