Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds billing interval switcher in plugin details and plugins browser. #59128

Merged
merged 13 commits into from
Dec 15, 2021

Conversation

cpapazoglou
Copy link
Contributor

@cpapazoglou cpapazoglou commented Dec 13, 2021

Changes proposed in this Pull Request

  • Adds a new compact prop to <Breadcrumb>, so that we can just display "Back" in smaller breakpoints
  • Creates a billing interval switcher component for the Marketplace by composition of two already existing components
  • Uses the above component in plugins browser and plugin details
  • Note: the placement in plugins browser is not identical to the designs but we can iterate on it on future PRs

Testing instructions

Scenario WPCOM sites with paid plugin

  • go to /plugins/[domain]
  • inspect the new switcher
  • change breakpoint, make sure nothing breaks
  • repeat for /plugins/woocommerce-subscriptions/

Scenario WPCOM sites with free plugin

  • go to /plugins/woocommerce/
  • switcher should not show

Scenario Jetpack Self hosted sites

  • go to /plugins/[domain]
  • switcher should not show
Before List After List
SS 2021-12-15 at 16 48 05 SS 2021-12-15 at 16 48 21
Before Details After Details
SS 2021-12-15 at 16 48 53 SS 2021-12-15 at 16 49 07

Fixes #57102

@github-actions
Copy link

github-actions bot commented Dec 13, 2021

@cpapazoglou cpapazoglou changed the title Add/billing-interval-switcher Adds billing interval switcher in plugin details and plugins browser. Dec 13, 2021
@cpapazoglou cpapazoglou self-assigned this Dec 13, 2021
@matticbot
Copy link
Contributor

matticbot commented Dec 13, 2021

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~124 bytes added 📈 [gzipped])

name                 parsed_size           gzip_size
entry-gutenboarding       +569 B  (+0.0%)     +124 B  (+0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~1477 bytes added 📈 [gzipped])

name                      parsed_size           gzip_size
plugins                       +4675 B  (+0.8%)    +1420 B  (+0.8%)
woocommerce-installation       +219 B  (+0.1%)      +57 B  (+0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~45 bytes added 📈 [gzipped])

name               parsed_size           gzip_size
async-load-design       +219 B  (+0.0%)      +45 B  (+0.0%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@gcsecsey gcsecsey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎉

client/components/breadcrumb/index.tsx Outdated Show resolved Hide resolved
@@ -92,6 +95,10 @@ function PluginDetails( props ) {
const isWpcom = selectedSite && ! isJetpack;
const isJetpackSelfHosted = selectedSite && isJetpack && ! isAtomic;

// Header Navigation and billing period switcher.
const isWide = useBreakpoint( '>1280px' );
const [ billingPeriod, setBillingPeriod ] = useState( 'MONTHLY' );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is any chance we can have it in global state(redux)? This would allow us to:

  • Keep the period selected when moving between pages.
  • Easier usage on down the line components as PluginBrowserItem

Copy link
Contributor Author

@cpapazoglou cpapazoglou Dec 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I had it in mind. Let's do it in a follow up.

client/components/breadcrumb/index.tsx Show resolved Hide resolved
Comment on lines +1 to +4
export enum IntervalLength {
ANNUALLY = 'ANNUALLY',
MONTHLY = 'MONTHLY',
}
Copy link
Collaborator

@WBerredo WBerredo Dec 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for address this, can we change those values to lowercase so we can use them directly when looking on plugin variations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sadly, no

<SegmentedControl>
<SegmentedControl.Item
selected={ intervalType === 'MONTHLY' }
onClick={ () => onChange( 'MONTHLY' ) }
>
<span className="plans-interval-toggle__label">{ monthlyLabel }</span>
</SegmentedControl.Item>
<SegmentedControl.Item
selected={ intervalType === 'ANNUALLY' }
onClick={ () => onChange( 'ANNUALLY' ) }
>
<span className="plans-interval-toggle__label">{ annuallyLabel }</span>
{ /*
* Check covers both cases of maxMonthlyDiscountPercentage
* not being undefined and not being 0
*/ }
{ intervalType === 'MONTHLY' && maxMonthlyDiscountPercentage && (
<PopupMessages>
{ sprintf(
// translators: will be like "Save up to 30% by paying annually...". Please keep "%%" for the percent sign
__(
'Save up to %(maxDiscount)d%% by paying annually and get a free domain for one year',
__i18n_text_domain__
),
{ maxDiscount: maxMonthlyDiscountPercentage }
) }
</PopupMessages>
) }
</SegmentedControl.Item>

Copy link
Collaborator

@WBerredo WBerredo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚢

@cpapazoglou cpapazoglou merged commit 831b4c5 into trunk Dec 15, 2021
@cpapazoglou cpapazoglou deleted the add/billing-interval-switcher branch December 15, 2021 16:00
@a8ci18n
Copy link

a8ci18n commented Dec 15, 2021

This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7043514

Thank you @cpapazoglou for including a screenshot in the description! This is really helpful for our translators.

@a8ci18n
Copy link

a8ci18n commented Dec 24, 2021

Translation for this Pull Request has now been finished.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Marketplace: Monthly / Annually component
5 participants