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 help text in react snippet editor #517

Merged

Conversation

danielFangstrom
Copy link
Contributor

@danielFangstrom danielFangstrom commented May 9, 2018

Summary

This PR can be summarized in the following changelog entry:

  • Adds a button to the react snippet editor that toggles the help text

Relevant technical choices:

  • Uses a wrapper that contains the button and the div
  • The HelpText component is included from the feature/content-analysis-in-sidebar branch and has already been code reviewed

Test instructions

This PR can be tested by following these steps:

  • Use define( 'YOAST_FEATURE_SNIPPET_PREVIEW', true ); in wordpress-seo to see the react snippet editor (for example on line 46 in class-metabox-formatter.php)
  • There should be a question mark button in the react snippet preview that should toggle help text above the snippet title
  • The appearance of the button and the text should be the same as in the current snippet preview (including focus and hover styles)
  • Running yarn test should pass all tests

Fixes #481

@danielFangstrom danielFangstrom added this to the 3.6 milestone May 9, 2018
Copy link
Contributor

@maartenleenders maartenleenders 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 🚧



const HelpTextContainer = styled.div`
max-width: 50em;
Copy link
Contributor

Choose a reason for hiding this comment

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

indentation?

`;

let HelpTextDiv = styled.div`
max-width: 30em !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this !important really necessary or is it a remnant from experimenting?

Copy link
Contributor

@maartenleenders maartenleenders May 9, 2018

Choose a reason for hiding this comment

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

Why is it in ems instead of px/%?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was copied from the specifications of the old snippet editor help text, but I have adjusted it to use pixels now instead.

max-height: 0;
`;

const colorHelpTextButton = "#0073aa";
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this color in the colors.json? Or, if not, a color that's very close?

Copy link
Contributor

Choose a reason for hiding this comment

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

And please move this to above the styled components


const colorHelpTextButton = "#0073aa";

const HelpTextContent = [ "This is a rendering of what this post might look like in Google's search results. ",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move this to above the styled components

/**
* Renders the help text wrapper.
*
* @returns {ReactElement} The rendered help text wrapper .
Copy link
Contributor

Choose a reason for hiding this comment

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

space before period

render() {
return (
<HelpTextContainer
className={ `${ this.props.className }` }>
Copy link
Contributor

Choose a reason for hiding this comment

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

Plkease try without ${

>
<StyledSvg
size="16px"
color="#72777c"
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use a color from colors.json (this one or a close one)

@@ -615,6 +566,9 @@ export default class SnippetPreview extends PureComponent {
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
return (
<section>
<div>
<HelpTextWrapper />
Copy link
Contributor

Choose a reason for hiding this comment

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

Please pass the specific help text as a prop here, instead of hardcoding it in the wrapper. This way, the wrapper remains reusable.

@danielFangstrom
Copy link
Contributor Author

Implemented most changes from the CR but temporarily on hold until a decision is made on the colors.

@danielFangstrom danielFangstrom force-pushed the stories/implement-help-text-in-snippet-preview-editor branch from ac1fd00 to bc48778 Compare May 14, 2018 13:11
margin: 0px 20px 10px 25px
`;

let HelpTextDiv = styled.div`
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like it could be a const instead of a let?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I change the properties of the div depending on a conditional in the render method, so I thought I needed let but it turns out that const works as well. Changed to the latter.



const HelpTextContainer = styled.div`
max-width: 600px;
Copy link
Contributor

Choose a reason for hiding this comment

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

One tab too much?

max-width: 600px;
padding: 1 0 3 1em;
font-weight: normal;
margin: 0px 20px 10px 25px
Copy link
Contributor

Choose a reason for hiding this comment

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

If 0px, replace with 0.

box-shadow: 0 0 0 0px #5b9dd9;
position: relative;
display: block;
margin: -44px -10px 10px 0px;
Copy link
Contributor

Choose a reason for hiding this comment

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

0px to 0

border-radius: 50%;
border: none;
clip: rect(1px 1px 1px 1px);
box-shadow: 0 0 0 0px #5b9dd9;
Copy link
Contributor

Choose a reason for hiding this comment

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

0px to 0, is there a color in colors.json that corresponds to the box shadow color?

margin: -44px -10px 10px 0px;
background-color: transparent;
float: right;
padding: 2px 0px 2px 6px;
Copy link
Contributor

Choose a reason for hiding this comment

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

0px to 0

/**
* Handles the onButtonClick event.
*
* Toggles the boolean isExpanded in the state
Copy link
Contributor

Choose a reason for hiding this comment

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

dot

* Renders the HelpTextWrapper component
*
* @param {Object} props The passed props.
* @param {string} props.className The class name.
Copy link
Contributor

Choose a reason for hiding this comment

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

Either line up the documentation, or keep the seperation space between the description and the variable name the same, now it's inconsistent. And should the helpText prop also be documented here?

@@ -659,6 +663,9 @@ export default class SnippetPreview extends PureComponent {
/* eslint-disable jsx-a11y/mouse-events-have-key-events */
return (
<section>
<div>
<HelpTextWrapper helpText = { helpText } />
Copy link
Contributor

Choose a reason for hiding this comment

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

no spacing around the = sign.

@@ -53,6 +54,9 @@ const angleRight = ( color ) => "data:image/svg+xml;charset=utf8," + encodeURI(
"</svg>"
);

export const helpText = [ "This is a rendering of what this post might look like in Google's search results. ",
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like it should be translatable

@boblinthorst
Copy link
Contributor

Cr: placed some comments

@abotteram
Copy link
Contributor

CR 👍

@igorschoester
Copy link
Member

igorschoester commented May 16, 2018

Acceptance 🚧

In Firefox it has a shadow effect:
firefox shadow

On Safari is has a slight shadow effect when pressing the button. This style is always applied, just visible in Safari:

.arVCw:active {
    box-shadow: inset 0 2px 5px -3px rgba( 0,0,0,0.5 );
}

@igorschoester igorschoester merged commit 686732b into develop May 16, 2018
@igorschoester igorschoester deleted the stories/implement-help-text-in-snippet-preview-editor branch May 16, 2018 09:30
@igorschoester
Copy link
Member

Acceptance 👍

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.

5 participants