-
Notifications
You must be signed in to change notification settings - Fork 22
UX improvement on WordPress.com account connection #1068
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
Changes from 8 commits
9fa7d17
4f82292
70ca60b
86705da
54d043a
828c3cf
6ffab4f
c21b63d
c0e5b96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import classnames from 'classnames'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { Flex, FlexItem } from '@wordpress/components'; | ||
import GridiconCheckmarkCircle from 'gridicons/dist/checkmark-circle'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './index.scss'; | ||
|
||
const ConnectedIconLabel = ( props ) => { | ||
const { className } = props; | ||
|
||
return ( | ||
<div className={ classnames( 'gla-connected-icon-label', className ) }> | ||
<Flex align="center" gap={ 1 }> | ||
<FlexItem> | ||
<GridiconCheckmarkCircle /> | ||
</FlexItem> | ||
<FlexItem> | ||
{ __( 'Connected', 'google-listings-and-ads' ) } | ||
</FlexItem> | ||
</Flex> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ConnectedIconLabel; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.gla-connected-icon-label { | ||
fill: currentColor; | ||
color: #23a713; | ||
|
||
svg { | ||
display: block; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import getConnectedJetpackInfo from '.~/utils/getConnectedJetpackInfo'; | ||
import WPComAccountCard from './wpcom-account-card'; | ||
import ConnectedIconLabel from '.~/components/connected-icon-label'; | ||
|
||
const ConnectedWPComAccountCard = ( { jetpack } ) => { | ||
return ( | ||
<WPComAccountCard | ||
description={ getConnectedJetpackInfo( jetpack ) } | ||
indicator={ <ConnectedIconLabel /> } | ||
/> | ||
); | ||
}; | ||
|
||
export default ConnectedWPComAccountCard; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,15 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Section from '.~/wcdl/section'; | ||
import CardContent from './card-content'; | ||
import ConnectedWPComAccountCard from './connected-wpcom-account-card'; | ||
import ConnectWPComAccountCard from './connect-wpcom-account-card'; | ||
|
||
const WordPressDotComAccount = () => { | ||
return ( | ||
<Section.Card> | ||
<Section.Card.Body> | ||
<CardContent /> | ||
</Section.Card.Body> | ||
</Section.Card> | ||
); | ||
const WordPressDotComAccount = ( { jetpack } ) => { | ||
if ( jetpack.active === 'yes' ) { | ||
return <ConnectedWPComAccountCard jetpack={ jetpack } />; | ||
} | ||
|
||
return <ConnectWPComAccountCard />; | ||
}; | ||
|
||
export default WordPressDotComAccount; |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,34 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* External dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import { __ } from '@wordpress/i18n'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
/** | ||||||||||||||||||||||||||||||||||||||||||||||||||||
* Internal dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import AccountCard from '.~/components/account-card'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
import wpLogoURL from './wp-logo.svg'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
const WPComAccountCard = ( props ) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
<AccountCard | ||||||||||||||||||||||||||||||||||||||||||||||||||||
appearance={ { | ||||||||||||||||||||||||||||||||||||||||||||||||||||
icon: ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
<img | ||||||||||||||||||||||||||||||||||||||||||||||||||||
src={ wpLogoURL } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
alt={ __( | ||||||||||||||||||||||||||||||||||||||||||||||||||||
'WordPress.com Logo', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
'google-listings-and-ads' | ||||||||||||||||||||||||||||||||||||||||||||||||||||
) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
width="40" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
height="40" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||||||||||||||||||||||||
title: 'WordPress.com', | ||||||||||||||||||||||||||||||||||||||||||||||||||||
} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+15
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❔ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought about that. For the long term code perspective, I think it may not be a good idea. If we were to make it consistent to handle WordPress.com Logo SVG, the I prefer to use composition here, and keep There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The size ratios of phone and store icons including their dependencies in the index.js are highlighted by red background. (Total three blocks. The zoom-in of phone icon block.) Their size is only about 1.3 kB after gzip. I think even if the
For the long term, regardless of their file size ratios, we could still achieve tree shaking and further file splitting by moving them to another file under the same folder of // Another standalone file
export const APPEARANCE_PHONE = {
icon: <GridiconPhone size={ 32 } />,
title: __( 'Phone number', 'google-listings-and-ads' ),
};
export const APPEARANCE_ADDRESS = {
icon: <Icon icon={ storeIcon } size={ 32 } />,
title: __( 'Store address', 'google-listings-and-ads' ),
}; And expose them from // .~/components/account-card/index.js
export { APPEARANCE_ADDRESS, APPEARANCE_PHONE } from './appearance-contact-info'; Then the bundle of consumer side would not contain phone and store icon codes if it doesn't use any of the constants. // A consumer component depends on the account-card file
import AccountCard, { APPEARANCE_GOOGLE } from '.~/components/account-card'; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's a good analysis 🙂 👍 What is that tool that you use to generate that treemap? 🤔
Yes, the size for the phone and store icons is small and not a primary concern for the present. To be clear, the mention of phone and store icons is to serve as an example. The point I was trying to bring up is that it can have a better code architecture design and be more scalable for the long run. With the current approach, if we are not mindful and careful, we might accidentally add a super large icon and it would be included in the bundle even though it is actually not used in the page.
Yes, correct, and that's why I was doing this
google-listings-and-ads/js/src/components/account-card/index.js Lines 82 to 85 in 454cd79
google-listings-and-ads/js/src/components/account-card/index.js Lines 29 to 49 in 454cd79
Edit: oops, I guess what you mean is that when we "move them to another file", we would also get rid of
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for replying. I'm good with both code structures. Just to clarify that even if these assets are imported from
It's Webpack Bundle Analyzer. And a relevant usage can be found in the Detailed test instructions section in #1073.
I think with the current code structure, no matter where the huge inline SVG appears, it will be included in index.js at all. And I believe it will be discovered by the bundlewatch check. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
{ ...props } | ||||||||||||||||||||||||||||||||||||||||||||||||||||
/> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
); | ||||||||||||||||||||||||||||||||||||||||||||||||||||
}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
export default WPComAccountCard; |
Uh oh!
There was an error while loading. Please reload this page.