-
Notifications
You must be signed in to change notification settings - Fork 53
Add a dismissable Alert component with 4 different styles: info, warning, error & success. #332
base: develop
Are you sure you want to change the base?
Conversation
packages/components/src/Alert.js
Outdated
* @returns {void} | ||
*/ | ||
onCrossClick() { | ||
Cookies.set( this.props.cookieName, "true", { expires: 7 } ); |
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.
Though the code checks only for the existence of the cookie (so that the actual cookie value doesn't matter) I think the cookie value is slightly confusing. It confused me also when CR'ing https://github.com/Yoast/my-yoast/pull/2790
For example. when an alert is hidden the actual cookie set could be something like:
errorAlert = "true"
At a first glance, I'd read that as "yes, display the error alert", while it means "hide it" instead. I'd just suggest to change the cookie value to hide
.
packages/components/src/Alert.js
Outdated
cookieName: "", | ||
}; | ||
|
||
export default injectIntl( Alert ); |
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.
When the Alert was used only in MyYoast, injectIntl
made sense. Now that is a package component, not sure this is what we'd want to use.
For example, when importing and using the Alert in Yoast SEO there would be the need to wrap the component in an IntlProvider
component. Instead, on Yoast SEO we're using @wordpress/i18n
. I think this should be changed to use __()
but I'd like confirmation from the architects. If so, all the code related to react-intl
(including in App.js) should be removed in favor of @wordpress/i18n
.
For reference, this is the Alert imported and used in Yoast SEO:
CR 👍 1 2 3 4 5 The Alert tested on a Yoast SEO page: |
0e53dc3
to
f436616
Compare
@afercia Thanks for your extensive review. I have implemented the changes as following:
|
Thanks @Dieterrr ! 4 5
The only way to fix it for me is by adding |
Even after I manually add |
I changed the typo for the link color. Acceptance 🚧 |
I merged with develop and fixed the snapshots. I'm currently getting the following error in myYoast when I link it.
@afercia I have reproduced the issue with the colors. When I log it instead of a color string it is undefined. I wonder if it's related to linking it because if I open the json file I the colors are there. I will look into it and into the js-cookie problem. |
I have put this in blocked and created an issue as the issues with webpack and linking the javascript monorepo were too time consuming and outside of the scope of this PR. Here is the issue: I don't think the current linking between MyYoast and the javascript monorepo is in a usable state and would propose not using it until these issues are fixed. |
Noting there's now a new PR #349 and maybe this one should be closed. |
Summary
Adds an Alert component to Yoast components. It has 4 different styles that can be set in its props: info, warning, error & success. It has an option to be dismissable, which will be saved in a cookie. The alert is based on this design: https://github.com/Yoast/design/issues/371#issuecomment-487953202
Relevant technical choices:
_colors.scss
. It's a lot of new colors so it makes the file a bit messy. Would like a second opinion on how to make this cleaner.Test instructions
This PR can be tested by following these steps:
![Screenshot 2019-08-05 at 15 42 57](https://user-images.githubusercontent.com/16388834/62469763-3f379f80-b799-11e9-9e9d-1229b161b82f.png)
* Inspect them and make sure they match the specifications here: https://github.com/Yoast/design/issues/371#issuecomment-487953202 * Close them and make sure they don't come back unless you delete the cookies :) * If you want to be thorough you can also yarn link to myYoast and test the alerts there.Impact check
UI changes
Quality assurance
Fixes #331