0.25.1 • Published 15 days ago

@bolttech/molecules-product-card v0.25.1

Weekly downloads
-
License
-
Repository
-
Last release
15 days ago

Product Card Component

The ProductCard component is a versatile React component designed to display product information, coverages, add-ons, and buttons for actions.

Installation

To use the ProductCard component, you need to install the required dependencies:

npm install @bolttech/molecules-product-card

or

yarn add @bolttech/molecules-product-card

Usage

You can utilize the ProductCard component by importing it and including it in your JSX. Here's an example:

import React from 'react';
import {ProductCard} from '@bolttech/molecules-product-card';
import {bolttechTheme, BolttechThemeProvider} from "@bolttech/frontend-foundations"; // Adjust the path to your component

function App() {
  // Sample data
  const productInfo = {
    productName: 'Product Name',
    productDescription: 'Product Description',
    productValue: '100.00',
    productCurrencyValue: '$',
    productDuration: '1 year',
    compareLabel: 'Compare',
    compareAction: () => console.log('Compare button clicked'),
    productImg: 'image-url.png',
  };

  const coverages = [
    {name: 'Coverage 1', value: 'Value 1'},
    {name: 'Coverage 2', value: 'Value 2'},
  ];

  const addOns = {
    additionalValue: '20.00',
    additionalValueCurrency: '$',
    checkboxLabel: 'Optional',
    checkboxId: 'optional-checkbox',
    specialDetails: [
      {label: 'Special Detail 1', icon: 'icon_name_1'},
      {label: 'Special Detail 2', icon: 'icon_name_2'},
    ],
  };

  const [isOpen, setIsOpen] = useState(false);

  const buttons = {
    showMoreButtonLabel: 'Show More',
    hideProductDetailsLabel: 'Hide Details',
    buyButtonLabel: 'Buy Now',
    buyButtonAction: () => console.log('Buy button clicked'),
    showMoreAction: (isOpenParam: boolean) => setIsOpen(isOpenParam),
  };

  const productDetails = {
    coveragesContainer: [
      {
        titleContainer: 'Coverage Details',
        coverages: [
          {name: 'Coverage 1', value: 'Value 1'},
          {name: 'Coverage 2', value: 'Value 2'},
        ],
      },
    ],
  };

  return (
    <BolttechThemeProvider theme={bolttechTheme}>
      {/* Product Card component */}
      <ProductCard
        productInfo={productInfo}
        coverages={coverages}
        addOns={addOns}
        buttons={buttons}
        productDetails={productDetails}
        dataTestId="product-card"
      >
      <div>Dynamic Content (Top)</div>
      <div>Dynamic Content (Bottom)</div>
      <div>...rest</div>
      </ProductCard>
    </BolttechThemeProvider>
  );
}

export default App;

Props

The ProductCard component accepts the following props:

PropTypeDescription
productInfoobjectObject containing information about the product.
coveragesarrayArray of coverages to display.
addOnsobjectObject containing information about add-ons.
buttonsobjectObject containing information about action buttons.
productDetailsobjectObject containing detailed information about the product.
dataTestIdstringThe data-testid attribute for testing purposes.
isOpenbooleanBoolean prop that controls if plan card is open or not.
childrenReact.ReactNode | React.ReactNode[]Content that will appear in details area,

the first item will be above of coveragesContainer and the rest will be bellow.

The productInfo object should have the following properties:

  • productName: The name of the product.
  • productDescription: Description of the product (optional).
  • productValue: The product's value.
  • productCurrencyValue: Currency symbol for the product value.
  • productDuration: Duration of the product (optional).
  • compareLabel: Text for the compare button (optional).
  • compareAction: Callback function for the compare button (optional).
  • productImg: URL or React component for the product image (optional).

The coverages array should contain objects with name and value properties.

The addOns object should have the following properties:

  • additionalValue: Additional value for add-ons.
  • additionalValueCurrency: Currency symbol for the additional value.
  • checkboxLabel: Label for the optional checkbox.
  • checkboxId: ID for the optional checkbox.
  • specialDetails: Array of special details for add-ons.

The buttons object should have the following properties:

  • showMoreButtonLabel: Label for the "Show More" button.
  • hideProductDetailsLabel: Label for the "Hide Details" button.
  • buyButtonLabel: Label for the "Buy Now" button.
  • buyButtonAction: Callback function for the "Buy Now" button.
  • showMoreAction: The callback function for control if details section is open or not.

The productDetails object should have the following properties:

  • coveragesContainer: Array of objects with title and coverages.

Functionality

The ProductCard component provides the following functionality:

  • Display: Renders product information, coverages, add-ons, and buttons.
  • Price Calculation: Calculates the current product price based on selected options.
  • Toggling: Toggles product details and compare state.
  • Action Buttons: Triggers actions for compare and buy buttons.

Contribution

Contributions to the ProductCard component are welcomed. If you encounter issues or have suggestions for improvements, feel free to open an issue or submit a pull request on the component's Bitbucket repository.

0.25.1

15 days ago

0.25.0

1 month ago

0.24.4

2 months ago

0.0.1

3 months ago

0.24.3

3 months ago

0.24.2

4 months ago

0.24.1

4 months ago

0.24.0

6 months ago

0.24.0-0

6 months ago

0.23.0

6 months ago

0.22.1

6 months ago

0.22.0

6 months ago

0.21.3

7 months ago

0.20.1

8 months ago

0.20.0

8 months ago

0.19.0

8 months ago

0.18.0

9 months ago

0.17.0

9 months ago

0.16.0

9 months ago

0.14.0

9 months ago

0.13.1

10 months ago

0.13.0

10 months ago

0.12.0

10 months ago

0.11.0

10 months ago

0.10.0

10 months ago

0.9.0

10 months ago

0.6.0

10 months ago

0.5.0

10 months ago

0.4.0

10 months ago

0.3.0

10 months ago

0.2.0

10 months ago

0.1.5

10 months ago

0.1.4

10 months ago

0.1.3

10 months ago

0.1.2

10 months ago

0.1.1

10 months ago

0.1.0

10 months ago