DepictCategoryProvider class

The DepictCategoryProvider class is what ties together all the configuration for the different components.

If you want to dynamically change some properties, for example the market, please let us know and we’ll help you out.

The following table shows the DepictCategoryProvider’s configuration properties, their types, and descriptions:

merchant
string

The merchant to use for the search.

market
string

The market to use for the search.

userId
string?

Optional unique identifier of a logged in user. Should be persistent across devices and sessions.

sessionId
string?

Optional unique identifier of the current session. Only necessary when performing server side requests to Depict.

metaData
Record<string, string>?

Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.

uniqueInstanceKeyForState
string?

A unique key for each instance, so that the state of each instance is kept separate.

categoryId
string?

The category id to show.

listingType
ListingType?

Whether this page is a collection or a category. If not specified, it will be inferred as described here

locale
category_i18n?

Category internationalisation (strings and price formatting).

The following table shows properties and methods of the DepictCategoryProvider class:

categoryId
string
default: "listingType"

`ListingType

CategoryPage function

The component displaying the category listing, including but not limited to sorting and filters. See screenshot.

The following table shows the CategoryPage’s configuration properties, their types, and descriptions:

gridSpacing
(string | { horizontal: string; vertical: string; })?
default: "2%"

The spacing between products.

columnsAtSize
[number, number?][]?
default: "[[2, 901], [3, 1024], [4]]"

How many columns to show at each media size. For example, [[2, 901], [3, 1024], [4]] means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.

productCard
(display: YourDisplay | null) => HTMLElement | HTMLElement[]

The product card function to use for rendering products.

categoryProvider
DepictCategoryProvider

The category provider instance.

showBreadcrumbs
boolean?
default: "true"

Whether to show the breadcrumbs in the category page.

showQuicklinks
boolean?
default: "true"

Whether to show the quicklinks in the category page.

categoryTitlePlugin
typeof CategoryTitle

categoryTitlePlugin is an optional plugin that can be used to customize the title-part of the category page. The default is CategoryTitle which shows the title of the category and the number of products within. EmbeddedNumProducts (exported from @depict-ai/js-ui) on the other hand only displays the number of products within a category and tries to fit this between the sort and filter button on mobile, if the text length of the localisation permits.

onCategoryIdChange
((newCategoryId?: string | undefined, oldCategoryId?: string | undefined) => void)?
default: "undefined"

Can be used to know when the CategoryPage is navigated to a new category and update other content on the page accordingly. Will be called when the CategoryPage is created, every time a navigation is performed between categories and once the CategoryPage is destroyed. When newCategoryId is undefined it means the category page has been closed/left, or you have provided undefined as the categoryId prop to the provider.

getContentBlocksByRow
Accessor<JSUIContentBlocksByRow>?

Function returned by contentBlockStore. See contentBlockStore.

Breadcrumb navigation helps users know their location in the category tree by providing a trail back to the root category. By default, the CategoryPage component contains breadcrumb navigation. You can disable its default breadcrumb navigation by setting the showBreadcrumbs property to false. To add a custom breadcrumb navigation, import the BreadCrumbs component from the SDK and nest it in the desired location on your DOM tree.

BreadCrumbs

Example:

import { BreadCrumbs, onExistObserver } from "@depict-ai/js-ui";

onExistObserver(".breadcrumbs-insertion", () =>
  BreadCrumbs({ categoryProvider })
);

Options:

categoryProvider
DepictCategoryProvider

The category provider instance to show BreadCrumbs for.

The QuickLinks component shows all available product categories in a carousel for easy navigation. By default, the CategoryPage component contains quick link navigation. You can disable its default quick link navigation by setting the showQuicklinks property to false. To add a custom quick link navigation, import the QuickLinks component from the SDK and nest it in the desired location on your DOM tree.

QuickLinks

Example:

import { QuickLinks, onExistObserver } from "@depict-ai/js-ui";

onExistObserver(".quicklinks-insertion", () =>
  QuickLinks({ categoryProvider })
);

Options:

categoryProvider
DepictCategoryProvider

The category provider instance to show QuickLinks for.