@stigg/react-sdk 4.3.1 → 4.4.0-beta.1

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 (187) hide show
  1. package/README.md +1 -1
  2. package/dist/components/checkout/Checkout.d.ts +5 -0
  3. package/dist/components/checkout/CheckoutContainer.d.ts +22 -0
  4. package/dist/components/checkout/CheckoutContainer.style.d.ts +26 -0
  5. package/dist/components/checkout/CheckoutProvider.d.ts +34 -0
  6. package/dist/components/checkout/components/Button.d.ts +8 -0
  7. package/dist/components/checkout/components/ContentLoadingSkeleton.d.ts +2 -0
  8. package/dist/components/checkout/components/InputField.d.ts +8 -0
  9. package/dist/components/checkout/components/Skeletons.style.d.ts +97 -0
  10. package/dist/components/checkout/components/index.d.ts +3 -0
  11. package/dist/components/checkout/formatting.d.ts +2 -0
  12. package/dist/components/checkout/hooks/index.d.ts +8 -0
  13. package/dist/components/checkout/hooks/useAddonsStepModel.d.ts +21 -0
  14. package/dist/components/checkout/hooks/useCheckoutModel.d.ts +10 -0
  15. package/dist/components/checkout/hooks/useCouponModel.d.ts +7 -0
  16. package/dist/components/checkout/hooks/useLoadCheckout.d.ts +11 -0
  17. package/dist/components/checkout/hooks/usePaymentStepModel.d.ts +16 -0
  18. package/dist/components/checkout/hooks/usePlanStepModel.d.ts +23 -0
  19. package/dist/components/checkout/hooks/usePreviewSubscription.d.ts +13 -0
  20. package/dist/components/checkout/hooks/useProgressBarModel.d.ts +26 -0
  21. package/dist/components/checkout/hooks/useSubscriptionModel.d.ts +5 -0
  22. package/dist/components/checkout/hooks/useSubscriptionState.d.ts +2 -0
  23. package/dist/components/checkout/index.d.ts +3 -0
  24. package/dist/components/checkout/planHeader/PlanHeader.d.ts +7 -0
  25. package/dist/components/checkout/planHeader/PlanHeader.style.d.ts +25 -0
  26. package/dist/components/checkout/planHeader/index.d.ts +1 -0
  27. package/dist/components/checkout/progressBar/CheckoutProgressBar.d.ts +2 -0
  28. package/dist/components/checkout/progressBar/CheckoutProgressBar.style.d.ts +48 -0
  29. package/dist/components/checkout/promotionCode/AddPromotionCode.d.ts +5 -0
  30. package/dist/components/checkout/promotionCode/AddPromotionCodeButton.d.ts +7 -0
  31. package/dist/components/checkout/promotionCode/AppliedPromotionCode.d.ts +6 -0
  32. package/dist/components/checkout/promotionCode/PromotionCodeSection.d.ts +5 -0
  33. package/dist/components/checkout/promotionCode/index.d.ts +1 -0
  34. package/dist/components/checkout/steps/addons/CheckoutAddonsStep.d.ts +2 -0
  35. package/dist/components/checkout/steps/addons/CheckoutAddonsStep.style.d.ts +93 -0
  36. package/dist/components/checkout/steps/addons/addon.utils.d.ts +15 -0
  37. package/dist/components/checkout/steps/addons/index.d.ts +1 -0
  38. package/dist/components/checkout/steps/payment/PaymentMethods.d.ts +20 -0
  39. package/dist/components/checkout/steps/payment/PaymentMethods.style.d.ts +117 -0
  40. package/dist/components/checkout/steps/payment/PaymentStep.d.ts +2 -0
  41. package/dist/components/checkout/steps/payment/index.d.ts +1 -0
  42. package/dist/components/checkout/steps/payment/stripe/StripePaymentForm.d.ts +2 -0
  43. package/dist/components/checkout/steps/payment/stripe/index.d.ts +3 -0
  44. package/dist/components/checkout/steps/payment/stripe/stripe.utils.d.ts +33 -0
  45. package/dist/components/checkout/steps/payment/stripe/useStripeIntegration.d.ts +5 -0
  46. package/dist/components/checkout/steps/payment/stripe/useSubmit.d.ts +13 -0
  47. package/dist/components/checkout/steps/plan/BillingPeriodPicker.d.ts +9 -0
  48. package/dist/components/checkout/steps/plan/BillingPeriodPicker.style.d.ts +52 -0
  49. package/dist/components/checkout/steps/plan/CheckoutChargeList.d.ts +16 -0
  50. package/dist/components/checkout/steps/plan/CheckoutPlanStep.d.ts +2 -0
  51. package/dist/components/checkout/steps/plan/CheckoutPlanStep.style.d.ts +12 -0
  52. package/dist/components/checkout/steps/plan/index.d.ts +1 -0
  53. package/dist/components/checkout/steps/surprise/SurpriseStep.d.ts +2 -0
  54. package/dist/components/checkout/summary/CheckoutSuccess.d.ts +3 -0
  55. package/dist/components/checkout/summary/CheckoutSummary.d.ts +16 -0
  56. package/dist/components/checkout/summary/CheckoutSummarySkeleton.d.ts +2 -0
  57. package/dist/components/checkout/summary/components/CheckoutCaptions.d.ts +11 -0
  58. package/dist/components/checkout/summary/components/LineItems.d.ts +36 -0
  59. package/dist/components/checkout/summary/components/WithSkeleton.d.ts +6 -0
  60. package/dist/components/checkout/summary/index.d.ts +2 -0
  61. package/dist/components/checkout/textOverrides.d.ts +32 -0
  62. package/dist/components/checkout/theme.d.ts +12 -0
  63. package/dist/components/common/Icon.d.ts +3 -2
  64. package/dist/components/common/PoweredByStigg.d.ts +1 -1
  65. package/dist/components/{paywall/TiersLayout.d.ts → common/TiersSelectContainer.d.ts} +2 -3
  66. package/dist/components/common/customIcons.d.ts +19 -5
  67. package/dist/components/common/mapExternalTheme.d.ts +2 -1
  68. package/dist/components/customerPortal/subscriptionOverview/subscriptionView/SubscriptionView.style.d.ts +1 -1
  69. package/dist/components/customerPortal/subscriptionOverview/tabs/SubscriptionTabs.d.ts +1 -1
  70. package/dist/components/hooks/useChargeSort.d.ts +3 -0
  71. package/dist/components/paywall/paywallTextOverrides.d.ts +0 -4
  72. package/dist/components/utils/calculateDiscountRate.d.ts +1 -0
  73. package/dist/components/utils/currencyUtils.d.ts +1 -1
  74. package/dist/components/utils/getPaidPriceText.d.ts +1 -3
  75. package/dist/components/{paywall/planPriceTier.d.ts → utils/priceTierUtils.d.ts} +3 -1
  76. package/dist/components/utils/priceUtils.d.ts +2 -0
  77. package/dist/index.d.ts +1 -0
  78. package/dist/react-sdk.cjs.development.js +6935 -238
  79. package/dist/react-sdk.cjs.development.js.map +1 -1
  80. package/dist/react-sdk.cjs.production.min.js +1 -1
  81. package/dist/react-sdk.cjs.production.min.js.map +1 -1
  82. package/dist/react-sdk.esm.js +7094 -242
  83. package/dist/react-sdk.esm.js.map +1 -1
  84. package/dist/stories/Checkout.stories.d.ts +3 -0
  85. package/dist/stories/CustomerPortal.stories.d.ts +1 -1
  86. package/dist/theme/getResolvedTheme.d.ts +4 -0
  87. package/dist/theme/types.d.ts +4 -0
  88. package/package.json +11 -5
  89. package/src/assets/arrow-forward.svg +3 -0
  90. package/src/assets/arrow-right.svg +6 -0
  91. package/src/assets/check.svg +5 -0
  92. package/src/assets/close.svg +3 -0
  93. package/src/assets/lottie/checkout-success.json +1 -0
  94. package/src/assets/nyancat.svg +634 -0
  95. package/src/assets/outlined-checked-circle-disabled.svg +6 -0
  96. package/src/assets/outlined-checked-circle.svg +6 -0
  97. package/src/assets/outlined-circle.svg +3 -0
  98. package/src/assets/payment-method.svg +11 -0
  99. package/src/assets/plus-icon.svg +6 -0
  100. package/src/assets/trash.svg +8 -0
  101. package/src/components/checkout/Checkout.tsx +30 -0
  102. package/src/components/checkout/CheckoutContainer.style.ts +35 -0
  103. package/src/components/checkout/CheckoutContainer.tsx +99 -0
  104. package/src/components/checkout/CheckoutProvider.tsx +149 -0
  105. package/src/components/checkout/components/Button.tsx +51 -0
  106. package/src/components/checkout/components/ContentLoadingSkeleton.tsx +41 -0
  107. package/src/components/checkout/components/InputField.tsx +22 -0
  108. package/src/components/checkout/components/Skeletons.style.ts +27 -0
  109. package/src/components/checkout/components/index.ts +3 -0
  110. package/src/components/checkout/formatting.ts +12 -0
  111. package/src/components/checkout/hooks/index.ts +8 -0
  112. package/src/components/checkout/hooks/useAddonsStepModel.ts +96 -0
  113. package/src/components/checkout/hooks/useCheckoutModel.ts +32 -0
  114. package/src/components/checkout/hooks/useCouponModel.ts +28 -0
  115. package/src/components/checkout/hooks/useLoadCheckout.ts +39 -0
  116. package/src/components/checkout/hooks/usePaymentStepModel.ts +49 -0
  117. package/src/components/checkout/hooks/usePlanStepModel.ts +169 -0
  118. package/src/components/checkout/hooks/usePreviewSubscription.ts +82 -0
  119. package/src/components/checkout/hooks/useProgressBarModel.ts +89 -0
  120. package/src/components/checkout/hooks/useSubscriptionModel.ts +16 -0
  121. package/src/components/checkout/hooks/useSubscriptionState.ts +26 -0
  122. package/src/components/checkout/index.ts +3 -0
  123. package/src/components/checkout/planHeader/PlanHeader.style.tsx +23 -0
  124. package/src/components/checkout/planHeader/PlanHeader.tsx +59 -0
  125. package/src/components/checkout/planHeader/index.ts +1 -0
  126. package/src/components/checkout/progressBar/CheckoutProgressBar.style.ts +34 -0
  127. package/src/components/checkout/progressBar/CheckoutProgressBar.tsx +53 -0
  128. package/src/components/checkout/promotionCode/AddPromotionCode.tsx +85 -0
  129. package/src/components/checkout/promotionCode/AddPromotionCodeButton.tsx +39 -0
  130. package/src/components/checkout/promotionCode/AppliedPromotionCode.tsx +37 -0
  131. package/src/components/checkout/promotionCode/PromotionCodeSection.tsx +27 -0
  132. package/src/components/checkout/promotionCode/index.ts +1 -0
  133. package/src/components/checkout/steps/addons/CheckoutAddonsStep.style.tsx +24 -0
  134. package/src/components/checkout/steps/addons/CheckoutAddonsStep.tsx +125 -0
  135. package/src/components/checkout/steps/addons/addon.utils.ts +68 -0
  136. package/src/components/checkout/steps/addons/index.ts +1 -0
  137. package/src/components/checkout/steps/payment/PaymentMethods.style.ts +26 -0
  138. package/src/components/checkout/steps/payment/PaymentMethods.tsx +86 -0
  139. package/src/components/checkout/steps/payment/PaymentStep.tsx +50 -0
  140. package/src/components/checkout/steps/payment/index.ts +1 -0
  141. package/src/components/checkout/steps/payment/stripe/StripePaymentForm.tsx +45 -0
  142. package/src/components/checkout/steps/payment/stripe/index.ts +3 -0
  143. package/src/components/checkout/steps/payment/stripe/stripe.utils.ts +109 -0
  144. package/src/components/checkout/steps/payment/stripe/useStripeIntegration.ts +27 -0
  145. package/src/components/checkout/steps/payment/stripe/useSubmit.ts +104 -0
  146. package/src/components/checkout/steps/plan/BillingPeriodPicker.style.tsx +46 -0
  147. package/src/components/checkout/steps/plan/BillingPeriodPicker.tsx +63 -0
  148. package/src/components/checkout/steps/plan/CheckoutChargeList.tsx +138 -0
  149. package/src/components/checkout/steps/plan/CheckoutPlanStep.style.tsx +6 -0
  150. package/src/components/checkout/steps/plan/CheckoutPlanStep.tsx +20 -0
  151. package/src/components/checkout/steps/plan/index.ts +1 -0
  152. package/src/components/checkout/steps/surprise/SurpriseStep.tsx +27 -0
  153. package/src/components/checkout/summary/CheckoutSuccess.tsx +30 -0
  154. package/src/components/checkout/summary/CheckoutSummary.tsx +288 -0
  155. package/src/components/checkout/summary/CheckoutSummarySkeleton.tsx +40 -0
  156. package/src/components/checkout/summary/components/CheckoutCaptions.tsx +120 -0
  157. package/src/components/checkout/summary/components/LineItems.tsx +177 -0
  158. package/src/components/checkout/summary/components/WithSkeleton.tsx +16 -0
  159. package/src/components/checkout/summary/index.ts +2 -0
  160. package/src/components/checkout/textOverrides.ts +62 -0
  161. package/src/components/checkout/theme.ts +43 -0
  162. package/src/components/common/Icon.tsx +17 -22
  163. package/src/components/common/PoweredByStigg.tsx +1 -1
  164. package/src/components/{paywall/TiersLayout.tsx → common/TiersSelectContainer.tsx} +8 -7
  165. package/src/components/common/Typography.tsx +11 -1
  166. package/src/components/common/customIcons.ts +19 -28
  167. package/src/components/common/mapExternalTheme.ts +29 -9
  168. package/src/components/customerPortal/subscriptionOverview/tabs/SubscriptionTabs.tsx +6 -12
  169. package/src/components/hooks/useChargeSort.ts +17 -0
  170. package/src/components/paywall/Paywall.tsx +1 -1
  171. package/src/components/paywall/PlanOffering.tsx +1 -1
  172. package/src/components/paywall/PlanOfferingButton.tsx +1 -1
  173. package/src/components/paywall/PlanPrice.tsx +5 -13
  174. package/src/components/paywall/paywallTextOverrides.ts +0 -3
  175. package/src/components/paywall/utils/calculateUnitQuantityText.ts +9 -4
  176. package/src/components/utils/calculateDiscountRate.ts +1 -1
  177. package/src/components/utils/currencyUtils.ts +1 -1
  178. package/src/components/utils/getPaidPriceText.ts +4 -10
  179. package/src/components/utils/getPlanPrice.ts +1 -1
  180. package/src/components/{paywall/planPriceTier.ts → utils/priceTierUtils.ts} +25 -3
  181. package/src/components/utils/priceUtils.ts +10 -0
  182. package/src/index.ts +1 -0
  183. package/src/stories/Checkout.stories.tsx +62 -0
  184. package/src/stories/CustomerPortal.stories.tsx +1 -1
  185. package/src/theme/Theme.tsx +6 -6
  186. package/src/theme/getResolvedTheme.ts +7 -1
  187. package/src/theme/types.ts +4 -0
@@ -7,8 +7,7 @@ import {
7
7
  } from '@stigg/js-client-sdk';
8
8
  import { currencyPriceFormatter } from './currencyUtils';
9
9
  import { PlanPriceText } from './getPlanPrice';
10
- import { calculateTierPrice } from '../paywall/planPriceTier';
11
- import { PaywallLocalization } from '../paywall';
10
+ import { calculateTierPrice, getPriceFeatureUnit } from './priceTierUtils';
12
11
 
13
12
  type GetPaidPriceTextParams = {
14
13
  planPrices: Price[];
@@ -17,7 +16,6 @@ type GetPaidPriceTextParams = {
17
16
  locale: string;
18
17
  shouldShowMonthlyPriceAmount: boolean;
19
18
  selectedTierByFeature: Record<string, PriceTierFragment>;
20
- paywallLocale: PaywallLocalization;
21
19
  };
22
20
 
23
21
  export function getPaidPriceText({
@@ -27,7 +25,6 @@ export function getPaidPriceText({
27
25
  locale,
28
26
  shouldShowMonthlyPriceAmount,
29
27
  selectedTierByFeature,
30
- paywallLocale,
31
28
  }: GetPaidPriceTextParams): PlanPriceText {
32
29
  const { amount, currency } = paywallCalculatedPrice || planPrices[0];
33
30
  const priceAmount = amount || 0;
@@ -38,10 +35,7 @@ export function getPaidPriceText({
38
35
 
39
36
  let tiers;
40
37
  let tierUnits;
41
- const pricePeriod = paywallLocale.price.pricePeriod(
42
- shouldShowMonthlyPriceAmount ? BillingPeriod.Monthly : BillingPeriod.Annually,
43
- );
44
- let unit = pricePeriod;
38
+ let unit = shouldShowMonthlyPriceAmount ? '/ month' : '/ year';
45
39
 
46
40
  for (const price of planPrices) {
47
41
  if (price.isTieredPrice) {
@@ -50,7 +44,7 @@ export function getPaidPriceText({
50
44
  currentTier = selectedTierByFeature[price.feature!.featureId] || currentTier;
51
45
 
52
46
  tiers = price.tiers;
53
- tierUnits = price.feature!.unitsPlural || '';
47
+ tierUnits = getPriceFeatureUnit(price);
54
48
  }
55
49
 
56
50
  priceNumber += calculateTierPrice(price, currentTier, selectedBillingPeriod, shouldShowMonthlyPriceAmount);
@@ -62,7 +56,7 @@ export function getPaidPriceText({
62
56
  const featureUnit = price.feature?.units || '';
63
57
 
64
58
  if (price.pricingModel === BillingModel.PerUnit && !price.isTieredPrice) {
65
- unit = shouldShowMonthlyPriceAmount ? `per ${featureUnit} ${pricePeriod}` : `per ${featureUnit} ${pricePeriod}`;
59
+ unit = shouldShowMonthlyPriceAmount ? `per ${featureUnit} / month` : `per ${featureUnit} / year`;
66
60
  } else if (price.pricingModel === BillingModel.UsageBased) {
67
61
  unit = `per ${featureUnit}`;
68
62
  }
@@ -50,7 +50,7 @@ export function getPlanPrice(
50
50
 
51
51
  return paywallLocale.price.paid
52
52
  ? paywallLocale.price.paid({ ...paidParams, plan })
53
- : getPaidPriceText({ ...paidParams, locale, shouldShowMonthlyPriceAmount, paywallLocale });
53
+ : getPaidPriceText({ ...paidParams, locale, shouldShowMonthlyPriceAmount });
54
54
  }
55
55
  default:
56
56
  return {
@@ -1,7 +1,30 @@
1
- import { PaywallPlan } from './types';
1
+ import { PaywallPlan } from '../paywall/types';
2
2
 
3
3
  import { BillingModel, TiersMode, BillingPeriod, Price, PriceTierFragment, Subscription } from '@stigg/js-client-sdk';
4
4
 
5
+ export function getPriceFeatureUnit(price: Price) {
6
+ if (!price.feature) {
7
+ return '';
8
+ }
9
+
10
+ return (price.feature!.unitQuantity != 1 ? price.feature!.unitsPlural : price.feature!.units) || '';
11
+ }
12
+
13
+ export function getTierByQuantity(tiers: PriceTierFragment[], quantity: number) {
14
+ if (!tiers) return;
15
+
16
+ const ascendingTiers = [...tiers];
17
+ ascendingTiers.sort((a, b) => a.upTo - b.upTo);
18
+
19
+ for (const tier of ascendingTiers) {
20
+ if (quantity <= tier.upTo) {
21
+ return tier;
22
+ }
23
+ }
24
+
25
+ return ascendingTiers[ascendingTiers.length - 1];
26
+ }
27
+
5
28
  export function calculateTierPrice(
6
29
  price: Price,
7
30
  currentTier: PriceTierFragment,
@@ -46,8 +69,7 @@ export function getSelectedTier(
46
69
  );
47
70
 
48
71
  if (tieredPrice) {
49
- const customerTier = price.tiers!.find(tier => tier.upTo === tieredPrice.feature!.unitQuantity);
50
- currentTier = customerTier || price.tiers![0];
72
+ currentTier = getTierByQuantity(price.tiers!, tieredPrice.feature!.unitQuantity || 1)!;
51
73
  }
52
74
  }
53
75
 
@@ -0,0 +1,10 @@
1
+ import { Price } from '@stigg/js-client-sdk';
2
+
3
+ export const getValidPriceQuantity = (price: Price, quantity: number) => {
4
+ if (price.minUnitQuantity && quantity < price.minUnitQuantity) {
5
+ return price.minUnitQuantity;
6
+ } else if (price.maxUnitQuantity && quantity > price.maxUnitQuantity) {
7
+ return price.maxUnitQuantity;
8
+ }
9
+ return quantity;
10
+ };
package/src/index.ts CHANGED
@@ -29,6 +29,7 @@ export {
29
29
  StiggContextValue,
30
30
  StiggContext,
31
31
  } from './components/StiggProvider';
32
+ export { Checkout, CheckoutProps, CheckoutTheme } from './components/checkout';
32
33
  export { useWaitForCheckoutCompleted, ProvisionStatus } from './components/hooks';
33
34
  export { HorizontalAlignment, TextAlignment } from './theme/types';
34
35
  export { CustomizedTheme as Theme } from './theme/Theme';
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import styled from '@emotion/styled/macro';
3
+ import { ComponentMeta, ComponentStory } from '@storybook/react';
4
+ import { Checkout } from '../components/checkout';
5
+ import { StiggProvider } from '../components/StiggProvider';
6
+ import { defaultArgsWithCustomer } from './baseArgs';
7
+
8
+ export default {
9
+ title: 'Stigg React SDK/Checkout',
10
+ component: Checkout,
11
+ decorators: [
12
+ (Story, { args }) => (
13
+ <StiggProvider
14
+ apiKey={args.apiKey}
15
+ customerId={args.customerId}
16
+ theme={args.theme}
17
+ locale={args.locale}
18
+ baseUri={args.baseUri}
19
+ enableEdge={args.disableEdge}>
20
+ <Story />
21
+ </StiggProvider>
22
+ ),
23
+ ],
24
+ } as ComponentMeta<typeof Checkout>;
25
+
26
+ const Wrapper = styled.div`
27
+ width: 1000px;
28
+ `;
29
+
30
+ const Template: ComponentStory<any> = (args) => (
31
+ <Wrapper>
32
+ <Checkout
33
+ planId={args.planId}
34
+ preferredBillingPeriod={args.preferredBillingPeriod}
35
+ billingCountryCode={args.billingCountryCode}
36
+ resourceId={args.resourceId}
37
+ onCheckoutCompleted={(results) => {
38
+ console.log('checkout finished!', results);
39
+ return Promise.resolve();
40
+ }}
41
+ onCheckout={async ({ checkoutParams, checkoutAction }) => {
42
+ console.log('checkout started!', checkoutParams);
43
+ const { success, errorMessage } = await checkoutAction();
44
+ return { success, errorMessage };
45
+ }}
46
+ onChangePlan={({ currentPlan }) => {
47
+ console.log('plan changed clicked!', { currentPlan });
48
+ }}
49
+ billingInformation={{ taxPercentage: 27 }}
50
+ />
51
+ </Wrapper>
52
+ );
53
+
54
+ export const DefaultCheckout = Template.bind({});
55
+ DefaultCheckout.args = {
56
+ ...defaultArgsWithCustomer,
57
+ planId: 'plan-revvenu-essentials',
58
+ baseUri: 'http://localhost:4000',
59
+ apiKey: 'client-72b058a6-0f22-4c86-adce-bf266d12e12e:9f356ceb-c94c-42a4-9572-10b12824da81',
60
+ // baseUri: 'https://api-staging.stigg.io',
61
+ // apiKey: 'client-79584f52-7ef9-4c58-b9ac-5080acf492e4:71f2274c-100a-4fa4-8a43-48fa3b16c627',
62
+ };
@@ -38,7 +38,7 @@ export default {
38
38
  </StiggProvider>
39
39
  ),
40
40
  ],
41
- } as ComponentMeta<typeof Paywall>;
41
+ } as ComponentMeta<typeof CustomerPortal>;
42
42
 
43
43
  const Wrapper = styled.div`
44
44
  width: 1000px;
@@ -1,15 +1,15 @@
1
+ import { merge } from 'lodash';
1
2
  import React, { PropsWithChildren } from 'react';
3
+ import { ThemeProvider as StyledThemeProvider } from 'styled-components';
2
4
  import { TypographyProps } from 'styled-typography';
3
5
  import { css, ThemeProvider } from '@emotion/react';
4
6
  import styled from '@emotion/styled/macro';
5
- import { ThemeProvider as MuiThemeProvider, createTheme } from '@mui/material/styles';
6
- import { ThemeProvider as StyledThemeProvider } from 'styled-components';
7
- import { merge } from 'lodash';
8
- import { Fonts } from './Fonts';
9
- import { DeepPartial } from '../types';
10
- import { StiggTheme } from './types';
7
+ import { createTheme, ThemeProvider as MuiThemeProvider } from '@mui/material/styles';
11
8
  import { useStiggContext } from '../components/StiggProvider';
9
+ import { DeepPartial } from '../types';
10
+ import { Fonts } from './Fonts';
12
11
  import { getResolvedTheme } from './getResolvedTheme';
12
+ import { StiggTheme } from './types';
13
13
 
14
14
  export type CustomizedTheme = DeepPartial<StiggTheme>;
15
15
 
@@ -14,10 +14,13 @@ export const flexLayoutMapper = (horizontalAlignment: HorizontalAlignment) => {
14
14
  export const getResolvedTheme = (customizedTheme?: CustomizedTheme): StiggTheme => {
15
15
  const primaryColor = Color(customizedTheme?.palette?.primary || '#327EEE');
16
16
  const textColor = Color(customizedTheme?.palette?.text?.primary || '#001E6C');
17
+ const successColor = Color('#4CAF50');
18
+ const errorColor = Color('#f44336');
17
19
 
18
20
  const baseTheme: StiggTheme = {
19
21
  palette: {
20
22
  primary: primaryColor.hex(),
23
+ primaryDark: primaryColor.darken(0.3).hex(),
21
24
  backgroundPaper: '#FFFFFF',
22
25
  backgroundHighlight: '#F5F6F9',
23
26
  backgroundSection: primaryColor.alpha(0.1).toString(),
@@ -29,7 +32,10 @@ export const getResolvedTheme = (customizedTheme?: CustomizedTheme): StiggTheme
29
32
  switchFill: primaryColor.lighten(0.5).hex(),
30
33
  switchHandle: primaryColor.hex(),
31
34
  warning: '#ed6c02',
32
- error: '#f44336',
35
+ error: errorColor.hex(),
36
+ errorDark: errorColor.darken(0.3).hex(),
37
+ success: successColor.hex(),
38
+ successDark: successColor.darken(0.3).hex(),
33
39
  white: '#FFFFFF',
34
40
  text: {
35
41
  primary: textColor.hex(),
@@ -8,6 +8,7 @@ export type FontVariant = {
8
8
  export type StiggTheme = {
9
9
  palette: {
10
10
  primary: string;
11
+ primaryDark: string;
11
12
  backgroundPaper: string;
12
13
  backgroundHighlight: string;
13
14
  backgroundSection: string;
@@ -20,7 +21,10 @@ export type StiggTheme = {
20
21
  switchHandle: string;
21
22
  warning: string;
22
23
  error: string;
24
+ errorDark: string;
23
25
  white: string;
26
+ success: string;
27
+ successDark: string;
24
28
  text: {
25
29
  primary: string;
26
30
  secondary: string;