@automattic/plans-grid-next 1.0.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/CHANGELOG.md +4 -0
- package/README.md +3 -0
- package/dist/cjs/__mocks__/wpcom-proxy-request.js +17 -0
- package/dist/cjs/__mocks__/wpcom-proxy-request.js.map +1 -0
- package/dist/cjs/_media-queries.scss +14 -0
- package/dist/cjs/_mixins.scss +15 -0
- package/dist/cjs/_shared.scss +174 -0
- package/dist/cjs/components/comparison-grid/index.js +527 -0
- package/dist/cjs/components/comparison-grid/index.js.map +1 -0
- package/dist/cjs/components/comparison-grid/index.stories.js +74 -0
- package/dist/cjs/components/comparison-grid/index.stories.js.map +1 -0
- package/dist/cjs/components/comparison-grid/style.scss +318 -0
- package/dist/cjs/components/dropdown-option.js +33 -0
- package/dist/cjs/components/dropdown-option.js.map +1 -0
- package/dist/cjs/components/features-grid/billing-timeframes.js +15 -0
- package/dist/cjs/components/features-grid/billing-timeframes.js.map +1 -0
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js +106 -0
- package/dist/cjs/components/features-grid/client-logo-list/client-list.js.map +1 -0
- package/dist/cjs/components/features-grid/client-logo-list/index.js +17 -0
- package/dist/cjs/components/features-grid/client-logo-list/index.js.map +1 -0
- package/dist/cjs/components/features-grid/client-logo-list/style.scss +52 -0
- package/dist/cjs/components/features-grid/enterprise-features.js +41 -0
- package/dist/cjs/components/features-grid/enterprise-features.js.map +1 -0
- package/dist/cjs/components/features-grid/index.js +130 -0
- package/dist/cjs/components/features-grid/index.js.map +1 -0
- package/dist/cjs/components/features-grid/index.stories.js +112 -0
- package/dist/cjs/components/features-grid/index.stories.js.map +1 -0
- package/dist/cjs/components/features-grid/mobile-free-domain.js +25 -0
- package/dist/cjs/components/features-grid/mobile-free-domain.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-features-list.js +56 -0
- package/dist/cjs/components/features-grid/plan-features-list.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-headers.js +15 -0
- package/dist/cjs/components/features-grid/plan-headers.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-logos.js +12 -0
- package/dist/cjs/components/features-grid/plan-logos.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-prices.js +14 -0
- package/dist/cjs/components/features-grid/plan-prices.js.map +1 -0
- package/dist/cjs/components/features-grid/plan-tagline.js +12 -0
- package/dist/cjs/components/features-grid/plan-tagline.js.map +1 -0
- package/dist/cjs/components/features-grid/previous-features-included-title.js +36 -0
- package/dist/cjs/components/features-grid/previous-features-included-title.js.map +1 -0
- package/dist/cjs/components/features-grid/spotlight-plan.js +24 -0
- package/dist/cjs/components/features-grid/spotlight-plan.js.map +1 -0
- package/dist/cjs/components/features-grid/spotlight-plan.scss +5 -0
- package/dist/cjs/components/features-grid/style.scss +630 -0
- package/dist/cjs/components/features-grid/table.js +38 -0
- package/dist/cjs/components/features-grid/table.js.map +1 -0
- package/dist/cjs/components/features-grid/top-buttons.js +15 -0
- package/dist/cjs/components/features-grid/top-buttons.js.map +1 -0
- package/dist/cjs/components/features.js +72 -0
- package/dist/cjs/components/features.js.map +1 -0
- package/dist/cjs/components/item.js +9 -0
- package/dist/cjs/components/item.js.map +1 -0
- package/dist/cjs/components/plan-button/index.js +21 -0
- package/dist/cjs/components/plan-button/index.js.map +1 -0
- package/dist/cjs/components/plan-button/style.scss +179 -0
- package/dist/cjs/components/plan-div-td-container.js +9 -0
- package/dist/cjs/components/plan-div-td-container.js.map +1 -0
- package/dist/cjs/components/plan-logo.js +45 -0
- package/dist/cjs/components/plan-logo.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js +39 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-selector.js +12 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-selector.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-toggle.js +55 -0
- package/dist/cjs/components/plan-type-selector/components/interval-type-toggle.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/components/popup-messages.js +108 -0
- package/dist/cjs/components/plan-type-selector/components/popup-messages.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-interval-options.js +56 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-interval-options.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js +45 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discount.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +68 -0
- package/dist/cjs/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/index.js +27 -0
- package/dist/cjs/components/plan-type-selector/index.js.map +1 -0
- package/dist/cjs/components/plan-type-selector/style.scss +196 -0
- package/dist/cjs/components/plans-2023-tooltip.js +46 -0
- package/dist/cjs/components/plans-2023-tooltip.js.map +1 -0
- package/dist/cjs/components/popular-badge.js +16 -0
- package/dist/cjs/components/popular-badge.js.map +1 -0
- package/dist/cjs/components/shared/action-button/index.js +91 -0
- package/dist/cjs/components/shared/action-button/index.js.map +1 -0
- package/dist/cjs/components/shared/action-button/style.scss +12 -0
- package/dist/cjs/components/shared/billing-timeframe/index.js +58 -0
- package/dist/cjs/components/shared/billing-timeframe/index.js.map +1 -0
- package/dist/cjs/components/shared/header-price/header-price-context.js +14 -0
- package/dist/cjs/components/shared/header-price/header-price-context.js.map +1 -0
- package/dist/cjs/components/shared/header-price/index.js +102 -0
- package/dist/cjs/components/shared/header-price/index.js.map +1 -0
- package/dist/cjs/components/shared/header-price/style.scss +112 -0
- package/dist/cjs/components/shared/plan-pill/index.js +6 -0
- package/dist/cjs/components/shared/plan-pill/index.js.map +1 -0
- package/dist/cjs/components/shared/plan-pill/style.scss +30 -0
- package/dist/cjs/components/shared/storage/components/plan-storage.js +28 -0
- package/dist/cjs/components/shared/storage/components/plan-storage.js.map +1 -0
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js +96 -0
- package/dist/cjs/components/shared/storage/components/storage-dropdown.js.map +1 -0
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js +40 -0
- package/dist/cjs/components/shared/storage/components/storage-feature-label.js.map +1 -0
- package/dist/cjs/components/shared/storage/constants.js +6 -0
- package/dist/cjs/components/shared/storage/constants.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-default-storage-option.js +26 -0
- package/dist/cjs/components/shared/storage/hooks/use-default-storage-option.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js +29 -0
- package/dist/cjs/components/shared/storage/hooks/use-plan-storage.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-purchased-storage-add-on.js +51 -0
- package/dist/cjs/components/shared/storage/hooks/use-purchased-storage-add-on.js.map +1 -0
- package/dist/cjs/components/shared/storage/hooks/use-storage-string.js +13 -0
- package/dist/cjs/components/shared/storage/hooks/use-storage-string.js.map +1 -0
- package/dist/cjs/components/shared/storage/index.js +14 -0
- package/dist/cjs/components/shared/storage/index.js.map +1 -0
- package/dist/cjs/components/sticky-container.js +74 -0
- package/dist/cjs/components/sticky-container.js.map +1 -0
- package/dist/cjs/constants.js +11 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/css-mixins.js +14 -0
- package/dist/cjs/css-mixins.js.map +1 -0
- package/dist/cjs/fixtures/plans.js +1542 -0
- package/dist/cjs/fixtures/plans.js.map +1 -0
- package/dist/cjs/fixtures/sites-plans.js +458 -0
- package/dist/cjs/fixtures/sites-plans.js.map +1 -0
- package/dist/cjs/fixtures/sites-purchases.js +133 -0
- package/dist/cjs/fixtures/sites-purchases.js.map +1 -0
- package/dist/cjs/grid-context.js +40 -0
- package/dist/cjs/grid-context.js.map +1 -0
- package/dist/cjs/hooks/data-store/is-popular-plan.js +9 -0
- package/dist/cjs/hooks/data-store/is-popular-plan.js.map +1 -0
- package/dist/cjs/hooks/data-store/types.js +3 -0
- package/dist/cjs/hooks/data-store/types.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plan-for-spotlight.js +18 -0
- package/dist/cjs/hooks/data-store/use-grid-plan-for-spotlight.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js +55 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js +56 -0
- package/dist/cjs/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-grid-plans.js +254 -0
- package/dist/cjs/hooks/data-store/use-grid-plans.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-highlight-labels.js +60 -0
- package/dist/cjs/hooks/data-store/use-highlight-labels.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-highlighted-features.js +35 -0
- package/dist/cjs/hooks/data-store/use-highlighted-features.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js +216 -0
- package/dist/cjs/hooks/data-store/use-plan-billing-description.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js +133 -0
- package/dist/cjs/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-plans-from-types.js +30 -0
- package/dist/cjs/hooks/data-store/use-plans-from-types.js.map +1 -0
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +90 -0
- package/dist/cjs/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -0
- package/dist/cjs/hooks/use-grid-size.js +33 -0
- package/dist/cjs/hooks/use-grid-size.js.map +1 -0
- package/dist/cjs/hooks/use-highlight-adjacency-matrix.js +31 -0
- package/dist/cjs/hooks/use-highlight-adjacency-matrix.js.map +1 -0
- package/dist/cjs/hooks/use-is-large-currency.js +69 -0
- package/dist/cjs/hooks/use-is-large-currency.js.map +1 -0
- package/dist/cjs/hooks/use-manage-tooltip-toggle.js +29 -0
- package/dist/cjs/hooks/use-manage-tooltip-toggle.js.map +1 -0
- package/dist/cjs/hooks/use-plan-pricing-info-from-grid-plans.js +17 -0
- package/dist/cjs/hooks/use-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/filter-unused-features-object.js +19 -0
- package/dist/cjs/lib/filter-unused-features-object.js.map +1 -0
- package/dist/cjs/lib/get-plan-features-object.js +11 -0
- package/dist/cjs/lib/get-plan-features-object.js.map +1 -0
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js +16 -0
- package/dist/cjs/lib/get-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/cjs/lib/is-same-plan.js +12 -0
- package/dist/cjs/lib/is-same-plan.js.map +1 -0
- package/dist/cjs/lib/sort-plan-properties.js +39 -0
- package/dist/cjs/lib/sort-plan-properties.js.map +1 -0
- package/dist/cjs/lib/touch-detect/index.js +20 -0
- package/dist/cjs/lib/touch-detect/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/__mocks__/wpcom-proxy-request.js +11 -0
- package/dist/esm/__mocks__/wpcom-proxy-request.js.map +1 -0
- package/dist/esm/_media-queries.scss +14 -0
- package/dist/esm/_mixins.scss +15 -0
- package/dist/esm/_shared.scss +174 -0
- package/dist/esm/components/comparison-grid/index.js +524 -0
- package/dist/esm/components/comparison-grid/index.js.map +1 -0
- package/dist/esm/components/comparison-grid/index.stories.js +71 -0
- package/dist/esm/components/comparison-grid/index.stories.js.map +1 -0
- package/dist/esm/components/comparison-grid/style.scss +318 -0
- package/dist/esm/components/dropdown-option.js +30 -0
- package/dist/esm/components/dropdown-option.js.map +1 -0
- package/dist/esm/components/features-grid/billing-timeframes.js +12 -0
- package/dist/esm/components/features-grid/billing-timeframes.js.map +1 -0
- package/dist/esm/components/features-grid/client-logo-list/client-list.js +104 -0
- package/dist/esm/components/features-grid/client-logo-list/client-list.js.map +1 -0
- package/dist/esm/components/features-grid/client-logo-list/index.js +14 -0
- package/dist/esm/components/features-grid/client-logo-list/index.js.map +1 -0
- package/dist/esm/components/features-grid/client-logo-list/style.scss +52 -0
- package/dist/esm/components/features-grid/enterprise-features.js +38 -0
- package/dist/esm/components/features-grid/enterprise-features.js.map +1 -0
- package/dist/esm/components/features-grid/index.js +127 -0
- package/dist/esm/components/features-grid/index.js.map +1 -0
- package/dist/esm/components/features-grid/index.stories.js +109 -0
- package/dist/esm/components/features-grid/index.stories.js.map +1 -0
- package/dist/esm/components/features-grid/mobile-free-domain.js +23 -0
- package/dist/esm/components/features-grid/mobile-free-domain.js.map +1 -0
- package/dist/esm/components/features-grid/plan-features-list.js +53 -0
- package/dist/esm/components/features-grid/plan-features-list.js.map +1 -0
- package/dist/esm/components/features-grid/plan-headers.js +12 -0
- package/dist/esm/components/features-grid/plan-headers.js.map +1 -0
- package/dist/esm/components/features-grid/plan-logos.js +9 -0
- package/dist/esm/components/features-grid/plan-logos.js.map +1 -0
- package/dist/esm/components/features-grid/plan-prices.js +11 -0
- package/dist/esm/components/features-grid/plan-prices.js.map +1 -0
- package/dist/esm/components/features-grid/plan-tagline.js +9 -0
- package/dist/esm/components/features-grid/plan-tagline.js.map +1 -0
- package/dist/esm/components/features-grid/previous-features-included-title.js +33 -0
- package/dist/esm/components/features-grid/previous-features-included-title.js.map +1 -0
- package/dist/esm/components/features-grid/spotlight-plan.js +21 -0
- package/dist/esm/components/features-grid/spotlight-plan.js.map +1 -0
- package/dist/esm/components/features-grid/spotlight-plan.scss +5 -0
- package/dist/esm/components/features-grid/style.scss +630 -0
- package/dist/esm/components/features-grid/table.js +35 -0
- package/dist/esm/components/features-grid/table.js.map +1 -0
- package/dist/esm/components/features-grid/top-buttons.js +12 -0
- package/dist/esm/components/features-grid/top-buttons.js.map +1 -0
- package/dist/esm/components/features.js +69 -0
- package/dist/esm/components/features.js.map +1 -0
- package/dist/esm/components/item.js +5 -0
- package/dist/esm/components/item.js.map +1 -0
- package/dist/esm/components/plan-button/index.js +18 -0
- package/dist/esm/components/plan-button/index.js.map +1 -0
- package/dist/esm/components/plan-button/style.scss +179 -0
- package/dist/esm/components/plan-div-td-container.js +7 -0
- package/dist/esm/components/plan-div-td-container.js.map +1 -0
- package/dist/esm/components/plan-logo.js +42 -0
- package/dist/esm/components/plan-logo.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js +34 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-dropdown.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-selector.js +8 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-selector.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-toggle.js +50 -0
- package/dist/esm/components/plan-type-selector/components/interval-type-toggle.js.map +1 -0
- package/dist/esm/components/plan-type-selector/components/popup-messages.js +105 -0
- package/dist/esm/components/plan-type-selector/components/popup-messages.js.map +1 -0
- package/dist/esm/components/plan-type-selector/hooks/use-interval-options.js +52 -0
- package/dist/esm/components/plan-type-selector/hooks/use-interval-options.js.map +1 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js +42 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discount.js.map +1 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js +65 -0
- package/dist/esm/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.js.map +1 -0
- package/dist/esm/components/plan-type-selector/index.js +24 -0
- package/dist/esm/components/plan-type-selector/index.js.map +1 -0
- package/dist/esm/components/plan-type-selector/style.scss +196 -0
- package/dist/esm/components/plans-2023-tooltip.js +41 -0
- package/dist/esm/components/plans-2023-tooltip.js.map +1 -0
- package/dist/esm/components/popular-badge.js +13 -0
- package/dist/esm/components/popular-badge.js.map +1 -0
- package/dist/esm/components/shared/action-button/index.js +88 -0
- package/dist/esm/components/shared/action-button/index.js.map +1 -0
- package/dist/esm/components/shared/action-button/style.scss +12 -0
- package/dist/esm/components/shared/billing-timeframe/index.js +55 -0
- package/dist/esm/components/shared/billing-timeframe/index.js.map +1 -0
- package/dist/esm/components/shared/header-price/header-price-context.js +10 -0
- package/dist/esm/components/shared/header-price/header-price-context.js.map +1 -0
- package/dist/esm/components/shared/header-price/index.js +99 -0
- package/dist/esm/components/shared/header-price/index.js.map +1 -0
- package/dist/esm/components/shared/header-price/style.scss +112 -0
- package/dist/esm/components/shared/plan-pill/index.js +4 -0
- package/dist/esm/components/shared/plan-pill/index.js.map +1 -0
- package/dist/esm/components/shared/plan-pill/style.scss +30 -0
- package/dist/esm/components/shared/storage/components/plan-storage.js +25 -0
- package/dist/esm/components/shared/storage/components/plan-storage.js.map +1 -0
- package/dist/esm/components/shared/storage/components/storage-dropdown.js +93 -0
- package/dist/esm/components/shared/storage/components/storage-dropdown.js.map +1 -0
- package/dist/esm/components/shared/storage/components/storage-feature-label.js +37 -0
- package/dist/esm/components/shared/storage/components/storage-feature-label.js.map +1 -0
- package/dist/esm/components/shared/storage/constants.js +3 -0
- package/dist/esm/components/shared/storage/constants.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-default-storage-option.js +22 -0
- package/dist/esm/components/shared/storage/hooks/use-default-storage-option.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js +27 -0
- package/dist/esm/components/shared/storage/hooks/use-plan-storage.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-purchased-storage-add-on.js +48 -0
- package/dist/esm/components/shared/storage/hooks/use-purchased-storage-add-on.js.map +1 -0
- package/dist/esm/components/shared/storage/hooks/use-storage-string.js +11 -0
- package/dist/esm/components/shared/storage/hooks/use-storage-string.js.map +1 -0
- package/dist/esm/components/shared/storage/index.js +9 -0
- package/dist/esm/components/shared/storage/index.js.map +1 -0
- package/dist/esm/components/sticky-container.js +69 -0
- package/dist/esm/components/sticky-container.js.map +1 -0
- package/dist/esm/constants.js +8 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/css-mixins.js +10 -0
- package/dist/esm/css-mixins.js.map +1 -0
- package/dist/esm/fixtures/plans.js +1540 -0
- package/dist/esm/fixtures/plans.js.map +1 -0
- package/dist/esm/fixtures/sites-plans.js +456 -0
- package/dist/esm/fixtures/sites-plans.js.map +1 -0
- package/dist/esm/fixtures/sites-purchases.js +131 -0
- package/dist/esm/fixtures/sites-purchases.js.map +1 -0
- package/dist/esm/grid-context.js +36 -0
- package/dist/esm/grid-context.js.map +1 -0
- package/dist/esm/hooks/data-store/is-popular-plan.js +5 -0
- package/dist/esm/hooks/data-store/is-popular-plan.js.map +1 -0
- package/dist/esm/hooks/data-store/types.js +2 -0
- package/dist/esm/hooks/data-store/types.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plan-for-spotlight.js +16 -0
- package/dist/esm/hooks/data-store/use-grid-plan-for-spotlight.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js +52 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-comparison-grid.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js +53 -0
- package/dist/esm/hooks/data-store/use-grid-plans-for-features-grid.js.map +1 -0
- package/dist/esm/hooks/data-store/use-grid-plans.js +249 -0
- package/dist/esm/hooks/data-store/use-grid-plans.js.map +1 -0
- package/dist/esm/hooks/data-store/use-highlight-labels.js +58 -0
- package/dist/esm/hooks/data-store/use-highlight-labels.js.map +1 -0
- package/dist/esm/hooks/data-store/use-highlighted-features.js +33 -0
- package/dist/esm/hooks/data-store/use-highlighted-features.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plan-billing-description.js +213 -0
- package/dist/esm/hooks/data-store/use-plan-billing-description.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js +130 -0
- package/dist/esm/hooks/data-store/use-plan-features-for-grid-plans.js.map +1 -0
- package/dist/esm/hooks/data-store/use-plans-from-types.js +27 -0
- package/dist/esm/hooks/data-store/use-plans-from-types.js.map +1 -0
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js +87 -0
- package/dist/esm/hooks/data-store/use-restructured-plan-features-for-comparison-grid.js.map +1 -0
- package/dist/esm/hooks/use-grid-size.js +29 -0
- package/dist/esm/hooks/use-grid-size.js.map +1 -0
- package/dist/esm/hooks/use-highlight-adjacency-matrix.js +29 -0
- package/dist/esm/hooks/use-highlight-adjacency-matrix.js.map +1 -0
- package/dist/esm/hooks/use-is-large-currency.js +66 -0
- package/dist/esm/hooks/use-is-large-currency.js.map +1 -0
- package/dist/esm/hooks/use-manage-tooltip-toggle.js +25 -0
- package/dist/esm/hooks/use-manage-tooltip-toggle.js.map +1 -0
- package/dist/esm/hooks/use-plan-pricing-info-from-grid-plans.js +13 -0
- package/dist/esm/hooks/use-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/esm/index.js +28 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/filter-unused-features-object.js +17 -0
- package/dist/esm/lib/filter-unused-features-object.js.map +1 -0
- package/dist/esm/lib/get-plan-features-object.js +9 -0
- package/dist/esm/lib/get-plan-features-object.js.map +1 -0
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js +12 -0
- package/dist/esm/lib/get-plan-pricing-info-from-grid-plans.js.map +1 -0
- package/dist/esm/lib/is-same-plan.js +8 -0
- package/dist/esm/lib/is-same-plan.js.map +1 -0
- package/dist/esm/lib/sort-plan-properties.js +35 -0
- package/dist/esm/lib/sort-plan-properties.js.map +1 -0
- package/dist/esm/lib/touch-detect/index.js +16 -0
- package/dist/esm/lib/touch-detect/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/tsconfig-cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/__mocks__/wpcom-proxy-request.d.ts +8 -0
- package/dist/types/__mocks__/wpcom-proxy-request.d.ts.map +1 -0
- package/dist/types/components/comparison-grid/index.d.ts +5 -0
- package/dist/types/components/comparison-grid/index.d.ts.map +1 -0
- package/dist/types/components/comparison-grid/index.stories.d.ts +66 -0
- package/dist/types/components/comparison-grid/index.stories.d.ts.map +1 -0
- package/dist/types/components/dropdown-option.d.ts +10 -0
- package/dist/types/components/dropdown-option.d.ts.map +1 -0
- package/dist/types/components/features-grid/billing-timeframes.d.ts +11 -0
- package/dist/types/components/features-grid/billing-timeframes.d.ts.map +1 -0
- package/dist/types/components/features-grid/client-logo-list/client-list.d.ts +11 -0
- package/dist/types/components/features-grid/client-logo-list/client-list.d.ts.map +1 -0
- package/dist/types/components/features-grid/client-logo-list/index.d.ts +4 -0
- package/dist/types/components/features-grid/client-logo-list/index.d.ts.map +1 -0
- package/dist/types/components/features-grid/enterprise-features.d.ts +11 -0
- package/dist/types/components/features-grid/enterprise-features.d.ts.map +1 -0
- package/dist/types/components/features-grid/index.d.ts +5 -0
- package/dist/types/components/features-grid/index.d.ts.map +1 -0
- package/dist/types/components/features-grid/index.stories.d.ts +173 -0
- package/dist/types/components/features-grid/index.stories.d.ts.map +1 -0
- package/dist/types/components/features-grid/mobile-free-domain.d.ts +8 -0
- package/dist/types/components/features-grid/mobile-free-domain.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-features-list.d.ts +31 -0
- package/dist/types/components/features-grid/plan-features-list.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-headers.d.ts +10 -0
- package/dist/types/components/features-grid/plan-headers.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-logos.d.ts +11 -0
- package/dist/types/components/features-grid/plan-logos.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-prices.d.ts +11 -0
- package/dist/types/components/features-grid/plan-prices.d.ts.map +1 -0
- package/dist/types/components/features-grid/plan-tagline.d.ts +10 -0
- package/dist/types/components/features-grid/plan-tagline.d.ts.map +1 -0
- package/dist/types/components/features-grid/previous-features-included-title.d.ts +10 -0
- package/dist/types/components/features-grid/previous-features-included-title.d.ts.map +1 -0
- package/dist/types/components/features-grid/spotlight-plan.d.ts +17 -0
- package/dist/types/components/features-grid/spotlight-plan.d.ts.map +1 -0
- package/dist/types/components/features-grid/table.d.ts +26 -0
- package/dist/types/components/features-grid/table.d.ts.map +1 -0
- package/dist/types/components/features-grid/top-buttons.d.ts +14 -0
- package/dist/types/components/features-grid/top-buttons.d.ts.map +1 -0
- package/dist/types/components/features.d.ts +17 -0
- package/dist/types/components/features.d.ts.map +1 -0
- package/dist/types/components/item.d.ts +5 -0
- package/dist/types/components/item.d.ts.map +1 -0
- package/dist/types/components/plan-button/index.d.ts +17 -0
- package/dist/types/components/plan-button/index.d.ts.map +1 -0
- package/dist/types/components/plan-div-td-container.d.ts +7 -0
- package/dist/types/components/plan-div-td-container.d.ts.map +1 -0
- package/dist/types/components/plan-logo.d.ts +12 -0
- package/dist/types/components/plan-logo.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/interval-type-dropdown.d.ts +4 -0
- package/dist/types/components/plan-type-selector/components/interval-type-dropdown.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/interval-type-selector.d.ts +4 -0
- package/dist/types/components/plan-type-selector/components/interval-type-selector.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/interval-type-toggle.d.ts +4 -0
- package/dist/types/components/plan-type-selector/components/interval-type-toggle.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/components/popup-messages.d.ts +9 -0
- package/dist/types/components/plan-type-selector/components/popup-messages.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/hooks/use-interval-options.d.ts +11 -0
- package/dist/types/components/plan-type-selector/hooks/use-interval-options.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discount.d.ts +4 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discount.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.d.ts +10 -0
- package/dist/types/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.d.ts.map +1 -0
- package/dist/types/components/plan-type-selector/index.d.ts +6 -0
- package/dist/types/components/plan-type-selector/index.d.ts.map +1 -0
- package/dist/types/components/plans-2023-tooltip.d.ts +11 -0
- package/dist/types/components/plans-2023-tooltip.d.ts.map +1 -0
- package/dist/types/components/popular-badge.d.ts +9 -0
- package/dist/types/components/popular-badge.d.ts.map +1 -0
- package/dist/types/components/shared/action-button/index.d.ts +19 -0
- package/dist/types/components/shared/action-button/index.d.ts.map +1 -0
- package/dist/types/components/shared/billing-timeframe/index.d.ts +8 -0
- package/dist/types/components/shared/billing-timeframe/index.d.ts.map +1 -0
- package/dist/types/components/shared/header-price/header-price-context.d.ts +12 -0
- package/dist/types/components/shared/header-price/header-price-context.d.ts.map +1 -0
- package/dist/types/components/shared/header-price/index.d.ts +11 -0
- package/dist/types/components/shared/header-price/index.d.ts.map +1 -0
- package/dist/types/components/shared/plan-pill/index.d.ts +3 -0
- package/dist/types/components/shared/plan-pill/index.d.ts.map +1 -0
- package/dist/types/components/shared/storage/components/plan-storage.d.ts +13 -0
- package/dist/types/components/shared/storage/components/plan-storage.d.ts.map +1 -0
- package/dist/types/components/shared/storage/components/storage-dropdown.d.ts +9 -0
- package/dist/types/components/shared/storage/components/storage-dropdown.d.ts.map +1 -0
- package/dist/types/components/shared/storage/components/storage-feature-label.d.ts +7 -0
- package/dist/types/components/shared/storage/components/storage-feature-label.d.ts.map +1 -0
- package/dist/types/components/shared/storage/constants.d.ts +2 -0
- package/dist/types/components/shared/storage/constants.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-default-storage-option.d.ts +14 -0
- package/dist/types/components/shared/storage/hooks/use-default-storage-option.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts +4 -0
- package/dist/types/components/shared/storage/hooks/use-plan-storage.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-purchased-storage-add-on.d.ts +3 -0
- package/dist/types/components/shared/storage/hooks/use-purchased-storage-add-on.d.ts.map +1 -0
- package/dist/types/components/shared/storage/hooks/use-storage-string.d.ts +4 -0
- package/dist/types/components/shared/storage/hooks/use-storage-string.d.ts.map +1 -0
- package/dist/types/components/shared/storage/index.d.ts +9 -0
- package/dist/types/components/shared/storage/index.d.ts.map +1 -0
- package/dist/types/components/sticky-container.d.ts +33 -0
- package/dist/types/components/sticky-container.d.ts.map +1 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/css-mixins.d.ts +3 -0
- package/dist/types/css-mixins.d.ts.map +1 -0
- package/dist/types/fixtures/plans.d.ts +201 -0
- package/dist/types/fixtures/plans.d.ts.map +1 -0
- package/dist/types/fixtures/sites-plans.d.ts +457 -0
- package/dist/types/fixtures/sites-plans.d.ts.map +1 -0
- package/dist/types/fixtures/sites-purchases.d.ts +96 -0
- package/dist/types/fixtures/sites-purchases.d.ts.map +1 -0
- package/dist/types/grid-context.d.ts +40 -0
- package/dist/types/grid-context.d.ts.map +1 -0
- package/dist/types/hooks/data-store/is-popular-plan.d.ts +2 -0
- package/dist/types/hooks/data-store/is-popular-plan.d.ts.map +1 -0
- package/dist/types/hooks/data-store/types.d.ts +40 -0
- package/dist/types/hooks/data-store/types.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plan-for-spotlight.d.ts +10 -0
- package/dist/types/hooks/data-store/use-grid-plan-for-spotlight.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts +5 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-comparison-grid.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts +5 -0
- package/dist/types/hooks/data-store/use-grid-plans-for-features-grid.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-grid-plans.d.ts +13 -0
- package/dist/types/hooks/data-store/use-grid-plans.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-highlight-labels.d.ts +20 -0
- package/dist/types/hooks/data-store/use-highlight-labels.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-highlighted-features.d.ts +22 -0
- package/dist/types/hooks/data-store/use-highlighted-features.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plan-billing-description.d.ts +16 -0
- package/dist/types/hooks/data-store/use-plan-billing-description.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts +21 -0
- package/dist/types/hooks/data-store/use-plan-features-for-grid-plans.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-plans-from-types.d.ts +10 -0
- package/dist/types/hooks/data-store/use-plans-from-types.d.ts.map +1 -0
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts +15 -0
- package/dist/types/hooks/data-store/use-restructured-plan-features-for-comparison-grid.d.ts.map +1 -0
- package/dist/types/hooks/use-grid-size.d.ts +18 -0
- package/dist/types/hooks/use-grid-size.d.ts.map +1 -0
- package/dist/types/hooks/use-highlight-adjacency-matrix.d.ts +15 -0
- package/dist/types/hooks/use-highlight-adjacency-matrix.d.ts.map +1 -0
- package/dist/types/hooks/use-is-large-currency.d.ts +16 -0
- package/dist/types/hooks/use-is-large-currency.d.ts.map +1 -0
- package/dist/types/hooks/use-manage-tooltip-toggle.d.ts +3 -0
- package/dist/types/hooks/use-manage-tooltip-toggle.d.ts.map +1 -0
- package/dist/types/hooks/use-plan-pricing-info-from-grid-plans.d.ts +11 -0
- package/dist/types/hooks/use-plan-pricing-info-from-grid-plans.d.ts.map +1 -0
- package/dist/types/index.d.ts +32 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/lib/filter-unused-features-object.d.ts +8 -0
- package/dist/types/lib/filter-unused-features-object.d.ts.map +1 -0
- package/dist/types/lib/get-plan-features-object.d.ts +4 -0
- package/dist/types/lib/get-plan-features-object.d.ts.map +1 -0
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts +9 -0
- package/dist/types/lib/get-plan-pricing-info-from-grid-plans.d.ts.map +1 -0
- package/dist/types/lib/is-same-plan.d.ts +3 -0
- package/dist/types/lib/is-same-plan.d.ts.map +1 -0
- package/dist/types/lib/sort-plan-properties.d.ts +3 -0
- package/dist/types/lib/sort-plan-properties.d.ts.map +1 -0
- package/dist/types/lib/touch-detect/index.d.ts +11 -0
- package/dist/types/lib/touch-detect/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +225 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +83 -0
- package/src/__mocks__/wpcom-proxy-request.js +13 -0
- package/src/_media-queries.scss +14 -0
- package/src/_mixins.scss +15 -0
- package/src/_shared.scss +174 -0
- package/src/components/comparison-grid/README.md +3 -0
- package/src/components/comparison-grid/index.stories.tsx +91 -0
- package/src/components/comparison-grid/index.tsx +1215 -0
- package/src/components/comparison-grid/style.scss +318 -0
- package/src/components/dropdown-option.tsx +44 -0
- package/src/components/features-grid/README.md +3 -0
- package/src/components/features-grid/billing-timeframes.tsx +37 -0
- package/src/components/features-grid/client-logo-list/client-list.tsx +199 -0
- package/src/components/features-grid/client-logo-list/index.tsx +24 -0
- package/src/components/features-grid/client-logo-list/style.scss +52 -0
- package/src/components/features-grid/enterprise-features.tsx +101 -0
- package/src/components/features-grid/index.stories.tsx +143 -0
- package/src/components/features-grid/index.tsx +442 -0
- package/src/components/features-grid/mobile-free-domain.tsx +51 -0
- package/src/components/features-grid/plan-features-list.tsx +187 -0
- package/src/components/features-grid/plan-headers.tsx +31 -0
- package/src/components/features-grid/plan-logos.tsx +27 -0
- package/src/components/features-grid/plan-prices.tsx +37 -0
- package/src/components/features-grid/plan-tagline.tsx +25 -0
- package/src/components/features-grid/previous-features-included-title.tsx +66 -0
- package/src/components/features-grid/spotlight-plan.scss +5 -0
- package/src/components/features-grid/spotlight-plan.tsx +77 -0
- package/src/components/features-grid/style.scss +630 -0
- package/src/components/features-grid/table.tsx +185 -0
- package/src/components/features-grid/top-buttons.tsx +49 -0
- package/src/components/features.tsx +168 -0
- package/src/components/item.tsx +9 -0
- package/src/components/plan-button/index.tsx +59 -0
- package/src/components/plan-button/style.scss +179 -0
- package/src/components/plan-div-td-container.tsx +15 -0
- package/src/components/plan-logo.tsx +111 -0
- package/src/components/plan-type-selector/components/interval-type-dropdown.tsx +70 -0
- package/src/components/plan-type-selector/components/interval-type-selector.tsx +13 -0
- package/src/components/plan-type-selector/components/interval-type-toggle.tsx +100 -0
- package/src/components/plan-type-selector/components/popup-messages.tsx +128 -0
- package/src/components/plan-type-selector/hooks/use-interval-options.tsx +89 -0
- package/src/components/plan-type-selector/hooks/use-max-discount.ts +64 -0
- package/src/components/plan-type-selector/hooks/use-max-discounts-for-plan-terms.ts +99 -0
- package/src/components/plan-type-selector/index.tsx +50 -0
- package/src/components/plan-type-selector/style.scss +196 -0
- package/src/components/plans-2023-tooltip.tsx +85 -0
- package/src/components/popular-badge.tsx +30 -0
- package/src/components/shared/README.md +1 -0
- package/src/components/shared/action-button/index.tsx +205 -0
- package/src/components/shared/action-button/style.scss +12 -0
- package/src/components/shared/billing-timeframe/index.tsx +106 -0
- package/src/components/shared/header-price/header-price-context.tsx +24 -0
- package/src/components/shared/header-price/index.tsx +278 -0
- package/src/components/shared/header-price/style.scss +112 -0
- package/src/components/shared/plan-pill/index.jsx +7 -0
- package/src/components/shared/plan-pill/style.scss +30 -0
- package/src/components/shared/storage/components/plan-storage.tsx +51 -0
- package/src/components/shared/storage/components/storage-dropdown.tsx +187 -0
- package/src/components/shared/storage/components/storage-feature-label.tsx +68 -0
- package/src/components/shared/storage/constants.ts +3 -0
- package/src/components/shared/storage/hooks/use-default-storage-option.ts +34 -0
- package/src/components/shared/storage/hooks/use-plan-storage.ts +41 -0
- package/src/components/shared/storage/hooks/use-purchased-storage-add-on.ts +53 -0
- package/src/components/shared/storage/hooks/use-storage-string.ts +13 -0
- package/src/components/shared/storage/index.ts +9 -0
- package/src/components/sticky-container.tsx +146 -0
- package/src/components/test/actions-button.tsx +397 -0
- package/src/components/test/billing-timeframe.tsx +341 -0
- package/src/components/test/header-price.tsx +189 -0
- package/src/components/test/plan-type-selector.tsx +44 -0
- package/src/constants.ts +13 -0
- package/src/css-mixins.tsx +11 -0
- package/src/fixtures/plans.ts +1539 -0
- package/src/fixtures/sites-plans.ts +455 -0
- package/src/fixtures/sites-purchases.ts +130 -0
- package/src/grid-context.tsx +104 -0
- package/src/hooks/data-store/is-popular-plan.ts +5 -0
- package/src/hooks/data-store/types.ts +41 -0
- package/src/hooks/data-store/use-grid-plan-for-spotlight.ts +35 -0
- package/src/hooks/data-store/use-grid-plans-for-comparison-grid.ts +81 -0
- package/src/hooks/data-store/use-grid-plans-for-features-grid.ts +79 -0
- package/src/hooks/data-store/use-grid-plans.tsx +360 -0
- package/src/hooks/data-store/use-highlight-labels.ts +88 -0
- package/src/hooks/data-store/use-highlighted-features.ts +51 -0
- package/src/hooks/data-store/use-plan-billing-description.tsx +309 -0
- package/src/hooks/data-store/use-plan-features-for-grid-plans.ts +219 -0
- package/src/hooks/data-store/use-plans-from-types.ts +51 -0
- package/src/hooks/data-store/use-restructured-plan-features-for-comparison-grid.ts +158 -0
- package/src/hooks/test/use-is-large-currency.ts +69 -0
- package/src/hooks/use-grid-size.ts +46 -0
- package/src/hooks/use-highlight-adjacency-matrix.ts +48 -0
- package/src/hooks/use-is-large-currency.ts +91 -0
- package/src/hooks/use-manage-tooltip-toggle.ts +30 -0
- package/src/hooks/use-plan-pricing-info-from-grid-plans.ts +36 -0
- package/src/index.tsx +46 -0
- package/src/lib/filter-unused-features-object.ts +31 -0
- package/src/lib/get-plan-features-object.ts +12 -0
- package/src/lib/get-plan-pricing-info-from-grid-plans.ts +31 -0
- package/src/lib/is-same-plan.ts +8 -0
- package/src/lib/sort-plan-properties.ts +46 -0
- package/src/lib/test/filter-plan-features-object.ts +65 -0
- package/src/lib/test/sort-plan-properties.ts +104 -0
- package/src/lib/touch-detect/README.md +11 -0
- package/src/lib/touch-detect/index.js +17 -0
- package/src/types.ts +340 -0
|
@@ -0,0 +1,1215 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getPlanClass,
|
|
3
|
+
FEATURE_GROUP_ESSENTIAL_FEATURES,
|
|
4
|
+
FEATURE_GROUP_PAYMENT_TRANSACTION_FEES,
|
|
5
|
+
getPlans,
|
|
6
|
+
} from '@automattic/calypso-products';
|
|
7
|
+
import { Gridicon, JetpackLogo } from '@automattic/components';
|
|
8
|
+
import { AddOns } from '@automattic/data-stores';
|
|
9
|
+
import { css } from '@emotion/react';
|
|
10
|
+
import styled from '@emotion/styled';
|
|
11
|
+
import { useRef, useMemo } from '@wordpress/element';
|
|
12
|
+
import { Icon, chevronRightSmall } from '@wordpress/icons';
|
|
13
|
+
import clsx from 'clsx';
|
|
14
|
+
import { useTranslate } from 'i18n-calypso';
|
|
15
|
+
import {
|
|
16
|
+
useState,
|
|
17
|
+
useCallback,
|
|
18
|
+
useEffect,
|
|
19
|
+
ChangeEvent,
|
|
20
|
+
Dispatch,
|
|
21
|
+
SetStateAction,
|
|
22
|
+
forwardRef,
|
|
23
|
+
} from 'react';
|
|
24
|
+
import { useInView } from 'react-intersection-observer';
|
|
25
|
+
import { plansGridMediumLarge } from '../../css-mixins';
|
|
26
|
+
import PlansGridContextProvider, { usePlansGridContext } from '../../grid-context';
|
|
27
|
+
import useGridSize from '../../hooks/use-grid-size';
|
|
28
|
+
import useHighlightAdjacencyMatrix from '../../hooks/use-highlight-adjacency-matrix';
|
|
29
|
+
import { useManageTooltipToggle } from '../../hooks/use-manage-tooltip-toggle';
|
|
30
|
+
import filterUnusedFeaturesObject from '../../lib/filter-unused-features-object';
|
|
31
|
+
import getPlanFeaturesObject from '../../lib/get-plan-features-object';
|
|
32
|
+
import { sortPlans } from '../../lib/sort-plan-properties';
|
|
33
|
+
import PlanTypeSelector from '../plan-type-selector';
|
|
34
|
+
import { Plans2023Tooltip } from '../plans-2023-tooltip';
|
|
35
|
+
import PopularBadge from '../popular-badge';
|
|
36
|
+
import ActionButton from '../shared/action-button';
|
|
37
|
+
import BillingTimeframe from '../shared/billing-timeframe';
|
|
38
|
+
import HeaderPrice from '../shared/header-price';
|
|
39
|
+
import HeaderPriceContextProvider from '../shared/header-price/header-price-context';
|
|
40
|
+
import { PlanStorage } from '../shared/storage';
|
|
41
|
+
import { StickyContainer } from '../sticky-container';
|
|
42
|
+
import type {
|
|
43
|
+
GridPlan,
|
|
44
|
+
ComparisonGridExternalProps,
|
|
45
|
+
ComparisonGridProps,
|
|
46
|
+
PlanActionOverrides,
|
|
47
|
+
TransformedFeatureObject,
|
|
48
|
+
PlanTypeSelectorProps,
|
|
49
|
+
} from '../../types';
|
|
50
|
+
import type {
|
|
51
|
+
FeatureObject,
|
|
52
|
+
Feature,
|
|
53
|
+
FeatureGroup,
|
|
54
|
+
PlanSlug,
|
|
55
|
+
FeatureGroupMap,
|
|
56
|
+
} from '@automattic/calypso-products';
|
|
57
|
+
import './style.scss';
|
|
58
|
+
|
|
59
|
+
const featureGroupRowTitleCellMaxWidth = 450;
|
|
60
|
+
const rowCellMaxWidth = 290;
|
|
61
|
+
|
|
62
|
+
const JetpackIconContainer = styled.div`
|
|
63
|
+
padding-inline-start: 6px;
|
|
64
|
+
display: inline-block;
|
|
65
|
+
vertical-align: middle;
|
|
66
|
+
line-height: 1;
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
const Title = styled.div< { isHiddenInMobile?: boolean } >`
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
font-size: 20px;
|
|
72
|
+
padding: 14px;
|
|
73
|
+
flex: 1;
|
|
74
|
+
display: flex;
|
|
75
|
+
align-items: center;
|
|
76
|
+
column-gap: 5px;
|
|
77
|
+
border: solid 1px #e0e0e0;
|
|
78
|
+
border-left: none;
|
|
79
|
+
border-right: none;
|
|
80
|
+
|
|
81
|
+
.gridicon {
|
|
82
|
+
transform: ${ ( props ) =>
|
|
83
|
+
props.isHiddenInMobile ? 'rotateZ( 180deg )' : 'rotateZ( 0deg )' };
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
${ plansGridMediumLarge( css`
|
|
88
|
+
padding-inline-start: 0;
|
|
89
|
+
border: none;
|
|
90
|
+
padding: 0;
|
|
91
|
+
max-width: 290px;
|
|
92
|
+
|
|
93
|
+
.gridicon {
|
|
94
|
+
display: none;
|
|
95
|
+
}
|
|
96
|
+
` ) }
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
const Grid = styled.div< { visiblePlans: number } >`
|
|
100
|
+
display: grid;
|
|
101
|
+
margin: 0 auto;
|
|
102
|
+
background: #fff;
|
|
103
|
+
border: solid 1px #e0e0e0;
|
|
104
|
+
${ ( props ) =>
|
|
105
|
+
props.visiblePlans &&
|
|
106
|
+
css`
|
|
107
|
+
max-width: ${ rowCellMaxWidth * props.visiblePlans + featureGroupRowTitleCellMaxWidth }px;
|
|
108
|
+
` }
|
|
109
|
+
|
|
110
|
+
${ plansGridMediumLarge( css`
|
|
111
|
+
border-radius: 5px;
|
|
112
|
+
` ) }
|
|
113
|
+
|
|
114
|
+
> .is-sticky-header-row {
|
|
115
|
+
border-bottom: solid 1px #e0e0e0;
|
|
116
|
+
background: #fff;
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
const Row = styled.div< {
|
|
121
|
+
isHiddenInMobile?: boolean;
|
|
122
|
+
className?: string;
|
|
123
|
+
isHighlighted?: boolean;
|
|
124
|
+
} >`
|
|
125
|
+
justify-content: space-between;
|
|
126
|
+
margin-bottom: -1px;
|
|
127
|
+
align-items: stretch;
|
|
128
|
+
display: ${ ( props ) => ( props.isHiddenInMobile ? 'none' : 'flex' ) };
|
|
129
|
+
|
|
130
|
+
${ plansGridMediumLarge( css`
|
|
131
|
+
display: flex;
|
|
132
|
+
align-items: center;
|
|
133
|
+
margin: 0 20px;
|
|
134
|
+
padding: 12px 0;
|
|
135
|
+
border-bottom: 1px solid #eee;
|
|
136
|
+
` ) }
|
|
137
|
+
|
|
138
|
+
${ ( props ) =>
|
|
139
|
+
props.isHighlighted &&
|
|
140
|
+
css`
|
|
141
|
+
${ plansGridMediumLarge( css`
|
|
142
|
+
background-color: #fafafa;
|
|
143
|
+
border-top: 1px solid #eee;
|
|
144
|
+
font-weight: bold;
|
|
145
|
+
margin: -1px 0 0;
|
|
146
|
+
padding: 12px 20px;
|
|
147
|
+
color: #3a434a;
|
|
148
|
+
` ) }
|
|
149
|
+
` };
|
|
150
|
+
`;
|
|
151
|
+
|
|
152
|
+
const PlanRow = styled( Row )`
|
|
153
|
+
&:last-of-type {
|
|
154
|
+
display: ${ ( props ) => ( props.isHiddenInMobile ? 'none' : 'flex' ) };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
${ plansGridMediumLarge( css`
|
|
158
|
+
border-bottom: none;
|
|
159
|
+
align-items: stretch;
|
|
160
|
+
|
|
161
|
+
&:last-of-type {
|
|
162
|
+
display: flex;
|
|
163
|
+
padding-top: 0;
|
|
164
|
+
padding-bottom: 0;
|
|
165
|
+
}
|
|
166
|
+
` ) }
|
|
167
|
+
`;
|
|
168
|
+
|
|
169
|
+
const TitleRow = styled( Row )`
|
|
170
|
+
cursor: pointer;
|
|
171
|
+
display: flex;
|
|
172
|
+
|
|
173
|
+
${ plansGridMediumLarge( css`
|
|
174
|
+
cursor: default;
|
|
175
|
+
border-bottom: none;
|
|
176
|
+
padding: 20px 0 10px;
|
|
177
|
+
pointer-events: none;
|
|
178
|
+
` ) }
|
|
179
|
+
`;
|
|
180
|
+
|
|
181
|
+
const Cell = styled.div< { textAlign?: 'start' | 'center' | 'end' } >`
|
|
182
|
+
text-align: ${ ( props ) => props.textAlign ?? 'start' };
|
|
183
|
+
display: flex;
|
|
184
|
+
flex: 1;
|
|
185
|
+
justify-content: flex-start;
|
|
186
|
+
flex-direction: column;
|
|
187
|
+
align-items: center;
|
|
188
|
+
padding: 33px 20px 0;
|
|
189
|
+
border-right: solid 1px #e0e0e0;
|
|
190
|
+
max-width: ${ rowCellMaxWidth }px;
|
|
191
|
+
|
|
192
|
+
.gridicon {
|
|
193
|
+
fill: currentColor;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
img {
|
|
197
|
+
max-width: 100%;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
&.title-is-subtitle {
|
|
201
|
+
padding-top: 0;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&:last-of-type {
|
|
205
|
+
border-right: none;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
${ Row }:last-of-type & {
|
|
209
|
+
padding-bottom: 24px;
|
|
210
|
+
|
|
211
|
+
${ plansGridMediumLarge( css`
|
|
212
|
+
padding-bottom: 0px;
|
|
213
|
+
` ) }
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
${ plansGridMediumLarge( css`
|
|
217
|
+
padding: 0 14px;
|
|
218
|
+
border-right: none;
|
|
219
|
+
justify-content: center;
|
|
220
|
+
|
|
221
|
+
&:first-of-type {
|
|
222
|
+
padding-inline-start: 0;
|
|
223
|
+
}
|
|
224
|
+
&:last-of-type {
|
|
225
|
+
padding-inline-end: 0;
|
|
226
|
+
border-right: none;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&.is-stuck {
|
|
230
|
+
padding-bottom: 16px;
|
|
231
|
+
}
|
|
232
|
+
` ) }
|
|
233
|
+
`;
|
|
234
|
+
|
|
235
|
+
const RowTitleCell = styled.div< {
|
|
236
|
+
isPlaceholderHeaderCell?: boolean;
|
|
237
|
+
isFeatureGroupRowTitleCell?: boolean;
|
|
238
|
+
} >`
|
|
239
|
+
display: none;
|
|
240
|
+
font-size: 14px;
|
|
241
|
+
padding-right: 10px;
|
|
242
|
+
${ plansGridMediumLarge( css`
|
|
243
|
+
display: block;
|
|
244
|
+
flex: 1;
|
|
245
|
+
min-width: 290px;
|
|
246
|
+
` ) }
|
|
247
|
+
max-width: ${ ( props ) => {
|
|
248
|
+
if ( props.isPlaceholderHeaderCell || props.isFeatureGroupRowTitleCell ) {
|
|
249
|
+
return `${ featureGroupRowTitleCellMaxWidth }px`;
|
|
250
|
+
}
|
|
251
|
+
return `${ rowCellMaxWidth }px`;
|
|
252
|
+
} };
|
|
253
|
+
`;
|
|
254
|
+
|
|
255
|
+
const PlanSelector = styled.header`
|
|
256
|
+
position: relative;
|
|
257
|
+
|
|
258
|
+
.plan-comparison-grid__title {
|
|
259
|
+
&.is-select-trigger {
|
|
260
|
+
display: flex;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.plan-comparison-grid__title-select {
|
|
265
|
+
appearance: none;
|
|
266
|
+
-moz-appearance: none;
|
|
267
|
+
-webkit-appearance: none;
|
|
268
|
+
background: 0 0;
|
|
269
|
+
border: none;
|
|
270
|
+
font-size: inherit;
|
|
271
|
+
color: inherit;
|
|
272
|
+
font-family: inherit;
|
|
273
|
+
opacity: 0;
|
|
274
|
+
width: 100%;
|
|
275
|
+
position: absolute;
|
|
276
|
+
top: 0;
|
|
277
|
+
left: 0;
|
|
278
|
+
cursor: pointer;
|
|
279
|
+
height: 30px;
|
|
280
|
+
|
|
281
|
+
&:focus ~ .plan-comparison-grid__title {
|
|
282
|
+
outline: thin dotted;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.plan-comparison-grid__title-icon {
|
|
287
|
+
position: relative;
|
|
288
|
+
top: -2px;
|
|
289
|
+
left: -2px;
|
|
290
|
+
width: 1px;
|
|
291
|
+
height: 1px;
|
|
292
|
+
overflow: visible;
|
|
293
|
+
|
|
294
|
+
svg {
|
|
295
|
+
fill: var( --color-link );
|
|
296
|
+
transform: rotate( 90deg );
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
`;
|
|
300
|
+
|
|
301
|
+
const FeatureFootnotes = styled.div`
|
|
302
|
+
ol {
|
|
303
|
+
margin: 2em 0 0 1em;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
ol li {
|
|
307
|
+
font-size: 11px;
|
|
308
|
+
padding-left: 1em;
|
|
309
|
+
}
|
|
310
|
+
`;
|
|
311
|
+
|
|
312
|
+
const FeatureFootnote = styled.span`
|
|
313
|
+
position: relative;
|
|
314
|
+
font-size: 50%;
|
|
315
|
+
font-weight: 600;
|
|
316
|
+
|
|
317
|
+
sup {
|
|
318
|
+
position: absolute;
|
|
319
|
+
top: -10px;
|
|
320
|
+
left: 0;
|
|
321
|
+
}
|
|
322
|
+
`;
|
|
323
|
+
|
|
324
|
+
type ComparisonGridHeaderProps = {
|
|
325
|
+
displayedGridPlans: GridPlan[];
|
|
326
|
+
visibleGridPlans: GridPlan[];
|
|
327
|
+
isInSignup: boolean;
|
|
328
|
+
isFooter?: boolean;
|
|
329
|
+
onPlanChange: ( currentPlan: PlanSlug, event: ChangeEvent< HTMLSelectElement > ) => void;
|
|
330
|
+
currentSitePlanSlug?: string | null;
|
|
331
|
+
planActionOverrides?: PlanActionOverrides;
|
|
332
|
+
selectedPlan?: string;
|
|
333
|
+
showRefundPeriod?: boolean;
|
|
334
|
+
isStuck: boolean;
|
|
335
|
+
isHiddenInMobile?: boolean;
|
|
336
|
+
planTypeSelectorProps?: PlanTypeSelectorProps;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
type ComparisonGridHeaderCellProps = Omit< ComparisonGridHeaderProps, 'planTypeSelectorProps' > & {
|
|
340
|
+
allVisible: boolean;
|
|
341
|
+
isLastInRow: boolean;
|
|
342
|
+
planSlug: PlanSlug;
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
type PlanFeatureFootnotes = {
|
|
346
|
+
footnoteList: string[];
|
|
347
|
+
footnotesByFeature: Record< Feature, number >;
|
|
348
|
+
};
|
|
349
|
+
|
|
350
|
+
const ComparisonGridHeaderCell = ( {
|
|
351
|
+
planSlug,
|
|
352
|
+
allVisible,
|
|
353
|
+
isLastInRow,
|
|
354
|
+
isFooter,
|
|
355
|
+
isInSignup,
|
|
356
|
+
visibleGridPlans,
|
|
357
|
+
onPlanChange,
|
|
358
|
+
displayedGridPlans,
|
|
359
|
+
currentSitePlanSlug,
|
|
360
|
+
planActionOverrides,
|
|
361
|
+
showRefundPeriod,
|
|
362
|
+
isStuck,
|
|
363
|
+
}: ComparisonGridHeaderCellProps ) => {
|
|
364
|
+
const { gridPlansIndex } = usePlansGridContext();
|
|
365
|
+
const gridPlan = gridPlansIndex[ planSlug ];
|
|
366
|
+
const highlightAdjacencyMatrix = useHighlightAdjacencyMatrix( {
|
|
367
|
+
renderedGridPlans: visibleGridPlans,
|
|
368
|
+
} );
|
|
369
|
+
|
|
370
|
+
if ( ! gridPlan ) {
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
const headerClasses = clsx( 'plan-comparison-grid__header-cell', getPlanClass( planSlug ), {
|
|
375
|
+
'popular-plan-parent-class': gridPlan.highlightLabel,
|
|
376
|
+
'is-last-in-row': isLastInRow,
|
|
377
|
+
'plan-is-footer': isFooter,
|
|
378
|
+
'is-left-of-highlight': highlightAdjacencyMatrix[ planSlug ]?.leftOfHighlight,
|
|
379
|
+
'is-right-of-highlight': highlightAdjacencyMatrix[ planSlug ]?.rightOfHighlight,
|
|
380
|
+
'is-only-highlight': highlightAdjacencyMatrix[ planSlug ]?.isOnlyHighlight,
|
|
381
|
+
'is-current-plan': gridPlan.current,
|
|
382
|
+
'is-stuck': isStuck,
|
|
383
|
+
} );
|
|
384
|
+
const popularBadgeClasses = clsx( {
|
|
385
|
+
'is-current-plan': gridPlan.current,
|
|
386
|
+
'popular-badge-is-stuck': isStuck,
|
|
387
|
+
} );
|
|
388
|
+
const showPlanSelect = ! allVisible && ! gridPlan.current;
|
|
389
|
+
|
|
390
|
+
return (
|
|
391
|
+
<Cell className={ headerClasses } textAlign="start">
|
|
392
|
+
<PopularBadge
|
|
393
|
+
isInSignup={ isInSignup }
|
|
394
|
+
planSlug={ planSlug }
|
|
395
|
+
additionalClassName={ popularBadgeClasses }
|
|
396
|
+
/>
|
|
397
|
+
<PlanSelector>
|
|
398
|
+
<h4
|
|
399
|
+
className={ clsx( 'plan-comparison-grid__title', showPlanSelect && 'is-select-trigger' ) }
|
|
400
|
+
>
|
|
401
|
+
<span className="plan-comparison-grid__title-label">{ gridPlan.planTitle }</span>
|
|
402
|
+
{ showPlanSelect && (
|
|
403
|
+
<span className="plan-comparison-grid__title-icon">
|
|
404
|
+
<Icon icon={ chevronRightSmall } size={ 30 } />
|
|
405
|
+
</span>
|
|
406
|
+
) }
|
|
407
|
+
</h4>
|
|
408
|
+
{ showPlanSelect && (
|
|
409
|
+
<select
|
|
410
|
+
onChange={ ( event: ChangeEvent< HTMLSelectElement > ) =>
|
|
411
|
+
onPlanChange( planSlug, event )
|
|
412
|
+
}
|
|
413
|
+
className="plan-comparison-grid__title-select"
|
|
414
|
+
value={ planSlug }
|
|
415
|
+
>
|
|
416
|
+
{ displayedGridPlans.map( ( { planSlug: otherPlan, planTitle } ) => {
|
|
417
|
+
const isVisiblePlan = visibleGridPlans.find(
|
|
418
|
+
( { planSlug } ) => planSlug === otherPlan
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
if ( isVisiblePlan && otherPlan !== planSlug ) {
|
|
422
|
+
return null;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
return (
|
|
426
|
+
<option key={ otherPlan } value={ otherPlan }>
|
|
427
|
+
{ planTitle }
|
|
428
|
+
</option>
|
|
429
|
+
);
|
|
430
|
+
} ) }
|
|
431
|
+
</select>
|
|
432
|
+
) }
|
|
433
|
+
</PlanSelector>
|
|
434
|
+
<HeaderPrice
|
|
435
|
+
planSlug={ planSlug }
|
|
436
|
+
currentSitePlanSlug={ currentSitePlanSlug }
|
|
437
|
+
visibleGridPlans={ visibleGridPlans }
|
|
438
|
+
/>
|
|
439
|
+
<div className="plan-comparison-grid__billing-info">
|
|
440
|
+
<BillingTimeframe planSlug={ planSlug } showRefundPeriod={ showRefundPeriod } />
|
|
441
|
+
</div>
|
|
442
|
+
<ActionButton
|
|
443
|
+
currentSitePlanSlug={ currentSitePlanSlug }
|
|
444
|
+
availableForPurchase={ gridPlan.availableForPurchase }
|
|
445
|
+
isInSignup={ isInSignup }
|
|
446
|
+
planSlug={ planSlug }
|
|
447
|
+
planActionOverrides={ planActionOverrides }
|
|
448
|
+
showMonthlyPrice={ false }
|
|
449
|
+
isStuck={ false }
|
|
450
|
+
visibleGridPlans={ visibleGridPlans }
|
|
451
|
+
/>
|
|
452
|
+
</Cell>
|
|
453
|
+
);
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
const PlanTypeSelectorWrapper = styled.div`
|
|
457
|
+
display: none;
|
|
458
|
+
${ plansGridMediumLarge( css`
|
|
459
|
+
display: block;
|
|
460
|
+
` ) }
|
|
461
|
+
`;
|
|
462
|
+
|
|
463
|
+
const ComparisonGridHeader = forwardRef< HTMLDivElement, ComparisonGridHeaderProps >(
|
|
464
|
+
(
|
|
465
|
+
{
|
|
466
|
+
displayedGridPlans,
|
|
467
|
+
visibleGridPlans,
|
|
468
|
+
isInSignup,
|
|
469
|
+
isFooter,
|
|
470
|
+
onPlanChange,
|
|
471
|
+
currentSitePlanSlug,
|
|
472
|
+
planActionOverrides,
|
|
473
|
+
selectedPlan,
|
|
474
|
+
isHiddenInMobile,
|
|
475
|
+
showRefundPeriod,
|
|
476
|
+
isStuck,
|
|
477
|
+
planTypeSelectorProps,
|
|
478
|
+
},
|
|
479
|
+
ref
|
|
480
|
+
) => {
|
|
481
|
+
const translate = useTranslate();
|
|
482
|
+
const allVisible = visibleGridPlans.length === displayedGridPlans.length;
|
|
483
|
+
const { coupon } = usePlansGridContext();
|
|
484
|
+
|
|
485
|
+
return (
|
|
486
|
+
<PlanRow isHiddenInMobile={ isHiddenInMobile } ref={ ref }>
|
|
487
|
+
<RowTitleCell
|
|
488
|
+
key="feature-name"
|
|
489
|
+
className="plan-comparison-grid__header-cell is-placeholder-header-cell"
|
|
490
|
+
isPlaceholderHeaderCell
|
|
491
|
+
>
|
|
492
|
+
{ isStuck && planTypeSelectorProps && (
|
|
493
|
+
<PlanTypeSelectorWrapper>
|
|
494
|
+
<PlanTypeSelector
|
|
495
|
+
{ ...planTypeSelectorProps }
|
|
496
|
+
title={ translate( 'Billing Cycle' ) }
|
|
497
|
+
hideDiscount
|
|
498
|
+
coupon={ coupon }
|
|
499
|
+
/>
|
|
500
|
+
</PlanTypeSelectorWrapper>
|
|
501
|
+
) }
|
|
502
|
+
</RowTitleCell>
|
|
503
|
+
<HeaderPriceContextProvider>
|
|
504
|
+
{ visibleGridPlans.map( ( { planSlug }, index ) => (
|
|
505
|
+
<ComparisonGridHeaderCell
|
|
506
|
+
planSlug={ planSlug }
|
|
507
|
+
key={ planSlug }
|
|
508
|
+
isLastInRow={ index === visibleGridPlans.length - 1 }
|
|
509
|
+
isFooter={ isFooter }
|
|
510
|
+
allVisible={ allVisible }
|
|
511
|
+
isInSignup={ isInSignup }
|
|
512
|
+
visibleGridPlans={ visibleGridPlans }
|
|
513
|
+
onPlanChange={ onPlanChange }
|
|
514
|
+
displayedGridPlans={ displayedGridPlans }
|
|
515
|
+
currentSitePlanSlug={ currentSitePlanSlug }
|
|
516
|
+
planActionOverrides={ planActionOverrides }
|
|
517
|
+
selectedPlan={ selectedPlan }
|
|
518
|
+
showRefundPeriod={ showRefundPeriod }
|
|
519
|
+
isStuck={ isStuck }
|
|
520
|
+
/>
|
|
521
|
+
) ) }
|
|
522
|
+
</HeaderPriceContextProvider>
|
|
523
|
+
</PlanRow>
|
|
524
|
+
);
|
|
525
|
+
}
|
|
526
|
+
);
|
|
527
|
+
|
|
528
|
+
const ComparisonGridFeatureGroupRowCell: React.FunctionComponent< {
|
|
529
|
+
feature?: FeatureObject;
|
|
530
|
+
allJetpackFeatures: Set< string >;
|
|
531
|
+
visibleGridPlans: GridPlan[];
|
|
532
|
+
planSlug: PlanSlug;
|
|
533
|
+
isStorageFeature: boolean;
|
|
534
|
+
intervalType: string;
|
|
535
|
+
setActiveTooltipId: Dispatch< SetStateAction< string > >;
|
|
536
|
+
showUpgradeableStorage: boolean;
|
|
537
|
+
activeTooltipId: string;
|
|
538
|
+
onStorageAddOnClick?: ( addOnSlug: AddOns.StorageAddOnSlug ) => void;
|
|
539
|
+
} > = ( {
|
|
540
|
+
feature,
|
|
541
|
+
visibleGridPlans,
|
|
542
|
+
planSlug,
|
|
543
|
+
isStorageFeature,
|
|
544
|
+
intervalType,
|
|
545
|
+
activeTooltipId,
|
|
546
|
+
setActiveTooltipId,
|
|
547
|
+
showUpgradeableStorage,
|
|
548
|
+
onStorageAddOnClick,
|
|
549
|
+
} ) => {
|
|
550
|
+
const { gridPlansIndex, enableFeatureTooltips, hideUnsupportedFeatures } = usePlansGridContext();
|
|
551
|
+
const gridPlan = gridPlansIndex[ planSlug ];
|
|
552
|
+
const translate = useTranslate();
|
|
553
|
+
const highlightAdjacencyMatrix = useHighlightAdjacencyMatrix( {
|
|
554
|
+
renderedGridPlans: visibleGridPlans,
|
|
555
|
+
} );
|
|
556
|
+
|
|
557
|
+
if ( ! gridPlan ) {
|
|
558
|
+
return null;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
const featureSlug = feature?.getSlug();
|
|
562
|
+
|
|
563
|
+
const hasFeature =
|
|
564
|
+
isStorageFeature ||
|
|
565
|
+
( featureSlug
|
|
566
|
+
? [ ...gridPlan.features.wpcomFeatures, ...gridPlan.features.jetpackFeatures ]
|
|
567
|
+
.filter( ( feature ) =>
|
|
568
|
+
'monthly' === intervalType ? ! feature.availableOnlyForAnnualPlans : true
|
|
569
|
+
)
|
|
570
|
+
.some( ( feature ) => feature.getSlug() === featureSlug )
|
|
571
|
+
: false );
|
|
572
|
+
|
|
573
|
+
const featureLabel = featureSlug
|
|
574
|
+
? gridPlan?.features?.comparisonGridFeatureLabels?.[ featureSlug ]
|
|
575
|
+
: undefined;
|
|
576
|
+
|
|
577
|
+
const cellClasses = clsx(
|
|
578
|
+
'plan-comparison-grid__feature-group-row-cell',
|
|
579
|
+
'plan-comparison-grid__plan',
|
|
580
|
+
getPlanClass( planSlug ),
|
|
581
|
+
{
|
|
582
|
+
'popular-plan-parent-class': gridPlan.highlightLabel,
|
|
583
|
+
'has-feature': hasFeature,
|
|
584
|
+
'has-feature-label': !! featureLabel,
|
|
585
|
+
'hide-unsupported-feature': hideUnsupportedFeatures && ! hasFeature && ! featureLabel,
|
|
586
|
+
'title-is-subtitle': 'live-chat-support' === featureSlug,
|
|
587
|
+
'is-left-of-highlight': highlightAdjacencyMatrix[ planSlug ]?.leftOfHighlight,
|
|
588
|
+
'is-right-of-highlight': highlightAdjacencyMatrix[ planSlug ]?.rightOfHighlight,
|
|
589
|
+
'is-only-highlight': highlightAdjacencyMatrix[ planSlug ]?.isOnlyHighlight,
|
|
590
|
+
}
|
|
591
|
+
);
|
|
592
|
+
const planPaymentTransactionFees = gridPlan.features.wpcomFeatures?.find(
|
|
593
|
+
( feature ) => feature?.getFeatureGroup?.() === FEATURE_GROUP_PAYMENT_TRANSACTION_FEES
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
return (
|
|
597
|
+
<Cell className={ cellClasses } textAlign="center">
|
|
598
|
+
{ isStorageFeature ? (
|
|
599
|
+
<>
|
|
600
|
+
<span className="plan-comparison-grid__plan-title">{ translate( 'Storage' ) }</span>
|
|
601
|
+
<PlanStorage
|
|
602
|
+
planSlug={ planSlug }
|
|
603
|
+
onStorageAddOnClick={ onStorageAddOnClick }
|
|
604
|
+
showUpgradeableStorage={ showUpgradeableStorage }
|
|
605
|
+
/>
|
|
606
|
+
</>
|
|
607
|
+
) : (
|
|
608
|
+
<>
|
|
609
|
+
{ FEATURE_GROUP_PAYMENT_TRANSACTION_FEES === featureSlug ? (
|
|
610
|
+
<>
|
|
611
|
+
{ planPaymentTransactionFees ? (
|
|
612
|
+
<>
|
|
613
|
+
<Plans2023Tooltip
|
|
614
|
+
text={ enableFeatureTooltips ? feature?.getDescription?.() : undefined }
|
|
615
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
616
|
+
activeTooltipId={ activeTooltipId }
|
|
617
|
+
id={ `${ planSlug }-${ featureSlug }` }
|
|
618
|
+
>
|
|
619
|
+
<span className="plan-comparison-grid__plan-title">
|
|
620
|
+
{ feature?.getAlternativeTitle?.() || feature?.getTitle() }
|
|
621
|
+
</span>
|
|
622
|
+
</Plans2023Tooltip>
|
|
623
|
+
<span className="plan-comparison-grid__plan-conditional-title">
|
|
624
|
+
{ planPaymentTransactionFees?.getAlternativeTitle?.() }
|
|
625
|
+
</span>
|
|
626
|
+
</>
|
|
627
|
+
) : (
|
|
628
|
+
<Gridicon icon="minus-small" color="#C3C4C7" />
|
|
629
|
+
) }
|
|
630
|
+
</>
|
|
631
|
+
) : (
|
|
632
|
+
<>
|
|
633
|
+
{ feature?.getIcon && (
|
|
634
|
+
<span className="plan-comparison-grid__plan-image">
|
|
635
|
+
{ /** Note: this approach may not work if the icon is not a string or ReactElement. */ }
|
|
636
|
+
{ feature.getIcon() as React.ReactNode }
|
|
637
|
+
</span>
|
|
638
|
+
) }
|
|
639
|
+
<Plans2023Tooltip
|
|
640
|
+
text={ enableFeatureTooltips ? feature?.getDescription?.() : undefined }
|
|
641
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
642
|
+
activeTooltipId={ activeTooltipId }
|
|
643
|
+
id={ `${ planSlug }-${ featureSlug }` }
|
|
644
|
+
>
|
|
645
|
+
<span className="plan-comparison-grid__plan-title">
|
|
646
|
+
{ feature?.getAlternativeTitle?.() || feature?.getTitle() }
|
|
647
|
+
</span>
|
|
648
|
+
</Plans2023Tooltip>
|
|
649
|
+
{ feature?.getCompareTitle && (
|
|
650
|
+
<span className="plan-comparison-grid__plan-subtitle">
|
|
651
|
+
{ feature.getCompareTitle() }
|
|
652
|
+
</span>
|
|
653
|
+
) }
|
|
654
|
+
{ featureLabel && (
|
|
655
|
+
<span className="plan-comparison-grid__plan-conditional-title">
|
|
656
|
+
{ featureLabel }
|
|
657
|
+
</span>
|
|
658
|
+
) }
|
|
659
|
+
{ hasFeature && feature?.getCompareSubtitle && (
|
|
660
|
+
<span className="plan-comparison-grid__plan-subtitle">
|
|
661
|
+
{ feature.getCompareSubtitle() }
|
|
662
|
+
</span>
|
|
663
|
+
) }
|
|
664
|
+
{ hasFeature && ! featureLabel && (
|
|
665
|
+
<Gridicon icon="checkmark" color="var(--studio-wordpress-blue-50)" />
|
|
666
|
+
) }
|
|
667
|
+
{ ! hasFeature && ! featureLabel && <Gridicon icon="minus-small" color="#C3C4C7" /> }
|
|
668
|
+
</>
|
|
669
|
+
) }
|
|
670
|
+
</>
|
|
671
|
+
) }
|
|
672
|
+
</Cell>
|
|
673
|
+
);
|
|
674
|
+
};
|
|
675
|
+
|
|
676
|
+
const ComparisonGridFeatureGroupRow: React.FunctionComponent< {
|
|
677
|
+
feature?: FeatureObject | TransformedFeatureObject;
|
|
678
|
+
isHiddenInMobile: boolean;
|
|
679
|
+
allJetpackFeatures: Set< string >;
|
|
680
|
+
visibleGridPlans: GridPlan[];
|
|
681
|
+
planFeatureFootnotes: PlanFeatureFootnotes;
|
|
682
|
+
isStorageFeature: boolean;
|
|
683
|
+
isHighlighted: boolean;
|
|
684
|
+
intervalType: string;
|
|
685
|
+
setActiveTooltipId: Dispatch< SetStateAction< string > >;
|
|
686
|
+
showUpgradeableStorage: boolean;
|
|
687
|
+
activeTooltipId: string;
|
|
688
|
+
onStorageAddOnClick?: ( addOnSlug: AddOns.StorageAddOnSlug ) => void;
|
|
689
|
+
} > = ( {
|
|
690
|
+
feature,
|
|
691
|
+
isHiddenInMobile,
|
|
692
|
+
allJetpackFeatures,
|
|
693
|
+
visibleGridPlans,
|
|
694
|
+
planFeatureFootnotes,
|
|
695
|
+
isStorageFeature,
|
|
696
|
+
isHighlighted,
|
|
697
|
+
intervalType,
|
|
698
|
+
activeTooltipId,
|
|
699
|
+
setActiveTooltipId,
|
|
700
|
+
showUpgradeableStorage,
|
|
701
|
+
onStorageAddOnClick,
|
|
702
|
+
} ) => {
|
|
703
|
+
const translate = useTranslate();
|
|
704
|
+
const rowClasses = clsx( 'plan-comparison-grid__feature-group-row', {
|
|
705
|
+
'is-storage-feature': isStorageFeature,
|
|
706
|
+
} );
|
|
707
|
+
const featureSlug = feature?.getSlug() ?? '';
|
|
708
|
+
const footnote = planFeatureFootnotes?.footnotesByFeature?.[ featureSlug ];
|
|
709
|
+
const tooltipId = `${ feature?.getSlug() }-comparison-grid`;
|
|
710
|
+
|
|
711
|
+
const { enableFeatureTooltips } = usePlansGridContext();
|
|
712
|
+
|
|
713
|
+
return (
|
|
714
|
+
<Row
|
|
715
|
+
isHiddenInMobile={ isHiddenInMobile }
|
|
716
|
+
className={ rowClasses }
|
|
717
|
+
isHighlighted={ isHighlighted }
|
|
718
|
+
>
|
|
719
|
+
<RowTitleCell
|
|
720
|
+
key="feature-name"
|
|
721
|
+
className="is-feature-group-row-title-cell"
|
|
722
|
+
isFeatureGroupRowTitleCell
|
|
723
|
+
>
|
|
724
|
+
{ isStorageFeature ? (
|
|
725
|
+
<Plans2023Tooltip
|
|
726
|
+
text={
|
|
727
|
+
enableFeatureTooltips
|
|
728
|
+
? translate( 'Space to store your photos, media, and more.' )
|
|
729
|
+
: undefined
|
|
730
|
+
}
|
|
731
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
732
|
+
activeTooltipId={ activeTooltipId }
|
|
733
|
+
id={ tooltipId }
|
|
734
|
+
>
|
|
735
|
+
{ translate( 'Storage' ) }
|
|
736
|
+
</Plans2023Tooltip>
|
|
737
|
+
) : (
|
|
738
|
+
<>
|
|
739
|
+
{ feature && (
|
|
740
|
+
<>
|
|
741
|
+
<Plans2023Tooltip
|
|
742
|
+
text={ enableFeatureTooltips ? feature.getDescription?.() : undefined }
|
|
743
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
744
|
+
activeTooltipId={ activeTooltipId }
|
|
745
|
+
id={ tooltipId }
|
|
746
|
+
>
|
|
747
|
+
{ feature.getTitle() }
|
|
748
|
+
{ footnote && (
|
|
749
|
+
<FeatureFootnote>
|
|
750
|
+
<sup>{ footnote }</sup>
|
|
751
|
+
</FeatureFootnote>
|
|
752
|
+
) }
|
|
753
|
+
</Plans2023Tooltip>
|
|
754
|
+
{ allJetpackFeatures.has( feature.getSlug() ) ? (
|
|
755
|
+
<JetpackIconContainer>
|
|
756
|
+
<Plans2023Tooltip
|
|
757
|
+
text={ translate(
|
|
758
|
+
'Security, performance, and growth tools—powered by Jetpack.'
|
|
759
|
+
) }
|
|
760
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
761
|
+
activeTooltipId={ activeTooltipId }
|
|
762
|
+
id={ `jp-${ tooltipId }` }
|
|
763
|
+
>
|
|
764
|
+
<JetpackLogo size={ 16 } />
|
|
765
|
+
</Plans2023Tooltip>
|
|
766
|
+
</JetpackIconContainer>
|
|
767
|
+
) : null }
|
|
768
|
+
</>
|
|
769
|
+
) }
|
|
770
|
+
</>
|
|
771
|
+
) }
|
|
772
|
+
</RowTitleCell>
|
|
773
|
+
{ visibleGridPlans.map( ( { planSlug } ) => (
|
|
774
|
+
<ComparisonGridFeatureGroupRowCell
|
|
775
|
+
key={ planSlug }
|
|
776
|
+
feature={ feature }
|
|
777
|
+
allJetpackFeatures={ allJetpackFeatures }
|
|
778
|
+
visibleGridPlans={ visibleGridPlans }
|
|
779
|
+
planSlug={ planSlug }
|
|
780
|
+
isStorageFeature={ isStorageFeature }
|
|
781
|
+
intervalType={ intervalType }
|
|
782
|
+
activeTooltipId={ activeTooltipId }
|
|
783
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
784
|
+
showUpgradeableStorage={ showUpgradeableStorage }
|
|
785
|
+
onStorageAddOnClick={ onStorageAddOnClick }
|
|
786
|
+
/>
|
|
787
|
+
) ) }
|
|
788
|
+
</Row>
|
|
789
|
+
);
|
|
790
|
+
};
|
|
791
|
+
|
|
792
|
+
const FeatureGroup = ( {
|
|
793
|
+
featureGroup,
|
|
794
|
+
selectedFeature,
|
|
795
|
+
intervalType,
|
|
796
|
+
activeTooltipId,
|
|
797
|
+
setActiveTooltipId,
|
|
798
|
+
showUpgradeableStorage,
|
|
799
|
+
onStorageAddOnClick,
|
|
800
|
+
featureGroupMap,
|
|
801
|
+
visibleGridPlans,
|
|
802
|
+
planFeatureFootnotes,
|
|
803
|
+
}: {
|
|
804
|
+
featureGroup: FeatureGroup;
|
|
805
|
+
selectedFeature?: string;
|
|
806
|
+
intervalType: string;
|
|
807
|
+
activeTooltipId: string;
|
|
808
|
+
setActiveTooltipId: Dispatch< SetStateAction< string > >;
|
|
809
|
+
showUpgradeableStorage: boolean;
|
|
810
|
+
onStorageAddOnClick?: ( addOnSlug: AddOns.StorageAddOnSlug ) => void;
|
|
811
|
+
featureGroupMap: Partial< FeatureGroupMap >;
|
|
812
|
+
visibleGridPlans: GridPlan[];
|
|
813
|
+
planFeatureFootnotes: {
|
|
814
|
+
footnoteList: string[];
|
|
815
|
+
footnotesByFeature: Record< string, number >;
|
|
816
|
+
};
|
|
817
|
+
} ) => {
|
|
818
|
+
const { allFeaturesList } = usePlansGridContext();
|
|
819
|
+
const [ firstSetOfFeatures ] = Object.keys( featureGroupMap );
|
|
820
|
+
const [ visibleFeatureGroups, setVisibleFeatureGroups ] = useState< string[] >( [
|
|
821
|
+
firstSetOfFeatures,
|
|
822
|
+
] );
|
|
823
|
+
const features = featureGroup.getFeatures();
|
|
824
|
+
const featureObjects = filterUnusedFeaturesObject(
|
|
825
|
+
visibleGridPlans,
|
|
826
|
+
getPlanFeaturesObject( allFeaturesList, features )
|
|
827
|
+
);
|
|
828
|
+
const isHiddenInMobile = ! visibleFeatureGroups.includes( featureGroup.slug );
|
|
829
|
+
|
|
830
|
+
const allJetpackFeatures = useMemo( () => {
|
|
831
|
+
const allPlans = getPlans();
|
|
832
|
+
const jetpackFeatures = new Set(
|
|
833
|
+
Object.values( allPlans )
|
|
834
|
+
.map(
|
|
835
|
+
( {
|
|
836
|
+
get2023PricingGridSignupJetpackFeatures,
|
|
837
|
+
get2023PlanComparisonJetpackFeatureOverride,
|
|
838
|
+
} ) => {
|
|
839
|
+
const jetpackFeatures = get2023PricingGridSignupJetpackFeatures?.();
|
|
840
|
+
const additionalJetpackFeatures = get2023PlanComparisonJetpackFeatureOverride?.();
|
|
841
|
+
|
|
842
|
+
return [
|
|
843
|
+
...( jetpackFeatures ? jetpackFeatures : [] ),
|
|
844
|
+
...( additionalJetpackFeatures ? additionalJetpackFeatures : [] ),
|
|
845
|
+
];
|
|
846
|
+
}
|
|
847
|
+
)
|
|
848
|
+
.flat()
|
|
849
|
+
);
|
|
850
|
+
|
|
851
|
+
return jetpackFeatures;
|
|
852
|
+
}, [] );
|
|
853
|
+
|
|
854
|
+
const handleFeatureGroupToggle = useCallback( () => {
|
|
855
|
+
const index = visibleFeatureGroups.indexOf( featureGroup.slug );
|
|
856
|
+
const newVisibleFeatureGroups = [ ...visibleFeatureGroups ];
|
|
857
|
+
|
|
858
|
+
if ( index === -1 ) {
|
|
859
|
+
newVisibleFeatureGroups.push( featureGroup.slug );
|
|
860
|
+
} else {
|
|
861
|
+
newVisibleFeatureGroups.splice( index, 1 );
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
setVisibleFeatureGroups( newVisibleFeatureGroups );
|
|
865
|
+
}, [ featureGroup, setVisibleFeatureGroups, visibleFeatureGroups ] );
|
|
866
|
+
|
|
867
|
+
// Skip non Jetpack feature groups without any available features.
|
|
868
|
+
if ( featureGroup.slug !== FEATURE_GROUP_ESSENTIAL_FEATURES && ! featureObjects.length ) {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
return (
|
|
873
|
+
<div key={ featureGroup.slug } className="plan-comparison-grid__feature-group">
|
|
874
|
+
<TitleRow
|
|
875
|
+
className="plan-comparison-grid__feature-group-title-row"
|
|
876
|
+
onClick={ handleFeatureGroupToggle }
|
|
877
|
+
>
|
|
878
|
+
<Title isHiddenInMobile={ isHiddenInMobile }>
|
|
879
|
+
<Gridicon icon="chevron-up" size={ 12 } color="#1E1E1E" />
|
|
880
|
+
<span>{ featureGroup.getTitle() }</span>
|
|
881
|
+
</Title>
|
|
882
|
+
</TitleRow>
|
|
883
|
+
{ featureObjects.map( ( feature ) => (
|
|
884
|
+
<ComparisonGridFeatureGroupRow
|
|
885
|
+
key={ feature.getSlug() }
|
|
886
|
+
feature={ feature }
|
|
887
|
+
isHiddenInMobile={ isHiddenInMobile }
|
|
888
|
+
allJetpackFeatures={ allJetpackFeatures }
|
|
889
|
+
visibleGridPlans={ visibleGridPlans }
|
|
890
|
+
planFeatureFootnotes={ planFeatureFootnotes }
|
|
891
|
+
isStorageFeature={ false }
|
|
892
|
+
isHighlighted={ feature.getSlug() === selectedFeature }
|
|
893
|
+
intervalType={ intervalType }
|
|
894
|
+
activeTooltipId={ activeTooltipId }
|
|
895
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
896
|
+
showUpgradeableStorage={ showUpgradeableStorage }
|
|
897
|
+
onStorageAddOnClick={ onStorageAddOnClick }
|
|
898
|
+
/>
|
|
899
|
+
) ) }
|
|
900
|
+
{ featureGroup.slug === FEATURE_GROUP_ESSENTIAL_FEATURES ? (
|
|
901
|
+
<ComparisonGridFeatureGroupRow
|
|
902
|
+
key="feature-storage"
|
|
903
|
+
isHiddenInMobile={ isHiddenInMobile }
|
|
904
|
+
allJetpackFeatures={ allJetpackFeatures }
|
|
905
|
+
visibleGridPlans={ visibleGridPlans }
|
|
906
|
+
planFeatureFootnotes={ planFeatureFootnotes }
|
|
907
|
+
isStorageFeature
|
|
908
|
+
isHighlighted={ false }
|
|
909
|
+
intervalType={ intervalType }
|
|
910
|
+
activeTooltipId={ activeTooltipId }
|
|
911
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
912
|
+
showUpgradeableStorage={ showUpgradeableStorage }
|
|
913
|
+
onStorageAddOnClick={ onStorageAddOnClick }
|
|
914
|
+
/>
|
|
915
|
+
) : null }
|
|
916
|
+
</div>
|
|
917
|
+
);
|
|
918
|
+
};
|
|
919
|
+
|
|
920
|
+
const ComparisonGrid = ( {
|
|
921
|
+
intervalType,
|
|
922
|
+
isInSignup,
|
|
923
|
+
currentSitePlanSlug,
|
|
924
|
+
planActionOverrides,
|
|
925
|
+
selectedPlan,
|
|
926
|
+
selectedFeature,
|
|
927
|
+
showUpgradeableStorage,
|
|
928
|
+
stickyRowOffset,
|
|
929
|
+
onStorageAddOnClick,
|
|
930
|
+
showRefundPeriod,
|
|
931
|
+
planTypeSelectorProps,
|
|
932
|
+
gridSize,
|
|
933
|
+
}: ComparisonGridProps ) => {
|
|
934
|
+
const { gridPlans, gridPlansIndex, featureGroupMap } = usePlansGridContext();
|
|
935
|
+
const [ activeTooltipId, setActiveTooltipId ] = useManageTooltipToggle();
|
|
936
|
+
const [ visiblePlans, setVisiblePlans ] = useState< PlanSlug[] >( [] );
|
|
937
|
+
|
|
938
|
+
const displayedGridPlans = useMemo( () => {
|
|
939
|
+
return sortPlans( gridPlans, currentSitePlanSlug, 'small' === gridSize );
|
|
940
|
+
}, [ gridPlans, currentSitePlanSlug, gridSize ] );
|
|
941
|
+
|
|
942
|
+
useEffect( () => {
|
|
943
|
+
setVisiblePlans( ( prev ) => {
|
|
944
|
+
let visibleLength = displayedGridPlans.length;
|
|
945
|
+
switch ( gridSize ) {
|
|
946
|
+
case 'large':
|
|
947
|
+
visibleLength = 4;
|
|
948
|
+
break;
|
|
949
|
+
case 'medium':
|
|
950
|
+
visibleLength = 3;
|
|
951
|
+
break;
|
|
952
|
+
case 'smedium':
|
|
953
|
+
case 'small':
|
|
954
|
+
visibleLength = 2;
|
|
955
|
+
break;
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
// visible length changed, update with the current gridPlans
|
|
959
|
+
// - we don't care about previous order
|
|
960
|
+
if ( prev.length !== visibleLength ) {
|
|
961
|
+
return displayedGridPlans.slice( 0, visibleLength ).map( ( { planSlug } ) => planSlug );
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
// prev state out of sync with current gridPlans (e.g. gridPlans updated to a different term)
|
|
965
|
+
// - we care about previous order
|
|
966
|
+
const isPrevStale = prev.some( ( planSlug ) => ! gridPlansIndex[ planSlug ] );
|
|
967
|
+
if ( isPrevStale ) {
|
|
968
|
+
return prev.map( ( planSlug ) => {
|
|
969
|
+
const gridPlan = displayedGridPlans.find(
|
|
970
|
+
( gridPlan ) => getPlanClass( gridPlan.planSlug ) === getPlanClass( planSlug )
|
|
971
|
+
);
|
|
972
|
+
|
|
973
|
+
return gridPlan?.planSlug ?? planSlug;
|
|
974
|
+
} );
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
// nothing to update
|
|
978
|
+
return prev;
|
|
979
|
+
} );
|
|
980
|
+
}, [ gridSize, displayedGridPlans, gridPlansIndex ] );
|
|
981
|
+
|
|
982
|
+
const visibleGridPlans = useMemo(
|
|
983
|
+
() =>
|
|
984
|
+
visiblePlans.reduce( ( acc, planSlug ) => {
|
|
985
|
+
const gridPlan = displayedGridPlans.find(
|
|
986
|
+
( gridPlan ) => getPlanClass( gridPlan.planSlug ) === getPlanClass( planSlug )
|
|
987
|
+
);
|
|
988
|
+
|
|
989
|
+
if ( gridPlan ) {
|
|
990
|
+
acc.push( gridPlan );
|
|
991
|
+
}
|
|
992
|
+
|
|
993
|
+
return acc;
|
|
994
|
+
}, [] as GridPlan[] ),
|
|
995
|
+
[ visiblePlans, displayedGridPlans ]
|
|
996
|
+
);
|
|
997
|
+
|
|
998
|
+
const onPlanChange = useCallback(
|
|
999
|
+
( currentPlan: PlanSlug, event: ChangeEvent< HTMLSelectElement > ) => {
|
|
1000
|
+
const newPlan = event.currentTarget.value;
|
|
1001
|
+
const newVisiblePlans = visiblePlans.map( ( plan ) =>
|
|
1002
|
+
plan === currentPlan ? ( newPlan as PlanSlug ) : plan
|
|
1003
|
+
);
|
|
1004
|
+
|
|
1005
|
+
setVisiblePlans( newVisiblePlans );
|
|
1006
|
+
},
|
|
1007
|
+
[ visiblePlans ]
|
|
1008
|
+
);
|
|
1009
|
+
|
|
1010
|
+
const planFeatureFootnotes = useMemo( () => {
|
|
1011
|
+
// This is the main list of all footnotes. It is displayed at the bottom of the comparison grid.
|
|
1012
|
+
const footnoteList: string[] = [];
|
|
1013
|
+
// This is a map of features to the index of the footnote in the main list of footnotes.
|
|
1014
|
+
const footnotesByFeature: Record< Feature, number > = {};
|
|
1015
|
+
|
|
1016
|
+
Object.values( featureGroupMap ).map( ( featureGroup ) => {
|
|
1017
|
+
const footnotes = featureGroup?.getFootnotes?.();
|
|
1018
|
+
|
|
1019
|
+
if ( ! footnotes ) {
|
|
1020
|
+
return;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
1023
|
+
Object.keys( footnotes ).map( ( footnote ) => {
|
|
1024
|
+
const footnoteFeatures = footnotes[ footnote ];
|
|
1025
|
+
|
|
1026
|
+
// First we add the footnote to the main list of footnotes.
|
|
1027
|
+
footnoteList.push( footnote );
|
|
1028
|
+
|
|
1029
|
+
// Then we add each feature that has this footnote to the map of footnotes by feature.
|
|
1030
|
+
const currentFootnoteIndex = footnoteList.length;
|
|
1031
|
+
footnoteFeatures.map( ( feature ) => {
|
|
1032
|
+
footnotesByFeature[ feature ] = currentFootnoteIndex;
|
|
1033
|
+
} );
|
|
1034
|
+
} );
|
|
1035
|
+
} );
|
|
1036
|
+
|
|
1037
|
+
return {
|
|
1038
|
+
footnoteList,
|
|
1039
|
+
footnotesByFeature,
|
|
1040
|
+
};
|
|
1041
|
+
}, [ featureGroupMap ] );
|
|
1042
|
+
|
|
1043
|
+
// 100px is the padding of the footer row
|
|
1044
|
+
const [ bottomHeaderRef, isBottomHeaderInView ] = useInView( { rootMargin: '-100px' } );
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* Search for "any" plan with a highlight label, not just the visible ones.
|
|
1048
|
+
* This will keep the grid static while user interacts (selects different plans to compare).
|
|
1049
|
+
* Some padding is applied in the stylesheet to cover the badges/labels.
|
|
1050
|
+
*/
|
|
1051
|
+
const hasHighlightedPlan = gridPlans.some( ( { highlightLabel } ) => !! highlightLabel );
|
|
1052
|
+
const classes = clsx( 'plans-grid-next-comparison-grid', {
|
|
1053
|
+
'has-highlighted-plan': hasHighlightedPlan,
|
|
1054
|
+
} );
|
|
1055
|
+
|
|
1056
|
+
return (
|
|
1057
|
+
<div className={ classes }>
|
|
1058
|
+
<Grid visiblePlans={ visiblePlans.length }>
|
|
1059
|
+
<StickyContainer
|
|
1060
|
+
disabled={ isBottomHeaderInView }
|
|
1061
|
+
stickyClass="is-sticky-header-row"
|
|
1062
|
+
stickyOffset={ stickyRowOffset }
|
|
1063
|
+
zIndex={ 1 }
|
|
1064
|
+
>
|
|
1065
|
+
{ ( isStuck: boolean ) => (
|
|
1066
|
+
<ComparisonGridHeader
|
|
1067
|
+
displayedGridPlans={ displayedGridPlans }
|
|
1068
|
+
visibleGridPlans={ visibleGridPlans }
|
|
1069
|
+
isInSignup={ isInSignup }
|
|
1070
|
+
onPlanChange={ onPlanChange }
|
|
1071
|
+
currentSitePlanSlug={ currentSitePlanSlug }
|
|
1072
|
+
planActionOverrides={ planActionOverrides }
|
|
1073
|
+
selectedPlan={ selectedPlan }
|
|
1074
|
+
showRefundPeriod={ showRefundPeriod }
|
|
1075
|
+
isStuck={ isStuck }
|
|
1076
|
+
planTypeSelectorProps={ planTypeSelectorProps }
|
|
1077
|
+
/>
|
|
1078
|
+
) }
|
|
1079
|
+
</StickyContainer>
|
|
1080
|
+
{ Object.values( featureGroupMap ).map( ( featureGroup: FeatureGroup ) => (
|
|
1081
|
+
<FeatureGroup
|
|
1082
|
+
key={ featureGroup.slug }
|
|
1083
|
+
featureGroup={ featureGroup }
|
|
1084
|
+
visibleGridPlans={ visibleGridPlans }
|
|
1085
|
+
featureGroupMap={ featureGroupMap }
|
|
1086
|
+
selectedFeature={ selectedFeature }
|
|
1087
|
+
intervalType={ intervalType }
|
|
1088
|
+
activeTooltipId={ activeTooltipId }
|
|
1089
|
+
setActiveTooltipId={ setActiveTooltipId }
|
|
1090
|
+
showUpgradeableStorage={ showUpgradeableStorage }
|
|
1091
|
+
onStorageAddOnClick={ onStorageAddOnClick }
|
|
1092
|
+
planFeatureFootnotes={ planFeatureFootnotes }
|
|
1093
|
+
/>
|
|
1094
|
+
) ) }
|
|
1095
|
+
<ComparisonGridHeader
|
|
1096
|
+
displayedGridPlans={ displayedGridPlans }
|
|
1097
|
+
visibleGridPlans={ visibleGridPlans }
|
|
1098
|
+
isInSignup={ isInSignup }
|
|
1099
|
+
isFooter
|
|
1100
|
+
onPlanChange={ onPlanChange }
|
|
1101
|
+
currentSitePlanSlug={ currentSitePlanSlug }
|
|
1102
|
+
planActionOverrides={ planActionOverrides }
|
|
1103
|
+
selectedPlan={ selectedPlan }
|
|
1104
|
+
showRefundPeriod={ showRefundPeriod }
|
|
1105
|
+
isStuck={ false }
|
|
1106
|
+
isHiddenInMobile
|
|
1107
|
+
ref={ bottomHeaderRef }
|
|
1108
|
+
planTypeSelectorProps={ planTypeSelectorProps }
|
|
1109
|
+
/>
|
|
1110
|
+
</Grid>
|
|
1111
|
+
|
|
1112
|
+
<div className="plan-comparison-grid__footer">
|
|
1113
|
+
{ planFeatureFootnotes?.footnoteList && (
|
|
1114
|
+
<FeatureFootnotes>
|
|
1115
|
+
<ol>
|
|
1116
|
+
{ planFeatureFootnotes?.footnoteList?.map( ( footnote, index ) => {
|
|
1117
|
+
return <li key={ `${ footnote }-${ index }` }>{ footnote }</li>;
|
|
1118
|
+
} ) }
|
|
1119
|
+
</ol>
|
|
1120
|
+
</FeatureFootnotes>
|
|
1121
|
+
) }
|
|
1122
|
+
</div>
|
|
1123
|
+
</div>
|
|
1124
|
+
);
|
|
1125
|
+
};
|
|
1126
|
+
|
|
1127
|
+
const GRID_BREAKPOINTS = new Map( [
|
|
1128
|
+
[ 'small', 0 ],
|
|
1129
|
+
[ 'smedium', 686 ],
|
|
1130
|
+
[ 'medium', 835 ], // enough to fit Enterpreneur plan. was 686
|
|
1131
|
+
[ 'large', 1005 ], // enough to fit Enterpreneur plan. was 870
|
|
1132
|
+
[ 'xlarge', 1180 ],
|
|
1133
|
+
] );
|
|
1134
|
+
|
|
1135
|
+
// TODO
|
|
1136
|
+
// Now that everything under is functional component, we can deprecate this wrapper and only keep ComparisonGrid instead.
|
|
1137
|
+
// More details can be found in https://github.com/Automattic/wp-calypso/issues/87047
|
|
1138
|
+
const WrappedComparisonGrid = ( {
|
|
1139
|
+
siteId,
|
|
1140
|
+
intent,
|
|
1141
|
+
gridPlans,
|
|
1142
|
+
useCheckPlanAvailabilityForPurchase,
|
|
1143
|
+
useAction,
|
|
1144
|
+
recordTracksEvent,
|
|
1145
|
+
allFeaturesList,
|
|
1146
|
+
intervalType,
|
|
1147
|
+
isInSignup,
|
|
1148
|
+
currentSitePlanSlug,
|
|
1149
|
+
selectedPlan,
|
|
1150
|
+
selectedFeature,
|
|
1151
|
+
showUpgradeableStorage,
|
|
1152
|
+
onStorageAddOnClick,
|
|
1153
|
+
stickyRowOffset,
|
|
1154
|
+
coupon,
|
|
1155
|
+
className,
|
|
1156
|
+
hideUnsupportedFeatures,
|
|
1157
|
+
enableFeatureTooltips,
|
|
1158
|
+
featureGroupMap,
|
|
1159
|
+
enableTermSavingsPriceDisplay,
|
|
1160
|
+
reflectStorageSelectionInPlanPrices,
|
|
1161
|
+
...otherProps
|
|
1162
|
+
}: ComparisonGridExternalProps ) => {
|
|
1163
|
+
const gridContainerRef = useRef< HTMLDivElement >( null );
|
|
1164
|
+
|
|
1165
|
+
// TODO: this will be deprecated along side removing the wrapper component
|
|
1166
|
+
const gridSize = useGridSize( {
|
|
1167
|
+
containerRef: gridContainerRef,
|
|
1168
|
+
containerBreakpoints: GRID_BREAKPOINTS,
|
|
1169
|
+
} );
|
|
1170
|
+
|
|
1171
|
+
const classNames = clsx( 'plans-grid-next', className, {
|
|
1172
|
+
'is-small': 'small' === gridSize,
|
|
1173
|
+
'is-smedium': 'smedium' === gridSize,
|
|
1174
|
+
'is-medium': 'medium' === gridSize,
|
|
1175
|
+
'is-large': 'large' === gridSize,
|
|
1176
|
+
'is-xlarge': 'xlarge' === gridSize,
|
|
1177
|
+
'is-visible': true,
|
|
1178
|
+
} );
|
|
1179
|
+
|
|
1180
|
+
return (
|
|
1181
|
+
<div ref={ gridContainerRef } className={ classNames }>
|
|
1182
|
+
<PlansGridContextProvider
|
|
1183
|
+
intent={ intent }
|
|
1184
|
+
siteId={ siteId }
|
|
1185
|
+
gridPlans={ gridPlans }
|
|
1186
|
+
useCheckPlanAvailabilityForPurchase={ useCheckPlanAvailabilityForPurchase }
|
|
1187
|
+
useAction={ useAction }
|
|
1188
|
+
recordTracksEvent={ recordTracksEvent }
|
|
1189
|
+
allFeaturesList={ allFeaturesList }
|
|
1190
|
+
coupon={ coupon }
|
|
1191
|
+
enableFeatureTooltips={ enableFeatureTooltips }
|
|
1192
|
+
featureGroupMap={ featureGroupMap }
|
|
1193
|
+
hideUnsupportedFeatures={ hideUnsupportedFeatures }
|
|
1194
|
+
enableTermSavingsPriceDisplay={ enableTermSavingsPriceDisplay }
|
|
1195
|
+
reflectStorageSelectionInPlanPrices={ reflectStorageSelectionInPlanPrices }
|
|
1196
|
+
>
|
|
1197
|
+
<ComparisonGrid
|
|
1198
|
+
intervalType={ intervalType }
|
|
1199
|
+
isInSignup={ isInSignup }
|
|
1200
|
+
currentSitePlanSlug={ currentSitePlanSlug }
|
|
1201
|
+
siteId={ siteId }
|
|
1202
|
+
selectedPlan={ selectedPlan }
|
|
1203
|
+
selectedFeature={ selectedFeature }
|
|
1204
|
+
showUpgradeableStorage={ showUpgradeableStorage }
|
|
1205
|
+
stickyRowOffset={ stickyRowOffset }
|
|
1206
|
+
onStorageAddOnClick={ onStorageAddOnClick }
|
|
1207
|
+
gridSize={ gridSize ?? undefined }
|
|
1208
|
+
{ ...otherProps }
|
|
1209
|
+
/>
|
|
1210
|
+
</PlansGridContextProvider>
|
|
1211
|
+
</div>
|
|
1212
|
+
);
|
|
1213
|
+
};
|
|
1214
|
+
|
|
1215
|
+
export default WrappedComparisonGrid;
|