1.0.5 • Published 2 years ago

react-products-gallery v1.0.5

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

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

NameTypeDescription
productsarrayCheck out the payload example from above. image, specs, and description are optional
optionsobjectCheck out the list of available options from the table below
callbacksobjectCheck out the list of available callbacks from the table below

Options

NameTypeDefaultDescription
wrapperStylesobject{}Inline style object for the top-level wrapper element
autoSelectProductbooleantrueIf true, the first product will be selected by default upon data load and search.
searchInputAutoFocusbooleanfalseIf true, search field will be focused by default upon initialization of the component.
searchInputPlaceholderstring"Find the product of your dreams"Placeholder text for the search field.
mobileWidthnumber768The boundary width of the component (in pixels) where it turns into mobile-friendly UI.
debounceDelaynumber350The debounce delay for the search result (in milliseconds) to become effective.

Callbacks

NameTypeParametersDescription
onSelectProductfunction(product: object)Fired when a product is selected from the left-hand list
onUpdateSearchfunction(keyword: string)Fired when the search keyword is changed. (Debounced)
onClearSearchfunctionNoneFired when the clear button of search field is clicked.
onAddToCartfunction(product: object)Fired when the cart button of the product detail section is clicked.
1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago