@stigg/react-sdk 4.8.0 → 4.9.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/dist/components/paywall/Paywall.d.ts +3 -2
- package/dist/components/paywall/PaywallContainer.d.ts +3 -2
- package/dist/components/paywall/types.d.ts +3 -0
- package/dist/components/paywall/utils/getPlansToDisplay.d.ts +2 -2
- package/dist/react-sdk.cjs.development.js +44 -32
- package/dist/react-sdk.cjs.development.js.map +1 -1
- package/dist/react-sdk.cjs.production.min.js +1 -1
- package/dist/react-sdk.cjs.production.min.js.map +1 -1
- package/dist/react-sdk.esm.js +51 -34
- package/dist/react-sdk.esm.js.map +1 -1
- package/package.json +3 -2
- package/src/components/checkout/summary/CheckoutSuccess.tsx +12 -7
- package/src/components/paywall/Paywall.tsx +4 -2
- package/src/components/paywall/PaywallContainer.tsx +4 -1
- package/src/components/paywall/PlanOffering.tsx +1 -1
- package/src/components/paywall/types.ts +2 -0
- package/src/components/paywall/utils/getPlansToDisplay.ts +10 -4
- package/src/stories/Paywall.stories.tsx +1 -0
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "4.
|
|
2
|
+
"version": "4.9.0",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"lint-fix": "yarn run lint --fix",
|
|
19
19
|
"size": "size-limit",
|
|
20
20
|
"analyze": "size-limit --why",
|
|
21
|
+
"fix:prettier": "prettier \"src/**/*.ts\" --write",
|
|
21
22
|
"storybook": "export NODE_OPTIONS=--openssl-legacy-provider && start-storybook -p 6006",
|
|
22
23
|
"build-storybook": "build-storybook",
|
|
23
24
|
"prepare": "husky install",
|
|
@@ -122,7 +123,7 @@
|
|
|
122
123
|
"moment": "^2.29.4",
|
|
123
124
|
"react-feather": "^2.0.10",
|
|
124
125
|
"react-loading-skeleton": "^3.1.0",
|
|
125
|
-
"react
|
|
126
|
+
"lottie-react": "^2.4.0",
|
|
126
127
|
"react-spinners": "^0.13.3",
|
|
127
128
|
"react-switch": "^7.0.0",
|
|
128
129
|
"styled-components": "^5.3.6",
|
|
@@ -2,7 +2,7 @@ import styled from '@emotion/styled/macro';
|
|
|
2
2
|
import Box from '@mui/material/Box';
|
|
3
3
|
import Color from 'color';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import Lottie from 'react
|
|
5
|
+
import Lottie from 'lottie-react';
|
|
6
6
|
import animationData from '../../../assets/lottie/checkout-success.json';
|
|
7
7
|
import { Typography } from '../../common/Typography';
|
|
8
8
|
import { CheckoutLocalization } from '../configurations/textOverrides';
|
|
@@ -59,15 +59,20 @@ const CheckoutSuccessText = styled(Typography)`
|
|
|
59
59
|
animation: fadeIn 5s ease-in forwards;
|
|
60
60
|
`;
|
|
61
61
|
|
|
62
|
+
const StyledLottie = styled(Lottie)`
|
|
63
|
+
display: flex;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
|
|
66
|
+
svg {
|
|
67
|
+
width: 350px !important;
|
|
68
|
+
height: auto !important;
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
|
|
62
72
|
export function CheckoutSuccess({ checkoutLocalization }: { checkoutLocalization: CheckoutLocalization }) {
|
|
63
73
|
return (
|
|
64
74
|
<CheckoutSuccessContainer className="stigg-checkout-success-container">
|
|
65
|
-
<
|
|
66
|
-
width={350}
|
|
67
|
-
height="auto"
|
|
68
|
-
isClickToPauseDisabled
|
|
69
|
-
options={{ loop: false, autoplay: true, animationData }}
|
|
70
|
-
/>
|
|
75
|
+
<StyledLottie animationData={animationData} loop={false} autoplay />
|
|
71
76
|
<CheckoutSuccessText variant="h1" color="primary.main">
|
|
72
77
|
{checkoutLocalization.summary.checkoutSuccessText}
|
|
73
78
|
</CheckoutSuccessText>
|
|
@@ -4,7 +4,7 @@ import styled from '@emotion/styled/macro';
|
|
|
4
4
|
import { PlanOffering } from './PlanOffering';
|
|
5
5
|
import { BillingPeriodPicker } from './BillingPeriodPicker';
|
|
6
6
|
import { calculatePaywallDiscountRate } from '../utils/calculateDiscountRate';
|
|
7
|
-
import { OnPlanSelectedCallbackFn, PaywallPlan, SubscribeIntentionType } from './types';
|
|
7
|
+
import { ShouldHidePlanFn, OnPlanSelectedCallbackFn, PaywallPlan, SubscribeIntentionType } from './types';
|
|
8
8
|
import { PaywallLocalization } from './paywallTextOverrides';
|
|
9
9
|
import { PoweredByStigg } from '../common/PoweredByStigg';
|
|
10
10
|
import { useStiggContext } from '../..';
|
|
@@ -51,6 +51,7 @@ type PaywallProps = {
|
|
|
51
51
|
onPlanSelected: OnPlanSelectedCallbackFn;
|
|
52
52
|
paywallLocale: PaywallLocalization;
|
|
53
53
|
locale: string;
|
|
54
|
+
shouldHidePlan?: ShouldHidePlanFn;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
export const Paywall = ({
|
|
@@ -65,13 +66,14 @@ export const Paywall = ({
|
|
|
65
66
|
onPlanSelected,
|
|
66
67
|
paywallLocale,
|
|
67
68
|
locale,
|
|
69
|
+
shouldHidePlan,
|
|
68
70
|
}: PaywallProps) => {
|
|
69
71
|
const { stigg } = useStiggContext();
|
|
70
72
|
const discountRate = calculatePaywallDiscountRate(plans);
|
|
71
73
|
const shouldShowDescriptionSection = plans.some((plan) => !!plan.description);
|
|
72
74
|
const hasMonthlyPrice = hasPricePointsForPlans(plans, BillingPeriod.Monthly);
|
|
73
75
|
const hasAnnuallyPrice = hasPricePointsForPlans(plans, BillingPeriod.Annually);
|
|
74
|
-
const plansToShow = getPlansToDisplay(plans, selectedBillingPeriod);
|
|
76
|
+
const plansToShow = getPlansToDisplay(plans, selectedBillingPeriod, shouldHidePlan);
|
|
75
77
|
|
|
76
78
|
const handleOnSubscribe = useCallback(
|
|
77
79
|
(plan: Plan, intentionType: SubscribeIntentionType, billableFeatures: BillableFeature[]) => {
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { BillingPeriod } from '@stigg/js-client-sdk';
|
|
3
3
|
import { Paywall } from './Paywall';
|
|
4
4
|
import { useLoadPaywallData } from './hooks/useLoadPaywallData';
|
|
5
|
-
import { OnPlanSelectedCallbackFn } from './types';
|
|
5
|
+
import { ShouldHidePlanFn, OnPlanSelectedCallbackFn } from './types';
|
|
6
6
|
import { getResolvedPaywallLocalize, PaywallLocalization } from './paywallTextOverrides';
|
|
7
7
|
import { DeepPartial } from '../../types';
|
|
8
8
|
import { PaywallLoader } from './PaywallLoader';
|
|
@@ -23,6 +23,7 @@ export type PaywallContainerProps = {
|
|
|
23
23
|
onBillingPeriodChange?: (billingPeriod: BillingPeriod) => void;
|
|
24
24
|
textOverrides?: DeepPartial<PaywallLocalization>;
|
|
25
25
|
billingCountryCode?: string;
|
|
26
|
+
shouldHidePlan?: ShouldHidePlanFn;
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
export const PaywallContainer = ({
|
|
@@ -35,6 +36,7 @@ export const PaywallContainer = ({
|
|
|
35
36
|
preferredBillingPeriod,
|
|
36
37
|
onBillingPeriodChange,
|
|
37
38
|
billingCountryCode,
|
|
39
|
+
shouldHidePlan,
|
|
38
40
|
}: PaywallContainerProps) => {
|
|
39
41
|
const hasCustomerPortalContext = useCheckContextExists(CustomerPortalContext);
|
|
40
42
|
let isCustomerPortalLoading = false;
|
|
@@ -86,6 +88,7 @@ export const PaywallContainer = ({
|
|
|
86
88
|
onPlanSelected={onPlanSelected}
|
|
87
89
|
paywallLocale={paywallLocale}
|
|
88
90
|
locale={locale}
|
|
91
|
+
shouldHidePlan={shouldHidePlan}
|
|
89
92
|
/>
|
|
90
93
|
);
|
|
91
94
|
|
|
@@ -185,7 +185,7 @@ export function PlanOffering({
|
|
|
185
185
|
|
|
186
186
|
return (
|
|
187
187
|
<PlanOfferingContainer
|
|
188
|
-
className={classNames('stigg-plan-offering-container', {
|
|
188
|
+
className={classNames(`stigg-${plan.id}`, 'stigg-plan-offering-container', {
|
|
189
189
|
'stigg-current-plan': plan.isCurrentCustomerPlan,
|
|
190
190
|
})}
|
|
191
191
|
$isHighlighted={isHighlighted}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { BillingPeriod, PricingType } from '@stigg/js-client-sdk';
|
|
2
|
-
import { PaywallPlan } from '../types';
|
|
2
|
+
import { ShouldHidePlanFn, PaywallPlan } from '../types';
|
|
3
3
|
import { hasPricePoints } from './hasPricePoints';
|
|
4
4
|
|
|
5
|
-
export function getPlansToDisplay(
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
export function getPlansToDisplay(
|
|
6
|
+
plans: PaywallPlan[],
|
|
7
|
+
selectedBillingPeriod: BillingPeriod,
|
|
8
|
+
shouldHidePlan?: ShouldHidePlanFn,
|
|
9
|
+
): PaywallPlan[] {
|
|
10
|
+
return plans
|
|
11
|
+
.filter((plan) => plan.pricingType !== PricingType.Paid || hasPricePoints(plan, selectedBillingPeriod))
|
|
12
|
+
.filter((plan) => !shouldHidePlan || !shouldHidePlan({ plan }));
|
|
13
|
+
}
|