@lime-bundles/widget 1.0.0 → 2.0.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 +76 -72
- package/dist/index.cjs +2494 -341
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -49
- package/dist/index.d.ts +22 -49
- package/dist/index.js +2505 -349
- package/dist/index.js.map +1 -1
- package/dist/lime-bundle.global.js +1112 -85
- package/dist/lime-bundle.global.js.map +1 -1
- package/docs/README.md +81 -0
- package/docs/css-variables.md +158 -0
- package/docs/hydrogen.md +185 -0
- package/docs/react-nextjs.md +379 -0
- package/docs/web-component.md +282 -0
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @lime-bundles/widget
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Drop-in `<lime-bundle>` web component for the **Lime Bundles Shopify app**. Embed merchant-configured bundles on any JavaScript-enabled headless storefront (Hydrogen, Astro, Vue, Svelte, plain HTML). If you're not a merchant using Lime Bundles, this package probably isn't what you're looking for.
|
|
4
|
+
|
|
5
|
+
Ships the full widget your merchants see in the admin preview: header, save badge, product list with count bubbles, savings bar, pricing footer, themed CTA.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
@@ -20,9 +22,9 @@ Or via CDN, zero build step:
|
|
|
20
22
|
<script type="module" src="https://unpkg.com/@lime-bundles/widget"></script>
|
|
21
23
|
```
|
|
22
24
|
|
|
23
|
-
##
|
|
25
|
+
## Paste-and-go
|
|
24
26
|
|
|
25
|
-
One snippet in your product page template. The widget
|
|
27
|
+
One snippet in your product page template. The widget resolves the current product from the URL (`/products/<handle>`) and renders every active bundle configured for it. Clicking **Add bundle** calls Shopify's tokenless Storefront Cart API and redirects to checkout with the discount applied.
|
|
26
28
|
|
|
27
29
|
```html
|
|
28
30
|
<script type="module" src="https://unpkg.com/@lime-bundles/widget"></script>
|
|
@@ -32,124 +34,126 @@ One snippet in your product page template. The widget auto-detects the current p
|
|
|
32
34
|
></lime-bundle>
|
|
33
35
|
```
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
Generate the token at `/app/settings/headless` in your Lime Bundles admin. It's a read-only Storefront Access Token (bundle metaobjects + product listings only), safe to ship in HTML.
|
|
36
38
|
|
|
37
|
-
|
|
39
|
+
## BYO cart
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
Listen for `lime-bundle:add-to-cart` and call `event.preventDefault()` to suppress the default redirect:
|
|
42
|
+
|
|
43
|
+
```js
|
|
44
|
+
document.querySelector("lime-bundle").addEventListener(
|
|
45
|
+
"lime-bundle:add-to-cart",
|
|
46
|
+
async (event) => {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
await myCart.linesAdd(event.detail.lines);
|
|
49
|
+
},
|
|
50
|
+
);
|
|
49
51
|
```
|
|
50
52
|
|
|
51
53
|
## Attributes
|
|
52
54
|
|
|
53
55
|
| Attribute | Required | Purpose |
|
|
54
56
|
|---|:-:|---|
|
|
55
|
-
| `shop-domain` | ✓ |
|
|
56
|
-
| `storefront-token` | ✓ |
|
|
57
|
-
| `bundle-gid` | |
|
|
58
|
-
| `product-handle` | | Render bundles for
|
|
59
|
-
| `app-url` | |
|
|
60
|
-
| `analytics` | |
|
|
61
|
-
| `locale` | | BCP-47 tag forwarded to Storefront API. |
|
|
57
|
+
| `shop-domain` | ✓ | `*.myshopify.com` domain. |
|
|
58
|
+
| `storefront-token` | ✓ | Storefront Access Token from `/app/settings/headless`. |
|
|
59
|
+
| `bundle-gid` | | Render one specific bundle. Overrides auto-detect. |
|
|
60
|
+
| `product-handle` | | Render bundles for this handle. Overrides URL detection. |
|
|
61
|
+
| `app-url` | | Enables impression + add-to-cart analytics when set. |
|
|
62
|
+
| `analytics` | | `"false"` suppresses analytics even when `app-url` is set. |
|
|
63
|
+
| `locale` | | BCP-47 tag forwarded to the Storefront API. |
|
|
62
64
|
|
|
63
|
-
Product resolution
|
|
65
|
+
**Product resolution** (when `bundle-gid` is absent): explicit `product-handle` → `<meta name="shopify:product-handle">` → `/products/<handle>` URL segment.
|
|
64
66
|
|
|
65
67
|
Changing any attribute at runtime re-fetches and re-renders.
|
|
66
68
|
|
|
67
69
|
## Events
|
|
68
70
|
|
|
71
|
+
All events bubble and pierce shadow-DOM boundaries (`composed: true`), so you can listen on any ancestor.
|
|
72
|
+
|
|
69
73
|
### `lime-bundle:add-to-cart`
|
|
70
74
|
|
|
71
|
-
Fired on CTA click. `event.
|
|
75
|
+
Fired on CTA click. Cancelable: `event.preventDefault()` suppresses the default checkout redirect.
|
|
72
76
|
|
|
73
77
|
```ts
|
|
74
|
-
{
|
|
75
|
-
lines: CartLineInput[];
|
|
76
|
-
bundleType: "fixed" | "volume" | "mix_match";
|
|
77
|
-
bundleId: string;
|
|
78
|
+
event.detail: {
|
|
79
|
+
lines: CartLineInput[]; // merchandiseId + quantity + attributes
|
|
78
80
|
}
|
|
79
81
|
```
|
|
80
82
|
|
|
81
|
-
Every line's `attributes` array includes `{ key: "_lime_bundle_gid", value: bundleId }`. Preserve it on the way to Shopify cart mutation or purchase attribution breaks.
|
|
82
|
-
|
|
83
|
-
### `lime-bundle:error`
|
|
84
|
-
|
|
85
|
-
Fired if bundle fetch / parse fails. `event.detail.error` is an `Error`. Render your own fallback UI in response.
|
|
83
|
+
Every line's `attributes[]` array includes `{ key: "_lime_bundle_gid", value: bundleId }`. Preserve it on the way to Shopify cart mutation or purchase attribution breaks.
|
|
86
84
|
|
|
87
|
-
|
|
85
|
+
### `lime-bundle:loaded`
|
|
88
86
|
|
|
89
|
-
|
|
87
|
+
Fired once the bundle(s) have been fetched and parsed.
|
|
90
88
|
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
fetch("/api/cart-add", { method: "POST", body: JSON.stringify(e.detail.lines) });
|
|
97
|
-
});
|
|
98
|
-
</script>
|
|
89
|
+
```ts
|
|
90
|
+
event.detail: {
|
|
91
|
+
bundleCount: number;
|
|
92
|
+
bundleTypes: Array<"fixed" | "volume" | "mix_match">;
|
|
93
|
+
}
|
|
99
94
|
```
|
|
100
95
|
|
|
101
|
-
|
|
96
|
+
### `lime-bundle:error`
|
|
102
97
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
bundle-gid="..."
|
|
108
|
-
@lime-bundle:add-to-cart="handle"
|
|
109
|
-
/>
|
|
98
|
+
Fired if fetch or parse fails.
|
|
99
|
+
|
|
100
|
+
```ts
|
|
101
|
+
event.detail: { message: string; code: string } // e.g. "LOAD_ERROR"
|
|
110
102
|
```
|
|
111
103
|
|
|
112
|
-
|
|
104
|
+
The widget renders its own inline fallback; listen for this event if you want to hide the parent or report to your own telemetry.
|
|
113
105
|
|
|
114
|
-
|
|
106
|
+
## What the widget handles for you
|
|
115
107
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
108
|
+
- **Merchant styling.** Every `--lb-*` CSS variable the merchant configured in the admin is applied inside the shadow root on render.
|
|
109
|
+
- **Custom CSS.** `shop.metafields["$app"].custom_css` is auto-fetched, sanitized, and injected.
|
|
110
|
+
- **Countdown timer.** When a bundle has `endsAt`, the widget ticks live and hides on expiry.
|
|
111
|
+
- **Variant dropdowns.** Products with multiple eligible variants render a `<select>`; switching live-updates the row price and bundle total.
|
|
112
|
+
- **Mix-match picker modal.** Full modal with search, quantity stepper, progress bar, focus trap, and keyboard navigation.
|
|
113
|
+
- **Out-of-stock handling.** Honours `widgetConfig.outOfStockBehavior` (`hide` vs `show_greyed_out`); hides the widget when the bundle is unfulfillable.
|
|
114
|
+
- **A/B testing.** Reads the merchant's A/B config, buckets the visitor via a first-party cookie, applies Variant B overrides.
|
|
115
|
+
- **Analytics.** Impression and add-to-cart events fire regardless of whether you override the cart.
|
|
124
116
|
|
|
125
117
|
## Styling
|
|
126
118
|
|
|
127
|
-
|
|
119
|
+
Override any CSS custom property on the host element:
|
|
128
120
|
|
|
129
121
|
```html
|
|
130
122
|
<lime-bundle
|
|
131
|
-
style="--lb-primary-color: #e91e63; --lb-radius: 16px;"
|
|
132
123
|
shop-domain="..."
|
|
124
|
+
style="--lb-primary-color: #e91e63; --lb-radius: 16px;"
|
|
133
125
|
></lime-bundle>
|
|
134
126
|
```
|
|
135
127
|
|
|
136
|
-
|
|
128
|
+
Full variable reference: [css-variables.md](./docs/css-variables.md).
|
|
129
|
+
|
|
130
|
+
## Non-React framework snippets
|
|
131
|
+
|
|
132
|
+
**Astro:**
|
|
133
|
+
|
|
134
|
+
```astro
|
|
135
|
+
<lime-bundle shop-domain="..." storefront-token={import.meta.env.PUBLIC_LIME_BUNDLES_TOKEN} />
|
|
136
|
+
<script>
|
|
137
|
+
import "@lime-bundles/widget";
|
|
138
|
+
</script>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
**Vue 3.** Configure `app.config.compilerOptions.isCustomElement = (tag) => tag === "lime-bundle"` to silence the unknown-element warning.
|
|
137
142
|
|
|
138
|
-
|
|
143
|
+
**Svelte.** No configuration needed; use `on:lime-bundle:add-to-cart={handler}`.
|
|
139
144
|
|
|
140
145
|
## Bundle size
|
|
141
146
|
|
|
142
|
-
|
|
147
|
+
IIFE build, gzipped: <30 KB. No runtime framework dependency.
|
|
143
148
|
|
|
144
|
-
##
|
|
149
|
+
## Version policy
|
|
145
150
|
|
|
146
|
-
|
|
151
|
+
All three packages (`core`, `react`, `widget`) bump majors together. The v2.0.0 release closes full rendering parity with the admin preview.
|
|
147
152
|
|
|
148
153
|
## License
|
|
149
154
|
|
|
150
|
-
MIT.
|
|
155
|
+
MIT.
|
|
151
156
|
|
|
152
|
-
##
|
|
157
|
+
## Support
|
|
153
158
|
|
|
154
|
-
|
|
155
|
-
- [Report issues](https://github.com/lime-app-dev/lime-bundles-app/issues)
|
|
159
|
+
Merchant support and bug reports: email via the Lime Bundles listing on the Shopify App Store.
|