Fejlesztőknek
Kezdj bele
Témák/Theme SDK

Theme SDK

Ez az oldal még csak angolul érhető el.

`@poltura/theme-sdk` is the public contract between a Poltura theme and the storefront that runs it: typed modules for authoring elements, reading store data and drawing every commerce feature.

Ezen az oldalon

@poltura/theme-sdk is the public contract between a Poltura theme and the storefront that runs it: typed modules for authoring elements, reading store data and drawing every commerce feature.

Importing

Every name is imported from its module, @poltura/theme-sdk/<module>. There is no root import and no deep import, and no name is exported from two modules, so auto-import always picks the right one.

import { defineSection, field } from '@poltura/theme-sdk/elements';
import { useCart } from '@poltura/theme-sdk/cart';

The package holds declarations only. The storefront provides the implementation at runtime, so a theme never bundles SDK code.

Kinds of export

KindName shapeWhat it is
HookuseXState and actions. The logic runs on the host and returns declared types only.
Part<Feature><Piece>, such as CartLineMarkup only, styled by tokens, className and classes. Parts never fetch data.
Default<Feature>, such as VariantPickerThe complete feature, built from its parts and hook. The storefront draws it when a theme ships nothing for the feature.
DefinerdefineXAuthoring calls the theme build reads statically.
FunctioncamelCase verbA pure helper without React. Rare.
ConstantcamelCase object or UPPER_CASE valueCatalogue values, so themes never write magic strings.
TypePascalCaseDeclared in the package and documented property by property.

Every feature follows the same pattern: a headless hook, parts that draw it and, for component-level features, a complete default. A theme can use the default, restyle it, or rebuild the feature from the hook and the parts.

One way to do each thing

  • Settings arrive already coerced and translated: element settings as the typed settings prop, theme settings from useThemeSettings(), child blocks from useChildBlocks().
  • Prices are drawn by the price parts from a PriceView. Any other amount goes through useFormat().money().
  • Data comes from named domain hooks that take one object parameter and return one result shape.

Versions

This is theme API v1, and the package major is the theme API version: SDK 1.x is theme API v1. A minor release adds exports or optional fields; only a new theme API version, released as SDK 2.0.0, removes or changes one. A theme written against one version keeps working on every later minor release of the same major.

Modules

ModuleImportPurpose
elements@poltura/theme-sdk/elementsAuthoring: define and override sections and blocks, fields, slots, inline editing and child blocks.
layout@poltura/theme-sdk/layoutLayout primitives and section chrome: containers, stacks, rows, grids and section frames.
sections@poltura/theme-sdk/sectionsComplete defaults of the platform's section types, for a theme override to wrap or delegate to.
settings@poltura/theme-sdk/settingsTheme settings and the settings of a template's own section.
i18n@poltura/theme-sdk/i18nTranslations, theme texts, the store's languages and the one formatter.
store@poltura/theme-sdk/storeThe store: identity, contact, company, brand, social links, market and features.
data@poltura/theme-sdk/dataStore reads: products, categories, collections, attributes, product types and the content pages and posts a setting points to, each one named hook with one result shape.
product@poltura/theme-sdk/productProducts, variants, options, availability, specifications, reviews, the product page view and the buy box.
price@poltura/theme-sdk/priceMoney, prices and price access: what a visitor may see and on which tax basis.
listing@poltura/theme-sdk/listingCollection, category and search listings: product cards, filters, sort and paging.
cart@poltura/theme-sdk/cartThe cart: its lines, totals, codes and gift cards, the state and actions the cart hook returns, and the cart page's parts.
checkout@poltura/theme-sdk/checkoutCheckout parts a theme may place outside checkout, such as the accepted payment methods.
customer@poltura/theme-sdk/customerThe signed-in shopper: customer, addresses, orders, the account area and the sign-in forms.
search@poltura/theme-sdk/searchStorefront search: the query, live results, suggestions and featured products.
chrome@poltura/theme-sdk/chromeThe header, footer and promo bar and their pieces: brand, user menu, switchers, mobile menu and colour mode.
navigation@poltura/theme-sdk/navigationStore menus, the category and page tree, mega menu panels and breadcrumb trails.
routing@poltura/theme-sdk/routingLinks, the router, page params and the merchant's site pages.
media@poltura/theme-sdk/mediaImages, videos, placeholders, media library files and theme assets.
forms@poltura/theme-sdk/formsStore forms: the merchant's published forms, the newsletter sign-up and the contact form.
content@poltura/theme-sdk/contentMerchant content: blog posts, legal documents, the FAQ, guides, rich text, Markdown and the contact page.
consent@poltura/theme-sdk/consentCookie consent: the shopper's choice and the actions that record it.
inbox@poltura/theme-sdk/inboxThe store's live chat: its state and actions, the complete widget and the parts it is built from.
slots@poltura/theme-sdk/slotsApp slots, app zones and host widget names.
ui@poltura/theme-sdk/uiGeneric interface primitives, class merging and DOM hooks.
editor@poltura/theme-sdk/editorThe customizer canvas: whether the page is being edited, and preview scenarios.
Utoljára frissítve