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
Design Picker: Include premium themes #59293
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~565 bytes removed 📉 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Sections (~31 bytes added 📈 [gzipped])
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 (~204 bytes added 📈 [gzipped])
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. Generated by performance advisor bot at iscalypsofastyet.com. |
8e119eb
to
5ca9b57
Compare
7ffdaaf
to
6674bbd
Compare
return async ( dispatch ) => { | ||
dispatch( { type: RECOMMENDED_THEMES_FETCH, filter } ); | ||
const query = { | ||
search: '', | ||
number: 50, | ||
tier: '', | ||
tier, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means the fetching takes the tier
into account, but the reducer doesn't take the tier
into account.
https://github.com/Automattic/wp-calypso/blob/031a60d1891e2c610d9e8048a241c7e523d8cef0/client/state/themes/reducer.js#L491
It will stash the response in the store using only the filter
, which means when the selector gets called it will return whatever tier just happens to have been last fetched.
A fix for this would be to store the response in the redux using both the filter
and tier
. But since I'd already planned on moving the theme fetching to @automattic/design-picker
anyway, I thought the addition of premium themes would be a good opportunity to make that change. Making the code sharable with Gutenboarding rather than modifying the recommended themes reducer.
I'm making that change here: #59342
#59342 doesn't implement the actual feature that this PR does though i.e. it doesn't use hasFeature
to decide whether to request premium themes or not. But I think that it'd be good to merge #59342 first so that we don't have to modify the Redux store.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool, I don't notice that we use action.filter
as the key of the themes. I think #59342 is a great refactor and I'm looking forward to merging it 👍
6674bbd
to
7c02162
Compare
ab76d59
to
147c197
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tested using Business plan, and planHasFeature()
doesn't return true for FEATURE_PREMIUM_THEMES
. Not sure why though.
return ( | ||
<Tooltip | ||
position="top center" | ||
// @ts-expect-error: @types/wordpress__components doesn't align with latest @wordpress/components |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much tidier 😅 I've worked around this in much hackier ways before
|
||
const [ userLoggedIn, isPremiumThemesAvailable ] = useSelector( ( state ) => [ | ||
isUserLoggedIn( state ), | ||
planHasFeature( sitePlanSlug, FEATURE_PREMIUM_THEMES ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
planHasFeature()
isn't actually a selector so doesn't need useSelector()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops...
Do you enable the feature flags? See:
Or maybe your business plan is expired 🤔 |
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7071877 Thank you @arthur791004 for including a screenshot in the description! This is really helpful for our translators. |
c387d06
to
04efb6e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you enable the feature flags?
This was my problem, I'd forgotten the feature flag.
Looks good 👍
I've pushed some changes to the unit tests to fix them and to include a test for the case where the theme config is missing the stylesheet information.
The thumbnails didn't work, as expected. But I'm confident it'll work once the diff has shipped because the iframe'd preview of the design is working. I suggested some changes to the diff.
We have to wait for the backend to ship first anyway, but I think we don't need to feel blocked by the string freeze error. When you drill into the details of the translation task it's basically all done now.
Yep, I think the thumbnail will work after the backend is shipped! |
ddb1a97
to
431b806
Compare
This Pull Request is now available for translation here: https://translate.wordpress.com/deliverables/7071877 Thank you @arthur791004 for including a screenshot in the description! This is really helpful for our translators. |
431b806
to
cfd1008
Compare
@arthur791004 Premium themes looks good.
Could we update the tooltip to be: Just to make sure I understand the order of operations in coordinating with the launch of the five Premium Themes (pdgA0m-b7-p2)
Is that correct? |
Sure, I'll add the new copy. But we need to wait for the translation after we update the copy. Besides, we should keep in mind that we have to remove/replace “Premium themes are included in your plan.” when we work on showing premium themes for the user with free or personal plan.
Yep, you're right! But I think we don't need to update this line. Is there any reason we have to? |
710c7d3
to
96ddc1c
Compare
Nope. All good. 😄 |
// @ts-expect-error: @types/wordpress__components doesn't align with latest @wordpress/components | ||
delay={ 300 } | ||
text={ `${ __( | ||
'Let your site stand out from the crowd with a modern and stylish Premium theme.', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arthur791004 Thanks for thinking ahead on this and making these two separate i18n strings! 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this string 'Let your site stand out from the crowd with a modern and stylish Premium theme.', already translated? If so, then don't let the new string block merging this PR.
We can add the new string in a subsequent PR. (I think translations can take a week or two right? )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the first string is done: https://translate.wordpress.com/developer/arthur791004 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll add a new string in follow-up PR.
96ddc1c
to
9a1f03c
Compare
@@ -1,6 +1,7 @@ | |||
import { isEnabled } from '@automattic/calypso-config'; | |||
import DesignPicker, { | |||
FeaturedPicksButtons, | |||
PremiumBadge, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change triggers the following TypeScript error:
yarn tsc -p client/tsconfig.json --noEmit
client/landing/gutenboarding/onboarding-block/designs/index.tsx:1:24 - error TS2614: Module '"@automattic/design-picker"' has no exported member 'PremiumBadge'. Did you mean to use 'import PremiumBadge from "@automattic/design-picker"' instead?
1 import DesignPicker, { PremiumBadge, getAvailableDesigns } from '@automattic/design-picker';
~~~~~~~~~~~~
Could you fix it @arthur791004? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well apparently this is an issue with tsc
, and it's just a matter of rebuilding packages to make those errors go away (more information here). Sorry for the ping Arthur.
Translation for this Pull Request has now been finished. |
Changes proposed in this Pull Request
planHasFeature
utils and then determine the value of thetier
should beall
orfree
PremiumBadge
component in the Design Picker package and passPremiumBadge
as a prop of the Design PickerExample of the premium badge and the hover behavior
Testing instructions
/start/setup-site/intent?siteSlug=<your_site>&flags=themes/premium
Related to #59025