Skip to content

Commit 8d15cc1

Browse files
committed
Remove dependency on App Bridge React and update components and navigation patterns
1 parent 9ff867b commit 8d15cc1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+60
-1980
lines changed

.changeset/light-gifts-relate.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@shopify/discount-app-components': major
3+
---
4+
5+
Support App Bridge React V4
6+
7+
- Remove dependency on App Bridge React V4.
8+
- Update readme to explain how to use discount-app-components with App Bridge React V4.
9+
- Removed navigation utilities included in this library in favor of App Bridge React patterns to be used in App.
10+
- Updated the CombinationCard to remove the ability to open the DiscountCombinationModal. This is no longer supported in App Bridge React.
11+
- Removed HelpText component.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ node_modules
77
.idea
88
.vscode/*
99
coverage
10+
yalc.lock

README.md

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![npm Package Version](https://img.shields.io/npm/v/@shopify/discount-app-components)](https://www.npmjs.com/package/@shopify/discount-app-components)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)
55

6-
`@shopify/discount-app-components` provides a set of stateless discount components to help 3p app developers create [AppBridge](https://shopify.dev/apps/tools/app-bridge)-powered discounts apps.
6+
`@shopify/discount-app-components` provides a set of stateless discount components to help 3p app developers create discounts apps.
77

88
## Note on updates
99

@@ -31,7 +31,7 @@ If you prefer [Yarn](https://yarnpkg.com/en/), use the following command instead
3131
yarn add @shopify/discount-app-components
3232
```
3333

34-
> 🛑 The project has `peerDependencies` of `@shopify/app-bridge`, `@shopify/app-bridge-react`, and `@shopify/polaris` which must also be installed in your app.
34+
> 🛑 The project has `peerDependencies` of `@shopify/app-bridge`, and `@shopify/polaris` which must also be installed in your app.
3535
3636
### Usage
3737

@@ -55,12 +55,11 @@ yarn add @shopify/discount-app-components
5555
/>
5656
```
5757

58-
2. This library contains a number of locale-specific components, and you will be required to pass a `locale` and a `ianaTimezone` to the discounts AppProvider. Also, this library will require you to wrap your app in a [Polaris AppProvider](https://polaris.shopify.com/components/utilities/app-provider) and an [AppBridge AppProvider](https://shopify.dev/apps/tools/app-bridge/getting-started/using-react#provider). A full example of an app root can be found below:
58+
2. This library contains a number of locale-specific components, and you will be required to pass a `locale` and a `ianaTimezone` to the discounts AppProvider.
5959

6060
```js
6161
import {Page, AppProvider as PolarisAppProvider} from '@shopify/polaris';
62-
import {Provider as AppBridgeProvider} from '@shopify/app-bridge-react';
63-
import {AppProvider} from '@shopify/discount-app-components';
62+
import {AppProvider as DiscountsProvider} from '@shopify/discount-app-components';
6463
6564
// See [Polaris AppProvider documentation](https://github.com/Shopify/polaris/blob/main/polaris-react/src/components/AppProvider/README.md#using-translations) for more details on using Polaris translations
6665
import enPolarisTranslations from '@shopify/polaris/locales/en.json';
@@ -76,39 +75,20 @@ yarn add @shopify/discount-app-components
7675
...
7776
7877
return (
79-
<AppBridgeProvider config={/* pass your app bridge config here */}>
8078
<PolarisAppProvider i18n={enPolarisTranslations}>
8179
{/* discount-app-component specific AppProvider */}
82-
<AppProvider locale="en-US" ianaTimezone="America/Los_Angeles">
80+
<DiscountsProvider locale="en-US" ianaTimezone="America/Los_Angeles">
8381
<Page title="Example app">
8482
{/* Add your discount components here */}
8583
</Page>
86-
</AppProvider>
84+
</DiscountsProvider>
8785
</PolarisAppProvider>
88-
</AppBridgeProvider>
8986
);
9087
}
9188
```
9289

9390
_**Note**: you may need to rename the discounts AppProvider to avoid clashing with another AppProvider component:_
9491

95-
```js
96-
import {AppProvider as DiscountAppComponentsProvider} from '@shopify/discount-app-components';
97-
```
98-
99-
_And in your app root:_
100-
101-
```js
102-
<DiscountAppComponentsProvider
103-
locale="en-US"
104-
ianaTimezone="America/Los_Angeles"
105-
>
106-
<Page title="Example app">{/* Add your discount components here */}</Page>
107-
</DiscountAppComponentsProvider>
108-
```
109-
110-
---
111-
11292
## Development
11393

11494
### Testing local changes in a consuming project

locales/cs.json

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -81,64 +81,6 @@
8181
"shippingLabel": "Slevy na dopravu"
8282
},
8383
"newBadge": "Nové",
84-
"HelpText": {
85-
"emptyState": {
86-
"product": {
87-
"title": "Nejsou nastaveny žádné slevy na produkty, které by bylo možné kombinovat.",
88-
"warning": {
89-
"withproduct": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na produkt, kterou bude možné kombinovat se slevami na produkty.",
90-
"withorder": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na produkt, kterou bude možné kombinovat se slevami na objednávku.",
91-
"withshipping": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na produkt, kterou bude možné kombinovat se slevami na dopravu."
92-
}
93-
},
94-
"order": {
95-
"title": "Nejsou nastaveny žádné slevy na objednávku, které by bylo možné kombinovat.",
96-
"warning": {
97-
"withproduct": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na objednávku, kterou bude možné kombinovat se slevami na produkty.",
98-
"withorder": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na objednávku, kterou bude možné kombinovat se slevami na objednávky.",
99-
"withshipping": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na objednávku, kterou bude možné kombinovat se slevami na dopravu."
100-
}
101-
},
102-
"shipping": {
103-
"title": "Nejsou nastaveny žádné slevy na dopravu, které by bylo možné kombinovat.",
104-
"warning": {
105-
"withproduct": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na dopravu, kterou bude možné kombinovat se slevami na produkty.",
106-
"withorder": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na dopravu, kterou bude možné kombinovat se slevami na objednávku.",
107-
"withshipping": "Pokud chcete zákazníkům umožnit uplatnění více než jedné slevy, nastavte alespoň jednu slevu na dopravu, kterou bude možné kombinovat se slevami na dopravu."
108-
}
109-
},
110-
"link": "Zjistit více"
111-
},
112-
"combinations": {
113-
"counts": {
114-
"product": {
115-
"one": "{count} slevu na produkt",
116-
"other": "{count} slev(y) na produkty",
117-
"few": "{count} slev(y) na produkty",
118-
"many": "{count} slev(y) na produkty"
119-
},
120-
"order": {
121-
"one": "{count} slevu na objednávku",
122-
"other": "{count} slev(y) na objednávku",
123-
"few": "{count} slev(y) na objednávku",
124-
"many": "{count} slev(y) na objednávku"
125-
},
126-
"shipping": {
127-
"one": "{count} slevu na dopravu",
128-
"other": "{count} slev(y) na dopravu",
129-
"few": "{count} slev(y) na dopravu",
130-
"many": "{count} slev(y) na dopravu"
131-
}
132-
},
133-
"info": {
134-
"one": "Je nastavena {discountCountLink}, kterou je možné kombinovat.",
135-
"other": "Jsou nastaveny {discountCountLink}, které je možné kombinovat.",
136-
"few": "Jsou nastaveny {discountCountLink}, které je možné kombinovat.",
137-
"many": "Jsou nastaveny {discountCountLink}, které je možné kombinovat."
138-
},
139-
"multipleEligibleDiscounts": "Pokud se na položku vztahuje více slev, uplatní se pouze ta nejvyšší."
140-
}
141-
},
14284
"discountClass": {
14385
"product": "produkt",
14486
"order": "objednávku",

locales/da.json

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -81,56 +81,6 @@
8181
"shippingLabel": "Leveringsrabatter"
8282
},
8383
"newBadge": "Ny",
84-
"HelpText": {
85-
"emptyState": {
86-
"product": {
87-
"title": "Ingen produktrabatter er indstillet til at blive kombineret.",
88-
"warning": {
89-
"withproduct": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én produktrabat, der kan kombineres med produktrabatter.",
90-
"withorder": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én produktrabat, der kan kombineres med ordrerabatter.",
91-
"withshipping": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én produktrabat, der kan kombineres med leveringsrabatter."
92-
}
93-
},
94-
"order": {
95-
"title": "Ingen bestillingsrabatter er indstillet til at blive kombineret.",
96-
"warning": {
97-
"withproduct": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én ordrerabat, der kan kombineres med produktrabatter.",
98-
"withorder": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én ordrerabat, der kan kombineres med ordrerabatter.",
99-
"withshipping": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én ordrerabat, der kan kombineres med leveringsrabatter."
100-
}
101-
},
102-
"shipping": {
103-
"title": "Ingen forsendelsesrabatter er indstillet til at blive kombineret.",
104-
"warning": {
105-
"withproduct": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én leveringsrabat, der kan kombineres med produktrabatter.",
106-
"withorder": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én leveringsrabat, der kan kombineres med ordrerabatter.",
107-
"withshipping": "Hvis du vil give dine kunder mulighed for at bruge mere end én rabat, skal du opsætte mindst én leveringsrabat, der kan kombineres med leveringsrabatter."
108-
}
109-
},
110-
"link": "Få mere at vide"
111-
},
112-
"combinations": {
113-
"counts": {
114-
"product": {
115-
"one": "{count} produktrabat",
116-
"other": "{count} produktrabatter"
117-
},
118-
"order": {
119-
"one": "{count} ordrerabat",
120-
"other": "{count} ordrerabatter"
121-
},
122-
"shipping": {
123-
"one": "{count} leveringsrabat",
124-
"other": "{count} leveringsrabatter"
125-
}
126-
},
127-
"info": {
128-
"one": "{discountCountLink} er indstillet til at blive kombineret.",
129-
"other": "{discountCountLink} er indstillet til at blive kombineret."
130-
},
131-
"multipleEligibleDiscounts": "Hvis en vare er kvalificeret til flere rabatter, anvendes kun den største rabat."
132-
}
133-
},
13484
"discountClass": {
13585
"product": "produkt",
13686
"order": "ordre",

locales/de.json

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -81,56 +81,6 @@
8181
"shippingLabel": "Versandrabatte"
8282
},
8383
"newBadge": "Neu",
84-
"HelpText": {
85-
"emptyState": {
86-
"product": {
87-
"title": "Es wurden keine kombinierbaren Produktrabatte eingerichtet.",
88-
"warning": {
89-
"withproduct": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Produktrabatt fest, der mit Produktrabatten kombinierbar ist.",
90-
"withorder": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Produktrabatt fest, der mit Bestellrabatten kombinierbar ist.",
91-
"withshipping": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Produktrabatt fest, der mit Versandrabatten kombinierbar ist."
92-
}
93-
},
94-
"order": {
95-
"title": "Es wurden keine kombinierbaren Bestellrabatte eingerichtet.",
96-
"warning": {
97-
"withproduct": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Bestellrabatt fest, der mit Produktrabatten kombinierbar ist.",
98-
"withorder": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Bestellrabatt fest, der mit Bestellrabatten kombinierbar ist.",
99-
"withshipping": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Bestellrabatt fest, der mit Versandrabatten kombinierbar ist."
100-
}
101-
},
102-
"shipping": {
103-
"title": "Es wurden keine kombinierbaren Versandrabatte eingerichtet.",
104-
"warning": {
105-
"withproduct": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Versandrabatt fest, der mit Produktrabatten kombinierbar ist.",
106-
"withorder": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Versandrabatt fest, der mit Bestellrabatten kombinierbar ist.",
107-
"withshipping": "Damit Kunden mehr als einen Rabatt nutzen können, lege mindestens einen Versandrabatt fest, der mit Versandrabatten kombinierbar ist."
108-
}
109-
},
110-
"link": "Weitere Informationen"
111-
},
112-
"combinations": {
113-
"counts": {
114-
"product": {
115-
"one": "{count} Produktrabatt",
116-
"other": "{count} Produktrabatte"
117-
},
118-
"order": {
119-
"one": "{count} Bestellrabatt",
120-
"other": "{count} Bestellrabatte"
121-
},
122-
"shipping": {
123-
"one": "{count} Versandrabatt",
124-
"other": "{count} Versandrabatte"
125-
}
126-
},
127-
"info": {
128-
"one": "{discountCountLink} ist kombinierbar.",
129-
"other": "{discountCountLink} sind kombinierbar."
130-
},
131-
"multipleEligibleDiscounts": "Wenn ein Artikel für mehrere Rabatte qualifiziert ist, wird nur der höchste Rabatt angewendet."
132-
}
133-
},
13484
"discountClass": {
13585
"product": "Produkt",
13686
"order": "Bestellung",

locales/en.json

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -117,56 +117,6 @@
117117
"title": "Some combinations can result in large discounts",
118118
"description": "Test a few combinations. If the total discount is too large, adjust which discounts can combine.",
119119
"link": "Learn more"
120-
},
121-
"HelpText": {
122-
"emptyState": {
123-
"product": {
124-
"title": "No product discounts are set to combine.",
125-
"warning": {
126-
"withproduct": "To let customers use more than one discount, set up at least one product discount that combines with product discounts.",
127-
"withorder": "To let customers use more than one discount, set up at least one product discount that combines with order discounts.",
128-
"withshipping": "To let customers use more than one discount, set up at least one product discount that combines with shipping discounts."
129-
}
130-
},
131-
"order": {
132-
"title": "No order discounts are set to combine.",
133-
"warning": {
134-
"withproduct": "To let customers use more than one discount, set up at least one order discount that combines with product discounts.",
135-
"withorder": "To let customers use more than one discount, set up at least one order discount that combines with order discounts.",
136-
"withshipping": "To let customers use more than one discount, set up at least one order discount that combines with shipping discounts."
137-
}
138-
},
139-
"shipping": {
140-
"title": "No shipping discounts are set to combine.",
141-
"warning": {
142-
"withproduct": "To let customers use more than one discount, set up at least one shipping discount that combines with product discounts.",
143-
"withorder": "To let customers use more than one discount, set up at least one shipping discount that combines with order discounts.",
144-
"withshipping": "To let customers use more than one discount, set up at least one shipping discount that combines with shipping discounts."
145-
}
146-
},
147-
"link": "Learn more"
148-
},
149-
"combinations": {
150-
"info": {
151-
"one": "{discountCountLink} is set to combine.",
152-
"other": "{discountCountLink} are set to combine."
153-
},
154-
"multipleEligibleDiscounts": "If an item is eligible for multiple discounts, only the largest will apply.",
155-
"counts": {
156-
"product": {
157-
"one": "{count} product discount",
158-
"other": "{count} product discounts"
159-
},
160-
"order": {
161-
"one": "{count} order discount",
162-
"other": "{count} order discounts"
163-
},
164-
"shipping": {
165-
"one": "{count} shipping discount",
166-
"other": "{count} shipping discounts"
167-
}
168-
}
169-
}
170120
}
171121
},
172122
"AppliesToCard": {

0 commit comments

Comments
 (0)