@automattic/plans-grid-next 1.0.0 → 1.0.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.
- package/dist/cjs/__mocks__/wpcom-proxy-request.js +3 -4
- package/dist/cjs/__mocks__/wpcom-proxy-request.js.map +1 -1
- package/dist/cjs/_shared.scss +9 -4
- package/dist/cjs/components/comparison-grid/index.js +18 -29
- package/dist/cjs/components/comparison-grid/index.js.map +1 -1
- package/dist/cjs/components/comparison-grid/index.stories.js +1 -0
- package/dist/cjs/components/comparison-grid/index.stories.js.map +1 -1
- package/dist/cjs/components/comparison-grid/style.scss +0 -17
- package/dist/cjs/components/dropdown-option.js +1 -1
- package/dist/cjs/components/features-grid/index.js +21 -6
- package/dist/cjs/components/features-grid/index.js.map +1 -1
- package/dist/cjs/components/features-grid/index.stories.js +1 -0
- package/dist/cjs/components/features-grid/index.stories.js.map +1 -1
- package/dist/cjs/components/features-grid/style.scss +2 -19
- package/dist/cjs/components/item.js +1 -2
- package/dist/cjs/components/item.js.map +1 -1
- package/dist/cjs/components/plan-button/style.scss +8 -7
- package/dist/cjs/components/plan-type-selector/hooks/use-interval-options.js +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-interval-options.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/style.scss +3 -1
- package/dist/cjs/components/shared/billing-timeframe/index.js +13 -5
- package/dist/cjs/components/shared/billing-timeframe/index.js.map +1 -1
- package/dist/cjs/components/shared/header-price/style.scss +2 -2
- package/dist/cjs/components/shared/storage/hooks/use-default-storage-option.js +1 -1
- package/dist/cjs/components/shared/storage/hooks/use-default-storage-option.js.map +1 -1
- package/dist/cjs/components/shared/storage/hooks/use-purchased-storage-add-on.js +1 -1
- package/dist/cjs/components/shared/storage/hooks/use-purchased-storage-add-on.js.map +1 -1
- package/dist/cjs/components/shared/storage/index.js +3 -2
- package/dist/cjs/components/shared/storage/index.js.map +1 -1
- package/dist/cjs/components/sticky-container.js +66 -6
- package/dist/cjs/components/sticky-container.js.map +1 -1
- package/dist/cjs/hooks/data-store/is-popular-plan.js +1 -2
- package/dist/cjs/hooks/data-store/is-popular-plan.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js +14 -11
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js +2 -2
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js.map +1 -1
- package/dist/cjs/hooks/use-grid-size.js +2 -4
- package/dist/cjs/hooks/use-grid-size.js.map +1 -1
- package/dist/cjs/hooks/use-is-large-currency.js +1 -1
- package/dist/cjs/hooks/use-is-large-currency.js.map +1 -1
- package/dist/cjs/hooks/use-manage-tooltip-toggle.js +1 -2
- package/dist/cjs/hooks/use-manage-tooltip-toggle.js.map +1 -1
- package/dist/cjs/hooks/use-plan-pricing-info-from-grid-plans.js +1 -2
- package/dist/cjs/hooks/use-plan-pricing-info-from-grid-plans.js.map +1 -1
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js +1 -2
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js.map +1 -1
- package/dist/cjs/lib/is-same-plan.js +1 -2
- package/dist/cjs/lib/is-same-plan.js.map +1 -1
- package/dist/cjs/lib/sort-plan-properties.js +19 -32
- package/dist/cjs/lib/sort-plan-properties.js.map +1 -1
- package/dist/cjs/lib/touch-detect/index.js +1 -2
- package/dist/cjs/lib/touch-detect/index.js.map +1 -1
- package/dist/esm/_shared.scss +9 -4
- package/dist/esm/components/comparison-grid/index.js +18 -29
- package/dist/esm/components/comparison-grid/index.js.map +1 -1
- package/dist/esm/components/comparison-grid/index.stories.js +1 -0
- package/dist/esm/components/comparison-grid/index.stories.js.map +1 -1
- package/dist/esm/components/comparison-grid/style.scss +0 -17
- package/dist/esm/components/dropdown-option.js +1 -1
- package/dist/esm/components/features-grid/index.js +21 -6
- package/dist/esm/components/features-grid/index.js.map +1 -1
- package/dist/esm/components/features-grid/index.stories.js +1 -0
- package/dist/esm/components/features-grid/index.stories.js.map +1 -1
- package/dist/esm/components/features-grid/style.scss +2 -19
- package/dist/esm/components/plan-button/style.scss +8 -7
- package/dist/esm/components/plan-type-selector/style.scss +3 -1
- package/dist/esm/components/shared/billing-timeframe/index.js +14 -6
- package/dist/esm/components/shared/billing-timeframe/index.js.map +1 -1
- package/dist/esm/components/shared/header-price/style.scss +2 -2
- package/dist/esm/components/sticky-container.js +66 -5
- package/dist/esm/components/sticky-container.js.map +1 -1
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js +14 -11
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -1
- package/dist/esm/hooks/data-store/use-plan-billing-description.js +1 -1
- package/dist/esm/hooks/use-grid-size.js +0 -1
- package/dist/esm/hooks/use-grid-size.js.map +1 -1
- package/dist/esm/lib/sort-plan-properties.js +18 -30
- package/dist/esm/lib/sort-plan-properties.js.map +1 -1
- package/dist/tsconfig-cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/comparison-grid/index.d.ts +1 -1
- package/dist/types/components/comparison-grid/index.d.ts.map +1 -1
- package/dist/types/components/comparison-grid/index.stories.d.ts +3 -1
- package/dist/types/components/comparison-grid/index.stories.d.ts.map +1 -1
- package/dist/types/components/dropdown-option.d.ts +0 -1
- package/dist/types/components/dropdown-option.d.ts.map +1 -1
- package/dist/types/components/features-grid/client-logo-list/client-list.d.ts +0 -1
- package/dist/types/components/features-grid/client-logo-list/client-list.d.ts.map +1 -1
- package/dist/types/components/features-grid/client-logo-list/index.d.ts.map +1 -1
- package/dist/types/components/features-grid/index.d.ts.map +1 -1
- package/dist/types/components/features-grid/index.stories.d.ts +5 -1
- package/dist/types/components/features-grid/index.stories.d.ts.map +1 -1
- package/dist/types/components/plan-button/index.d.ts +10 -10
- package/dist/types/components/plan-button/index.d.ts.map +1 -1
- package/dist/types/components/plan-div-td-container.d.ts +0 -1
- package/dist/types/components/plan-div-td-container.d.ts.map +1 -1
- package/dist/types/components/plan-logo.d.ts +0 -1
- package/dist/types/components/plan-logo.d.ts.map +1 -1
- package/dist/types/components/plan-type-selector/components/interval-type-dropdown.d.ts +0 -1
- package/dist/types/components/plan-type-selector/components/interval-type-dropdown.d.ts.map +1 -1
- package/dist/types/components/plan-type-selector/components/interval-type-selector.d.ts +0 -1
- package/dist/types/components/plan-type-selector/components/interval-type-selector.d.ts.map +1 -1
- package/dist/types/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.d.ts.map +1 -1
- package/dist/types/components/popular-badge.d.ts +0 -1
- package/dist/types/components/popular-badge.d.ts.map +1 -1
- package/dist/types/components/shared/billing-timeframe/index.d.ts.map +1 -1
- package/dist/types/components/shared/header-price/header-price-context.d.ts +0 -1
- package/dist/types/components/shared/header-price/header-price-context.d.ts.map +1 -1
- package/dist/types/components/shared/storage/hooks/use-storage-string.d.ts +0 -1
- package/dist/types/components/shared/storage/hooks/use-storage-string.d.ts.map +1 -1
- package/dist/types/components/sticky-container.d.ts +22 -0
- package/dist/types/components/sticky-container.d.ts.map +1 -1
- package/dist/types/grid-context.d.ts +0 -1
- package/dist/types/grid-context.d.ts.map +1 -1
- package/dist/types/hooks/data-store/types.d.ts +1 -0
- package/dist/types/hooks/data-store/types.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plans.d.ts +1 -1
- package/dist/types/hooks/data-store/use-grid-plans.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-highlight-labels.d.ts +0 -1
- package/dist/types/hooks/data-store/use-highlight-labels.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-plan-billing-description.d.ts +0 -1
- package/dist/types/hooks/data-store/use-plan-billing-description.d.ts.map +1 -1
- package/dist/types/hooks/use-grid-size.d.ts +0 -1
- package/dist/types/hooks/use-grid-size.d.ts.map +1 -1
- package/dist/types/lib/get-plan-features-object.d.ts.map +1 -1
- package/dist/types/lib/sort-plan-properties.d.ts +1 -1
- package/dist/types/lib/sort-plan-properties.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -1
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/_shared.scss +9 -4
- package/src/components/comparison-grid/index.stories.tsx +1 -0
- package/src/components/comparison-grid/index.tsx +19 -33
- package/src/components/comparison-grid/style.scss +0 -17
- package/src/components/dropdown-option.tsx +1 -1
- package/src/components/features-grid/index.stories.tsx +1 -0
- package/src/components/features-grid/index.tsx +21 -9
- package/src/components/features-grid/style.scss +2 -19
- package/src/components/plan-button/style.scss +8 -7
- package/src/components/plan-type-selector/style.scss +3 -1
- package/src/components/shared/billing-timeframe/index.tsx +15 -7
- package/src/components/shared/header-price/style.scss +2 -2
- package/src/components/sticky-container.tsx +74 -3
- package/src/components/test/billing-timeframe.tsx +2 -2
- package/src/hooks/data-store/types.ts +1 -0
- package/src/hooks/data-store/use-grid-plans-for-features-grid.ts +14 -10
- package/src/hooks/data-store/use-plan-billing-description.tsx +1 -1
- package/src/hooks/use-grid-size.ts +0 -1
- package/src/lib/sort-plan-properties.ts +18 -37
- package/src/lib/test/sort-plan-properties.ts +50 -32
- package/src/types.ts +1 -0
|
@@ -2,21 +2,81 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
import { Global, css } from '@emotion/react';
|
|
3
3
|
import styled from '@emotion/styled';
|
|
4
4
|
import clsx from 'clsx';
|
|
5
|
-
import { useRef, useState, useLayoutEffect } from 'react';
|
|
6
|
-
const styles = ({ disabled, stickyOffset, zIndex, }) => disabled
|
|
5
|
+
import { useRef, useState, useLayoutEffect, useEffect } from 'react';
|
|
6
|
+
const styles = ({ disabled, stickyOffset, stickyPadding, zIndex, }) => disabled
|
|
7
7
|
? ''
|
|
8
8
|
: css `
|
|
9
9
|
position: sticky;
|
|
10
|
-
top: ${stickyOffset + 'px'};
|
|
10
|
+
top: ${stickyOffset - stickyPadding + 'px'};
|
|
11
11
|
z-index: ${zIndex};
|
|
12
12
|
`;
|
|
13
13
|
const Container = styled.div `
|
|
14
14
|
${styles}
|
|
15
15
|
`;
|
|
16
|
+
/**
|
|
17
|
+
* Renders a sticky container.
|
|
18
|
+
*
|
|
19
|
+
* The following is an illustration on how the container's top property is calculated.
|
|
20
|
+
*
|
|
21
|
+
* +~~~~~~~~ stickyParent (where the container scrolls)
|
|
22
|
+
* stickyOffset ~~~~~~~~~~+ |
|
|
23
|
+
* (e.g. masterbar) | |
|
|
24
|
+
* v v
|
|
25
|
+
* +------#-----------------+
|
|
26
|
+
* | # |<~~~~~~~+~~~~~ stickyPadding
|
|
27
|
+
* | +----#--------------+ |
|
|
28
|
+
* | | # @ |<~+~~~~~ stickyParent's content area
|
|
29
|
+
* | | # @ | |
|
|
30
|
+
* | | # @ <~~~~~~~~+~~+~~~~~ the container's top
|
|
31
|
+
* | | # @ | | (= stickyOffset - stickyPadding)
|
|
32
|
+
* | | ============= | |
|
|
33
|
+
* | | ^ | |
|
|
34
|
+
* | | | | |
|
|
35
|
+
* | | +~~~~~~~~~~~~~+~~+~~~~~ the container
|
|
36
|
+
* | | | |
|
|
37
|
+
*/
|
|
16
38
|
export function StickyContainer(props) {
|
|
17
39
|
const { stickyOffset = 0, zIndex = 2, stickyClass = '', element = 'div', disabled = false, children, } = props;
|
|
18
40
|
const stickyRef = useRef(null);
|
|
41
|
+
const [stickyParent, setStickyParent] = useState(null);
|
|
42
|
+
const [stickyPadding, setStickyPadding] = useState(0);
|
|
19
43
|
const [isStuck, setIsStuck] = useState(false);
|
|
44
|
+
/**
|
|
45
|
+
* Calculate the first scrollable parent and its padding-top.
|
|
46
|
+
*/
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!stickyRef.current || typeof getComputedStyle === 'undefined') {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
let scrollParent = stickyRef.current;
|
|
52
|
+
while (scrollParent) {
|
|
53
|
+
const style = getComputedStyle(scrollParent);
|
|
54
|
+
const overflowY = style.overflowY;
|
|
55
|
+
if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'overlay') {
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
scrollParent = scrollParent.parentElement;
|
|
59
|
+
}
|
|
60
|
+
const receiveScrollParent = (el) => {
|
|
61
|
+
const styles = getComputedStyle(el);
|
|
62
|
+
const paddingTop = parseFloat(styles.paddingTop);
|
|
63
|
+
setStickyParent(scrollParent);
|
|
64
|
+
setStickyPadding(paddingTop);
|
|
65
|
+
};
|
|
66
|
+
if (scrollParent) {
|
|
67
|
+
scrollParent.style.position = 'relative';
|
|
68
|
+
receiveScrollParent(scrollParent);
|
|
69
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
70
|
+
const observer = new ResizeObserver(([parent]) => {
|
|
71
|
+
receiveScrollParent(parent.target);
|
|
72
|
+
});
|
|
73
|
+
observer.observe(scrollParent);
|
|
74
|
+
return () => {
|
|
75
|
+
observer.disconnect();
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}, []);
|
|
20
80
|
/**
|
|
21
81
|
* This effect sets the value of `isStuck` state when it detects that
|
|
22
82
|
* the element is sticky.
|
|
@@ -45,6 +105,7 @@ export function StickyContainer(props) {
|
|
|
45
105
|
setIsStuck(entry.intersectionRatio < 1);
|
|
46
106
|
}
|
|
47
107
|
}, {
|
|
108
|
+
root: stickyParent,
|
|
48
109
|
rootMargin: `-${stickyOffset + 1}px 0px 0px 0px`,
|
|
49
110
|
threshold: [0, 1],
|
|
50
111
|
});
|
|
@@ -54,7 +115,7 @@ export function StickyContainer(props) {
|
|
|
54
115
|
return () => {
|
|
55
116
|
observer.disconnect();
|
|
56
117
|
};
|
|
57
|
-
}, [disabled, stickyOffset]);
|
|
118
|
+
}, [disabled, stickyParent, stickyOffset, stickyPadding]);
|
|
58
119
|
const isStuckFinalState = !disabled && isStuck;
|
|
59
120
|
return (_jsxs(_Fragment, { children: [_jsx(Global, { styles: css `
|
|
60
121
|
/**
|
|
@@ -64,6 +125,6 @@ export function StickyContainer(props) {
|
|
|
64
125
|
.layout__content {
|
|
65
126
|
overflow: unset;
|
|
66
127
|
}
|
|
67
|
-
` }), _jsx(Container, { ...props, as: element, ref: stickyRef, stickyOffset: stickyOffset, disabled: disabled, className: clsx({ [stickyClass]: isStuckFinalState }), zIndex: zIndex, children: children(isStuckFinalState) })] }));
|
|
128
|
+
` }), _jsx(Container, { ...props, as: element, ref: stickyRef, stickyOffset: stickyOffset, stickyPadding: stickyPadding, disabled: disabled, className: clsx({ [stickyClass]: isStuckFinalState }), zIndex: zIndex, children: children(isStuckFinalState) })] }));
|
|
68
129
|
}
|
|
69
130
|
//# sourceMappingURL=sticky-container.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sticky-container.js","sourceRoot":"","sources":["../../../src/components/sticky-container.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,EAAoB,QAAQ,EAAE,eAAe,EAAa,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"sticky-container.js","sourceRoot":"","sources":["../../../src/components/sticky-container.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,gBAAgB,CA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nB,SAAS,EAAG,IAAI,CAAE,EAAE,CAAE,WAAW,CAAE,EAAE,iBAAiB,EAAE,CAAE,EAC1D,MAAM,EAAG,MAAM,YAEb,QAAQ,CAAE,iBAAiB,CAAE,GACpB,IACV,CACH,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useMemo } from '@wordpress/element';
|
|
2
2
|
import useGridPlans from './use-grid-plans';
|
|
3
3
|
import usePlanFeaturesForGridPlans from './use-plan-features-for-grid-plans';
|
|
4
|
-
const useGridPlansForFeaturesGrid = ({ allFeaturesList, coupon, eligibleForFreeHostingTrial, hasRedeemedDomainCredit, hiddenPlans, intent, isDisplayingPlansNeededForFeature, isInSignup, isSubdomainNotGenerated, selectedFeature, selectedPlan, showLegacyStorageFeature, siteId, term, useCheckPlanAvailabilityForPurchase, useFreeTrialPlanSlugs, highlightLabelOverrides, isDomainOnlySite, reflectStorageSelectionInPlanPrices, }) => {
|
|
4
|
+
const useGridPlansForFeaturesGrid = ({ allFeaturesList, coupon, eligibleForFreeHostingTrial, hasRedeemedDomainCredit, hiddenPlans, hideCurrentPlan, intent, isDisplayingPlansNeededForFeature, isInSignup, isSubdomainNotGenerated, selectedFeature, selectedPlan, showLegacyStorageFeature, siteId, term, useCheckPlanAvailabilityForPurchase, useFreeTrialPlanSlugs, highlightLabelOverrides, isDomainOnlySite, reflectStorageSelectionInPlanPrices, }) => {
|
|
5
5
|
const gridPlans = useGridPlans({
|
|
6
6
|
allFeaturesList,
|
|
7
7
|
coupon,
|
|
@@ -36,18 +36,21 @@ const useGridPlansForFeaturesGrid = ({ allFeaturesList, coupon, eligibleForFreeH
|
|
|
36
36
|
return null;
|
|
37
37
|
}
|
|
38
38
|
return gridPlans.reduce((acc, gridPlan) => {
|
|
39
|
-
if (gridPlan.isVisible) {
|
|
40
|
-
return
|
|
41
|
-
...acc,
|
|
42
|
-
{
|
|
43
|
-
...gridPlan,
|
|
44
|
-
features: planFeaturesForFeaturesGrid[gridPlan.planSlug],
|
|
45
|
-
},
|
|
46
|
-
];
|
|
39
|
+
if (!gridPlan.isVisible) {
|
|
40
|
+
return acc;
|
|
47
41
|
}
|
|
48
|
-
|
|
42
|
+
if (hideCurrentPlan && gridPlan.current) {
|
|
43
|
+
return acc;
|
|
44
|
+
}
|
|
45
|
+
return [
|
|
46
|
+
...acc,
|
|
47
|
+
{
|
|
48
|
+
...gridPlan,
|
|
49
|
+
features: planFeaturesForFeaturesGrid[gridPlan.planSlug],
|
|
50
|
+
},
|
|
51
|
+
];
|
|
49
52
|
}, []);
|
|
50
|
-
}, [gridPlans, planFeaturesForFeaturesGrid]);
|
|
53
|
+
}, [gridPlans, planFeaturesForFeaturesGrid, hideCurrentPlan]);
|
|
51
54
|
};
|
|
52
55
|
export default useGridPlansForFeaturesGrid;
|
|
53
56
|
//# sourceMappingURL=use-grid-plans-for-features-grid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grid-plans-for-features-grid.js","sourceRoot":"","sources":["../../../../src/hooks/data-store/use-grid-plans-for-features-grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,2BAA2B,MAAM,oCAAoC,CAAC;AAI7E,MAAM,2BAA2B,GAAG,CAAE,EACrC,eAAe,EACf,MAAM,EACN,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,MAAM,EACN,iCAAiC,EACjC,UAAU,EACV,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,MAAM,EACN,IAAI,EACJ,mCAAmC,EACnC,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,mCAAmC,GACf,EAAsB,EAAE;IAC5C,MAAM,SAAS,GAAG,YAAY,CAAE;QAC/B,eAAe;QACf,MAAM;QACN,2BAA2B;QAC3B,uBAAuB;QACvB,WAAW;QACX,MAAM;QACN,iCAAiC;QACjC,uBAAuB;QACvB,eAAe;QACf,YAAY;QACZ,wBAAwB;QACxB,MAAM;QACN,IAAI;QACJ,mCAAmC;QACnC,qBAAqB;QACrB,uBAAuB;QACvB,gBAAgB;QAChB,mCAAmC;KACnC,CAAE,CAAC;IAEJ,MAAM,2BAA2B,GAAG,2BAA2B,CAAE;QAChE,eAAe;QACf,SAAS,EAAE,SAAS,IAAI,EAAE;QAC1B,uBAAuB;QACvB,MAAM;QACN,UAAU;QACV,eAAe;QACf,wBAAwB;KACxB,CAAE,CAAC;IAEJ,OAAO,OAAO,CAAE,GAAG,EAAE;QACpB,IAAK,CAAE,SAAS,EAAG,CAAC;YACnB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO,SAAS,CAAC,MAAM,CAAE,CAAE,GAAG,EAAE,QAAQ,EAAG,EAAE;YAC5C,IAAK,QAAQ,CAAC,SAAS,EAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"use-grid-plans-for-features-grid.js","sourceRoot":"","sources":["../../../../src/hooks/data-store/use-grid-plans-for-features-grid.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,2BAA2B,MAAM,oCAAoC,CAAC;AAI7E,MAAM,2BAA2B,GAAG,CAAE,EACrC,eAAe,EACf,MAAM,EACN,2BAA2B,EAC3B,uBAAuB,EACvB,WAAW,EACX,eAAe,EACf,MAAM,EACN,iCAAiC,EACjC,UAAU,EACV,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,wBAAwB,EACxB,MAAM,EACN,IAAI,EACJ,mCAAmC,EACnC,qBAAqB,EACrB,uBAAuB,EACvB,gBAAgB,EAChB,mCAAmC,GACf,EAAsB,EAAE;IAC5C,MAAM,SAAS,GAAG,YAAY,CAAE;QAC/B,eAAe;QACf,MAAM;QACN,2BAA2B;QAC3B,uBAAuB;QACvB,WAAW;QACX,MAAM;QACN,iCAAiC;QACjC,uBAAuB;QACvB,eAAe;QACf,YAAY;QACZ,wBAAwB;QACxB,MAAM;QACN,IAAI;QACJ,mCAAmC;QACnC,qBAAqB;QACrB,uBAAuB;QACvB,gBAAgB;QAChB,mCAAmC;KACnC,CAAE,CAAC;IAEJ,MAAM,2BAA2B,GAAG,2BAA2B,CAAE;QAChE,eAAe;QACf,SAAS,EAAE,SAAS,IAAI,EAAE;QAC1B,uBAAuB;QACvB,MAAM;QACN,UAAU;QACV,eAAe;QACf,wBAAwB;KACxB,CAAE,CAAC;IAEJ,OAAO,OAAO,CAAE,GAAG,EAAE;QACpB,IAAK,CAAE,SAAS,EAAG,CAAC;YACnB,OAAO,IAAI,CAAC;QACb,CAAC;QAED,OAAO,SAAS,CAAC,MAAM,CAAE,CAAE,GAAG,EAAE,QAAQ,EAAG,EAAE;YAC5C,IAAK,CAAE,QAAQ,CAAC,SAAS,EAAG,CAAC;gBAC5B,OAAO,GAAG,CAAC;YACZ,CAAC;YACD,IAAK,eAAe,IAAI,QAAQ,CAAC,OAAO,EAAG,CAAC;gBAC3C,OAAO,GAAG,CAAC;YACZ,CAAC;YACD,OAAO;gBACN,GAAG,GAAG;gBACN;oBACC,GAAG,QAAQ;oBACX,QAAQ,EAAE,2BAA2B,CAAE,QAAQ,CAAC,QAAQ,CAAE;iBAC1D;aACD,CAAC;QACH,CAAC,EAAE,EAAgB,CAAE,CAAC;IACvB,CAAC,EAAE,CAAE,SAAS,EAAE,2BAA2B,EAAE,eAAe,CAAE,CAAE,CAAC;AAClE,CAAC,CAAC;AAEF,eAAe,2BAA2B,CAAC"}
|
|
@@ -32,7 +32,7 @@ export default function usePlanBillingDescription({ siteId, planSlug, pricing, i
|
|
|
32
32
|
: yearlyVariantPricing.originalPrice?.monthly;
|
|
33
33
|
if (yearlyVariantMaybeDiscountedPrice &&
|
|
34
34
|
yearlyVariantMaybeDiscountedPrice < originalPrice.monthly) {
|
|
35
|
-
return translate(
|
|
35
|
+
return translate('Save %(discountRate)s%% by paying annually', {
|
|
36
36
|
args: {
|
|
37
37
|
discountRate: Math.floor((100 * (originalPrice.monthly - yearlyVariantMaybeDiscountedPrice)) /
|
|
38
38
|
originalPrice.monthly),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-grid-size.js","sourceRoot":"","sources":["../../../src/hooks/use-grid-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-grid-size.js","sourceRoot":"","sources":["../../../src/hooks/use-grid-size.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAa/D;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW,CAAE,EAAE,YAAY,EAAE,oBAAoB,EAAS;IACjF,MAAM,CAAE,QAAQ,EAAE,WAAW,CAAE,GAAG,QAAQ,CAAmB,IAAI,CAAE,CAAC;IAEpE,eAAe,CAAE,GAAG,EAAE;QACrB,IAAK,CAAE,YAAY,CAAC,OAAO,EAAG,CAAC;YAC9B,OAAO;QACR,CAAC;QAED,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAE,CAAE,CAAE,KAAK,CAAE,EAAG,EAAE;YACpD,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC,WAAW,CAAC;YAEpC,IAAK,KAAK,EAAG,CAAC;gBACb,KAAM,MAAM,CAAE,GAAG,EAAE,KAAK,CAAE,IAAI,CAAE,GAAG,oBAAoB,CAAE,CAAC,OAAO,EAAE,EAAG,CAAC;oBACtE,IAAK,KAAK,IAAI,KAAK,EAAG,CAAC;wBACtB,WAAW,CAAE,GAAG,CAAE,CAAC;wBACnB,MAAM;oBACP,CAAC;gBACF,CAAC;YACF,CAAC;QACF,CAAC,CAAE,CAAC;QAEJ,QAAQ,CAAC,OAAO,CAAE,YAAY,CAAC,OAAO,CAAE,CAAC;QAEzC,OAAO,GAAG,EAAE,CAAC,QAAQ,CAAC,UAAU,EAAE,CAAC;IACpC,CAAC,EAAE,CAAE,YAAY,EAAE,oBAAoB,CAAE,CAAE,CAAC;IAE5C,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -1,35 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// Try to find the current paid plan in the plans list
|
|
6
|
-
if (currentSitePlanProductSlug && !isFreePlan(currentSitePlanProductSlug)) {
|
|
7
|
-
firstPlanIndex = gridPlans.findIndex((gridPlan) => {
|
|
8
|
-
return gridPlan.planSlug === currentSitePlanProductSlug;
|
|
9
|
-
});
|
|
1
|
+
export function sortPlans(gridPlans, currentSitePlanProductSlug) {
|
|
2
|
+
// If we don't have plans to sort, return empty array
|
|
3
|
+
if (!gridPlans.length) {
|
|
4
|
+
return [];
|
|
10
5
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
// If we have a current site plan and we're on mobile, sort to prioritize it
|
|
7
|
+
if (currentSitePlanProductSlug) {
|
|
8
|
+
return [...gridPlans].sort((planA, planB) => {
|
|
9
|
+
// If planA is the current plan, it should come first (-1 moves it up)
|
|
10
|
+
if (planA.planSlug === currentSitePlanProductSlug) {
|
|
11
|
+
return -1;
|
|
12
|
+
}
|
|
13
|
+
// If planB is the current plan, it should come first (1 moves planA down)
|
|
14
|
+
if (planB.planSlug === currentSitePlanProductSlug) {
|
|
15
|
+
return 1;
|
|
16
|
+
}
|
|
17
|
+
// Otherwise, maintain original order
|
|
18
|
+
return 0;
|
|
15
19
|
});
|
|
16
|
-
// If the popular plan exists, on mobile, it will be second plan for comparison.
|
|
17
|
-
if (firstPlanIndex > 0 && isMobile) {
|
|
18
|
-
firstPlanIndex = firstPlanIndex - 1;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (firstPlanIndex < 0) {
|
|
22
|
-
return gridPlans;
|
|
23
20
|
}
|
|
24
|
-
return [
|
|
25
|
-
// The first plan
|
|
26
|
-
gridPlans[firstPlanIndex],
|
|
27
|
-
// Rest of the plans in default order
|
|
28
|
-
...gridPlans.slice(firstPlanIndex + 1),
|
|
29
|
-
// Leftover plans (before the first plan) in descending order of value
|
|
30
|
-
...gridPlans.slice(0, firstPlanIndex).sort((planA, planB) => {
|
|
31
|
-
return ((planB?.pricing.originalPrice.full || 0) - (planA?.pricing.originalPrice.full || 0));
|
|
32
|
-
}),
|
|
33
|
-
].filter((gridPlan) => Boolean(gridPlan));
|
|
21
|
+
return [...gridPlans];
|
|
34
22
|
}
|
|
35
23
|
//# sourceMappingURL=sort-plan-properties.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-plan-properties.js","sourceRoot":"","sources":["../../../src/lib/sort-plan-properties.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sort-plan-properties.js","sourceRoot":"","sources":["../../../src/lib/sort-plan-properties.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,SAAS,CACxB,SAAqB,EACrB,0BAA0C;IAE1C,qDAAqD;IACrD,IAAK,CAAE,SAAS,CAAC,MAAM,EAAG,CAAC;QAC1B,OAAO,EAAE,CAAC;IACX,CAAC;IACD,4EAA4E;IAC5E,IAAK,0BAA0B,EAAG,CAAC;QAClC,OAAO,CAAE,GAAG,SAAS,CAAE,CAAC,IAAI,CAAE,CAAE,KAAK,EAAE,KAAK,EAAG,EAAE;YAChD,sEAAsE;YACtE,IAAK,KAAK,CAAC,QAAQ,KAAK,0BAA0B,EAAG,CAAC;gBACrD,OAAO,CAAC,CAAC,CAAC;YACX,CAAC;YACD,0EAA0E;YAC1E,IAAK,KAAK,CAAC,QAAQ,KAAK,0BAA0B,EAAG,CAAC;gBACrD,OAAO,CAAC,CAAC;YACV,CAAC;YACD,qCAAqC;YACrC,OAAO,CAAC,CAAC;QACV,CAAC,CAAE,CAAC;IACL,CAAC;IACD,OAAO,CAAE,GAAG,SAAS,CAAE,CAAC;AACzB,CAAC"}
|