@lucrex/storefront-blocks 0.0.0-stage → 0.1.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 +44 -2
- package/dist/index.cjs +1231 -0
- package/dist/index.mjs +1208 -0
- package/dist/server.cjs +1278 -0
- package/dist/server.mjs +1257 -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/context.d.ts +7 -0
- package/dist/types/data.d.ts +71 -0
- package/dist/types/document.d.ts +29 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/json-schema.d.ts +15 -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/validate.d.ts +18 -0
- package/package.json +57 -5
package/README.md
CHANGED
|
@@ -1,3 +1,45 @@
|
|
|
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
|
+
## Checkout hooks
|
|
40
|
+
|
|
41
|
+
Product and checkout blocks output the `data-funnel`, `data-field`, `data-offer-*`, `data-total` and `.cs-submit` hooks that the storefront SDK binds to. Keep them when changing a block.
|
|
42
|
+
|
|
43
|
+
## Releasing
|
|
44
|
+
|
|
45
|
+
Bump `version`, then push a `storefront-blocks-v<version>` tag. CI tests, builds and publishes to npm.
|