1. Shopbox Grid
  2. Implementation

Shopbox Grid

Implementation

Here we will outline how to implement the Shopbox Homepage on your site.

Prerequisites

Steps

1. Insert Shopbox-Grid script:

Please insert the below script into the of your website across all pages.

html
<script async src="https://grid.shopbox.ai/sbgrid.min.js"></script>

2. Shopbox Homepage Component Location:

Decide where you would like the Shopbox Homepage components to appear and then insert the <div> below in the desired location. This should be a full width <div> and should render straight away if the header script and the <div> are inserted correctly. You should have received an email from your customer success agent with the following items:

Variable Description
NO_OF_ROWS This is the number of rows of widgets that you are inserting
UNIQUE_CLIENT_ID The unique client ID you were assigned at implementation time
CURRENCY The default currency on your site
GRID_ID The unqiue ID that is assigned to your homepage grid setup

You can copy the below code and replace with the relevant items from the email, but this will also be included with the email.

html
<div style="--sb-rows: NO_OF_ROWS; min-height: calc(240px * var(--sb-rows));">
  <shopbox-grid cid="UNIQUE_CLIENT_ID" currency="CURRENCY" id="GRID_ID"> </shopbox-grid>
</div>

2.1 Additional options and how to use them

Variable Description Options Default
maxwidth max width of the grid Pixel value or 'unset' 1200px
imgfit controls how images are sized contain or cover contain
minfactorialdigits minimum number of factorial digits for prices Integer 2
NO_OF_ROWS number of loader rows to display CSS Variable 1
html
<div style="--sb-rows: NO_OF_ROWS; min-height: calc(240px * var(--sb-rows));">
  <shopbox-grid cid="UNIQUE_CLIENT_ID" imgfit="contain" maxwidth="1200px" minfactorialdigits="2" currency="CURRENCY" id="GRID_ID">
  </shopbox-grid>
</div>

2.2 Customizing the grid using CSS Variables

The grid builder in the Shopbox Hub offers most of these as predefined fields for customization. If you prefer to do the same with custom css (in the custom css panel of the grid), you can do so using the variables provided below. s

CSS Variable Default Value Controls the style of
General grid element styles
--sb-grid-item-border 1px solid #e0e0e0 Grid element border
--sb-grid-item-br 3px Grid element border radius
--sb-grid-item-bc #fff Grid element background color
Grid element heading styles
--sb-grid-title-color unset Grid element heading color
--sb-grid-title-fs 15px Grid element heading font size
--sb-grid-title-fw bold Grid element heading font weight
--sb-grid-title-ff unset Grid element heading font family
Grid product styles
--sb-product-border 1px solid transparent Product card border
--sb-product-br 2px Product card border radius
--sb-product-color #222 Product name color
--sb-product-fs 14px Product name font size
--sb-product-fw 300 Product name font weight
--sb-product-ff unset Product name font family
--sb-product-img-ar 1/1 Product image aspect ratio
Grid product price styles
--sb-price-color #3a3a3a Price color
--sb-sale-color #3a3a3a Sale price color
--sb-price-fs 12px Price font size
--sb-price-fw 300 Price font weight
--sb-price-ff unset Price font family
--sb-price-text-align center Price alignment
--sb-price-padding 0 1px; Price padding
--sb-price-sale-order 1 or -1 Changes orders of sale and normal price
Grid product sale banner styles
--sb-banner-br 2px Sale banner border radius
--sb-banner-text-color #fff Sale banner text color
--sb-banner-fs 12px Sale banner font size
--sb-banner-padding 2px 4px Sale banner padding
--sb-banner-color-sale #ff4433 Sale banner background color for products on sale
--sb-banner-color-new #2e8b57 Sale banner background color for new products
See more button styles
--sb-see-more-color #1770e4 See more button text color
--sb-see-more-fs 13px See more button font size
--sb-see-more-fw 400 See more button font weight
--sb-see-more-ff unset See more button font family
--sb-see-more-text-decoration underline See more button text decoration
Grid carousel controls styles
--sb-carousel-controls-width 2em Carousel control arrow buttons width
--sb-carousel-controls-height 5em Carousel control arrow buttons height
--sb-carousel-controls-background-color #fff Carousel control arrow buttons background color
--sb-carousel-controls-position 10px Carousel control arrow buttons position (offset prev/next button left/right)
--sb-carousel-controls-border-radius 2px Carousel control arrow buttons border radius
--sb-carousel-controls-box-shadow 0 1px 3px #888 Carousel control arrow buttons box shadow

Example:

css
#shopbox-grid {
  --sb-grid-title-color: #424242;
  --sb-grid-title-fs: 18px;
  --sb-product-img-ar: 4/3;
}
/* Or just modify them on mobile with a media query */
@media (max-width: 768px) {
  #shopbox-grid {
    --sb-product-img-ar: 16/9;
  }
}

Target specific types of elements using plain css with the provided classes for each type (.sb-grid-item, .sb-grid-carousel, .sb-grid-banner )

css
#shopbox-grid .sb-item-carousel {
  font-size: 24px;
}

Targeting element types of a certain grid size is also possible, different classes for that can be seen when inspecting the element in the browser. Example:

css
/* Targets only full width carousels */
#shopbox-grid .sb-grid-carousel.sb-grid-carousel--4 {
  font-size: 28px;
}
/* Targets only 1 block wide grid elements showing 4 products */
#shopbox-grid .sb-grid-item.sb-grid-size-1x4 {
  font-size: 12px;
}

Please note not to use the randomly generated classnames that are prefixed with svelte- (for example: svelte-lo95p). As those are used for scoping internal CSS and change for each minor version update of the Shopbox Grid.

2.3 Custom fonts

Using custom fonts in the grid is also straight forward. Only thing to note here is that the Grid Builder preview will not show font changes, as we do not load the fonts ourselves. Fonts are expected to be loaded on the page on the page, on the clients website, where the grid is rendered.

2.4 Image aspect ratios for banners

Banners in the shobpox grid can range from size 1-4 columns each. These are the aspect ratios we recommend for each size:

  • Baners with 1 column size: 4/3.
  • Banners ranging from 2 to 4 columns in size: 21/9.

If a different aspect ratio is needed for any of the sizes it can be changed with CSS.