1.1.1 • Published 2 years ago

react-custom-product v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

react-custom-product

A lightweight React component providing customization for your product image.

Demo https://react-custom-product-demo.vercel.app/

Features

Current components

  • Custom Product Color
  • 3D ShowCase (multiple images are needed)
  • Product Switch
  • Product Cover
  • Product Gallery
  • Hotspot

Under construction

  • Hover product
  • Masked Product
  • Custom Background
  • Auto Gallery

DEFINITIONS

ProductCustomColor - change your products color and have a nice animation.

Be sure you have exact images with just different colors. (different shapes or pxs wont work properly)

import { ProductCustomColor } from 'react-custom-product'

export default function Example() {
  return <ProductCustomColor 
    width="500px" 
    height="150px" 
    src="/img/model-1.png" 
  />
}
PropTypeDefaultDescription
srcStringrequiredImage (after you change the src, will trigger the effect).
cssCSSProperties{}pass styles to the container
widthString100%Be sure you use a fixed px size for this effect
heightString100%Be sure you use a fixed px size for this effect
durationString.6Milliseconds animation will last.

ShowCase - show your product in 3d (works for web and mobile)

be sure you have more than +10 images to have a good transition, images must be the same, but takend from different angles.

import { ShowCase } from 'react-custom-product'

export default function Example() {
    const showCaseImages = [
      '/images/1.png',
      '/images/2.png',
      '/images/3.png',
      '...'
    ]

    return <ShowCase images={showCaseImages} />
}
PropTypeDefaultDescription
imagesString[]requiredImages array (will be preload)
bgString''Image for background.
widthString100%width size
heightString100%height size
defaultDirectionBooleantrueIn case the drag and drop direction should goes to the opposite direction.
initialImageNumber0Image you want to be show at first (array position)
cssCSSProperties{}styles to the container
throttleNumber.04Milliseconds the mouse will be read to calculate and mvoe right/left.
pxThresholdNumber4How many pixels are needed in order to make the decision of movement.

ProductSwitch - Simple - switch from different products shapes.

import { ProductSwitch } from 'react-custom-product'

export default function Example() {
  return <ProductSwitch src="/img/model-1.png" />
}
PropTypeDefaultDescription
srcStringrequiredImage (after you change the src, will trigger the effect).
cssCSSProperties{}styles to the container
widthString100%
heightString100%
durationString1Milliseconds animation will last.

ProductCover - Product color cover.

Colors cover can be manually manipulated with this component.

import { ProductCover } from 'react-custom-product'

export default function Example() {
  return  <ProductCover
            src="/models/1.png"
            cover="/models/2.png"
            width="550px"
            height="400px"
            coverWidth={50}
            coverHeight={50} />
}
PropTypeDefaultDescription
srcStringrequiredImage.
coverStringrequiredImage which is covering the src.
cssCSSProperties{}styles to the container
widthString100%
heightString100%
coverWidthNumber100Percentage number
coverHeightNumber100Percentage number

SwitchGallery - Simple gallery.

Simple gallery to show multiple product images

export default function SwitchGalleryExample() {
  const images = [
    '/images/1.png',
    '/images/2.png',
    '/images/3.png',
    '...'
  ]

  return <SwitchGallery
    images={images}
  />
}
PropTypeDefaultDescription
imagesString[]requiredImages.
cssCSSProperties{}container styles
cssImageCSSProperties{}current image styles
cssImageSelectorContainerCSSProperties{}container preview images styles
cssImageSelectorCSSProperties{}preview images styles

ProductHotspot - Image Hotspot.

Hover some hotspot of your product and show info

const CustomMessage1 = () => <a href="#">Simple link</a>
const CustomMessage2 = () => <div>Custom message/info</div>

export default function ProductHotspotExample() {

  const spots = [
    {
      x: '35%',
      y: '70%',
      children: CustomMessage1()
    },
    {
      x: '65%',
      y: '20%',
      children: CustomMessage2()
    }
  ]

  return <ProductHotspot 
    src={`hotspot/1.webp`} spots={spots} height="auto" />
}
PropTypeDefaultDescription
srcStringrequiredImage.
spotsProductHotspotPoint[]{}positions and react element for each hotspot
cssCSSProperties{}container styles
widthString100%
heightString100%
altString''image alt attribute
CSS ClassDescription
__react_custom_product__hotspot_point_containerSpot container.
__react_custom_product__hotspot_pointPoint.
__react_custom_product__hotspot_messageCustom spot message container.

ProductMask - Svg Mask for products

You can choose either our 2 shapes or add yours.

export default function ProductMaskExample() {
  return <ProductMask type='2' src={`/autos/mask/1.webp`} css={{scale: '1.2'}} />
}
PropTypeDefaultDescription
srcStringrequiredImage.
altString''Alt attribute.
typeString'1'Shape, options: 1 or 2. If you add a new one, use the id of the new element: id="clip-polygon--3", here your type would be 3.
cssCSSProperties{}container styles
polygonReact.ElementundefinedCustom SVG Polygon Element. e.g. <clipPath id="clip-polygon--3"><polygon points=" 8 0, 8.1 0, 8.1 11, 0 11"></polygon><rect x="8" y="0" width="14.2" height="11"></rect><polygon points="22.1 0, 30.2 0, 22.2 11, 22.1 11"></polygon></clipPath>

Time coding on the projects so far:

React Library

wakatime

NextJS Test&Demo

wakatime

Demo Repo

1.1.1

2 years ago

1.1.0

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago