ui.shipaid.com 0.3.67 → 0.3.69

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.
Files changed (28) hide show
  1. package/README.md +202 -200
  2. package/dist/widget.es.js +11 -6
  3. package/dist/widget.iife.js +17 -12
  4. package/dist/widget.umd.js +17 -12
  5. package/dist-types/common/shopify/index.d.ts +6 -6
  6. package/dist-types/common/shopify/protection.d.ts +7 -7
  7. package/dist-types/common/shopify/types/ShopifyCart.d.ts +29 -29
  8. package/dist-types/common/shopify/types/ShopifyProduct.d.ts +12 -12
  9. package/dist-types/common/types/ShipAid.d.ts +82 -82
  10. package/dist-types/widget/src/assets/confirmation-styles.d.ts +2 -2
  11. package/dist-types/widget/src/assets/icons.d.ts +9 -9
  12. package/dist-types/widget/src/assets/learn-more-styles.d.ts +2 -2
  13. package/dist-types/widget/src/assets/styles.d.ts +2 -2
  14. package/dist-types/widget/src/components/checkout-button.d.ts +7 -0
  15. package/dist-types/widget/src/components/checkout-package-protection.d.ts +13 -13
  16. package/dist-types/widget/src/components/checkoutButton.d.ts +13 -0
  17. package/dist-types/widget/src/components/confirmation-popup.d.ts +9 -9
  18. package/dist-types/widget/src/components/content-loader.d.ts +6 -0
  19. package/dist-types/widget/src/components/learn-more-popup.d.ts +8 -8
  20. package/dist-types/widget/src/components/shipaid-cart-confirmation.d.ts +15 -15
  21. package/dist-types/widget/src/shipaid-widget.d.ts +145 -145
  22. package/dist-types/widget/src/utils/fetch_interceptor.d.ts +3 -3
  23. package/dist-types/widget/src/utils/fetch_interceptor.test.d.ts +1 -1
  24. package/dist-types/widget/types/shipaid.d.ts +10 -10
  25. package/dist-types/widget/types/shopify.d.ts +29 -29
  26. package/dist-types/widget/types/widget.d.ts +13 -13
  27. package/package.json +48 -48
  28. package/dist-types/widget/src/components/product-add-confirmation.d.ts +0 -13
package/README.md CHANGED
@@ -1,200 +1,202 @@
1
- # ShipAid Shopify Widget
2
-
3
- This is the repository for the ShipAid Shopify (and possibly others in future) widget. It uses the [Lit](https://lit.dev/) web components library, so it is recommended to become familiar with it before contributing to this repository.
4
-
5
- Using Lit provides a framework that allows us to build a reactive UI, using JSX-like syntax - no need to use JQuery etc. And it can easily be installed in a page by using the custom web component name:
6
- ```html
7
- <shipaid-widget>Fallback Content</shipaid-widget>
8
- ```
9
-
10
- ## Overview
11
-
12
- This widget provides an interface where a user can choose to add or remove ShipAid protection - this is actually a product in their store that can be added to cart. When the component is loaded, we immediately run a request to fetch the ShipAid protection product details from our API, as well as the customers current cart from the [Shopify AJAX API](https://shopify.dev/api/ajax/reference/cart).
13
- Once we have this data, we can check whether the customer currently has the ShipAid product in their cart, and show either the add or remove product buttons based on this.
14
-
15
- We also emit various [custom events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events#adding_custom_data_%E2%80%93_customevent) when we add or remove the ShipAid product from the cart, so other developers can listen to these events, and update AJAX carts.
16
-
17
- ### Installation
18
-
19
- Add the script tag to the theme - if the theme has an ajax cart, you'll likely want to add this to the `theme.liquid` file, otherwise if the store has only a cart page (`/cart`), then you can add it to just that page, to save it being unecessarily loaded when it isn't needed.
20
- As we don't want to affect a stores speed at all, you should add it to the bottom of the page just before the ending body tag (`</body>`), rather than inside the `<head>` block.
21
-
22
- ```html
23
- <!-- ShipAid Widget -->
24
- <script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
25
- ```
26
- Then add the widget element where needed:
27
-
28
- ```html
29
- <shipaid-widget></shipaid-widget>
30
-
31
- <!-- Disable polling example -->
32
- <shipaid-widget disablePolling></shipaid-widget>
33
-
34
- <!-- With customised text -->
35
- <shipaid-widget>
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>
51
- </shipaid-widget>
52
- ```
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 font size/weight for example - but color changes should be handled by CSS variables:
55
- ```html
56
- <span slot="title" style="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` |
74
- | `customerId ` | Passes the information of the customer to the widget. Add if merchant wants to disable auto opt-in for some customers based on the customer tags. | `boolean` |
75
- | `lang ` | Sets the widget language (see the translations section below). This value can be any supported [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). | `string` defaults to `en` |
76
- | `refreshCart` | Refresh the page if shipaid product quantity is greater than one to sync product qty at checkout | `boolean` |
77
- | `persistPopup` | Use local storage to show popup so that popup don't re-render on script refresh | `boolean` |
78
-
79
- ### Events
80
-
81
- This is a list of the events emitted by the widget. You can listen to these events like so:
82
- ```js
83
- document.addEventListener('shipaid-protection-status', ({ detail }) => {
84
- console.log(detail.cart) // ShopifyCart
85
- })
86
- ```
87
-
88
- | Event | Description | Payload |
89
- |-------|-------------|---------|
90
- | `shipaid-loaded` | Dispatched when the widget has finished fetching data from the API, and has successfully rendered. | Contains the data from the ShipAid API: [`ShipAidStore`](/types/shipaid.ts) |
91
- | `shipaid-protection-status` | Dispatched when a user either adds or removes the protection product from their cart. | `{ protection: boolean, cart: ShopifyCart, lineItem: ShopifyCartItem }` |
92
-
93
- ### Methods
94
-
95
- 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:
96
-
97
- ```js
98
- const shipAidEl = document.querySelector('shipaid-widget')
99
- if (shipAidEl) await shipAidEl.updateCart()
100
- ```
101
-
102
- | Method | Description | Payload |
103
- |--------|-------------|---------|
104
- | `hasProtection` | Returns a boolean which indicates whether the protection item is currently in the cart. | |
105
- | `updateCart` | Updates the internal cart, and triggers any protection product updates - use this method with with ajax carts, to update protection state without needing to reload the page. | Optional - the cart object from the ajax API. |
106
- | `addProtection` | Adds the relevant protection item to cart. | |
107
- | `removeProtection` | Removes the protection item from the cart. | |
108
-
109
- ### Styles
110
-
111
- If you need to change any of the widget colors to suit a specific theme, there are various CSS variables you can use to do so. These should be added to the style attribute on the widget element:
112
-
113
- ```html
114
- <shipaid-widget
115
- style="
116
- --shipaid-text: #fff;
117
- --shipaid-prompt-actions-price-color: #fff;
118
- "
119
- >
120
- </shipaid-widget>
121
- ```
122
-
123
- | Variable | Description | Default |
124
- |----------|-------------|---------|
125
- | `--shipaid-text` | Changes the global text color. | `#000000` |
126
- | `--shipaid-text-muted` | Changes the global muted text color. | `#aaaaaa` |
127
- | `--shipaid-prompt-margin` | Changes the margins of the main container element. | `2rem 0px 4rem auto` |
128
- | `--shipaid-prompt-width` | Changes the width of the main container element. | `400px` |
129
- | `--shipaid-prompt-width-mobile` | Changes the mobile width of the main container element. | `100%` |
130
- | `--shipaid-prompt-actions-price-color` | Changes the color of the price element. | `var(--shipaid-text-muted)` |
131
- | `--shipaid-prompt-actions-button-color` | Changes the color of the add/remove button element. | `var(--shipaid-primary)` |
132
- | `--shipaid-prompt-badge-background-color` | Changes the background color of the learn more button element. | `var(--shipaid-light-grey)` |
133
- | `--shipaid-prompt-badge-text-color` | Changes the color of the learn more button element. | `var(--shipaid-text)` |
134
- | `--shipaid-logo-height` | Changes the height of ShipAid logo. | `var(--shipaid-logo-height, 35px)` |
135
- | `--shipaid-logo-max-height` | Changes the max height of ShipAid logo. | `var(--shipaid-logo-max-height, 35px)` |
136
- | `--shipaid-logo-width` | Changes the width of ShipAid logo. | `var(--shipaid-logo-width, auto)` |
137
- | `--shipaid-logo-max-width` | Changes the max width of ShipAid logo. | `var(--shipaid-logo-max-width, 50px)` |
138
- | `--shipaid-prompt-footer-button-size` | Changes the height of info button in footer. | `var(--shipaid-prompt-footer-button-size, 10px)` |
139
- | `--shipaid-prompt-badge-border-radius` | Changes border radius of footer | `var(--shipaid-prompt-badge-border-radius, 30px)` |
140
- | `--shipaid-footer-badge-logo-height` | Changes the height of logo in footer. | `var(--shipaid-footer-badge-logo-height, 9px)` |
141
- | `--shipaid-prompt-footer-location` | Changes the position of footer badge | `var(--shipaid-prompt-footer-location, flex-start)` |
142
- | `--shipaid-prompt-product-actions-content` | Changes the spaces between price and add/remove button | `var(--shipaid-prompt-product-actions-content, space-between)` |
143
- | `--shipaid-prompt-footer-topMargin` | Changes margin between header and badge footer | `var(--shipaid-prompt-footer-topMargin, 0px)` |
144
- | `-shipaid-prompt-footer-display` | Changes the display option for footer | `var(-shipaid-prompt-footer-display, flex)` |
145
-
146
- Other variables can be found [here](/widget/src/assets/styles.ts) (`/widget/src/assets/styles.ts`).
147
-
148
- ### Translations
149
-
150
- This widget also supports multiple languages, using the `lit-translate` plugin. The widget language can be configured using an attribute and would usally be static, but supports reactively swapping the language if a theme needs - i.e. if a user switches the language using a select option in the theme, then the widget language could be updated at the same time by selecting the widget element, and setting the `lang` attribute.
151
-
152
- To create lang files, you should copy the default `/lang/en.json` file, and rename it to an [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) - for example `cp /src/lang/en.json /src/lang/fs.json`. You can then go through each key, and translate the existing text to the relevant language. This should be all you need to do - the widget automatically (and lazily, to save bundle size) imports the relevant lang file when it is specified. It will also fallback to the default `en.json` lang file if a certain language doesn't exist yet.
153
-
154
-
155
- ## Contributing
156
-
157
- ### Requirements
158
-
159
- - Node v16+
160
- - PNPM
161
- - Development Shopify store (with the ShipAid app installed)
162
- - ShipAid API development/staging instance
163
-
164
- ### Development
165
-
166
- You will need to make sure your development store has the ShipAid app installed, so the store and its protection product is added to the DB. You will also need to ensure the Shopify app you are testing this with has an app proxy added, and pointed towards an API instance.
167
-
168
- ```sh
169
- pnpm install
170
- pnpm run develop
171
- ```
172
-
173
- Once the project is running, add the below to your development Shopify store `theme.liquid`:
174
-
175
- ```html
176
- <!-- Dev -->
177
- <script src="http://localhost:3000/src/shipaid-widget.ts"type="module" ></script>
178
-
179
- <!-- Prod -->
180
- <!-- ShipAid Widget -->
181
- <script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
182
- ```
183
- And add the widget element where needed:
184
-
185
- ```html
186
- <shipaid-widget>
187
- <p>Loading ShipAid Protection</p>
188
- </shipaid-widget>
189
- ```
190
-
191
- ### Build
192
-
193
- Once the project has been built, you can publish the project to NPM, and users can add the script to their store using a package CDN (I.e. [Unpkg](https://unpkg.com/)).
194
-
195
- ```sh
196
- pnpm install
197
- pnpm run lint
198
- pnpm run build
199
- pnpm publish
200
- ```
1
+ # ShipAid Shopify Widget
2
+
3
+ This is the repository for the ShipAid Shopify (and possibly others in future) widget. It uses the [Lit](https://lit.dev/) web components library, so it is recommended to become familiar with it before contributing to this repository.
4
+
5
+ Using Lit provides a framework that allows us to build a reactive UI, using JSX-like syntax - no need to use JQuery etc. And it can easily be installed in a page by using the custom web component name:
6
+ ```html
7
+ <shipaid-widget>Fallback Content</shipaid-widget>
8
+ ```
9
+
10
+ ## Overview
11
+
12
+ This widget provides an interface where a user can choose to add or remove ShipAid protection - this is actually a product in their store that can be added to cart. When the component is loaded, we immediately run a request to fetch the ShipAid protection product details from our API, as well as the customers current cart from the [Shopify AJAX API](https://shopify.dev/api/ajax/reference/cart).
13
+ Once we have this data, we can check whether the customer currently has the ShipAid product in their cart, and show either the add or remove product buttons based on this.
14
+
15
+ We also emit various [custom events](https://developer.mozilla.org/en-US/docs/Web/Events/Creating_and_triggering_events#adding_custom_data_%E2%80%93_customevent) when we add or remove the ShipAid product from the cart, so other developers can listen to these events, and update AJAX carts.
16
+
17
+ ### Installation
18
+
19
+ Add the script tag to the theme - if the theme has an ajax cart, you'll likely want to add this to the `theme.liquid` file, otherwise if the store has only a cart page (`/cart`), then you can add it to just that page, to save it being unecessarily loaded when it isn't needed.
20
+ As we don't want to affect a stores speed at all, you should add it to the bottom of the page just before the ending body tag (`</body>`), rather than inside the `<head>` block.
21
+
22
+ ```html
23
+ <!-- ShipAid Widget -->
24
+ <script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
25
+ ```
26
+ Then add the widget element where needed:
27
+
28
+ ```html
29
+ <shipaid-widget></shipaid-widget>
30
+
31
+ <!-- Disable polling example -->
32
+ <shipaid-widget disablePolling></shipaid-widget>
33
+
34
+ <!-- With customised text -->
35
+ <shipaid-widget>
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>
51
+ </shipaid-widget>
52
+ ```
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 font size/weight for example - but color changes should be handled by CSS variables:
55
+ ```html
56
+ <span slot="title" style="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` |
74
+ | `customerId ` | Passes the information of the customer to the widget. Add if merchant wants to disable auto opt-in for some customers based on the customer tags. | `boolean` |
75
+ | `lang ` | Sets the widget language (see the translations section below). This value can be any supported [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes). | `string` defaults to `en` |
76
+ | `refreshCart` | Refresh the page if shipaid product quantity is greater than one to sync product qty at checkout | `boolean` |
77
+ | `persistPopup` | Use local storage to show popup so that popup don't re-render on script refresh | `boolean` |
78
+
79
+ ### Events
80
+
81
+ This is a list of the events emitted by the widget. You can listen to these events like so:
82
+ ```js
83
+ document.addEventListener('shipaid-protection-status', ({ detail }) => {
84
+ console.log(detail.cart) // ShopifyCart
85
+ })
86
+ ```
87
+
88
+ | Event | Description | Payload |
89
+ |-------|-------------|---------|
90
+ | `shipaid-loaded` | Dispatched when the widget has finished fetching data from the API, and has successfully rendered. | Contains the data from the ShipAid API: [`ShipAidStore`](/types/shipaid.ts) |
91
+ | `shipaid-protection-status` | Dispatched when a user either adds or removes the protection product from their cart. | `{ protection: boolean, cart: ShopifyCart, lineItem: ShopifyCartItem }` |
92
+
93
+ ### Methods
94
+
95
+ 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:
96
+
97
+ ```js
98
+ const shipAidEl = document.querySelector('shipaid-widget')
99
+ if (shipAidEl) await shipAidEl.updateCart()
100
+ ```
101
+
102
+ | Method | Description | Payload |
103
+ |--------|-------------|---------|
104
+ | `hasProtection` | Returns a boolean which indicates whether the protection item is currently in the cart. | |
105
+ | `updateCart` | Updates the internal cart, and triggers any protection product updates - use this method with with ajax carts, to update protection state without needing to reload the page. | Optional - the cart object from the ajax API. |
106
+ | `addProtection` | Adds the relevant protection item to cart. | |
107
+ | `removeProtection` | Removes the protection item from the cart. | |
108
+
109
+ ### Styles
110
+
111
+ If you need to change any of the widget colors to suit a specific theme, there are various CSS variables you can use to do so. These should be added to the style attribute on the widget element:
112
+
113
+ ```html
114
+ <shipaid-widget
115
+ style="
116
+ --shipaid-text: #fff;
117
+ --shipaid-prompt-actions-price-color: #fff;
118
+ "
119
+ >
120
+ </shipaid-widget>
121
+ ```
122
+
123
+ | Variable | Description | Default |
124
+ |----------|-------------|---------|
125
+ | `--shipaid-text` | Changes the global text color. | `#000000` |
126
+ | `--shipaid-text-muted` | Changes the global muted text color. | `#aaaaaa` |
127
+ | `--shipaid-prompt-margin` | Changes the margins of the main container element. | `2rem 0px 4rem auto` |
128
+ | `--shipaid-prompt-width` | Changes the width of the main container element. | `400px` |
129
+ | `--shipaid-prompt-width-mobile` | Changes the mobile width of the main container element. | `100%` |
130
+ | `--shipaid-prompt-actions-price-color` | Changes the color of the price element. | `var(--shipaid-text-muted)` |
131
+ | `--shipaid-prompt-actions-button-color` | Changes the color of the add/remove button element. | `var(--shipaid-primary)` |
132
+ | `--shipaid-prompt-badge-background-color` | Changes the background color of the learn more button element. | `var(--shipaid-light-grey)` |
133
+ | `--shipaid-prompt-badge-text-color` | Changes the color of the learn more button element. | `var(--shipaid-text)` |
134
+ | `--shipaid-logo-height` | Changes the height of ShipAid logo. | `var(--shipaid-logo-height, 35px)` |
135
+ | `--shipaid-logo-max-height` | Changes the max height of ShipAid logo. | `var(--shipaid-logo-max-height, 35px)` |
136
+ | `--shipaid-logo-width` | Changes the width of ShipAid logo. | `var(--shipaid-logo-width, auto)` |
137
+ | `--shipaid-logo-max-width` | Changes the max width of ShipAid logo. | `var(--shipaid-logo-max-width, 50px)` |
138
+ | `--shipaid-prompt-footer-button-size` | Changes the height of info button in footer. | `var(--shipaid-prompt-footer-button-size, 10px)` |
139
+ | `--shipaid-prompt-badge-border-radius` | Changes border radius of footer | `var(--shipaid-prompt-badge-border-radius, 30px)` |
140
+ | `--shipaid-footer-badge-logo-height` | Changes the height of logo in footer. | `var(--shipaid-footer-badge-logo-height, 9px)` |
141
+ | `--shipaid-prompt-footer-location` | Changes the position of footer badge | `var(--shipaid-prompt-footer-location, flex-start)` |
142
+ | `--shipaid-prompt-product-actions-content` | Changes the spaces between price and add/remove button | `var(--shipaid-prompt-product-actions-content, space-between)` |
143
+ | `--shipaid-prompt-footer-topMargin` | Changes margin between header and badge footer | `var(--shipaid-prompt-footer-topMargin, 0px)` |
144
+ | `-shipaid-prompt-footer-display` | Changes the display option for footer | `var(-shipaid-prompt-footer-display, flex)` |
145
+ | `--shipaid-active-logo-color` | Changes the logo color when the product is in the cart | `#000000` |
146
+ | `--shipaid-inactive-logo-color` | Changes the logo color when the product isn't in the cart | `#0056d6` |
147
+
148
+ Other variables can be found [here](/widget/src/assets/styles.ts) (`/widget/src/assets/styles.ts`).
149
+
150
+ ### Translations
151
+
152
+ This widget also supports multiple languages, using the `lit-translate` plugin. The widget language can be configured using an attribute and would usally be static, but supports reactively swapping the language if a theme needs - i.e. if a user switches the language using a select option in the theme, then the widget language could be updated at the same time by selecting the widget element, and setting the `lang` attribute.
153
+
154
+ To create lang files, you should copy the default `/lang/en.json` file, and rename it to an [ISO 639-1 code](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) - for example `cp /src/lang/en.json /src/lang/fs.json`. You can then go through each key, and translate the existing text to the relevant language. This should be all you need to do - the widget automatically (and lazily, to save bundle size) imports the relevant lang file when it is specified. It will also fallback to the default `en.json` lang file if a certain language doesn't exist yet.
155
+
156
+
157
+ ## Contributing
158
+
159
+ ### Requirements
160
+
161
+ - Node v16+
162
+ - PNPM
163
+ - Development Shopify store (with the ShipAid app installed)
164
+ - ShipAid API development/staging instance
165
+
166
+ ### Development
167
+
168
+ You will need to make sure your development store has the ShipAid app installed, so the store and its protection product is added to the DB. You will also need to ensure the Shopify app you are testing this with has an app proxy added, and pointed towards an API instance.
169
+
170
+ ```sh
171
+ pnpm install
172
+ pnpm run develop
173
+ ```
174
+
175
+ Once the project is running, add the below to your development Shopify store `theme.liquid`:
176
+
177
+ ```html
178
+ <!-- Dev -->
179
+ <script src="http://localhost:3000/src/shipaid-widget.ts"type="module" ></script>
180
+
181
+ <!-- Prod -->
182
+ <!-- ShipAid Widget -->
183
+ <script src="https://unpkg.com/ui.shipaid.com/dist/widget.es.js" type="module"></script>
184
+ ```
185
+ And add the widget element where needed:
186
+
187
+ ```html
188
+ <shipaid-widget>
189
+ <p>Loading ShipAid Protection</p>
190
+ </shipaid-widget>
191
+ ```
192
+
193
+ ### Build
194
+
195
+ Once the project has been built, you can publish the project to NPM, and users can add the script to their store using a package CDN (I.e. [Unpkg](https://unpkg.com/)).
196
+
197
+ ```sh
198
+ pnpm install
199
+ pnpm run lint
200
+ pnpm run build
201
+ pnpm publish
202
+ ```
package/dist/widget.es.js CHANGED
@@ -1128,7 +1128,7 @@ const CheckmarkIcon = x`
1128
1128
  >
1129
1129
  <g
1130
1130
  transform="translate(0.000000,500.000000) scale(0.100000,-0.100000)"
1131
- fill="#0056d6"
1131
+ fill="var(--shipaid-inactive-logo-color)"
1132
1132
  stroke="none"
1133
1133
  >
1134
1134
  <path
@@ -1150,7 +1150,7 @@ const ShipAidLogo = x`
1150
1150
  >
1151
1151
  <g
1152
1152
  transform="translate(0.000000,500.000000) scale(0.100000,-0.100000)"
1153
- fill="#000000"
1153
+ fill="var(--shipaid-active-logo-color)"
1154
1154
  stroke="none"
1155
1155
  >
1156
1156
  <path
@@ -2999,7 +2999,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
2999
2999
  display: flex;
3000
3000
  align-items: center;
3001
3001
  justify-content: space-between;
3002
- font-size: 14px;
3002
+ font-size: calc(0.1rem + 0.334vw);
3003
3003
  margin-bottom: 1rem;
3004
3004
  }
3005
3005
  .protection-text {
@@ -3008,9 +3008,8 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3008
3008
  align-items: center;
3009
3009
  gap: 0.5rem;
3010
3010
  }
3011
-
3012
3011
  .protection-text p {
3013
- font-size: 1.3rem;
3012
+ margin: 0px;
3014
3013
  }
3015
3014
  .help-icon {
3016
3015
  cursor: pointer;
@@ -3130,7 +3129,7 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3130
3129
  display: flex;
3131
3130
  align-items: center;
3132
3131
  justify-content: space-between;
3133
- font-size: 14px;
3132
+ font-size: calc(0.1rem + 0.334vw);
3134
3133
  margin-bottom: 1rem;
3135
3134
  }
3136
3135
 
@@ -3142,6 +3141,10 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3142
3141
  font-size: 1.3rem;
3143
3142
  }
3144
3143
 
3144
+ .protection-text p {
3145
+ margin: 0px;
3146
+ }
3147
+
3145
3148
  .help-icon {
3146
3149
  cursor: pointer;
3147
3150
  opacity: 0.7;
@@ -3599,6 +3602,8 @@ const _ShipAidWidget = class _ShipAidWidget extends s$1 {
3599
3602
  --shipaid-font-heavy: 700;
3600
3603
  --shipaid-prompt-badge: #f2f7ff;
3601
3604
  width: 100%;
3605
+ --shipaid-active-logo-color: #000000;
3606
+ --shipaid-inactive-logo-color: #0056d6;
3602
3607
  }
3603
3608
 
3604
3609
  * {