ui.shipaid.com 0.2.11 → 0.2.13-beta
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 +47 -12
- package/dist/widget.es.js +295 -247
- package/dist/widget.iife.js +139 -130
- package/dist/widget.umd.js +139 -130
- package/dist-types/src/components/learn-more-popup.d.ts +8 -0
- package/dist-types/src/components/learn-more-styles.d.ts +2 -0
- package/dist-types/src/shipaid-widget.d.ts +4 -0
- package/package.json +9 -9
package/README.md
CHANGED
|
@@ -33,14 +33,53 @@ Then add the widget element where needed:
|
|
|
33
33
|
|
|
34
34
|
<!-- With customised text -->
|
|
35
35
|
<shipaid-widget>
|
|
36
|
-
<p>Loading ShipAid Protection</p>
|
|
36
|
+
<p slot="loading">Loading ShipAid Protection</p>
|
|
37
|
+
</shipaid-widget>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Test Mode
|
|
41
|
+
|
|
42
|
+
Sometimes, a store won't have activated their subscription before you install the widget - in this case, the widget does not display (you will notice a message in the console reflecting this). So to force the widget to show while you are installing and testing it, you can add this query param to the page URL: `shipaid-test`.
|
|
43
|
+
For example: `https://some-store.myshopify.com/cart?shipaid-text`
|
|
44
|
+
|
|
45
|
+
### Slots
|
|
46
|
+
|
|
47
|
+
Slots, with the syntax `slot="<slot name>"`, can be used to customise the widgets content - for example, a merchant may want to add a custom subtitle, which can be done like so:
|
|
48
|
+
```html
|
|
49
|
+
<shipaid-widget>
|
|
50
|
+
<p slot="subtitle">Shipping protection is required to be able to return or refunds items.</p>
|
|
37
51
|
</shipaid-widget>
|
|
38
52
|
```
|
|
39
53
|
|
|
54
|
+
The default content will be replaced by any slot content. You can also add inline styles to the slots, if you need to change the text color for example:
|
|
55
|
+
```html
|
|
56
|
+
<span slot="title" style="color: white; font-weight: 500;">Package Protection</span>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
| Name | Description |
|
|
60
|
+
|--------|-------------|
|
|
61
|
+
| `loading` | Replaces the text that is shown whilst the widget is loading - I.e. fetching content from the Shopify or ShipAid API's. |
|
|
62
|
+
| `title` | Replaces the default title. |
|
|
63
|
+
| `subtitle` | Replaces the default subtitle. |
|
|
64
|
+
|
|
65
|
+
### Props
|
|
66
|
+
|
|
67
|
+
This is a list of props that can be used to configure the widget:
|
|
68
|
+
|
|
69
|
+
| Prop | Description | Value/Type |
|
|
70
|
+
|--------|-------------|---------|
|
|
71
|
+
| `disablePolling` | Sets whether the cart should disable polling (enabled by default) - should be disabled if integrating manually with an ajax cart. | `boolean` |
|
|
72
|
+
| `pollingInterval` | If polling is enabled, it sets the interval (in ms) between API updates. | `number` in milliseconds |
|
|
73
|
+
| `disableRefresh ` | Sets whether the store cart should be updated when the protection item is added/removed. Add if you want to initially hide the protection product from the cart, even if it has just been added. | `boolean` |
|
|
40
74
|
|
|
41
75
|
### Events
|
|
42
76
|
|
|
43
|
-
This is a list of the events emitted by the widget:
|
|
77
|
+
This is a list of the events emitted by the widget. You can listen to these events like so:
|
|
78
|
+
```js
|
|
79
|
+
document.addEventListener('shipaid-protection-status', ({ detail }) => {
|
|
80
|
+
console.log(detail.cart) // ShopifyCart
|
|
81
|
+
})
|
|
82
|
+
```
|
|
44
83
|
|
|
45
84
|
| Event | Description | Payload |
|
|
46
85
|
|-------|-------------|---------|
|
|
@@ -49,7 +88,12 @@ This is a list of the events emitted by the widget:
|
|
|
49
88
|
|
|
50
89
|
### Methods
|
|
51
90
|
|
|
52
|
-
This is a list of public methods that can be used to change protection settings:
|
|
91
|
+
This is a list of public methods available on the widget HTMLElement that can be used to change protection settings. These can be used by querying the element:
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
const shipAidEl = document.querySelector('shipaid-widget')
|
|
95
|
+
if (shipAidEl) await shipAidEl.updateCart()
|
|
96
|
+
```
|
|
53
97
|
|
|
54
98
|
| Method | Description | Payload |
|
|
55
99
|
|--------|-------------|---------|
|
|
@@ -58,15 +102,6 @@ This is a list of public methods that can be used to change protection settings:
|
|
|
58
102
|
| `addProtection` | Adds the relevant protection item to cart. | |
|
|
59
103
|
| `removeProtection` | Removes the protection item from the cart. | |
|
|
60
104
|
|
|
61
|
-
### Props
|
|
62
|
-
|
|
63
|
-
This is a list of props that can be used to configure the widget:
|
|
64
|
-
|
|
65
|
-
| Prop | Description | Value/Type |
|
|
66
|
-
|--------|-------------|---------|
|
|
67
|
-
| `disablePolling` | Sets whether the cart should disable polling (enabled by default) - should be disabled if integrating manually with an ajax cart. | `boolean` |
|
|
68
|
-
| `pollingInterval` | If polling is enabled, it sets the interval (in ms) between API updates. | `number` in milliseconds |
|
|
69
|
-
| `disableRefresh ` | Sets whether the store cart should be updated when the protection item is added/removed. Add if you want to initially hide the protection product from the cart, even if it has just been added. | `boolean` |
|
|
70
105
|
|
|
71
106
|
## Contributing
|
|
72
107
|
|