UNPKG

@shopgate/engage

Version:
5 lines 926 B
import React,{memo}from'react';import PropTypes from'prop-types';import noop from'lodash/noop';import{css}from'glamor';import{useWidgetStyles}from"../../../core";import SwatchContent from"./SwatchContent";var WIDGET_ID='@shopgate/engage/product/VariantSwatch';/** * The variant swatch component. * @param {Object} props The component props. * @returns {JSX} */var VariantSwatch=function VariantSwatch(_ref){var swatch=_ref.swatch,onClick=_ref.onClick;if(!swatch){return null;}var styles=useWidgetStyles(WIDGET_ID);var classNames={swatch:styles&&styles.swatch?css(styles.swatch).toString():null,item:styles&&styles.item?css(styles.item).toString():null,itemSelected:styles&&styles.itemSelected?css(styles.itemSelected).toString():null};return React.createElement(SwatchContent,{swatch:swatch,classNames:classNames,onClick:onClick});};VariantSwatch.defaultProps={swatch:null,onClick:noop};export default memo(VariantSwatch);