-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Component: Banner #9653
Component: Banner #9653
Conversation
Design wise it's looking great so far! :) Just a tiny addition: can we add these rules to handle a more evident hover state aligned with how we do things elsewhere (i.e. themes, reader):
I made the selector as CSS ones, but add them as you see fit in the SCSS. Some smaller design details which I'm sure are already on your list, but just to be sure:
Ace work there! Thanks! |
onClick(); | ||
|
||
if ( href ) { | ||
window.location.href( href ); |
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 we need this if the rendered <Button />
will be an anchor element anyways? If we do, we should at the very least call on page
instead of window.location
directly.
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.
Good point: I'd also raise the issue that if there's a URL to point to, the link should always be a standard href=
so it leverages of all the browser optimizations for it (open in a new tab, right click, drag'n'drop, etc).
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.
Sorry guys, this wasn't supposed to be still here. I'm gonna remove it ASAP.
} = this.props; | ||
|
||
if ( event ) { | ||
analytics.tracks.recordEvent( 'calypso_upgrade_banner_cta_click', { |
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.
Had you considered using the Redux analytics action creators? I could even see this hooking into the onClick
prop, something like:
export default connect( null, ( dispatch, { onClick, event } ) => {
if ( event ) {
onClick = flow(
onClick,
partial( recordGoogleEvent, 'calypso_upgrade_banner_cta_click', { cta_name: event } )
);
}
return { onClick };
} )( UpgradeBanner );
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 pretty much copied it from the Card component without giving it much thought, and that's exactly why it's on the todo list. :)
</ul> | ||
} | ||
</div> | ||
{ ! button && |
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.
Some docs for the component would be good, since it's not obvious to me why button
wouldn't be an indicator for rendering the button (here, appears opposite?)
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.
Readme incoming. I was more interested in pushing to trigger some design related discussions. :)
<div className="upgrade-banner__description"> | ||
{ description } | ||
</div> | ||
{ list && |
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.
Should we check length (perhaps size( list ) > 0
using _.size
) to avoid rendering the list if it's empty?
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.
Considering that the purpose of this component is display some copy text, is it really something we should be worried about?
(Also, is there a reason to use _.size
instead of Array.length
?)
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'm just imagining some case where we dynamically compose a list to pass to this component, and if that list happens to be empty, we might render this element, which I assume would have some base styling applied to push margins etc?
(Also, is there a reason to use
_.size
instead ofArray.length
?)
const list = undefined;
console.log( size( list ) );
// => 0
console.log( list.length ) );
// Uncaught TypeError: Cannot read property 'length' of undefined
} | ||
} | ||
|
||
bannerContent() { |
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.
Usually I find if you're creating separate render methods, either (a) it should be inlined into the base render
method or (b) it should be split into a separate component.
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 guess a separate button component could make sense in this case, considering how many more props the card version has compared to the button one.
As the button version is pretty much ready, though, maybe I could include it here and split in a following PR?
Looping in @rickybanister Ties into the discussion around extending the nudge to other uses than upgrading |
The way it is implemented at the moment, this seems like a component and not a block to me. The main benefit of the old upgrade nudge is that it abstracted a few things for you. For instance, you would pass a It also handled display logic for showing or not showing a nudge based on what features your current plan supports, which is very important. Finally, I suggest looking at the cosmetic props (like color) and removing them in favor of the component handling it. If a feature belongs to a specific plan, the component would use the color from said plan, etc. Same with price, it'd be good for the block to grab the price via a selector, because there are many intricacies there that should not be left up to be figured out by the person using one of these banners. |
With the new
Do you think it's fine like this, or should I increase the two-liners vertical paddings? |
Let's keep that. We can always tweak later. :) |
I've added the Banner i3 version. Colors: I've opted for the strictest approach. Icons: icons are mandatory if no plan is defined. Otherwise, the icon defaults to the PlanIcon. Testable at http://calypso.localhost:3000/devdocs/design/banner |
d088244
to
a124772
Compare
I think we are almost there! :) The only odd thing in the DevDocs is that the I'd also suggest to have a canonical example of each of the three plans banners in the showcase: identical, just with the text changed to match the plan and the same structure. So it's clear what changes from one plan to the other, and just that change. I'd thus then add a separate one that changes the icon from the default. To be clearer:
Makes sense? |
@folletto It does, and yes, the icons seemed off to me too. Gonna fix the icons and add the dismiss button asap! |
New screenshot with all features added (cc @folletto) All things considered, I stick with my proposal of having several sub-components (ie. |
I did a test run, design wise 👍 |
At this point I'd say we should review and ship this now and, if needs arise, extend it with specific sub-components at a later time. |
|
||
static defaultProps = { | ||
dismissTemporary: false, | ||
feature: false, |
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.
If there's no reasonable default, we don't need to assign a defaultProps
value. We could just not define any default and it would work just as well, leveraging truthiness of undefined
prop in the condition where it's used. Also saves you the need to assign it as a oneOf
option in propTypes
.
- Card version: add hover transitions and box shadows. - Increase description top margin. - Do not show empty description div if description is not provided. - Darken description and list text color. - Reduce banner action right margin.
- Use Redux analytics. - Remove `href` leftover in `handleClick`. - Add check on list size.
Add `getSelectedSiteSlug` selector to build the `href` prop pointing to the pricing page and highlighting the requested feature.
- Reorder devdocs examples. - Add default icon. - Center icons in circles. - Updated README.
e8c1112
to
2486f02
Compare
Add the missing style after this revert: 333edb53d812c3f424590ada 1a98717c35a277e1
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.
Minor notes, but otherwise LGTM 👍
dismissPreferenceName: PropTypes.string, | ||
dismissTemporary: PropTypes.bool, | ||
event: PropTypes.string, | ||
feature: PropTypes.oneOf( [ ...getValidFeatureKeys() ] ), |
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.
You can drop the spread:
feature: PropTypes.oneOf( getValidFeatureKeys() ),
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.
Dang, you're totally right!
static defaultProps = { | ||
dismissTemporary: false, | ||
onClick: noop, | ||
} |
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.
ESLint does not warn yet, but static property and instance property initializers need semicolons.
https://github.com/tc39/proposal-class-public-fields/pull/45/files
https://tc39.github.io/proposal-class-public-fields/
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.
Uh, I wasn't aware of this.
Gonna fix it and merge.
- Dropped an unnecessary leftover spread. - Added semicolons to static properties.
As proposed by @folletto, here's the new
UpgradeBanner
component, aiming to replaceUpgradeNudge
and all its custom variations.Goals:
Testing
http://calypso.localhost:3000/devdocs/blocks/upgrade-banners
Status
Screenshots