@lucrex/storefront-blocks 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +58 -2
- package/dist/index.cjs +2561 -0
- package/dist/index.mjs +2538 -0
- package/dist/server.cjs +2608 -0
- package/dist/server.mjs +2587 -0
- package/dist/types/block.d.ts +244 -0
- package/dist/types/blocks/checkout.d.ts +5 -0
- package/dist/types/blocks/content.d.ts +19 -0
- package/dist/types/blocks/index.d.ts +3 -0
- package/dist/types/blocks/layout.d.ts +9 -0
- package/dist/types/blocks/product.d.ts +13 -0
- package/dist/types/blocks/store.d.ts +75 -0
- package/dist/types/context.d.ts +11 -0
- package/dist/types/data.d.ts +141 -0
- package/dist/types/document.d.ts +29 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/json-schema.d.ts +15 -0
- package/dist/types/money.d.ts +2 -0
- package/dist/types/page.d.ts +14 -0
- package/dist/types/server.d.ts +10 -0
- package/dist/types/style.d.ts +188 -0
- package/dist/types/templates/funnels.d.ts +7 -0
- package/dist/types/templates/online-stores.d.ts +10 -0
- package/dist/types/validate.d.ts +18 -0
- package/package.json +57 -5
package/README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @lucrex/storefront-blocks
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The page format, blocks and built-in templates behind Lucrex storefront pages. The page builder, the AI and the backend renderer all use this package, so a page looks the same in the editor and once published.
|
|
4
|
+
|
|
5
|
+
## The page format
|
|
6
|
+
|
|
7
|
+
A page is JSON:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"root": { "props": { "fonts": [{ "family": "Cairo", "weights": [400, 700] }], "css": "" } },
|
|
12
|
+
"content": [
|
|
13
|
+
{
|
|
14
|
+
"type": "Section",
|
|
15
|
+
"props": {
|
|
16
|
+
"id": "hero",
|
|
17
|
+
"style": { "padding": "48px 16px", "mobile": { "padding": "24px 12px" } },
|
|
18
|
+
"css": "& h1 { letter-spacing: -0.02em; }",
|
|
19
|
+
"content": [{ "type": "ProductTitle", "props": { "id": "title", "level": "h1" } }]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- Every block has a unique `id`. Its root element gets `data-block="<id>"`.
|
|
27
|
+
- `style` takes CSS properties in camelCase, with `tablet` and `mobile` overrides.
|
|
28
|
+
- `css` is scoped to the block. Nesting is allowed and `&` is the block itself.
|
|
29
|
+
- Slot props (`content`, `column1`…) hold more blocks.
|
|
30
|
+
- Product and checkout blocks read live data (product, offers, form fields, wilayas) at render time. The page never stores prices.
|
|
31
|
+
|
|
32
|
+
`pageJsonSchema()` describes every block for an AI agent. `parsePageDocument()` validates a page and reports each problem with its path.
|
|
33
|
+
|
|
34
|
+
## Entry points
|
|
35
|
+
|
|
36
|
+
- `@lucrex/storefront-blocks`: browser safe. Blocks, `PageContent`, page CSS, validation, JSON Schema and templates.
|
|
37
|
+
- `@lucrex/storefront-blocks/server`: everything above plus `renderPage(document, data)`, which returns `{ html, css, fontStylesheets, preloadImages }` with the CSS checked, scoped and lowered for older browsers.
|
|
38
|
+
|
|
39
|
+
## Templates
|
|
40
|
+
|
|
41
|
+
- `funnelTemplate(templateId, { formPosition })`: the page of a funnel.
|
|
42
|
+
- `onlineStorePages(templateId)`: the 13 pages of an online store: `header`, `footer`, `home`, `all-products`, `category`, `product`, `thank-you`, `contact`, `about`, `privacy-policy`, `refund-policy`, `terms-of-service` and `not-found`. Only `home` differs between templates. Each store template also has its own CSS in the backend.
|
|
43
|
+
|
|
44
|
+
## Page data
|
|
45
|
+
|
|
46
|
+
`renderPage(document, data)` takes the page data the blocks read:
|
|
47
|
+
|
|
48
|
+
- Funnel pages and store product pages pass the product and checkout data (`funnel`, `product`, `offers`, `deliveryPrices`, `geo`, `api`). Store product pages set `lazyCities`, so the SDK loads the cities.
|
|
49
|
+
- Store pages pass `store`: the labels in the store language, the money format, the store settings, categories and home products, plus `listing`, `productPage` or `article` for those pages.
|
|
50
|
+
|
|
51
|
+
Store blocks take their text from the store settings and labels. A block `text`, `title` or `label` prop replaces it.
|
|
52
|
+
|
|
53
|
+
## Checkout and store hooks
|
|
54
|
+
|
|
55
|
+
Product and checkout blocks output the `data-funnel`, `data-field`, `data-offer-*`, `data-total` and `.cs-submit` hooks that the storefront SDK binds to. Store blocks output the `data-store`, `data-track`, `data-product-card`, `data-filter-category`, `data-contact-*` and `data-order` hooks. Keep them when changing a block.
|
|
56
|
+
|
|
57
|
+
## Releasing
|
|
58
|
+
|
|
59
|
+
Bump `version`, then push a `storefront-blocks-v<version>` tag. CI tests, builds and publishes to npm. The release then waits in npm's Staged Packages until a maintainer approves it.
|