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

Implementation ai buttons next to seo keyphrase assessments #21348

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
fb3c95b
Creates a draft AI button
Jordi-PV Apr 26, 2024
f9d98ec
SetHasAIFixes for the relevant assessments
FAMarfuaty Apr 29, 2024
51dfa9a
SetHasAIFixes for the relevant assessments part 2
FAMarfuaty Apr 29, 2024
e36d882
Render the AI button when the conditions are met
FAMarfuaty Apr 29, 2024
73da739
Removes AI button className props
Jordi-PV Apr 29, 2024
8a027da
Refactors the AI Button component
Jordi-PV Apr 29, 2024
ce6a96c
Adds button functionalities
Jordi-PV Apr 30, 2024
3828705
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into implement…
FAMarfuaty Apr 30, 2024
6fae8be
Places buttons and adds sparkles icon
Jordi-PV Apr 30, 2024
17c273b
Grabs ui-library components with Root component
Jordi-PV May 1, 2024
b43aba6
Separate the Button base and create button for AI fixes
FAMarfuaty May 1, 2024
748e672
Use the yoast components for the AI button
FAMarfuaty May 1, 2024
704bc64
Merge branch 'implementation-ai-buttons-next-to-seo-keyphrase-assessm…
FAMarfuaty May 1, 2024
160c79e
Render sparkles icon
FAMarfuaty May 1, 2024
06a7fcc
Removes ui-library button and tooltip
Jordi-PV May 2, 2024
d931780
Refactors AIFixesButton actions!
Jordi-PV May 2, 2024
38bee54
Move the AI Assessment Fixes button to separate folder
FAMarfuaty May 6, 2024
f0ea4b0
Add the state of the active AI Fixes button to the store
FAMarfuaty May 6, 2024
734cadf
Implement the background color of the AI button when pressed
FAMarfuaty May 6, 2024
b2b09f2
Rename AI button
FAMarfuaty May 6, 2024
771052f
Make the Edit button styling in line with the highlighting and AI button
FAMarfuaty May 6, 2024
b7368e5
Fix typo
FAMarfuaty May 6, 2024
f7bd451
Fix typo
FAMarfuaty May 6, 2024
bb62fed
Move the styling to the button itself
FAMarfuaty May 6, 2024
0ea4d4a
Only handle pressed button state in Premium. The pressed button state…
FAMarfuaty May 7, 2024
51ff8a2
Adjust the grid styling
FAMarfuaty May 7, 2024
fd9260d
Remove unused props
FAMarfuaty May 7, 2024
59e56e6
update tests
FAMarfuaty May 7, 2024
984f600
Move the logic for checking whether an assessment has AI fixes to the…
FAMarfuaty May 7, 2024
37fec24
Add unit tests
FAMarfuaty May 7, 2024
8665d8f
Fix missing semicolon and adjust tests
FAMarfuaty May 7, 2024
8109e6d
Add unit tests
FAMarfuaty May 7, 2024
6dde924
Add unit tests
FAMarfuaty May 7, 2024
abc9a77
Add more space between the assessments
Jordi-PV May 8, 2024
620a5af
Add unit tests
FAMarfuaty May 8, 2024
c682c5e
Merge branch 'feature/fix-assessments' of github.com:Yoast/wordpress-…
FAMarfuaty May 8, 2024
fb99b93
Update snapshots
Jordi-PV May 8, 2024
d06adb6
Add a max-width to the buttons + update snapshot
Jordi-PV May 8, 2024
e63917a
Move the logic to check the editor to inside the button component itself
FAMarfuaty May 8, 2024
9bf0dab
Provide `isPremium` from the higher level component.This makes it so …
FAMarfuaty May 8, 2024
6a9feb7
Merge branch 'implementation-ai-buttons-next-to-seo-keyphrase-assessm…
FAMarfuaty May 8, 2024
d06ec0d
Update tests
FAMarfuaty May 8, 2024
6127607
Only relies on the state of the active AI button from the store to ke…
FAMarfuaty May 8, 2024
dfb131f
Adjust comment
FAMarfuaty May 8, 2024
7c28694
Apply suggestions from code review
FAMarfuaty May 13, 2024
f379882
Adapt code comment
FAMarfuaty May 13, 2024
0118d8d
Make `AIAssessmentFixesButton` depends on less parameters
FAMarfuaty May 13, 2024
ded30ad
Update tests
FAMarfuaty May 13, 2024
390adea
If AI fixes button is active when the Highlighting button is clicked,…
FAMarfuaty May 13, 2024
01ce12f
If highlighting button is active when the AI Fixes button is clicked,…
FAMarfuaty May 13, 2024
7a35604
mock a selector for testing
FAMarfuaty May 13, 2024
dd392ab
Rename a component
FAMarfuaty May 13, 2024
de9e65a
Fix a typo
FAMarfuaty May 13, 2024
57ac159
Merge branch 'feature/fix-assessments' of github.com:Yoast/wordpress-…
FAMarfuaty May 13, 2024
19e0d45
Use the same button height when clicked and not clicked and adjust th…
FAMarfuaty May 13, 2024
06c422b
Adjust the tests
FAMarfuaty May 13, 2024
ede70f0
Fix typos
FAMarfuaty May 14, 2024
4a41337
Make sure that the AI button is not shown in Elementor
FAMarfuaty May 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/analysis-report/src/AnalysisList.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default function AnalysisList( props ) {
bulletColor={ color }
hasMarksButton={ result.hasMarks }
hasEditButton={ result.hasJumps }
hasAIFixes={ result.hasAIFixes }
ariaLabelMarks={ ariaLabelMarks }
ariaLabelEdit={ ariaLabelEdit }
pressed={ isMarkButtonPressed }
Expand All @@ -109,6 +110,7 @@ export default function AnalysisList( props ) {
onResultChange={ props.onResultChange }
markButtonFactory={ props.markButtonFactory }
shouldUpsellHighlighting={ props.shouldUpsellHighlighting }
renderAIFixesButton={ props.renderAIFixesButton }
renderHighlightingUpsell={ props.renderHighlightingUpsell }
/>;
} ) }
Expand All @@ -128,6 +130,7 @@ AnalysisList.propTypes = {
onResultChange: PropTypes.func,
shouldUpsellHighlighting: PropTypes.bool,
renderHighlightingUpsell: PropTypes.func,
renderAIFixesButton: PropTypes.func,
};

AnalysisList.defaultProps = {
Expand All @@ -141,4 +144,5 @@ AnalysisList.defaultProps = {
onResultChange: noop,
shouldUpsellHighlighting: false,
renderHighlightingUpsell: noop,
renderAIFixesButton: noop,
};
42 changes: 29 additions & 13 deletions packages/analysis-report/src/AnalysisResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,25 @@ import React, { useCallback, useEffect, useState } from "react";
import PropTypes from "prop-types";
import styled from "styled-components";
import { noop } from "lodash";

import { SvgIcon, IconButtonToggle, IconCTAEditButton, BetaBadge } from "@yoast/components";
import { strings } from "@yoast/helpers";

const { stripTagsFromHtmlString } = strings;

const ALLOWED_TAGS = [ "a", "b", "strong", "em", "i" ];

const ResultButtonsContainer = styled.div`
display: grid;
grid-template-rows: 1fr;
max-width: 32px;
// This gap value is half the gap value between assessment result list items, which is 12px.
gap: 6px;
`;

const AnalysisResultBase = styled.li`
// This is the height of the IconButtonToggle.
min-height: 24px;
margin-bottom: 12px;
padding: 0;
display: flex;
align-items: flex-start;
Expand Down Expand Up @@ -125,18 +133,21 @@ const AnalysisResult = ( { markButtonFactory, ...props } ) => {
{ props.hasBetaBadgeLabel && <BetaBadge /> }
<span dangerouslySetInnerHTML={ { __html: stripTagsFromHtmlString( props.text, ALLOWED_TAGS ) } } />
</AnalysisResultText>
{ marksButton }
{ props.renderHighlightingUpsell( isOpen, closeModal ) }
{
props.hasEditButton && props.isPremium &&
<IconCTAEditButton
className={ props.editButtonClassName }
onClick={ props.onButtonClickEdit }
id={ props.buttonIdEdit }
icon="edit"
ariaLabel={ props.ariaLabelEdit }
/>
}
<ResultButtonsContainer>
{ marksButton }
{ props.renderHighlightingUpsell( isOpen, closeModal ) }
{
props.hasEditButton && props.isPremium &&
<IconCTAEditButton
className={ props.editButtonClassName }
onClick={ props.onButtonClickEdit }
id={ props.buttonIdEdit }
icon="edit"
ariaLabel={ props.ariaLabelEdit }
/>
}
{ props.renderAIFixesButton( props.hasAIFixes, props.id ) }
</ResultButtonsContainer>
</AnalysisResultBase>
);
};
Expand All @@ -147,6 +158,8 @@ AnalysisResult.propTypes = {
bulletColor: PropTypes.string.isRequired,
hasMarksButton: PropTypes.bool.isRequired,
hasEditButton: PropTypes.bool,
hasAIButton: PropTypes.bool,
hasAIFixes: PropTypes.bool,
buttonIdMarks: PropTypes.string.isRequired,
buttonIdEdit: PropTypes.string,
pressed: PropTypes.bool.isRequired,
Expand All @@ -168,6 +181,7 @@ AnalysisResult.propTypes = {
] ),
shouldUpsellHighlighting: PropTypes.bool,
renderHighlightingUpsell: PropTypes.func,
renderAIFixesButton: PropTypes.func,
};

AnalysisResult.defaultProps = {
Expand All @@ -177,6 +191,7 @@ AnalysisResult.defaultProps = {
editButtonClassName: "",
hasBetaBadgeLabel: false,
hasEditButton: false,
hasAIFixes: false,
buttonIdEdit: "",
ariaLabelEdit: "",
onButtonClickEdit: noop,
Expand All @@ -186,6 +201,7 @@ AnalysisResult.defaultProps = {
marker: noop,
shouldUpsellHighlighting: false,
renderHighlightingUpsell: noop,
renderAIFixesButton: noop,
};

export default AnalysisResult;
12 changes: 6 additions & 6 deletions packages/analysis-report/src/ContentAnalysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@ const ContentAnalysisContainer = styled.div`
const StyledCollapsible = styled( Collapsible )`
margin-bottom: 8px;

button:first-child svg {
margin: -2px 8px 0 -2px; // Compensate icon size set to 18px.
}

${ StyledIconsButton } {
padding: 8px 0;
color: ${ colors.$color_blue }
color: ${ colors.$color_blue };
margin: -2px 8px 0 -2px; // Compensate icon size set to 18px.
}
`;

Expand All @@ -37,7 +34,7 @@ const StyledCollapsible = styled( Collapsible )`
*/
class ContentAnalysis extends React.Component {
/**
* Renders a Collapsible component with a liset of Analysis results.
* Renders a Collapsible component with a list of Analysis results.
*
* @param {string} title The title of the collapsible section.
* @param {number} headingLevel Heading level: 1 for h1, 2 for h2, etc.
Expand Down Expand Up @@ -65,6 +62,7 @@ class ContentAnalysis extends React.Component {
markButtonFactory={ this.props.markButtonFactory }
onMarksButtonClick={ this.props.onMarkButtonClick }
onEditButtonClick={ this.props.onEditButtonClick }
renderAIFixesButton={ this.props.renderAIFixesButton }
isPremium={ this.props.isPremium }
onResultChange={ this.props.onResultChange }
shouldUpsellHighlighting={ this.props.shouldUpsellHighlighting }
Expand Down Expand Up @@ -156,6 +154,7 @@ ContentAnalysis.propTypes = {
onResultChange: PropTypes.func,
shouldUpsellHighlighting: PropTypes.bool,
renderHighlightingUpsell: PropTypes.func,
renderAIFixesButton: PropTypes.func,
};

ContentAnalysis.defaultProps = {
Expand All @@ -178,6 +177,7 @@ ContentAnalysis.defaultProps = {
onResultChange: () => {},
shouldUpsellHighlighting: false,
renderHighlightingUpsell: () => {},
renderAIFixesButton: () => {},
};

export default ContentAnalysis;