Skip to main content

<SubComponets/>

We created some subcomponents to make the creation of custom product tiles as easy as possible!

  • Badge: A component that represent the text based badge
  • Badges: A component that represent a list of text based badges
  • ProductCard: A component that wraps the product subcomponents and provides the product tile base structure
  • ProductImage: A component that represent the product image element
  • ProductInfo: A wrapper for the product info
  • ProductPrice: A component that represent the product price element
  • ProductTitle: A component that represent the product Title element
  • Rating: A component that represent the product rating using stars
  • ProductDescription: A component that represents the product description

Example

MyProduct.jsx
import {
ProductCard, ProductImage, Badges,ProductInfo,
ProductTitle,ProductPrice,Swatches, Rating, ProductDescription
} from "fast-component-library/FastProduct";

import {ReportType,useFastState,AddToCart, swatchType} from "fast-component-library";

import {FastSimonSDK} from "fast-simon-sdk";

const MyProduct = ({product}) => {
const {query} = useFastState();

const getBadges = () => {
let badges = [];

if(product.p_c){
badges.push( {
className:"sale", title:"On Sale", textColor:"white", bgColor:"red"
});
}

if(product.vra && product.vra.length > 0 ){
badges.push( {
className:"more", title:"Options Available", textColor:"white", bgColor:"blue"
});
}

return badges;
}

const clickHandler = () => {
FastSimonSDK.event({
eventName: ReportType.Search,
data: {
query,
productID: id,
position: index ? index + 1 : undefined,
imageID,
}
});
}

const addToCartClicked = () => {
// add to cart here
}

return (
<ProductCard className={"product-card"} data-id={product.id}>
<ProductImage alt={product.l} src={product.t1 || product.t2} url={product.u} redirectType={"single-page"} onClick={clickHandler} className={"product-image"}
wrapperClass={"product-image-wrapper"}>
<Badges badges={getBadges()}/>
</ProductImage>
<ProductInfo className={"product-info"}>
<ProductTitle label={product.l} url={product.u} redirectType={"single-page"} onClick={clickHandler} className={"product-title"}
wrapperClass={"product-title-wrapper"}/>
<ProductDescription description={product.d} className={"product-description-wrapper"}/>
<ProductPrice price={product.p} comparePrice={product.p_c} currency={product.c}
customClasses={{price: "product-price", compare: "product-compare-price", wrapper: "product-price-wrapper"}}/>
<Swatches variants={product.vra} type={swatchType.Image} selectedVariantID={product.vra && product.vra.length > 0 && product.vra[0][0]}
customClasses={{
swatch: "product-single-swatch",
wrapper: "product-swatches-wrapper",
more: "product-more-swatches"
}}/>
<Rating score={product.review_score} id={product.id} reviewCount={product.review_count}
customClasses={{
count: "product-review-count",
wrapper: "product-review-wrapper",
star: "product-review-start"
}}/>
</ProductInfo>
<AddToCart onAdd={addToCartClicked} className={"add to cart"} status={""}/>
</ProductCard>
)
}

export default MyProduct;
index.jsx
import {Results, ProductGrid,FastSimonApi,SearchBox} from "fast-simon-react-component-libray";
import React from "react";
import MyProduct from "../components"

export const App = () => {
return (
<FastSimonApi storeID={1} uuid={"rand-omuu-id12-3456"}>
<header>
Search: <SearchBox/>
</header>

<Results>
<ProductGrid renderProduct={product => <MyProduct product={product} key={product.id}/>}/>
</Results>
</FastSimonApi>
)
}

Props

Badge

OptionTypeDescription
titlestring (required)Badge title
bgColorstring (required)Badge background color
textColorstring (required)Badge text color
boldboolean (default=true)Apply cold text to badge
classNamestringCustom class for the badge

Badges

OptionTypeDescription
badgesBadgesPropsA list of badges
classNamestringBadge wrapper custom class

ProductCard

OptionTypeDescription
All div base propsAll div base propsAll div base props

ProductImage

OptionTypeDescription
All img base propsAll img base propsAll img base props
srcstring (required)Image url
altstring (required)Image title
fallbackImagestringIn case the img fails to load
wrapperClassstringImage wrapper class
redirectTypeRedirectTypesingle-page - will use
to url, multi page will redirect to url directly

ProductInfo

OptionTypeDescription
All div base propsAll div base propsAll div base props

ProductPrice

OptionTypeDescription
pricestring (required)Product Price
comparePricestringProduct Compare at Price
currencyCurrency (default="USD")Product currency
customClassesPriceCustomClassesCustom Classes for the elements

ProductTitle

OptionTypeDescription
labelstring (required)Product title
highlightQueryboolean (default=true)Highlight the query inside the product
redirectTypeRedirectTypesingle-page - will use
to url, multi page will redirect to url directly
urlstring (required)Product URL
wrapperClassstringProduct title wrapper class

Rating

OptionTypeDescription
scorenumber (required)Product rating score
maxScorenumber (default=100)Product max score (usually 100)
idstring (required)Product id is used for the SVG to fill the stars
titlestring (default=#ffb400)title top show on hover
colorstring (required)color of the starts
reviewCountnumberProduct title wrapper class
customClassesRatingCustomClassesCustom Classes for the elements

ProductDescription

OptionTypeDescription
descriptionstring (required)Product description
highlightQueryboolean (default=true)Highlight the query inside the product
all div propsall div propsall div props

Types

interface PriceCustomClasses {
wrapper?: string
price?: string
compare?: string
}

interface RatingCustomClasses {
wrapper?: string
star?: string
count?: string
}