Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Adds StoreAlerts component #1627

Merged
merged 13 commits into from
Feb 26, 2019
Merged

Adds StoreAlerts component #1627

merged 13 commits into from
Feb 26, 2019

Conversation

tiagonoronha
Copy link
Contributor

@tiagonoronha tiagonoronha commented Feb 19, 2019

Fixes #115

Basic component, still in development.

screenshot 2019-02-19 at 21 10 40

Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

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

Looking really great @tiagonoronha - couple of comments

this.totalAlerts = this.totalAlerts.bind( this );
}

totalAlerts() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm thinking eventually the array of alerts will be passed in as a prop, so we could probably update the logic in the component to be ready for that. We could create a defaultProps that passes in your dummy instance as the alerts prop. And you could then use this.props.alerts here

const alert = dummy[ currentAlert ] ? dummy[ currentAlert ] : null;
const type = alertTypes[ alert.type ] ? alertTypes[ alert.type ] : null;
const className = classnames( 'woocommerce-store-alerts', {
'is-alert-emergency': type && 'emergency' === alert.type,
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of checking for type here and having alert.type in each line, should we just assign alert.type to a const somewhere after line 103?

role="status"
aria-live="polite"
>
{ currentAlert + 1 } { __( 'of', 'wc-admin' ) } { this.totalAlerts() }
Copy link
Contributor

Choose a reason for hiding this comment

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

This might need to use interpolateComponents for a proper translation setup. Here is an example

] }
className={ className }
action={
this.totalAlerts() > 1 && (
Copy link
Contributor

Choose a reason for hiding this comment

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

If moved to props, we could assign the length of the alerts array to a const and use it throughout here.

const numberOfAlerts = this.props.alerts.length;

@tiagonoronha
Copy link
Contributor Author

@timmyc thanks for the feedback! I made a few changes, hopefully it simplified things :)

Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

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

Nice refactors @tiagonoronha - the props are looking great. One comment about putting a feature flag around this so it only shows in dev mode. Also I'm seeing a few glitches on mobile:

iOS / Mobile Safari buttons on next line
Not sure what the optimal positioning is on mobile ( cc @LevinMedia for any input here )
image

Android / Chrome
image

^ in both above, the alerts are also aligned with the left side of the screen and there is some margin on the right. Not sure if we want this full-width or with a bit of padding/margin on each side like we have for the date picker / filters.

role="status"
aria-live="polite"
>
{ interpolateComponents( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@@ -66,6 +67,8 @@ class Layout extends Component {
<TransientNotices />

<div className="woocommerce-layout__primary" id="woocommerce-layout__primary">
<StoreAlerts />
Copy link
Contributor

Choose a reason for hiding this comment

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

Prior to merging this in, I think we should add a feature flag around this so it only shows up in Dev mode. #1500 has some examples on how that is done.

}
>
<div className="woocommerce-store-alerts__message">{ alert.message }</div>
<Button isPrimary className="woocommerce-store-alerts__button" href={ alert.action.url }>
Copy link
Contributor

@LevinMedia LevinMedia Feb 21, 2019

Choose a reason for hiding this comment

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

Can you change button to isDefault ?

There's some funky override going on in there somewhere, when I change it to isDefault the normal state button text is white, when it should be $core-grey-dark-500

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm also seeing the same issues on mobile that are noted above.

I'd like the left margin to match the rest of the content (it should be 16px on the smallest screens) and position the segmented button above the alert title?

screen shot 2019-02-21 at 2 23 44 pm

@tiagonoronha tiagonoronha self-assigned this Feb 21, 2019
@tiagonoronha
Copy link
Contributor Author

@LevinMedia @timmyc

Made a few changes :)

screenshot 2019-02-21 at 23 38 33

screenshot 2019-02-21 at 23 43 49

Also added the feature flag!

@tiagonoronha
Copy link
Contributor Author

@LevinMedia full context:

screenshot 2019-02-22 at 11 38 37

screenshot 2019-02-22 at 11 39 24

@LevinMedia
Copy link
Contributor

Thanks @tiagonoronha looking good!

Copy link
Contributor

@timmyc timmyc left a comment

Choose a reason for hiding this comment

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

This is looking great @tiagonoronha - I say we merge this and in the next sprint we can tackle how to add in real data to the priority notif area.

@@ -67,7 +67,7 @@ class Layout extends Component {
<TransientNotices />

<div className="woocommerce-layout__primary" id="woocommerce-layout__primary">
<StoreAlerts />
{ window.wcAdminFeatures[ 'store-alerts' ] && <StoreAlerts /> }
Copy link
Contributor

Choose a reason for hiding this comment

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

<3

@tiagonoronha tiagonoronha merged commit eaeee60 into master Feb 26, 2019
@tiagonoronha tiagonoronha deleted the add/115-store-alerts branch February 26, 2019 23:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants