@automattic/plans-grid-next 1.0.1 → 1.0.3
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/CHANGELOG.md +4 -1
- package/dist/cjs/_shared.scss +4 -3
- package/dist/cjs/components/comparison-grid/index.js +101 -71
- package/dist/cjs/components/comparison-grid/index.js.map +1 -1
- package/dist/cjs/components/comparison-grid/index.stories.js.map +1 -1
- package/dist/cjs/components/comparison-grid/style.scss +10 -2
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js +0 -12
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js.map +1 -1
- package/dist/cjs/components/features-grid/index.js +9 -6
- package/dist/cjs/components/features-grid/index.js.map +1 -1
- package/dist/cjs/components/features-grid/plan-features-list.js +10 -3
- package/dist/cjs/components/features-grid/plan-features-list.js.map +1 -1
- package/dist/cjs/components/features-grid/plan-headers.js +2 -2
- package/dist/cjs/components/features-grid/plan-headers.js.map +1 -1
- package/dist/cjs/components/features-grid/plan-tagline.js +1 -1
- package/dist/cjs/components/features-grid/plan-tagline.js.map +1 -1
- package/dist/cjs/components/features-grid/style.scss +111 -21
- package/dist/cjs/components/features-grid/table.js +1 -1
- package/dist/cjs/components/features-grid/table.js.map +1 -1
- package/dist/cjs/components/features.js +43 -4
- package/dist/cjs/components/features.js.map +1 -1
- package/dist/cjs/components/item.js +1 -1
- package/dist/cjs/components/item.js.map +1 -1
- package/dist/cjs/components/plan-button/index.js +5 -3
- package/dist/cjs/components/plan-button/index.js.map +1 -1
- package/dist/cjs/components/plan-button/style.scss +71 -47
- package/dist/cjs/components/plan-div-td-container.js +4 -1
- package/dist/cjs/components/plan-div-td-container.js.map +1 -1
- package/dist/cjs/components/plan-logo.js +6 -3
- package/dist/cjs/components/plan-logo.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js +12 -1
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -1
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js +4 -33
- 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 +11 -13
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -1
- package/dist/cjs/components/plans-2023-tooltip.js +16 -5
- package/dist/cjs/components/plans-2023-tooltip.js.map +1 -1
- package/dist/cjs/components/shared/action-button/index.js +22 -7
- package/dist/cjs/components/shared/action-button/index.js.map +1 -1
- package/dist/cjs/components/shared/action-button/style.scss +4 -0
- package/dist/cjs/components/shared/billing-timeframe/index.js +8 -4
- package/dist/cjs/components/shared/billing-timeframe/index.js.map +1 -1
- package/dist/cjs/components/shared/header-price/index.js +60 -15
- package/dist/cjs/components/shared/header-price/index.js.map +1 -1
- package/dist/cjs/components/shared/header-price/style.scss +10 -2
- package/dist/cjs/components/shared/storage/components/plan-storage.js +2 -2
- package/dist/cjs/components/shared/storage/components/plan-storage.js.map +1 -1
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js +29 -6
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js.map +1 -1
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js +2 -1
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js.map +1 -1
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js +2 -0
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js.map +1 -1
- package/dist/cjs/fixtures/sites-purchases.js +2 -4
- package/dist/cjs/fixtures/sites-purchases.js.map +1 -1
- package/dist/cjs/grid-context.js +4 -1
- package/dist/cjs/grid-context.js.map +1 -1
- package/dist/cjs/hooks/data-store/get-renewal-pricing-text.js +50 -0
- package/dist/cjs/hooks/data-store/get-renewal-pricing-text.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js +6 -1
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js +6 -1
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-grid-plans.js +175 -21
- package/dist/cjs/hooks/data-store/use-grid-plans.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-highlight-labels.js +13 -4
- package/dist/cjs/hooks/data-store/use-highlight-labels.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js +68 -13
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-plan-billing-period.js +14 -0
- package/dist/cjs/hooks/data-store/use-plan-billing-period.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js +76 -2
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +60 -12
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -1
- package/dist/cjs/hooks/data-store/use-title-badges.js +19 -0
- package/dist/cjs/hooks/data-store/use-title-badges.js.map +1 -0
- package/dist/cjs/hooks/use-grid-size.js.map +1 -1
- package/dist/cjs/hooks/use-is-large-currency.js +2 -2
- package/dist/cjs/hooks/use-is-large-currency.js.map +1 -1
- package/dist/cjs/hooks/use-visible-grid-plans.js +70 -0
- package/dist/cjs/hooks/use-visible-grid-plans.js.map +1 -0
- package/dist/cjs/index.js +8 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/get-plan-features-object.js +15 -2
- package/dist/cjs/lib/get-plan-features-object.js.map +1 -1
- package/dist/cjs/lib/plan-pricing-utils.js +135 -0
- package/dist/cjs/lib/plan-pricing-utils.js.map +1 -0
- package/dist/esm/_shared.scss +4 -3
- package/dist/esm/components/comparison-grid/index.js +102 -72
- package/dist/esm/components/comparison-grid/index.js.map +1 -1
- package/dist/esm/components/comparison-grid/index.stories.js.map +1 -1
- package/dist/esm/components/comparison-grid/style.scss +10 -2
- package/dist/esm/components/features-grid/client-logo-list/client-list.js +0 -12
- package/dist/esm/components/features-grid/client-logo-list/client-list.js.map +1 -1
- package/dist/esm/components/features-grid/index.js +9 -6
- package/dist/esm/components/features-grid/index.js.map +1 -1
- package/dist/esm/components/features-grid/plan-features-list.js +10 -3
- package/dist/esm/components/features-grid/plan-features-list.js.map +1 -1
- package/dist/esm/components/features-grid/plan-headers.js +3 -3
- package/dist/esm/components/features-grid/plan-headers.js.map +1 -1
- package/dist/esm/components/features-grid/plan-tagline.js +1 -1
- package/dist/esm/components/features-grid/plan-tagline.js.map +1 -1
- package/dist/esm/components/features-grid/style.scss +111 -21
- package/dist/esm/components/features-grid/table.js +1 -1
- package/dist/esm/components/features-grid/table.js.map +1 -1
- package/dist/esm/components/features.js +44 -5
- package/dist/esm/components/features.js.map +1 -1
- package/dist/esm/components/item.js +1 -1
- package/dist/esm/components/item.js.map +1 -1
- package/dist/esm/components/plan-button/index.js +5 -3
- package/dist/esm/components/plan-button/index.js.map +1 -1
- package/dist/esm/components/plan-button/style.scss +71 -47
- package/dist/esm/components/plan-div-td-container.js +4 -1
- package/dist/esm/components/plan-div-td-container.js.map +1 -1
- package/dist/esm/components/plan-logo.js +7 -4
- package/dist/esm/components/plan-logo.js.map +1 -1
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js +12 -1
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -1
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js +3 -33
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js.map +1 -1
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +11 -13
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -1
- package/dist/esm/components/plans-2023-tooltip.js +16 -5
- package/dist/esm/components/plans-2023-tooltip.js.map +1 -1
- package/dist/esm/components/shared/action-button/index.js +22 -7
- package/dist/esm/components/shared/action-button/index.js.map +1 -1
- package/dist/esm/components/shared/action-button/style.scss +4 -0
- package/dist/esm/components/shared/billing-timeframe/index.js +8 -4
- package/dist/esm/components/shared/billing-timeframe/index.js.map +1 -1
- package/dist/esm/components/shared/header-price/index.js +60 -15
- package/dist/esm/components/shared/header-price/index.js.map +1 -1
- package/dist/esm/components/shared/header-price/style.scss +10 -2
- package/dist/esm/components/shared/storage/components/plan-storage.js +2 -2
- package/dist/esm/components/shared/storage/components/plan-storage.js.map +1 -1
- package/dist/esm/components/shared/storage/components/storage-dropdown.js +30 -7
- package/dist/esm/components/shared/storage/components/storage-dropdown.js.map +1 -1
- package/dist/esm/components/shared/storage/components/storage-feature-label.js +2 -1
- package/dist/esm/components/shared/storage/components/storage-feature-label.js.map +1 -1
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js +3 -1
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js.map +1 -1
- package/dist/esm/fixtures/sites-purchases.js +2 -4
- package/dist/esm/fixtures/sites-purchases.js.map +1 -1
- package/dist/esm/grid-context.js +4 -1
- package/dist/esm/grid-context.js.map +1 -1
- package/dist/esm/hooks/data-store/get-renewal-pricing-text.js +47 -0
- package/dist/esm/hooks/data-store/get-renewal-pricing-text.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js +6 -1
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -1
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js +6 -1
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -1
- package/dist/esm/hooks/data-store/use-grid-plans.js +176 -22
- package/dist/esm/hooks/data-store/use-grid-plans.js.map +1 -1
- package/dist/esm/hooks/data-store/use-highlight-labels.js +14 -5
- package/dist/esm/hooks/data-store/use-highlight-labels.js.map +1 -1
- package/dist/esm/hooks/data-store/use-plan-billing-description.js +66 -11
- package/dist/esm/hooks/data-store/use-plan-billing-description.js.map +1 -1
- package/dist/esm/hooks/data-store/use-plan-billing-period.js +12 -0
- package/dist/esm/hooks/data-store/use-plan-billing-period.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js +77 -3
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -1
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +59 -11
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -1
- package/dist/esm/hooks/data-store/use-title-badges.js +17 -0
- package/dist/esm/hooks/data-store/use-title-badges.js.map +1 -0
- package/dist/esm/hooks/use-grid-size.js.map +1 -1
- package/dist/esm/hooks/use-is-large-currency.js +1 -1
- package/dist/esm/hooks/use-is-large-currency.js.map +1 -1
- package/dist/esm/hooks/use-visible-grid-plans.js +66 -0
- package/dist/esm/hooks/use-visible-grid-plans.js.map +1 -0
- package/dist/esm/index.js +4 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/get-plan-features-object.js +15 -2
- package/dist/esm/lib/get-plan-features-object.js.map +1 -1
- package/dist/esm/lib/plan-pricing-utils.js +129 -0
- package/dist/esm/lib/plan-pricing-utils.js.map +1 -0
- 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 +2 -2
- package/dist/types/components/dropdown-option.d.ts.map +1 -1
- package/dist/types/components/features-grid/billing-timeframes.d.ts.map +1 -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/enterprise-features.d.ts.map +1 -1
- package/dist/types/components/features-grid/index.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-features-list.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-headers.d.ts +2 -0
- package/dist/types/components/features-grid/plan-headers.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-logos.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-prices.d.ts.map +1 -1
- package/dist/types/components/features-grid/plan-tagline.d.ts.map +1 -1
- package/dist/types/components/features-grid/previous-features-included-title.d.ts.map +1 -1
- package/dist/types/components/features-grid/spotlight-plan.d.ts.map +1 -1
- package/dist/types/components/features-grid/table.d.ts.map +1 -1
- package/dist/types/components/features-grid/top-buttons.d.ts.map +1 -1
- package/dist/types/components/features.d.ts.map +1 -1
- package/dist/types/components/item.d.ts +2 -1
- package/dist/types/components/item.d.ts.map +1 -1
- package/dist/types/components/plan-button/index.d.ts +2 -1
- package/dist/types/components/plan-button/index.d.ts.map +1 -1
- package/dist/types/components/plan-div-td-container.d.ts +2 -0
- package/dist/types/components/plan-div-td-container.d.ts.map +1 -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.map +1 -1
- package/dist/types/components/plan-type-selector/hooks/use-max-discount.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/plans-2023-tooltip.d.ts.map +1 -1
- package/dist/types/components/shared/action-button/index.d.ts +2 -1
- package/dist/types/components/shared/action-button/index.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.map +1 -1
- package/dist/types/components/shared/header-price/index.d.ts.map +1 -1
- package/dist/types/components/shared/storage/components/plan-storage.d.ts.map +1 -1
- package/dist/types/components/shared/storage/components/storage-dropdown.d.ts.map +1 -1
- package/dist/types/components/shared/storage/components/storage-feature-label.d.ts.map +1 -1
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts +1 -1
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts.map +1 -1
- package/dist/types/css-mixins.d.ts.map +1 -1
- package/dist/types/fixtures/sites-purchases.d.ts +2 -4
- package/dist/types/fixtures/sites-purchases.d.ts.map +1 -1
- package/dist/types/grid-context.d.ts +4 -1
- package/dist/types/grid-context.d.ts.map +1 -1
- package/dist/types/hooks/data-store/get-renewal-pricing-text.d.ts +14 -0
- package/dist/types/hooks/data-store/get-renewal-pricing-text.d.ts.map +1 -0
- package/dist/types/hooks/data-store/types.d.ts +21 -0
- package/dist/types/hooks/data-store/types.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plan-for-spotlight.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts +1 -1
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.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.map +1 -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.map +1 -1
- package/dist/types/hooks/data-store/use-plan-billing-period.d.ts +8 -0
- package/dist/types/hooks/data-store/use-plan-billing-period.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts +4 -1
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-plans-from-types.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts +4 -1
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts.map +1 -1
- package/dist/types/hooks/data-store/use-title-badges.d.ts +9 -0
- package/dist/types/hooks/data-store/use-title-badges.d.ts.map +1 -0
- package/dist/types/hooks/use-grid-size.d.ts +3 -2
- package/dist/types/hooks/use-grid-size.d.ts.map +1 -1
- package/dist/types/hooks/use-highlight-adjacency-matrix.d.ts.map +1 -1
- package/dist/types/hooks/use-visible-grid-plans.d.ts +14 -0
- package/dist/types/hooks/use-visible-grid-plans.d.ts.map +1 -0
- package/dist/types/index.d.ts +9 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/filter-unused-features-object.d.ts.map +1 -1
- package/dist/types/lib/get-plan-features-object.d.ts +1 -1
- package/dist/types/lib/get-plan-features-object.d.ts.map +1 -1
- package/dist/types/lib/plan-pricing-utils.d.ts +105 -0
- package/dist/types/lib/plan-pricing-utils.d.ts.map +1 -0
- package/dist/types/types.d.ts +33 -6
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +39 -28
- package/src/_shared.scss +4 -3
- package/src/components/comparison-grid/index.stories.tsx +1 -1
- package/src/components/comparison-grid/index.tsx +263 -158
- package/src/components/comparison-grid/style.scss +10 -2
- package/src/components/features-grid/client-logo-list/client-list.tsx +0 -25
- package/src/components/features-grid/index.tsx +37 -19
- package/src/components/features-grid/plan-features-list.tsx +15 -4
- package/src/components/features-grid/plan-headers.tsx +10 -3
- package/src/components/features-grid/plan-tagline.tsx +1 -1
- package/src/components/features-grid/style.scss +111 -21
- package/src/components/features-grid/table.tsx +4 -2
- package/src/components/features.tsx +66 -6
- package/src/components/item.tsx +6 -3
- package/src/components/plan-button/index.tsx +7 -1
- package/src/components/plan-button/style.scss +71 -47
- package/src/components/plan-div-td-container.tsx +6 -2
- package/src/components/plan-logo.tsx +16 -9
- package/src/components/plan-type-selector/components/interval-type-dropdown.tsx +14 -1
- package/src/components/plan-type-selector/hooks/use-max-discount.ts +8 -47
- package/src/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.ts +19 -17
- package/src/components/plans-2023-tooltip.tsx +17 -5
- package/src/components/shared/action-button/index.tsx +46 -5
- package/src/components/shared/action-button/style.scss +4 -0
- package/src/components/shared/billing-timeframe/index.tsx +12 -7
- package/src/components/shared/header-price/index.tsx +129 -27
- package/src/components/shared/header-price/style.scss +10 -2
- package/src/components/shared/storage/components/plan-storage.tsx +2 -2
- package/src/components/shared/storage/components/storage-dropdown.tsx +36 -15
- package/src/components/shared/storage/components/storage-feature-label.tsx +2 -1
- package/src/components/shared/storage/hooks/use-plan-storage.ts +3 -0
- package/src/components/test/actions-button.tsx +5 -0
- package/src/components/test/billing-timeframe.tsx +1 -1
- package/src/components/test/header-price.tsx +342 -4
- package/src/fixtures/sites-purchases.ts +2 -4
- package/src/grid-context.tsx +9 -0
- package/src/hooks/data-store/get-renewal-pricing-text.ts +73 -0
- package/src/hooks/data-store/types.ts +21 -0
- package/src/hooks/data-store/use-grid-plans-for-comparison-grid.ts +10 -0
- package/src/hooks/data-store/use-grid-plans-for-features-grid.ts +10 -0
- package/src/hooks/data-store/use-grid-plans.tsx +189 -23
- package/src/hooks/data-store/use-highlight-labels.ts +12 -3
- package/src/hooks/data-store/use-plan-billing-description.tsx +80 -15
- package/src/hooks/data-store/use-plan-billing-period.tsx +28 -0
- package/src/hooks/data-store/use-plan-features-for-grid-plans.ts +135 -1
- package/src/hooks/data-store/use-restructured-plan-features-for-comparison-grid.ts +93 -20
- package/src/hooks/data-store/use-title-badges.ts +31 -0
- package/src/hooks/test/use-visible-grid-plans.tsx +116 -0
- package/src/hooks/use-grid-size.ts +3 -2
- package/src/hooks/use-is-large-currency.ts +1 -1
- package/src/hooks/use-visible-grid-plans.tsx +102 -0
- package/src/index.tsx +20 -0
- package/src/lib/get-plan-features-object.ts +23 -2
- package/src/lib/plan-pricing-utils.ts +211 -0
- package/src/lib/test/plan-pricing-utils.ts +594 -0
- package/src/style-imports.d.ts +3 -0
- package/src/types.ts +45 -4
- package/dist/cjs/components/features-grid/mobile-free-domain.js +0 -25
- package/dist/cjs/components/features-grid/mobile-free-domain.js.map +0 -1
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js +0 -15
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js.map +0 -1
- package/dist/cjs/lib/sort-plan-properties.js +0 -26
- package/dist/cjs/lib/sort-plan-properties.js.map +0 -1
- package/dist/esm/components/features-grid/mobile-free-domain.js +0 -23
- package/dist/esm/components/features-grid/mobile-free-domain.js.map +0 -1
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js +0 -12
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js.map +0 -1
- package/dist/esm/lib/sort-plan-properties.js +0 -23
- package/dist/esm/lib/sort-plan-properties.js.map +0 -1
- package/dist/types/components/features-grid/mobile-free-domain.d.ts +0 -8
- package/dist/types/components/features-grid/mobile-free-domain.d.ts.map +0 -1
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts +0 -9
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts.map +0 -1
- package/dist/types/lib/sort-plan-properties.d.ts +0 -3
- package/dist/types/lib/sort-plan-properties.d.ts.map +0 -1
- package/src/components/features-grid/mobile-free-domain.tsx +0 -51
- package/src/lib/get-plan-pricing-info-from-grid-plans.ts +0 -31
- package/src/lib/sort-plan-properties.ts +0 -27
- package/src/lib/test/sort-plan-properties.ts +0 -122
package/src/components/item.tsx
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
export function PlanFeaturesItem( props: { children?: ReactNode } ) {
|
|
3
|
+
export function PlanFeaturesItem( props: { children?: ReactNode; style?: CSSProperties } ) {
|
|
4
4
|
return (
|
|
5
|
-
<div
|
|
5
|
+
<div
|
|
6
|
+
className="plan-features-2023-grid__item plan-features-2023-grid__item-available"
|
|
7
|
+
style={ props.style }
|
|
8
|
+
>
|
|
6
9
|
<div className="plan-features-2023-grid__item-info-container">{ props.children }</div>
|
|
7
10
|
</div>
|
|
8
11
|
);
|
|
@@ -18,6 +18,7 @@ const PlanButton = ( {
|
|
|
18
18
|
disabled = false,
|
|
19
19
|
isStuck = false,
|
|
20
20
|
isLargeCurrency = false,
|
|
21
|
+
ariaLabel,
|
|
21
22
|
}: {
|
|
22
23
|
planSlug?: PlanSlug;
|
|
23
24
|
children: React.ReactNode;
|
|
@@ -30,6 +31,7 @@ const PlanButton = ( {
|
|
|
30
31
|
disabled?: boolean;
|
|
31
32
|
isStuck?: boolean;
|
|
32
33
|
isLargeCurrency?: boolean;
|
|
34
|
+
ariaLabel?: string;
|
|
33
35
|
} ) => {
|
|
34
36
|
const className = clsx(
|
|
35
37
|
classes,
|
|
@@ -39,7 +41,8 @@ const PlanButton = ( {
|
|
|
39
41
|
'is-current-plan': current,
|
|
40
42
|
'is-stuck': isStuck,
|
|
41
43
|
'is-large-currency': isLargeCurrency,
|
|
42
|
-
}
|
|
44
|
+
},
|
|
45
|
+
disabled && 'disabled'
|
|
43
46
|
);
|
|
44
47
|
|
|
45
48
|
return (
|
|
@@ -50,6 +53,9 @@ const PlanButton = ( {
|
|
|
50
53
|
borderless={ borderless }
|
|
51
54
|
disabled={ disabled }
|
|
52
55
|
href={ href }
|
|
56
|
+
aria-label={ ariaLabel }
|
|
57
|
+
// eslint-disable-next-line jsx-a11y/tabindex-no-positive
|
|
58
|
+
tabIndex={ 2 }
|
|
53
59
|
>
|
|
54
60
|
{ children }
|
|
55
61
|
</Button>
|
|
@@ -1,93 +1,106 @@
|
|
|
1
|
-
@import
|
|
1
|
+
@import '@automattic/onboarding/styles/mixins';
|
|
2
2
|
|
|
3
3
|
.button.plan-features-2023-grid__actions-button {
|
|
4
4
|
line-height: 20px;
|
|
5
|
-
border-radius:
|
|
5
|
+
border-radius: 2px;
|
|
6
6
|
padding: 10px 12px;
|
|
7
7
|
border: unset;
|
|
8
8
|
text-align: center;
|
|
9
9
|
text-wrap: balance;
|
|
10
10
|
width: 100%;
|
|
11
|
-
color: var(--color-text-inverted);
|
|
11
|
+
color: var( --color-text-inverted );
|
|
12
12
|
|
|
13
13
|
&:hover {
|
|
14
|
-
color: var(--color-text-inverted);
|
|
14
|
+
color: var( --color-text-inverted );
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
&.is-free-plan
|
|
18
|
-
|
|
17
|
+
&.is-free-plan,
|
|
18
|
+
&.is-woo-hosted-basic-plan,
|
|
19
|
+
&.is-woo-hosted-pro-plan {
|
|
20
|
+
background-color: var( --studio-wordpress-blue-50 );
|
|
19
21
|
|
|
20
22
|
&:focus {
|
|
21
|
-
box-shadow:
|
|
23
|
+
box-shadow:
|
|
24
|
+
0 0 0 2px var( --studio-white ),
|
|
25
|
+
0 0 0 4px var( --studio-wordpress-blue-50 );
|
|
22
26
|
}
|
|
23
27
|
|
|
24
28
|
&:hover {
|
|
25
|
-
background-color: var(--studio-wordpress-blue-60);
|
|
29
|
+
background-color: var( --studio-wordpress-blue-60 );
|
|
26
30
|
}
|
|
27
|
-
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
&.is-personal-plan {
|
|
31
|
-
background-color: var(--studio-wordpress-blue-60);
|
|
34
|
+
background-color: var( --studio-wordpress-blue-60 );
|
|
32
35
|
|
|
33
36
|
&:focus {
|
|
34
|
-
box-shadow:
|
|
37
|
+
box-shadow:
|
|
38
|
+
0 0 0 2px var( --studio-white ),
|
|
39
|
+
0 0 0 4px var( --studio-wordpress-blue-60 );
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
&:hover {
|
|
38
|
-
background-color: var(--studio-wordpress-blue-70);
|
|
43
|
+
background-color: var( --studio-wordpress-blue-70 );
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
&.is-premium-plan {
|
|
43
|
-
background-color: var(--studio-wordpress-blue-70);
|
|
48
|
+
background-color: var( --studio-wordpress-blue-70 );
|
|
44
49
|
|
|
45
50
|
&:focus {
|
|
46
|
-
box-shadow:
|
|
51
|
+
box-shadow:
|
|
52
|
+
0 0 0 2px var( --studio-white ),
|
|
53
|
+
0 0 0 4px var( --studio-wordpress-blue-70 );
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
&:hover {
|
|
50
|
-
background-color: var(--studio-wordpress-blue-80);
|
|
57
|
+
background-color: var( --studio-wordpress-blue-80 );
|
|
51
58
|
}
|
|
52
59
|
}
|
|
53
60
|
|
|
54
61
|
&.is-business-plan {
|
|
55
|
-
background-color: var(--studio-woocommerce-purple-60);
|
|
62
|
+
background-color: var( --studio-woocommerce-purple-60 );
|
|
56
63
|
|
|
57
64
|
&:focus {
|
|
58
|
-
box-shadow:
|
|
65
|
+
box-shadow:
|
|
66
|
+
0 0 0 2px var( --studio-white ),
|
|
67
|
+
0 0 0 4px var( --studio-woocommerce-purple-60 );
|
|
59
68
|
}
|
|
60
69
|
|
|
61
70
|
&:hover {
|
|
62
|
-
background-color: var(--studio-woocommerce-purple-70);
|
|
71
|
+
background-color: var( --studio-woocommerce-purple-70 );
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
+ .button.is-borderless {
|
|
66
75
|
background: transparent;
|
|
67
76
|
font-size: $font-body-small;
|
|
68
|
-
color: var(--studio-woocommerce-purple-60);
|
|
77
|
+
color: var( --studio-woocommerce-purple-60 );
|
|
69
78
|
text-decoration: none;
|
|
70
79
|
|
|
71
80
|
&:focus {
|
|
72
|
-
box-shadow:
|
|
81
|
+
box-shadow:
|
|
82
|
+
0 0 0 2px var( --studio-white ),
|
|
83
|
+
0 0 0 4px var( --studio-woocommerce-purple-60 );
|
|
73
84
|
}
|
|
74
85
|
}
|
|
75
86
|
}
|
|
76
87
|
|
|
77
88
|
&.is-wooexpress-medium-plan {
|
|
78
|
-
background-color: var(--color-accent);
|
|
79
|
-
color: var(--color-text-inverted);
|
|
89
|
+
background-color: var( --color-accent );
|
|
90
|
+
color: var( --color-text-inverted );
|
|
80
91
|
font-weight: 400;
|
|
81
92
|
|
|
82
93
|
&:focus {
|
|
83
|
-
box-shadow:
|
|
94
|
+
box-shadow:
|
|
95
|
+
0 0 0 2px var( --color-surface ),
|
|
96
|
+
0 0 0 4px var( --color-accent );
|
|
84
97
|
}
|
|
85
98
|
}
|
|
86
99
|
|
|
87
100
|
&.is-wooexpress-small-plan {
|
|
88
|
-
background-color: var(--color-surface);
|
|
89
|
-
color: var(--color-accent);
|
|
90
|
-
border: 1px solid var(--color-accent);
|
|
101
|
+
background-color: var( --color-surface );
|
|
102
|
+
color: var( --color-accent );
|
|
103
|
+
border: 1px solid var( --color-accent );
|
|
91
104
|
font-weight: 400;
|
|
92
105
|
}
|
|
93
106
|
|
|
@@ -95,42 +108,48 @@
|
|
|
95
108
|
display: inline-block;
|
|
96
109
|
width: 85%;
|
|
97
110
|
text-align: center;
|
|
98
|
-
background-color: var(--color-surface);
|
|
99
|
-
color: var(--color-accent);
|
|
100
|
-
border: 1px solid
|
|
111
|
+
background-color: var( --color-surface );
|
|
112
|
+
color: var( --color-accent );
|
|
113
|
+
border: 1px solid var( --color-accent );
|
|
101
114
|
font-weight: 400;
|
|
102
115
|
}
|
|
103
116
|
|
|
104
117
|
&.is-ecommerce-plan {
|
|
105
|
-
background-color: var(--studio-woocommerce-purple-40);
|
|
118
|
+
background-color: var( --studio-woocommerce-purple-40 );
|
|
106
119
|
|
|
107
120
|
&:focus {
|
|
108
|
-
box-shadow:
|
|
121
|
+
box-shadow:
|
|
122
|
+
0 0 0 2px var( --studio-white ),
|
|
123
|
+
0 0 0 4px var( --studio-woocommerce-purple-40 );
|
|
109
124
|
}
|
|
110
125
|
|
|
111
126
|
&:hover {
|
|
112
|
-
background-color: var(--studio-woocommerce-purple-50);
|
|
127
|
+
background-color: var( --studio-woocommerce-purple-50 );
|
|
113
128
|
}
|
|
114
129
|
}
|
|
115
130
|
|
|
116
131
|
&.is-wpcom-enterprise-grid-plan {
|
|
117
|
-
background-color: var(--studio-gray-80);
|
|
132
|
+
background-color: var( --studio-gray-80 );
|
|
118
133
|
|
|
119
134
|
&:focus {
|
|
120
|
-
box-shadow:
|
|
135
|
+
box-shadow:
|
|
136
|
+
0 0 0 2px var( --studio-white ),
|
|
137
|
+
0 0 0 4px var( --studio-gray-80 );
|
|
121
138
|
}
|
|
122
139
|
|
|
123
140
|
&:hover {
|
|
124
|
-
background-color: var(--studio-gray-90);
|
|
141
|
+
background-color: var( --studio-gray-90 );
|
|
125
142
|
}
|
|
126
143
|
}
|
|
127
144
|
|
|
128
145
|
&.is-p2-plus-plan {
|
|
129
|
-
background-color: var(--color-accent);
|
|
130
|
-
color: var(--color-text-inverted);
|
|
146
|
+
background-color: var( --color-accent );
|
|
147
|
+
color: var( --color-text-inverted );
|
|
131
148
|
|
|
132
149
|
&:focus {
|
|
133
|
-
box-shadow:
|
|
150
|
+
box-shadow:
|
|
151
|
+
0 0 0 2px var( --color-surface ),
|
|
152
|
+
0 0 0 4px var( --color-accent );
|
|
134
153
|
}
|
|
135
154
|
}
|
|
136
155
|
|
|
@@ -140,25 +159,30 @@
|
|
|
140
159
|
&.is-secondary,
|
|
141
160
|
&.is-current-plan,
|
|
142
161
|
&.is-default {
|
|
143
|
-
background-color: var(--studio-white);
|
|
144
|
-
color: var(--studio-gray-100);
|
|
145
|
-
box-shadow: inset 0 0 0 1px var(--studio-gray-10);
|
|
162
|
+
background-color: var( --studio-white );
|
|
163
|
+
color: var( --studio-gray-100 );
|
|
164
|
+
box-shadow: inset 0 0 0 1px var( --studio-gray-10 );
|
|
146
165
|
|
|
147
166
|
&.is-storage-upgradeable {
|
|
148
|
-
background-color: var(--color-accent);
|
|
149
|
-
color: var(--color-text-inverted);
|
|
167
|
+
background-color: var( --color-accent );
|
|
168
|
+
color: var( --color-text-inverted );
|
|
150
169
|
}
|
|
151
170
|
|
|
152
171
|
&:hover {
|
|
153
|
-
|
|
154
|
-
|
|
172
|
+
background-color: var( --studio-white );
|
|
173
|
+
box-shadow: inset 0 0 0 1px var( --studio-gray-80 );
|
|
155
174
|
}
|
|
156
175
|
}
|
|
157
176
|
|
|
177
|
+
&:hover[disabled] {
|
|
178
|
+
background: none;
|
|
179
|
+
box-shadow: inset 0 0 0 1px #e0e0e0;
|
|
180
|
+
}
|
|
181
|
+
|
|
158
182
|
&.disabled,
|
|
159
183
|
&[disabled] {
|
|
160
|
-
background-color: var(--studio-white);
|
|
161
|
-
color: var(--color-neutral-light);
|
|
184
|
+
background-color: var( --studio-white );
|
|
185
|
+
color: var( --color-neutral-light );
|
|
162
186
|
box-shadow: inset 0 0 0 1px #e0e0e0;
|
|
163
187
|
}
|
|
164
188
|
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
1
2
|
const PlanDivOrTdContainer = (
|
|
2
3
|
props: (
|
|
3
4
|
| React.HTMLAttributes< HTMLDivElement >
|
|
4
5
|
| React.HTMLAttributes< HTMLTableCellElement >
|
|
5
|
-
) & { isTableCell?: boolean; scope?: string }
|
|
6
|
+
) & { isTableCell?: boolean; scope?: string; isHeader?: boolean }
|
|
6
7
|
): JSX.Element => {
|
|
7
|
-
const { children, isTableCell, ...otherProps } = props;
|
|
8
|
+
const { children, isTableCell, isHeader, ...otherProps } = props;
|
|
9
|
+
if ( isHeader ) {
|
|
10
|
+
return <th { ...otherProps }>{ children }</th>;
|
|
11
|
+
}
|
|
8
12
|
return isTableCell ? (
|
|
9
13
|
<td { ...otherProps }>{ children }</td>
|
|
10
14
|
) : (
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
isPremiumPlan,
|
|
9
9
|
isFreePlan,
|
|
10
10
|
PlanSlug,
|
|
11
|
+
isPartnerBundleOnboarding,
|
|
11
12
|
} from '@automattic/calypso-products';
|
|
12
13
|
import { CloudLogo, VIPLogo, WooLogo } from '@automattic/components';
|
|
13
14
|
import clsx from 'clsx';
|
|
@@ -29,8 +30,12 @@ const PlanLogo: React.FunctionComponent< {
|
|
|
29
30
|
} > = ( { planSlug, isInSignup, renderedGridPlans, isTableCell, planIndex } ) => {
|
|
30
31
|
const [ activeTooltipId, setActiveTooltipId ] = useManageTooltipToggle();
|
|
31
32
|
const translate = useTranslate();
|
|
32
|
-
const
|
|
33
|
-
const
|
|
33
|
+
const { gridPlansIndex, intent } = usePlansGridContext();
|
|
34
|
+
const isWooHostingSolutionsIntent = intent === 'plans-woo-hosting-solutions';
|
|
35
|
+
const shouldShowWooLogo =
|
|
36
|
+
isWooHostingSolutionsIntent ||
|
|
37
|
+
( isEcommercePlan( planSlug ) && ! isWooExpressPlan( planSlug ) );
|
|
38
|
+
const shouldShowPopularBadge = ! isPartnerBundleOnboarding();
|
|
34
39
|
const { current } = gridPlansIndex[ planSlug ];
|
|
35
40
|
const highlightAdjacencyMatrix = useHighlightAdjacencyMatrix( {
|
|
36
41
|
renderedGridPlans,
|
|
@@ -65,13 +70,15 @@ const PlanLogo: React.FunctionComponent< {
|
|
|
65
70
|
className={ tableItemClasses }
|
|
66
71
|
isTableCell={ isTableCell }
|
|
67
72
|
>
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
+
{ shouldShowPopularBadge && (
|
|
74
|
+
<PopularBadge
|
|
75
|
+
isInSignup={ isInSignup }
|
|
76
|
+
planSlug={ planSlug }
|
|
77
|
+
additionalClassName={ popularBadgeClasses }
|
|
78
|
+
/>
|
|
79
|
+
) }
|
|
73
80
|
<header className={ headerClasses }>
|
|
74
|
-
{ isBusinessPlan( planSlug ) && (
|
|
81
|
+
{ ! isWooHostingSolutionsIntent && isBusinessPlan( planSlug ) && (
|
|
75
82
|
<Plans2023Tooltip
|
|
76
83
|
text={ translate(
|
|
77
84
|
'WP Cloud gives you the tools you need to add scalable, highly available, extremely fast WordPress hosting.'
|
|
@@ -93,7 +100,7 @@ const PlanLogo: React.FunctionComponent< {
|
|
|
93
100
|
<WooLogo />
|
|
94
101
|
</Plans2023Tooltip>
|
|
95
102
|
) }
|
|
96
|
-
{ isWpcomEnterpriseGridPlan( planSlug ) && (
|
|
103
|
+
{ ! isWooHostingSolutionsIntent && isWpcomEnterpriseGridPlan( planSlug ) && (
|
|
97
104
|
<Plans2023Tooltip
|
|
98
105
|
text={ translate( 'The trusted choice for enterprise WordPress hosting.' ) }
|
|
99
106
|
id="enterprise-logo"
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { recordTracksEvent } from '@automattic/calypso-analytics';
|
|
2
2
|
import { CustomSelectControl } from '@wordpress/components';
|
|
3
|
+
import { useTranslate } from 'i18n-calypso';
|
|
3
4
|
import { useRef } from 'react';
|
|
4
5
|
import DropdownOption from '../../dropdown-option';
|
|
5
6
|
import useIntervalOptions from '../hooks/use-interval-options';
|
|
@@ -19,6 +20,7 @@ export const IntervalTypeDropdown: React.FunctionComponent< IntervalTypeProps >
|
|
|
19
20
|
) as SupportedUrlFriendlyTermType;
|
|
20
21
|
const optionsList = useIntervalOptions( props );
|
|
21
22
|
const hasOpenedDropdown = useRef( false );
|
|
23
|
+
const translate = useTranslate();
|
|
22
24
|
|
|
23
25
|
const selectOptionsList = Object.values( optionsList ).map( ( option ) => ( {
|
|
24
26
|
key: option.key,
|
|
@@ -32,8 +34,18 @@ export const IntervalTypeDropdown: React.FunctionComponent< IntervalTypeProps >
|
|
|
32
34
|
) : null }
|
|
33
35
|
</DropdownOption>
|
|
34
36
|
) as unknown as string,
|
|
37
|
+
accessibleName: option.name as string,
|
|
35
38
|
} ) );
|
|
36
39
|
|
|
40
|
+
const selectedOption = selectOptionsList.find( ( { key } ) => key === supportedIntervalType );
|
|
41
|
+
// Translators: This is a description of the currently selected billing period for accessibility.
|
|
42
|
+
// billingPeriod is the name of the billing period and it's translated.
|
|
43
|
+
const describedByText = selectedOption?.accessibleName
|
|
44
|
+
? translate( 'Currently selected billing period: %(billingPeriod)s', {
|
|
45
|
+
args: { billingPeriod: selectedOption.accessibleName },
|
|
46
|
+
} )
|
|
47
|
+
: undefined;
|
|
48
|
+
|
|
37
49
|
return (
|
|
38
50
|
<div className="plan-type-selector__interval-type-dropdown-container">
|
|
39
51
|
<CustomSelectControl
|
|
@@ -49,8 +61,9 @@ export const IntervalTypeDropdown: React.FunctionComponent< IntervalTypeProps >
|
|
|
49
61
|
} }
|
|
50
62
|
className="plan-type-selector__interval-type-dropdown"
|
|
51
63
|
label=""
|
|
64
|
+
describedBy={ describedByText as string }
|
|
52
65
|
options={ selectOptionsList }
|
|
53
|
-
value={
|
|
66
|
+
value={ selectedOption }
|
|
54
67
|
onChange={ ( {
|
|
55
68
|
selectedItem: { key: intervalType },
|
|
56
69
|
}: {
|
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type PlanSlug,
|
|
3
|
-
TERM_ANNUALLY,
|
|
4
|
-
getPlanSlugForTermVariant,
|
|
5
|
-
isMonthly,
|
|
6
|
-
isWpComPlan,
|
|
7
|
-
} from '@automattic/calypso-products';
|
|
1
|
+
import { type PlanSlug } from '@automattic/calypso-products';
|
|
8
2
|
import { Plans } from '@automattic/data-stores';
|
|
9
3
|
import { useState } from '@wordpress/element';
|
|
4
|
+
import useMaxDiscountsForPlanTerms from './use-max-discounts-for-plan-terms';
|
|
10
5
|
|
|
11
6
|
export default function useMaxDiscount(
|
|
12
7
|
plans: PlanSlug[],
|
|
@@ -14,47 +9,13 @@ export default function useMaxDiscount(
|
|
|
14
9
|
siteId?: number | null
|
|
15
10
|
): number {
|
|
16
11
|
const [ maxDiscount, setMaxDiscount ] = useState( 0 );
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.filter( Boolean ) as PlanSlug[];
|
|
21
|
-
const monthlyPlansPricing = Plans.usePricingMetaForGridPlans( {
|
|
22
|
-
planSlugs: wpcomMonthlyPlans,
|
|
23
|
-
siteId,
|
|
24
|
-
coupon: undefined,
|
|
12
|
+
const discounts = useMaxDiscountsForPlanTerms(
|
|
13
|
+
plans,
|
|
14
|
+
[ 'monthly', 'yearly' ],
|
|
25
15
|
useCheckPlanAvailabilityForPurchase,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
siteId,
|
|
30
|
-
coupon: undefined,
|
|
31
|
-
useCheckPlanAvailabilityForPurchase,
|
|
32
|
-
} );
|
|
33
|
-
|
|
34
|
-
const discounts = wpcomMonthlyPlans.map( ( planSlug ) => {
|
|
35
|
-
const yearlyVariantPlanSlug = getPlanSlugForTermVariant( planSlug, TERM_ANNUALLY );
|
|
36
|
-
|
|
37
|
-
if ( ! yearlyVariantPlanSlug ) {
|
|
38
|
-
return 0;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const monthlyPlanAnnualCost =
|
|
42
|
-
( monthlyPlansPricing?.[ planSlug ]?.originalPrice.full ?? 0 ) * 12;
|
|
43
|
-
|
|
44
|
-
if ( ! monthlyPlanAnnualCost ) {
|
|
45
|
-
return 0;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const yearlyPlanAnnualCost =
|
|
49
|
-
yearlyPlansPricing?.[ yearlyVariantPlanSlug ]?.discountedPrice.full ||
|
|
50
|
-
yearlyPlansPricing?.[ yearlyVariantPlanSlug ]?.originalPrice.full ||
|
|
51
|
-
0;
|
|
52
|
-
|
|
53
|
-
return Math.floor(
|
|
54
|
-
( ( monthlyPlanAnnualCost - yearlyPlanAnnualCost ) / ( monthlyPlanAnnualCost || 1 ) ) * 100
|
|
55
|
-
);
|
|
56
|
-
} );
|
|
57
|
-
const currentMaxDiscount = discounts.length ? Math.max( ...discounts ) : 0;
|
|
16
|
+
siteId
|
|
17
|
+
);
|
|
18
|
+
const currentMaxDiscount = discounts[ 'yearly' ] ?? 0;
|
|
58
19
|
|
|
59
20
|
if ( currentMaxDiscount > 0 && currentMaxDiscount !== maxDiscount ) {
|
|
60
21
|
setMaxDiscount( currentMaxDiscount );
|
|
@@ -10,6 +10,11 @@ import {
|
|
|
10
10
|
isWpcomEnterpriseGridPlan,
|
|
11
11
|
} from '@automattic/calypso-products';
|
|
12
12
|
import { Plans } from '@automattic/data-stores';
|
|
13
|
+
import {
|
|
14
|
+
calculateDiscountPercentage,
|
|
15
|
+
fromPricingMetaForGridPlan,
|
|
16
|
+
getPlanPriceForDuration,
|
|
17
|
+
} from '../../../lib/plan-pricing-utils';
|
|
13
18
|
|
|
14
19
|
/**
|
|
15
20
|
* Calculate the maximum discount for each term for a given set of plans
|
|
@@ -41,7 +46,6 @@ export default function useMaxDiscountsForPlanTerms(
|
|
|
41
46
|
? currentLowestTerm
|
|
42
47
|
: term;
|
|
43
48
|
}, terms[ 0 ] );
|
|
44
|
-
const lowestTermInMonths = getBillingMonthsForTerm( lowestTerm );
|
|
45
49
|
|
|
46
50
|
const lowestTermPlanSlugs = allRelatedPlanSlugs.filter(
|
|
47
51
|
( planSlug ) => getPlan( planSlug )?.term === lowestTerm
|
|
@@ -60,34 +64,32 @@ export default function useMaxDiscountsForPlanTerms(
|
|
|
60
64
|
>;
|
|
61
65
|
termDefinitionsMapping.forEach( ( termMapping ) => {
|
|
62
66
|
if ( termMapping.term === lowestTerm ) {
|
|
63
|
-
return
|
|
67
|
+
return;
|
|
64
68
|
}
|
|
65
69
|
const termDiscounts = lowestTermPlanSlugs.map( ( lowestTermPlanSlug ) => {
|
|
66
70
|
const lowestTermPlanPricing = plansPricing?.[ lowestTermPlanSlug ];
|
|
67
|
-
const
|
|
68
|
-
|
|
71
|
+
const lowestTermInfo = lowestTermPlanPricing
|
|
72
|
+
? fromPricingMetaForGridPlan( lowestTermPlanPricing )
|
|
73
|
+
: null;
|
|
74
|
+
if ( ! lowestTermInfo ) {
|
|
69
75
|
return 0;
|
|
70
76
|
}
|
|
71
|
-
const lowestTermMonthlyCost = lowestTermPlanCost / lowestTermInMonths;
|
|
72
77
|
|
|
73
|
-
/**
|
|
74
|
-
* Calculate the monthly cost of the term price
|
|
75
|
-
*/
|
|
76
78
|
const variantPlanSlug =
|
|
77
79
|
getPlanSlugForTermVariant( lowestTermPlanSlug, termMapping.term ) ?? '';
|
|
78
80
|
const variantPlanPricing = plansPricing?.[ variantPlanSlug ];
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
const variantInfo = variantPlanPricing
|
|
82
|
+
? fromPricingMetaForGridPlan( variantPlanPricing )
|
|
83
|
+
: null;
|
|
84
|
+
if ( ! variantInfo ) {
|
|
82
85
|
return 0;
|
|
83
86
|
}
|
|
84
|
-
const variantTermInMonths = getBillingMonthsForTerm(
|
|
85
|
-
URL_FRIENDLY_TERMS_MAPPING[ termMapping.urlFriendlyTerm ]
|
|
86
|
-
);
|
|
87
|
-
const variantTermMonthlyCost = variantTermPrice / variantTermInMonths;
|
|
88
87
|
|
|
89
|
-
return
|
|
90
|
-
(
|
|
88
|
+
return (
|
|
89
|
+
calculateDiscountPercentage(
|
|
90
|
+
getPlanPriceForDuration( lowestTermInfo, variantInfo.termMonths ),
|
|
91
|
+
getPlanPriceForDuration( variantInfo, variantInfo.termMonths )
|
|
92
|
+
) ?? 0
|
|
91
93
|
);
|
|
92
94
|
} );
|
|
93
95
|
termWiseMaxDiscount[ termMapping.urlFriendlyTerm ] = termDiscounts.length
|
|
@@ -4,16 +4,27 @@ import { TranslateResult } from 'i18n-calypso';
|
|
|
4
4
|
import { Dispatch, PropsWithChildren, SetStateAction, useRef } from 'react';
|
|
5
5
|
import { hasTouch } from '../lib/touch-detect';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Prevents widows by replacing the last space with a non-breaking space.
|
|
9
|
+
* @param text - The text to process
|
|
10
|
+
* @returns The text with the last space replaced with a non-breaking space
|
|
11
|
+
*/
|
|
12
|
+
const preventWidows = ( text: TranslateResult ): TranslateResult => {
|
|
13
|
+
if ( typeof text !== 'string' ) {
|
|
14
|
+
return text;
|
|
15
|
+
}
|
|
16
|
+
// Replace the last space with a non-breaking space to prevent widows
|
|
17
|
+
return text.replace( /\s+(\S+)$/, '\u00A0$1' );
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const HoverAreaContainer = styled.span``;
|
|
10
21
|
|
|
11
22
|
const StyledTooltip = styled( Tooltip )`
|
|
12
23
|
&.tooltip.popover .popover__inner {
|
|
13
24
|
background: var( --color-masterbar-background );
|
|
14
25
|
text-align: start;
|
|
15
26
|
border-radius: 4px;
|
|
16
|
-
min-height:
|
|
27
|
+
min-height: 16px;
|
|
17
28
|
width: 210px;
|
|
18
29
|
align-items: center;
|
|
19
30
|
font-style: normal;
|
|
@@ -58,6 +69,7 @@ export const Plans2023Tooltip = ( {
|
|
|
58
69
|
};
|
|
59
70
|
|
|
60
71
|
const isVisible = activeTooltipId === id;
|
|
72
|
+
const processedText = preventWidows( text );
|
|
61
73
|
|
|
62
74
|
return (
|
|
63
75
|
<>
|
|
@@ -78,7 +90,7 @@ export const Plans2023Tooltip = ( {
|
|
|
78
90
|
hideArrow
|
|
79
91
|
showOnMobile={ showOnMobile }
|
|
80
92
|
>
|
|
81
|
-
{
|
|
93
|
+
{ processedText }
|
|
82
94
|
</StyledTooltip>
|
|
83
95
|
</>
|
|
84
96
|
);
|