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

Add optional help text to contentanalysis #480

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/ContentAnalysisWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export default function HelpCenterWrapper() {
console.log( "Marker button clicked", id, marker );
} }
marksButtonStatus={ "enabled" }
helpText={ [
"Enter the search term you'd like this post to be found with and see how it would rank. ",
<a key="1" href="https://yoa.st/" target="_blank" rel="noopener">Learn more about the Content Analysis Tool.</a>,
] }
/>
);
}
34 changes: 21 additions & 13 deletions composites/Plugin/ContentAnalysis/components/ContentAnalysis.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
/* External dependencies */
import React from "react";
import styled from "styled-components";
import colors from "../../../../style-guide/colors.json";
import PropTypes from "prop-types";

import { injectIntl, intlShape, defineMessages, FormattedMessage } from "react-intl";

/* Internal dependencies */
import colors from "../../../../style-guide/colors.json";
import { makeOutboundLink } from "../../../../utils/makeOutboundLink";
import AnalysisResult from "../components/AnalysisResult.js";
import AnalysisCollapsible from "../components/AnalysisCollapsible.js";
import HelpText, { HelpTextPropType } from "../../../../composites/Plugin/Shared/components/HelpText";

export const ContentAnalysisContainer = styled.div`
width: 100%;
Expand Down Expand Up @@ -205,21 +208,25 @@ class ContentAnalysis extends React.Component {
* @returns {ReactElement} The rendered ContentAnalysis component.
*/
render() {
let problemsResults = this.props.problemsResults;
let improvementsResults = this.props.improvementsResults;
let goodResults = this.props.goodResults;
let considerationsResults = this.props.considerationsResults;
let errorsResults = this.props.errorsResults;
let headingLevel = this.props.headingLevel;
let errorsFound = errorsResults.length;
let problemsFound = problemsResults.length;
let improvementsFound = improvementsResults.length;
let considerationsFound = considerationsResults.length;
let goodResultsFound = goodResults.length;
const {
problemsResults,
improvementsResults,
goodResults,
considerationsResults,
errorsResults,
headingLevel,
helpText,
} = this.props;
const errorsFound = errorsResults.length;
const problemsFound = problemsResults.length;
const improvementsFound = improvementsResults.length;
const considerationsFound = considerationsResults.length;
const goodResultsFound = goodResults.length;

// Analysis collapsibles are only rendered when there is at least one analysis result for that category present.
return (
<ContentAnalysisContainer>
{ helpText && <HelpText text={ helpText } /> }
{ this.renderLanguageNotice() }
{ errorsFound > 0 &&
<AnalysisCollapsible
Expand Down Expand Up @@ -276,6 +283,7 @@ ContentAnalysis.propTypes = {
marksButtonStatus: PropTypes.string,
marksButtonClassName: PropTypes.string,
intl: intlShape.isRequired,
helpText: HelpTextPropType,
};

ContentAnalysis.defaultProps = {
Expand Down
Loading