0.6.6 • Published 3 years ago

mediaopt-vpr v0.6.6

Weekly downloads
24
License
MIT
Repository
-
Last release
3 years ago

Built With Stencil

Mediaopt Visual Product Recommendations component

Using this component

  • Put a script tag similar to this
    <script type="module" src="https://cdn.jsdelivr.net/npm/mediaopt-vpr@latest/www/build/mediaopt-widgets.esm.js"></script>
    <script nomodule src="https://cdn.jsdelivr.net/npm/mediaopt-vpr@latest/www/build/mediaopt-widgets.js"></script>
    in the head of your index.html
  • Then you can use the element anywhere in your template with <vi-vpr-view></vi-vpr-view> tag
  • Use attributes for provide credentials or customize component view

Component properties

PropertyAttributeDescriptionTypeDefault
blockTitleblock-titleTitle for recommendations widgetstring'Recommended products'
columnscolumnsNumber of columns for recommendationsnumber4
currencySigncurrency-signCurrency sign will shown after pricestringundefined
imageRatioimage-ratioRatio of each recommended product imagenumber1.5
imageWidthimage-widthWidth of each recommended product imagenumber150
pricePrefixprice-prefixprefix will shown before pricestringundefined
productIdproduct-idId of product you need recommendations forstringundefined
sliderModeslider-modeUse slider or grid viewbooleanfalse
tokentokenMediaopt customer tokenstringundefined

Component events

EventDescriptionType
recommendationClickEvent fires ones when user click on deeplinkCustomEvent<{ productId?: string; title?: string; brand?: string; productType?: string; deeplink?: string; image?: { original?: string; thumbnail?: string; }; price?: { actual?: number; sale?: number; }; }>
recommendationLoadEvent fires ones when recommendation rendered on pageCustomEvent<{ productId?: string; title?: string; brand?: string; productType?: string; deeplink?: string; image?: { original?: string; thumbnail?: string; }; price?: { actual?: number; sale?: number; }; }>
recommendationViewEvent fires ones when recommendation appears on the viewportCustomEvent<{ productId?: string; title?: string; brand?: string; productType?: string; deeplink?: string; image?: { original?: string; thumbnail?: string; }; price?: { actual?: number; sale?: number; }; }>

Styling a component

Because some of CSS style properties can not be inherited we provide an styling API based on CSS Shadow Parts spec.

NB: If you don't need to support browsers without Shadow Parts support (IE, Firefox for Android and Samsung Internet) you can adding id to style tag and use Shadow Parts styling anywhere

To use Shadow Parts add style tag to head of your page:

<style id="vpr-styles">
    mopt-vpr::part(price-outdated) {
      color: inherit;
      font-size: 12px;
      font-weight: 400;
      text-align: center;
    }

    mopt-vpr::part(price-discount) {
      color: #dc616d;
      font-size: 14px;
      font-weight: 600;
      text-align: center;
    }
</style>

Here is a list of shadow parts you can style:

  • product
  • recommendations-title
  • product-image
  • product-image-link
  • product-title
  • price-prefix
  • price-currency
  • price-regular
  • price-outdated
  • price-discount
  • brand
  • product-type

This image describe which elements affected by parts:

exported-parts

Combination of CSS Grids and Shadow Parts allows to change visual position of some elements. For example, if you want to put title below image use

    mopt-vpr::part(product-title) {
      grid-row: 1;
    }

NB: This feature will not work if you will change display property of element!

Development

Automatic interfaces generations

Before running or build project you should generate interfaces. Use npm run build_interfaces to generate interface schema from Swagger docs. Docs url should be in .env file as value for OPENAPI_URL key. Interfaces will be saved to /src/interfaces/generated.ts

Building

To build the component for production, run:

npm run build

To run the unit tests for the components, run:

npm test
0.6.6

3 years ago

0.6.5

3 years ago

0.6.3

3 years ago

0.6.4

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.9

3 years ago

0.5.8

3 years ago

0.5.7

3 years ago

0.5.6

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.2

3 years ago

0.3.3

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.3

4 years ago

0.0.4

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago