Socket
Socket
Sign inDemoInstall

react-catalog-view

Package Overview
Dependencies
242
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-catalog-view

React component to render catalog view for products, services, image gallery or any other E-commerce applications.


Version published
Maintainers
2
Install size
25.4 MB
Created

Readme

Source

logo

Introduction

React component to render catalog view for products, services, image gallery or any other E-commerce applications.

Click here for demo

rcv-demo

Installation:

   npm install react-catalog-view

Features:

  • JSON data array: Accepts formatted JSON data array and renders them as cards in a catalog view.

  • Fully Customizable: Classes can be overridden easily to customize catalog view.

  • Responsive FlexBox: Based on CSS flexbox. Default view is responsive for all screens.

  • Card Sizes: Cards are available in small, medium and large size.

  • Custom Action Buttons: Two action buttons with custom css, button text & custom callbacks on click event.

  • Skeleton Loading: Show custom number of skeleton content cards while loading.

  • Lightweight: No additional dependencies or CSS Framework required.

Preview:

Responsive on small screens

rcv-demo-2

Skeleton loading

rcv-demo-3

With Custom Card Controls

rcv-demo-4

With Custom CSS

rcv-demo-5

E-Commerce Example

rcv-demo-6

Example:

    import React from 'react';
    import Catalog from "react-catalog-view";
    
    function ProductData(props){
      let products = 
       [
         {
            id: 1,
            title: "Canvas",
            description: "High quality canvas shoes.",
            price: "20",
            discounted: "15",
            currency: "$",
            image: "http://domain.com/images/1.jpg",
         },
         {
            id: 2,
            title: "Sport shoes",
            description: "Sporty shoes, durable at affordable ranges.",
            price: "25",
            currency: "$",
            discounted: "15",
            image: "http://domain.com/images/5.jpg",
         },
         {
            id: 3,
            title: "Heels",
            description: "Fashionable trendy heels.",
            currency: "$",
            price: "30",
            image: "http://domain.com/images/6.jpg",
         }
      ];

      const CONTENT_KEYS = 
      {             
         imgKey: "image",
         cardTitleKey: "title",
         cardDescriptionKey: "description",
         priceKey: "price",
         discountedPriceKey: "discounted",
         priceCurrencyKey: "currency",
         discountCurrencyKey: "currency"
      };
	
      return(
        <Catalog
           data = {products}		
           // Array of JSON Objects (required)
           contentKeys={CONTENT_KEYS}  
           // JSON Object defining the keys that will be 
           // used from the data array, keys should match. (required)
           skeleton={0}
           // Any non zero number will override default cards
           // and will show that many skeleton cards.           
           cardSize="sm"
           // Card sizes, sm, md and lg for small, medium  and large
           btnOneText="View"
           // Enter text for action button one 
           // or pass empty string to hide.  
           btnTwoText="Purchase Now"
           // Enter text for action button two 
           // or pass empty string to hide.
           btnOneHandler={(args, event, objectData)=>{
            // 'objectData' returns object data from 'data' prop
            // any arguments passed will be before 'event' 
            // and 'objectData'
           }}
           btnTwoHandler={(args, event, row)=>{
            // 'objectData' returns object data from 'data' prop
            // any arguments passed will be before 'event' 
            // and 'objectData'
           }}
           imageClickHandler={(args, event, row)=>{
            // 'objectData' returns object data from 'data' prop
            // any arguments passed will be before 'event' 
            // and 'objectData'
           }}
           cardControls={ dataObj => {
               return(
                  <div>
                     <input className='my-custom-input' placeholder='custom-input' />
                     <button className='my-custom-button' type='submit'> OK </button> 
                  </div>
               )
            }
            // Pass a function which returns JSX to be rendered inside card
            // This function will have 'dataObj' containing JSON of
            // the item each card represents
        />
      )
  }

Props:

PropTypeDescription
dataArrayArray of JSON objects to be rendered (required)
contentKeysJSONJSON object which matches the keys in 'data' array (required)
{ 
imgKey: "image",
cardTitleKey: "title",
cardDescriptionKey: "description",
priceKey: "price",
discountedPriceKey: "discounted",
priceCurrencyKey: "currency",
discountCurrencyKey: "currency"
}
cardSizeStringCard sizes, sm, md and lg for small, medium and large
skeletonNumberAny non zero number will generate that many skeleton cards, skeleton cards over rides default view
btnOneTextStringEnter text for action button one or pass empty string to hide
btnTwoTextStringEnter text for action button two or pass empty string to hide
btnOneHandlerCallbackCallback function for onClick
btnTwoHandlerCallbackCallback function for onClick
imageClickHandlerCallbackCallback function for image click
cardControlsFunctionRender custom component passed as a function

CSS Classes:

Default CSS classes for easy css customization.

ClassNameDescription
rcv-container-customFor parent container
rcv-object-sm-custom
@media(max-width: 575px)
For container of small cards
rcv-object-md-custom
@media(max-width: 575px)
For container of medium cards
rcv-object-lg-custom
@media(max-width: 575px)
For container of large cards
rcv-catalog-card-customFor customizing card
rcv-product-image-container-customFor product image container
rcv-product-image-container-custom>imgFor product image
rcv-product-text-customFor product text
rcv-product-name-customFor product name
rcv-product-description-customFor product description
rcv-original-price-customFor original price text
rcv-discount-price-customFor discount price text
rcv-btn-one-customFor button one
rcv-btn-two-customFor button two

Support:

For support contact: adnanali17official@gmail.com, daniyal_09.2005@hotmail.com

Keywords

FAQs

Last updated on 19 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc