1.0.1 • Published 5 months ago

@35up/recommendations-slider v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

35up Recommendations Slider

Web-component for 35up Recommendations Slider.

Usage: 1. Install the package:

npm i -S @35up/recommendations-slider
  1. Put in your page
import '@35up/recommendations-slider';

function handleAddToCartClick(e: CustomEvent): void {
  const product = e.detail;
  // Add product to your shopping cart
}

function handleProductClick(e: CustomEvent): void {
  const product = e.detail;
  // For example, show a dialog with details
}

const baseProduct = {
  title: 'Apple iPhone 12 Pro - Pacific blue',
};

const slider = document.createElement('tfup-recommendations-slider');

// Set properties
slider.seller = "your-seller-id";
slider.baseProduct = baseProduct;

// Subscribe to events from slider
slider.addEventListener('recommendation-click', handleProductClick);
slider.addEventListener('add-to-cart', handleAddToCartClick);

// Insert the slider in your page
document.getElementById('place-for-slider').appendChild(slider);

Note: this is vanilla js example, for your framework or ui library use corresponding syntax. If you use react, consider our React wrapper