Skip to content
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

Implement SeoAnalysis and ReadabilityAnalysis components #492

Merged
merged 48 commits into from
Jul 26, 2018

Conversation

igorschoester
Copy link
Member

@igorschoester igorschoester commented May 3, 2018

Summary

This PR can be summarized in the following changelog entry:

  • Originally planned to create two components: SEO Analysis and Readability Analysis. However, this change has been reverted and now this PR creates support for using the smaller components which later be used to build the functionality of the original two planned components.

Relevant technical choices:

This PR became a little more involved than the issue would indicate.

  • Added the @wordpress/i18n package to replace react-intl.
  • Extracted a LanguageNotice component from ContentAnalysis.
  • Removed the HelpText (and the LanguageNotice) from ContentAnalysis.
  • Updated the HelpText & KeywordInput components.
  • Replaced the react-intl with the @wordpress/i18n variant in the makeOutboundLink util.
  • Updated KeywordExample to work correctly with new changes.
  • Added onChange to the KeywordInput props.
  • Added 'Focus keyword:' label to KeywordInput.
  • Tweaked design of components to better match proposed design:
    -- Changed the size of the collapsible header arrows.
    -- Made the header the "correct" blue: blue_medium, aka #1e8cbe.
    -- The traffic light icons are resized to be slightly smaller
    -- The blue headings should be slightly smaller: Same size as the text in the p element (13px) and the 'Focus keyword:' heading.

Related links

Sidebar design: https://github.com/Yoast/roadmap/issues/5#issuecomment-385635913
Keyword input for classic. See error message: Yoast/wordpress-seo#9179 (comment)

Test instructions

This PR can be tested by following these steps:

  • Normal pull: git checkout stories/475-implement-seo-analysis-component.
  • Normal install: yarn install.
  • Run the local dev server of yoast-components: yarn start.
  • In the tab 'Content Analysis' the language notice should be at the top and the style changes should be present in the content analysis below.
  • In the tab 'Keyword' the HelpText should be visible above and the keyword input below. The keyword input should throw an error when a comma is entered. Also, there should be a 'Focus keyword' label.
  • Checkout its sibling PR in WordPress-SEO: Moved language notice props to seperate component wordpress-seo#10438.
  • Normal install: yarn install, yarn link yoast-components, grunt build
  • Run the local dev server in WordPress-SEO: yarn start.
  • Visit the edit-post page.
  • Check the readability analysis in the metabox.
  • Check if the language notice shows as it should.

Fixes #475

@IreneStr
Copy link
Contributor

IreneStr commented May 4, 2018

@igorschoester

The style of KeywordInput might not be enough. Should this be an auto height input?

The inputfield should grow vertically when the input is too long for one line

The up and down arrows in front on the analysis points look fatter. Should this be updated too?

Yes. And it's no problem that that means that it will change in the metabox as well.

Added an already obsolete Separator component. Should I remove this?

Yes

Are the links for the HelpText the same in both SEO & readability?

Please ask content or support what are the best posts to use for the links. Please ask Annelieke to create shortlinks for any newly introduced links.

@Dieterrr Dieterrr changed the base branch from feature/content-analysis-in-sidebar to develop July 9, 2018 09:58
@Dieterrr Dieterrr changed the base branch from develop to feature/content-analysis-in-sidebar July 9, 2018 09:59
@Dieterrr Dieterrr changed the base branch from feature/content-analysis-in-sidebar to develop July 10, 2018 11:59
@boblinthorst
Copy link
Contributor

A concern I have is what'll happen to the current metabox upon merging. Many style changes will be made to make everything look good on the sidebar, but in the process, the original metabox will have the same changes. And what looks good in a sidebar, doesn't necessarily look good in the metabox.

I've discussed this with Igor, and concluded that, in the event we make the original metabox unworkable, we should just add the old code and keep that part intact, and make sure this new sidebar is it's own contained code.

*/
render() {
return (
<Container>
<HelpText text={ [
"Enter the search term you'd like this post to be found with and see how it would rank. ",
<HelpTextLink key="1" href="https://yoa.st/" target="_blank" rel="noopener">
Copy link
Contributor

Choose a reason for hiding this comment

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

target="_blank" rel="noopener" should be removed as they're overriding the makeOutboundLink() defaults. Notice noreferrer is not rendered. Remove these two attributes and makeOutboundLink() will work as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

My mistake, missed that. Apologies.

`;

const KeywordField = styled.input`
border: 3px solid initial;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why initial? Doesn't seem to work, at least in the shorthand syntax. Chrome and Firefox discard the whole border property (please check in your browser's inspector). The single property border-color: initial; seems to work at least in Chrome and Firefox but I guess it's not what we want, because it looks different across browsers.
For other input fields borders we're using $color_input_border or $color_grey or directly #ddd to be consistent with WordPress. Note: the contrast ratio is not sufficient but this should be addressed separately.

margin-top: 0;

a {
color: ${ colors.$color_snippet_focus };
Copy link
Contributor

Choose a reason for hiding this comment

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

This point still needs an answer. @hedgefield seems to me we should let links inherit the default WordPress colors for links (default: #0073aa), as we're already doing for all the links in the meta box. Why we should use a different color?

Choose a reason for hiding this comment

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

Ahh that's the default link color, I thought it was the Yoast Blue (the hex code is very similar), which isn't in our colors scss, so I changed it to that. But yes if that's the link color we use everywhere, we should use that.

`;

const ChangeLanguageLink = makeOutboundLink( styled.a`
color: ${ colors.$color_snippet_focus };
Copy link
Contributor

Choose a reason for hiding this comment

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

Same consideration for links colors, see above

@afercia
Copy link
Contributor

afercia commented Jul 19, 2018

CR 🚧

A few considerations to address.

<a key="1" href="https://yoa.st/" target="_blank" rel="noopener">Learn more about the Content Analysis Tool.</a>,
] }
/>
<div>
Copy link
Contributor

@maartenleenders maartenleenders Jul 23, 2018

Choose a reason for hiding this comment

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

Could be a <React.Fragment>, div is not necessary

never mind this is the example app, doesn't matter that much then

@maartenleenders
Copy link
Contributor

CR 👍

@maartenleenders
Copy link
Contributor

maartenleenders commented Jul 25, 2018

Acceptance 🚧

  • Since the ContentAnalysis component was touched (LanguageNotice was split out from it), wordpress-seo needs to be updated to render the new independend LanguageNotice.
  • The styling in the ContentAnalysis seems to be slightly below our standards, but that is my opinion. I think we'd do well to give everything a little more 'breathing room' with padding/margins. @hedgefield has offered to sit in on a little styling session to improve things. I would also be fine if you split this up into a new issue, as this PR has become quite big.

@boblinthorst
Copy link
Contributor

boblinthorst commented Jul 25, 2018

I've created a sibling pr to deal with the languageNotice. I've decided to create a seperate issue for the styling issues. Mostly because this pr is way too big, but also partially because the styling of the content analysis hasn't been touched that much in this pr, so addressing this here would add even more responsibilities to this pr.

The seperate issue: #671

Copy link
Contributor

@jcomack jcomack left a comment

Choose a reason for hiding this comment

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

CR done 🏗

@@ -1,6 +1,7 @@
import React from "react";

import ContentAnalysis from "../composites/Plugin/ContentAnalysis/components/ContentAnalysis";
import LanguageNoticeWrapper from "./LanguageNoticeWrapper.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe @atimmer mentioned something about not importing files in this manner. Not sure if that's relevant to this or not.

Copy link
Contributor

@boblinthorst boblinthorst Jul 26, 2018

Choose a reason for hiding this comment

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

Anton did say something about importing in this style. But i believe he referred to to importing yoast-components from wordpress-seo.

When importing components from yoast-components in wpseo, exporting the component in the index.js file of yoast-components, allows you to import it in wordpress-seo directly from yoast-components.

I didn't do that properly in this pull, so the remark was still valid.

I'll still check with Anton if a similar way of importing is possible within yoast-components itself.

Update: Anton confirmed the new way of importing only applies to when using yoast-components outside the project.

@@ -5,32 +5,92 @@ import styled from "styled-components";
// Internal dependencies.
import KeywordInput from "../composites/Plugin/Shared/components/KeywordInput";
import SynonymsSection from "../composites/Plugin/Synonyms/components/SynonymsSection";
import HelpText from "../composites/Plugin/Shared/components/HelpText.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

See previous comment regarding this style of important components.

*/
render() {
return (
<Container>
<HelpText text={ [
"Enter the search term you'd like this post to be found with and see how it would rank. ",
<HelpTextLink key="1" href="https://yoa.st/">
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this link purely an example?

Copy link
Contributor

@boblinthorst boblinthorst Jul 25, 2018

Choose a reason for hiding this comment

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

This example can only be reached in the standalone. Which you can visit by running the dev-server in yoast-components (yarn start) and going to localhost:3333 in your browser.

import React from "react";
import styled from "styled-components";

import LanguageNotice, { languageNoticePropType } from "../composites/Plugin/Shared/components/LanguageNotice.js";
Copy link
Contributor

Choose a reason for hiding this comment

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

See previous comment regarding the importing of files.

* @param {String} props.id The id of the KeywordInput.
* @param {IconsButton} props.label The label of the KeywordInput.
* @param {boolean} props.keyword The initial keyword passed to the state.
* @param {Object} props The props for this input field component.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd vouch for being consistent with the usage of names... So instead of speaking of 'this input field component' I'd say 'The props for the KeywordInput'.

* @param {Object} props The props for this language notice wrapper.
* @param {string} props.changeLanguageLink The URL where the language can be changed.
* @param {bool} props.canChangeLanguage Whether or not the language can be changed.
* @param {string} props.language The current set language.
Copy link
Contributor

Choose a reason for hiding this comment

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

current should be currently.

* @param {Object} props The props for this language notice wrapper.
* @param {string} props.changeLanguageLink The URL where the language can be changed.
* @param {bool} props.canChangeLanguage Whether or not the language can be changed.
* @param {string} props.language The current set language.
Copy link
Contributor

Choose a reason for hiding this comment

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

current should be currently.

export default class LanguageNotice extends PureComponent {
/**
* Renders the language notice. Provides a link to a setting page in case of
* administrator, a notice to contact an administrator otherwise.
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd recommend rewriting this to something like the following:

'Renders the language notice. Provides a link to a setting page if the currently set language can be changed. Provides a message to contact an administrator otherwise.'


// Determine the correct text.
let text = canChangeLanguage ? canChangeLanguageText : canNotChangeLanguageText;
// Replace the %s with a strong marked language.
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing whitespace above comment.

let text = canChangeLanguage ? canChangeLanguageText : canNotChangeLanguageText;
// Replace the %s with a strong marked language.
text = sprintf( text, `{{strong}}${ language }{{/strong}}` );
// Replace the strong marking with an actual ReactComponent.
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing whitespace above comment.

@maartenleenders
Copy link
Contributor

CR 👍

@maartenleenders maartenleenders merged commit a7059f4 into develop Jul 26, 2018
@maartenleenders
Copy link
Contributor

Acceptance 👍

@maartenleenders maartenleenders deleted the stories/475-implement-seo-analysis-component branch July 26, 2018 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants