Skip to main content

Custom Banner

Introduction

The banner accepts multiple templates which are used to construct the banner:

  • fitting-banner: The banner displayed if at least one fitting, in-stock size for a product exists
  • non-fitting-banner: The banner displayed if there is no fitting or in-stock size for a product
  • in-stock-item: The element displayed for each fitting, in-stock item
  • out-of-stock-item: The element displayed for each fitting, out-of-stock item

The details on how these templates get used and put together are explained in the following sections.

Fitting Banner

The fitting banner template gets used if there is at least one fitting size for a particular product. It has two slots available:

  • label: Gets replaced by a text similar to "Recommended size:" in the same language as the widget uses.
  • items: This is where the in-stock-item and out-of-stock-item templates get inserted (one per fitting size).

The following chart should help in clarifying how everything gets put together:

Template Mechanism Illustration

The following templates are used for the above illustration:

<template slot="fitting-banner">
<slot name="label"></slot>
<slot name="items"></slot>
</template>

<template slot="in-stock-item">
<span class="stock">
<span class="indicator"></span>
<span>
<slot name="size"></slot>
</span>
</span>
</template>

<template slot="out-of-stock-item">
<span class="stock">
<span class="indicator bad"></span>
<span>
<slot name="size"></slot>
</span>
</span>
</template>
Result
Example for a custom banner

If you want to supply your own text (or remove it), simply replace the <slot name="label"> with text:

<template slot="fitting-banner">
The following sizes fit you:
<slot name="items"></slot>
</template>

<template slot="in-stock-item">
<span class="stock">
<span class="indicator"></span>
<span>
<slot name="size"></slot>
</span>
</span>
</template>

<template slot="out-of-stock-item">
<span class="stock">
<span class="indicator bad"></span>
<span>
<slot name="size"></slot>
</span>
</span>
</template>
Result
Example for a custom banner

Similarly, if you want to show the user that some size fits, but not list all the sizes, simply remove the <slot name="items">:

info

You can remove the <template slot="in-stock-item"> and <template slot="out-of-stock-item"> in this case, as they would be inserted in the slot that was just removed.

<template slot="fitting-banner">
Fits you ✅
</template>
Result
Example for a custom banner

Non-Fitting Banner

The non-fitting banner template gets used if there is no fitting size for a particular product. It has only one slot available:

  • label: Gets replaced by a text similar to "Recommended size:" in the same language as the widget uses.

A basic example:

<template slot="non-fitting-banner">
<span class="sad">No size fits :(</span>
</template>
Result
Example for a custom banner

If, instead, you want nothing to be shown in the case of no fitting sizes, simply keep the template empty (or don't include it at all):

<template slot="non-fitting-banner">
<!-- kept empty as we don't want to show anything in this case -->
</template>
Result

Nothing to show here

Examples

Vertical List

<template slot="fitting-banner">
<div class="table">
<div class="row">
<span>Size</span>
<span>Stock</span>
</div>
<slot name="items"></slot>
</div>
</template>

<template slot="in-stock-item">
<div class="row">
<span>
<slot name="size"></slot>
</span>
<span></span>
</div>
</template>

<template slot="out-of-stock-item">
<div class="row">
<span>
<slot name="size"></slot>
</span>
<span></span>
</div>
</template>
Result
Example for a custom bannerExample for a custom banner

Detailed Info on Hover

<template slot="fitting-banner">
<div class="banner">

<div class="details">
🞂
<div class="overlay">
<slot name="items"></slot>
</div>
</div>
</div>
</template>

<template slot="non-fitting-banner">
<div class="banner no-fit"></div>
</template>

<template slot="in-stock-item">
<div class="item">
<slot name="size"></slot>
</div>
</template>

<template slot="out-of-stock-item">
<!-- intentionally left empty -->
</template>
Result

No fitting sizes:

Example for a custom banner

Fitting sizes:

Example for a custom banner

On Hover:

Example for a custom banner