@orderlyshop/web-components 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/AGENTS.md +110 -0
- package/README.md +685 -0
- package/bin/orderly-build-category-pages.mjs +160 -0
- package/bin/orderly-generate-category-pages.mjs +308 -0
- package/bin/orderly-hydrate-static-pages.mjs +595 -0
- package/bin/orderly-init-navigation.mjs +327 -0
- package/bin/orderly-init-shop.mjs +876 -0
- package/bin/orderly-init-taxonomy.mjs +2 -0
- package/bin/orderly-publish-site.mjs +342 -0
- package/custom-elements.json +495 -0
- package/dist/browser/orderly-web-components.define.global.js +3085 -0
- package/dist/browser/orderly-web-components.define.global.js.map +1 -0
- package/dist/browser/orderly-web-components.global.js +3085 -0
- package/dist/browser/orderly-web-components.global.js.map +1 -0
- package/dist/default-shop-DWdB_MRd.d.ts +220 -0
- package/dist/default-shop.d.ts +6 -0
- package/dist/default-shop.js +762 -0
- package/dist/default-shop.js.map +1 -0
- package/dist/define-IAQk8OmQ.d.ts +9 -0
- package/dist/define.d.ts +2 -0
- package/dist/define.js +10266 -0
- package/dist/define.js.map +1 -0
- package/dist/index.d.ts +683 -0
- package/dist/index.js +10589 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation.d.ts +51 -0
- package/dist/navigation.js +818 -0
- package/dist/navigation.js.map +1 -0
- package/dist/query.d.ts +31 -0
- package/dist/query.js +115 -0
- package/dist/query.js.map +1 -0
- package/dist/registry-CPDecU3g.d.ts +6 -0
- package/dist/shop-BnT1C6kG.d.ts +173 -0
- package/dist/shop-query.d.ts +8 -0
- package/dist/shop-query.js +100 -0
- package/dist/shop-query.js.map +1 -0
- package/dist/shop.d.ts +8 -0
- package/dist/shop.js +10359 -0
- package/dist/shop.js.map +1 -0
- package/dist/stores.d.ts +46 -0
- package/dist/stores.js +145 -0
- package/dist/stores.js.map +1 -0
- package/dist/taxonomy.d.ts +35 -0
- package/dist/taxonomy.js +247 -0
- package/dist/taxonomy.js.map +1 -0
- package/dist/types-CCQDd6Nd.d.ts +95 -0
- package/docs/components/README.md +610 -0
- package/docs/components/product-grid.md +176 -0
- package/docs/components/product-rail.md +174 -0
- package/examples/shop/README.md +71 -0
- package/examples/shop/package.json +28 -0
- package/examples/shop/src/category.html +20 -0
- package/examples/shop/src/checkout.html +21 -0
- package/examples/shop/src/forretningsbetingelser.html +80 -0
- package/examples/shop/src/includes/body-end.html +1 -0
- package/examples/shop/src/includes/body-start.html +2 -0
- package/examples/shop/src/includes/head.html +32 -0
- package/examples/shop/src/index.html +25 -0
- package/examples/shop/src/navigation.ts +154 -0
- package/examples/shop/src/product.html +24 -0
- package/examples/shop/src/templates/shop-footer.html +76 -0
- package/examples/shop/tsconfig.json +32 -0
- package/examples/shop/vite.config.mjs +184 -0
- package/html-custom-data.json +262 -0
- package/package.json +118 -0
- package/server/README.md +111 -0
- package/server/apache/.htaccess +18 -0
- package/server/nginx/orderly-products.conf +24 -0
- package/server/node/product-snapshot-server.mjs +133 -0
- package/server/php/orderly-product.php +204 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Agent Guide For `@orderlyshop/web-components`
|
|
2
|
+
|
|
3
|
+
Use this package as a headless storefront component library. Prefer native custom elements, light-DOM templates, and normal CSS over framework-specific wrappers unless the user asks for a framework integration.
|
|
4
|
+
|
|
5
|
+
## Discovery
|
|
6
|
+
|
|
7
|
+
- Read `README.md` for setup and package-wide concepts.
|
|
8
|
+
- Read `docs/components/README.md` for component APIs.
|
|
9
|
+
- Read `docs/components/product-rail.md` and `docs/components/product-grid.md` before implementing product listing UI.
|
|
10
|
+
- Read `custom-elements.json` for machine-readable custom element metadata.
|
|
11
|
+
- Read `html-custom-data.json` when generating vanilla HTML or configuring editor autocomplete.
|
|
12
|
+
- Inspect `examples/shop` for a complete vanilla TypeScript shop that customizes the defaults without replacing package logic.
|
|
13
|
+
- When creating a new shop from scratch, run `npx orderly-init-shop` first. It scaffolds the vanilla HTML/TypeScript/Vite structure that the package expects, including `src/includes/head.html`, `src/navigation.ts`, `src/shop-query.ts`, page templates, and package scripts.
|
|
14
|
+
|
|
15
|
+
## Query Rules
|
|
16
|
+
|
|
17
|
+
- Use `configureShop({ defaultShop: { defaultQuery } })` for shop-wide query scope. `defaultQuery` is a full Core `SearchQuery`.
|
|
18
|
+
- Do not create package-specific account id shortcuts. Tenant scoping is just `SearchQuery.SourceAccountId`.
|
|
19
|
+
- For simple markup-driven searches, use declarative query attributes:
|
|
20
|
+
- `keywords` maps to `SearchQuery.Query`.
|
|
21
|
+
- `tags` maps to `SearchQuery.Tags`.
|
|
22
|
+
- `hidden-query` maps to `SearchQuery.HiddenQuery`.
|
|
23
|
+
- `order-by` maps to `SearchQuery.OrderBy`.
|
|
24
|
+
- `store-id` maps to `SearchQuery.StoreId`.
|
|
25
|
+
- `featured` maps to `SearchQuery.Featured`.
|
|
26
|
+
- The same query values can be grouped inside a child `<query>` element.
|
|
27
|
+
- Use typed JavaScript properties for full Core contracts:
|
|
28
|
+
- `query: SearchQuery`
|
|
29
|
+
- `defaultQuery: SearchQuery`
|
|
30
|
+
- `client: OrderlyClient`
|
|
31
|
+
- `basketController: BasketController`
|
|
32
|
+
- In vanilla browser scripts, use `OrderlyWebComponents.createSearchQuery({ query, tags, orderBy })` from the standalone bundle when you need a SearchQuery without importing protobuf helpers.
|
|
33
|
+
|
|
34
|
+
## Implementation Defaults
|
|
35
|
+
|
|
36
|
+
- Keep components headless. Add behavior and default light-DOM markup, not bundled theme CSS.
|
|
37
|
+
- Built-in UI copy defaults to Danish. Use `configureShop({ uiLanguage: "EN" })` for English shops, and prefer shop attributes/templates for wording that is unique to one storefront.
|
|
38
|
+
- Preserve template override support through `data-orderly-template`, `data-orderly-bind`, `data-orderly-slot`, and `data-orderly-action`.
|
|
39
|
+
- Put shop-wide templates in a shared document-level registry, for example template files included from `body-start.html`, using `data-orderly-template` plus `data-orderly-for`.
|
|
40
|
+
- Keep browser-only package code free of Node HTTP modules.
|
|
41
|
+
- Do not store tokens, API keys, OAuth responses, or cookie values.
|
|
42
|
+
- Treat localStorage basket and checkout profile data as user-owned state. Do not add secret persistence.
|
|
43
|
+
- Product images should default to `fit="contain"`, white background, and square aspect ratio in product tiles.
|
|
44
|
+
- Product grids should support continuation-token based dynamic paging without requiring a visible load-more button.
|
|
45
|
+
- Use `orderly-home-page` for default storefront homepages instead of generating product rails in app code.
|
|
46
|
+
- Use `orderly-category-page` for category routes. Default category links should use `/categories/<category-path>/` so builds can generate and hydrate server-rendered category pages. Use `/category.html#id=<encoded-category-path-or-slug>` only for shops that explicitly opt into hash routing.
|
|
47
|
+
- Keep `orderly-navigation` sticky by default. Use `sticky="false"` only when a shop intentionally wants navigation to scroll away.
|
|
48
|
+
- Use `orderly-checkout-page` for checkout pages instead of wiring `orderly-checkout` and `orderly-basket` manually in app code.
|
|
49
|
+
- Use `orderly-product-detail-page` for full product routes. Set `share-url` to the product `SearchObject.ShareURL.URL`; the component loads the product through `SearchQuery.ShareUrl`.
|
|
50
|
+
- Keep category page generation in the normal shop build. Use `orderly-build-category-pages` without `--no-hydrate` so homepage/category pages get initial HTML for SEO and less visible loading shift. Pass `--base-url` or set `VITE_ORDERLY_BASE_URL` to override the default `https://service.orderly.shop` snapshot backend.
|
|
51
|
+
- For real product URLs on traditional hosting, use the package-owned helpers in `server/`: Apache `.htaccess`, Nginx rewrite config, PHP product renderer, and optional Node product snapshot endpoint. Do not copy this logic into example-shop.
|
|
52
|
+
- Use `navigation.ts` for shop category/navigation structure. Export `navigationDefinitions: NavigationDefinition[]`.
|
|
53
|
+
- Use `npx orderly-init-navigation` to create the default file or `npx orderly-init-navigation --suggest --account-id <account-id>` to dump sampled product data for agent-assisted navigation design.
|
|
54
|
+
- Navigation definitions are recursive but should stay at most two category levels deep for normal shops. Each item must include `label` and a stable globally unique `slug`, and can include optional `heroImage`, optional `description`, optional `query`, and optional `children`.
|
|
55
|
+
- Use plain `SearchQueryInput` objects in navigation definitions, for example `query: { query: "sko sneakers", tags: ["sko"] }`.
|
|
56
|
+
|
|
57
|
+
## Common Patterns
|
|
58
|
+
|
|
59
|
+
Declarative product rail:
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<orderly-product-rail
|
|
63
|
+
title="Sko"
|
|
64
|
+
cta-label="Se alle"
|
|
65
|
+
cta-href="/categories/sko/"
|
|
66
|
+
keywords="H&M"
|
|
67
|
+
tags="børnetøj,bluser">
|
|
68
|
+
</orderly-product-rail>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Structured query markup:
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<orderly-product-rail title="Sko">
|
|
75
|
+
<query>
|
|
76
|
+
<tags>børnetøj,bluser</tags>
|
|
77
|
+
<keywords>H&M</keywords>
|
|
78
|
+
<order-by>CreatedTime desc</order-by>
|
|
79
|
+
</query>
|
|
80
|
+
</orderly-product-rail>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Typed query setup:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { create } from "@bufbuild/protobuf";
|
|
87
|
+
import { SearchQuerySchema } from "@orderlyshop/core-client";
|
|
88
|
+
|
|
89
|
+
productRail.query = create(SearchQuerySchema, {
|
|
90
|
+
Query: "H&M",
|
|
91
|
+
OrderBy: ["CreatedTime desc"]
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Standalone browser setup:
|
|
96
|
+
|
|
97
|
+
```html
|
|
98
|
+
<script src="/node_modules/@orderlyshop/web-components/dist/browser/orderly-web-components.global.js"></script>
|
|
99
|
+
<script>
|
|
100
|
+
const { configureShop } = OrderlyWebComponents;
|
|
101
|
+
configureShop({
|
|
102
|
+
uiLanguage: "DA",
|
|
103
|
+
defaultShop: {
|
|
104
|
+
navigationDefinitions: [
|
|
105
|
+
{ label: "Sko", slug: "sko", query: { query: "sko sneakers" } }
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
</script>
|
|
110
|
+
```
|