diff --git a/packages/analysis-report/src/AnalysisList.js b/packages/analysis-report/src/AnalysisList.js index 5270756dabf..c407f5f25a9 100644 --- a/packages/analysis-report/src/AnalysisList.js +++ b/packages/analysis-report/src/AnalysisList.js @@ -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 } @@ -109,6 +110,7 @@ export default function AnalysisList( props ) { onResultChange={ props.onResultChange } markButtonFactory={ props.markButtonFactory } shouldUpsellHighlighting={ props.shouldUpsellHighlighting } + renderAIFixesButton={ props.renderAIFixesButton } renderHighlightingUpsell={ props.renderHighlightingUpsell } />; } ) } @@ -128,6 +130,7 @@ AnalysisList.propTypes = { onResultChange: PropTypes.func, shouldUpsellHighlighting: PropTypes.bool, renderHighlightingUpsell: PropTypes.func, + renderAIFixesButton: PropTypes.func, }; AnalysisList.defaultProps = { @@ -141,4 +144,5 @@ AnalysisList.defaultProps = { onResultChange: noop, shouldUpsellHighlighting: false, renderHighlightingUpsell: noop, + renderAIFixesButton: noop, }; diff --git a/packages/analysis-report/src/AnalysisResult.js b/packages/analysis-report/src/AnalysisResult.js index 060f62b1940..2fae915ccdc 100644 --- a/packages/analysis-report/src/AnalysisResult.js +++ b/packages/analysis-report/src/AnalysisResult.js @@ -3,7 +3,6 @@ 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"; @@ -11,9 +10,18 @@ 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; @@ -125,18 +133,21 @@ const AnalysisResult = ( { markButtonFactory, ...props } ) => { { props.hasBetaBadgeLabel && } - { marksButton } - { props.renderHighlightingUpsell( isOpen, closeModal ) } - { - props.hasEditButton && props.isPremium && - - } + + { marksButton } + { props.renderHighlightingUpsell( isOpen, closeModal ) } + { + props.hasEditButton && props.isPremium && + + } + { props.renderAIFixesButton( props.hasAIFixes, props.id ) } + ); }; @@ -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, @@ -168,6 +181,7 @@ AnalysisResult.propTypes = { ] ), shouldUpsellHighlighting: PropTypes.bool, renderHighlightingUpsell: PropTypes.func, + renderAIFixesButton: PropTypes.func, }; AnalysisResult.defaultProps = { @@ -177,6 +191,7 @@ AnalysisResult.defaultProps = { editButtonClassName: "", hasBetaBadgeLabel: false, hasEditButton: false, + hasAIFixes: false, buttonIdEdit: "", ariaLabelEdit: "", onButtonClickEdit: noop, @@ -186,6 +201,7 @@ AnalysisResult.defaultProps = { marker: noop, shouldUpsellHighlighting: false, renderHighlightingUpsell: noop, + renderAIFixesButton: noop, }; export default AnalysisResult; diff --git a/packages/analysis-report/src/ContentAnalysis.js b/packages/analysis-report/src/ContentAnalysis.js index f21ee54e80e..29206cfda62 100644 --- a/packages/analysis-report/src/ContentAnalysis.js +++ b/packages/analysis-report/src/ContentAnalysis.js @@ -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. } `; @@ -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. @@ -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 } @@ -156,6 +154,7 @@ ContentAnalysis.propTypes = { onResultChange: PropTypes.func, shouldUpsellHighlighting: PropTypes.bool, renderHighlightingUpsell: PropTypes.func, + renderAIFixesButton: PropTypes.func, }; ContentAnalysis.defaultProps = { @@ -178,6 +177,7 @@ ContentAnalysis.defaultProps = { onResultChange: () => {}, shouldUpsellHighlighting: false, renderHighlightingUpsell: () => {}, + renderAIFixesButton: () => {}, }; export default ContentAnalysis; diff --git a/packages/analysis-report/tests/__snapshots__/AnalysisResultTest.js.snap b/packages/analysis-report/tests/__snapshots__/AnalysisResultTest.js.snap index f9fa3b24728..6d615cd7f9f 100644 --- a/packages/analysis-report/tests/__snapshots__/AnalysisResultTest.js.snap +++ b/packages/analysis-report/tests/__snapshots__/AnalysisResultTest.js.snap @@ -9,7 +9,7 @@ exports[`the AnalysisResult component matches the snapshot 1`] = ` flex: none; } -.c5 { +.c6 { width: 18px; height: 18px; -webkit-flex: none; @@ -17,7 +17,7 @@ exports[`the AnalysisResult component matches the snapshot 1`] = ` flex: none; } -.c4 { +.c5 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -38,22 +38,30 @@ exports[`the AnalysisResult component matches the snapshot 1`] = ` border-radius: 3px; cursor: pointer; padding: 0; - height: 23px; + height: 24px; } -.c4:hover { +.c5:hover { border-color: #fff; } -.c4:disabled { +.c5:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c4 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c0 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -106,30 +114,34 @@ exports[`the AnalysisResult component matches the snapshot 1`] = ` } />

- + + + + + `; @@ -142,7 +154,7 @@ exports[`the AnalysisResult component with a activated premium matches the snaps flex: none; } -.c5 { +.c6 { width: 18px; height: 18px; -webkit-flex: none; @@ -150,25 +162,44 @@ exports[`the AnalysisResult component with a activated premium matches the snaps flex: none; } -.c4 { +.c5 { + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; box-sizing: border-box; min-width: 32px; - display: inline-block; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; border: 1px solid #ccc; background-color: #f7f7f7; box-shadow: #ccc; border-radius: 3px; cursor: pointer; padding: 0; - height: "24px"; + height: 24px; } -.c4:hover { +.c5:hover { border-color: #fff; } +.c4 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c0 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -226,28 +257,32 @@ exports[`the AnalysisResult component with a activated premium matches the snaps } />

- + + + + + `; @@ -260,8 +295,16 @@ exports[`the AnalysisResult component with a beta badge label matches the snapsh flex: none; } +.c4 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c0 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -319,6 +362,9 @@ exports[`the AnalysisResult component with a beta badge label matches the snapsh } />

+
`; @@ -331,7 +377,7 @@ exports[`the AnalysisResult component with disabled buttons matches the snapshot flex: none; } -.c5 { +.c6 { width: 18px; height: 18px; -webkit-flex: none; @@ -339,7 +385,7 @@ exports[`the AnalysisResult component with disabled buttons matches the snapshot flex: none; } -.c4 { +.c5 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -360,22 +406,30 @@ exports[`the AnalysisResult component with disabled buttons matches the snapshot border-radius: 3px; cursor: pointer; padding: 0; - height: 23px; + height: 24px; } -.c4:hover { +.c5:hover { border-color: #fff; } -.c4:disabled { +.c5:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c4 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c0 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -428,30 +482,34 @@ exports[`the AnalysisResult component with disabled buttons matches the snapshot } />

- + + + + +
`; @@ -464,8 +522,16 @@ exports[`the AnalysisResult component with hidden buttons matches the snapshot 1 flex: none; } +.c4 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c0 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -518,6 +584,9 @@ exports[`the AnalysisResult component with hidden buttons matches the snapshot 1 } />

+
`; @@ -530,7 +599,7 @@ exports[`the AnalysisResult component with html in the text matches the snapshot flex: none; } -.c5 { +.c6 { width: 18px; height: 18px; -webkit-flex: none; @@ -538,7 +607,7 @@ exports[`the AnalysisResult component with html in the text matches the snapshot flex: none; } -.c4 { +.c5 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -559,22 +628,30 @@ exports[`the AnalysisResult component with html in the text matches the snapshot border-radius: 3px; cursor: pointer; padding: 0; - height: 23px; + height: 24px; } -.c4:hover { +.c5:hover { border-color: #fff; } -.c4:disabled { +.c5:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c4 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c0 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -627,30 +704,34 @@ exports[`the AnalysisResult component with html in the text matches the snapshot } />

- + + + + +
`; @@ -663,8 +744,16 @@ exports[`the AnalysisResult component with suppressed text matches the snapshot flex: none; } +.c4 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c0 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -717,5 +806,8 @@ exports[`the AnalysisResult component with suppressed text matches the snapshot } />

+
`; diff --git a/packages/analysis-report/tests/__snapshots__/ContentAnalysisTest.js.snap b/packages/analysis-report/tests/__snapshots__/ContentAnalysisTest.js.snap index d60aae3478f..30a93f17d8b 100644 --- a/packages/analysis-report/tests/__snapshots__/ContentAnalysisTest.js.snap +++ b/packages/analysis-report/tests/__snapshots__/ContentAnalysisTest.js.snap @@ -139,7 +139,7 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego margin-left: 8px; } -.c21 { +.c22 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -163,19 +163,27 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego height: 24px; } -.c21:hover { +.c22:hover { border-color: #fff; } -.c21:disabled { +.c22:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -216,13 +224,10 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -238,7 +243,7 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -246,12 +251,12 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c22 { +.c23 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -259,12 +264,12 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego color: #1e1e1e !important; } -.c22 .c13 { +.c23 .c13 { font-weight: 500; color: #1e1e1e; } -.c23 { +.c24 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -272,12 +277,12 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego color: #1e1e1e !important; } -.c23 .c13 { +.c24 .c13 { font-weight: 500; color: #1e1e1e; } -.c24 { +.c25 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -285,7 +290,7 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego color: #1e1e1e !important; } -.c24 .c13 { +.c25 .c13 { font-weight: 500; color: #1e1e1e; } @@ -371,6 +376,9 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego } />

+
@@ -378,7 +386,7 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego className="c1 c2" >

+ + + + +

@@ -475,7 +487,7 @@ exports[`ContentAnalysis the ContentAnalysis component with custom result catego className="c1 c2" >

+ + + + + @@ -885,7 +910,7 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat margin-left: 8px; } -.c21 { +.c22 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -909,19 +934,27 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat height: 24px; } -.c21:hover { +.c22:hover { border-color: #fff; } -.c21:disabled { +.c22:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -962,13 +995,10 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -984,7 +1014,7 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -992,12 +1022,12 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c22 { +.c23 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -1005,12 +1035,12 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat color: #1e1e1e !important; } -.c22 .c13 { +.c23 .c13 { font-weight: 500; color: #1e1e1e; } -.c23 { +.c24 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -1018,12 +1048,12 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat color: #1e1e1e !important; } -.c23 .c13 { +.c24 .c13 { font-weight: 500; color: #1e1e1e; } -.c24 { +.c25 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -1031,7 +1061,7 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat color: #1e1e1e !important; } -.c24 .c13 { +.c25 .c13 { font-weight: 500; color: #1e1e1e; } @@ -1117,6 +1147,9 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat } />

+
@@ -1124,7 +1157,7 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat className="c1 c2" >

+ + + + + @@ -1221,7 +1258,7 @@ exports[`ContentAnalysis the ContentAnalysis component with disabled buttons mat className="c1 c2" >

+ + + + + @@ -1631,8 +1681,16 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match margin-left: 8px; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -1673,13 +1731,10 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -1695,7 +1750,7 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -1703,12 +1758,12 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c21 { +.c22 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -1716,12 +1771,12 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match color: #1e1e1e !important; } -.c21 .c13 { +.c22 .c13 { font-weight: 500; color: #1e1e1e; } -.c22 { +.c23 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -1729,12 +1784,12 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match color: #1e1e1e !important; } -.c22 .c13 { +.c23 .c13 { font-weight: 500; color: #1e1e1e; } -.c23 { +.c24 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -1742,7 +1797,7 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match color: #1e1e1e !important; } -.c23 .c13 { +.c24 .c13 { font-weight: 500; color: #1e1e1e; } @@ -1828,6 +1883,9 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match } />

+
@@ -1835,7 +1893,7 @@ exports[`ContentAnalysis the ContentAnalysis component with hidden buttons match className="c1 c2" >

+ + + + + @@ -2630,7 +2715,7 @@ exports[`ContentAnalysis the ContentAnalysis component with specified header lev className="c1 c2" >

+ + + + + @@ -3040,7 +3138,7 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match margin-left: 8px; } -.c22 { +.c23 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -3064,19 +3162,27 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match height: 24px; } -.c22:hover { +.c23:hover { border-color: #fff; } -.c22:disabled { +.c23:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -3101,7 +3207,7 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match color: inherit; } -.c21 { +.c22 { margin: 0 16px 0 0; -webkit-flex: 1 1 auto; -ms-flex: 1 1 auto; @@ -3125,13 +3231,10 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -3147,7 +3250,7 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3155,12 +3258,12 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c23 { +.c24 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3168,12 +3271,12 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match color: #1e1e1e !important; } -.c23 .c13 { +.c24 .c13 { font-weight: 500; color: #1e1e1e; } -.c24 { +.c25 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3181,12 +3284,12 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match color: #1e1e1e !important; } -.c24 .c13 { +.c25 .c13 { font-weight: 500; color: #1e1e1e; } -.c25 { +.c26 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3194,7 +3297,7 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match color: #1e1e1e !important; } -.c25 .c13 { +.c26 .c13 { font-weight: 500; color: #1e1e1e; } @@ -3280,6 +3383,9 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match } />

+
@@ -3287,7 +3393,7 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match className="c1 c2" >

+ + + + + @@ -3413,7 +3526,7 @@ exports[`ContentAnalysis the ContentAnalysis component with upsell results match className="c1 c2" >

+ + + + + @@ -3823,7 +3949,7 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m margin-left: 8px; } -.c21 { +.c22 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -3847,19 +3973,27 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m height: 24px; } -.c21:hover { +.c22:hover { border-color: #fff; } -.c21:disabled { +.c22:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -3900,13 +4034,10 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -3922,7 +4053,7 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3930,12 +4061,12 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c22 { +.c23 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3943,12 +4074,12 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m color: #1e1e1e !important; } -.c22 .c13 { +.c23 .c13 { font-weight: 500; color: #1e1e1e; } -.c23 { +.c24 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3956,12 +4087,12 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m color: #1e1e1e !important; } -.c23 .c13 { +.c24 .c13 { font-weight: 500; color: #1e1e1e; } -.c24 { +.c25 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -3969,7 +4100,7 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m color: #1e1e1e !important; } -.c24 .c13 { +.c25 .c13 { font-weight: 500; color: #1e1e1e; } @@ -4055,6 +4186,9 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m } />

+
@@ -4062,7 +4196,7 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m className="c1 c2" >

+ + + + + @@ -4159,7 +4297,7 @@ exports[`ContentAnalysis the ContentAnalysis component without language notice m className="c1 c2" >

+ + + + + @@ -4569,7 +4720,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons margin-left: 8px; } -.c22 { +.c23 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -4593,19 +4744,27 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons height: 24px; } -.c22:hover { +.c23:hover { border-color: #fff; } -.c22:disabled { +.c23:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -4646,13 +4805,10 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -4668,7 +4824,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -4676,12 +4832,12 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c21 { +.c22 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -4689,7 +4845,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons color: #1e1e1e !important; } -.c21 .c13 { +.c22 .c13 { font-weight: 500; color: #1e1e1e; } @@ -4775,6 +4931,9 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons } />

+
@@ -4782,7 +4941,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and cons className="c1 c2" >

+ + + + + @@ -5119,7 +5288,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr margin-left: 8px; } -.c22 { +.c23 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -5143,19 +5312,27 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr height: 24px; } -.c22:hover { +.c23:hover { border-color: #fff; } -.c22:disabled { +.c23:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -5196,13 +5373,10 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -5218,7 +5392,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -5226,12 +5400,12 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c21 { +.c22 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -5239,7 +5413,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr color: #1e1e1e !important; } -.c21 .c13 { +.c22 .c13 { font-weight: 500; color: #1e1e1e; } @@ -5325,6 +5499,9 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr } />

+
@@ -5332,7 +5509,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems and impr className="c1 c2" >

+ + + + + @@ -5669,7 +5856,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches margin-left: 8px; } -.c23 { +.c24 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -5693,19 +5880,27 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches height: 24px; } -.c23:hover { +.c24:hover { border-color: #fff; } -.c23:disabled { +.c24:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -5746,13 +5941,10 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -5768,7 +5960,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -5776,12 +5968,12 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } -.c21 { +.c22 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -5789,12 +5981,12 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches color: #1e1e1e !important; } -.c21 .c13 { +.c22 .c13 { font-weight: 500; color: #1e1e1e; } -.c22 { +.c23 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -5802,7 +5994,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches color: #1e1e1e !important; } -.c22 .c13 { +.c23 .c13 { font-weight: 500; color: #1e1e1e; } @@ -5888,6 +6080,9 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches } />

+
@@ -5895,7 +6090,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems matches className="c1 c2" >

+ + + + + @@ -6305,7 +6513,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems, improve margin-left: 8px; } -.c21 { +.c22 { -webkit-align-items: center; -webkit-box-align: center; -ms-flex-align: center; @@ -6329,19 +6537,27 @@ exports[`ContentAnalysis the ContentAnalysis component without problems, improve height: 24px; } -.c21:hover { +.c22:hover { border-color: #fff; } -.c21:disabled { +.c22:disabled { background-color: #f7f7f7; box-shadow: none; border: none; cursor: default; } +.c20 { + display: grid; + grid-template-rows: 1fr; + max-width: 32px; + gap: 6px; +} + .c16 { min-height: 24px; + margin-bottom: 12px; padding: 0; display: -webkit-box; display: -webkit-flex; @@ -6382,13 +6598,10 @@ exports[`ContentAnalysis the ContentAnalysis component without problems, improve margin-bottom: 8px; } -.c2 button:first-child svg { - margin: -2px 8px 0 -2px; -} - .c2 .c9 { padding: 8px 0; color: #0066cd; + margin: -2px 8px 0 -2px; } .c3 { @@ -6404,7 +6617,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems, improve color: #1e1e1e; } -.c20 { +.c21 { margin: 0 !important; padding: 0 !important; font-size: 13px !important; @@ -6412,7 +6625,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems, improve color: #1e1e1e !important; } -.c20 .c13 { +.c21 .c13 { font-weight: 500; color: #1e1e1e; } @@ -6498,6 +6711,9 @@ exports[`ContentAnalysis the ContentAnalysis component without problems, improve } />

+
@@ -6505,7 +6721,7 @@ exports[`ContentAnalysis the ContentAnalysis component without problems, improve className="c1 c2" >

+ + + + + diff --git a/packages/components/src/IconAIFixesButton.js b/packages/components/src/IconAIFixesButton.js new file mode 100644 index 00000000000..eaaeb65fe44 --- /dev/null +++ b/packages/components/src/IconAIFixesButton.js @@ -0,0 +1,67 @@ +import React from "react"; +import PropTypes from "prop-types"; + +/* Yoast dependencies */ +import { colors } from "@yoast/style-guide"; + +/* Internal dependencies */ +import IconButtonBase from "./IconButtonBase"; + +/** + * Returns the IconAIFixesButton component. + * + * @param {Object} props Component props. + * + * @returns {JSX.Element} IconAIFixesButton component. + */ +const IconAIFixesButton = function( props ) { + return ( + + { props.children } + + ); +}; + +IconAIFixesButton.propTypes = { + children: PropTypes.node, + id: PropTypes.string.isRequired, + ariaLabel: PropTypes.string.isRequired, + onClick: PropTypes.func, + unpressedBoxShadowColor: PropTypes.string, + pressedBoxShadowColor: PropTypes.string, + pressedBackground: PropTypes.string, + unpressedBackground: PropTypes.string, + pressedIconColor: PropTypes.string, + unpressedIconColor: PropTypes.string, + pressed: PropTypes.bool.isRequired, + hoverBorderColor: PropTypes.string, + className: PropTypes.string, +}; + +IconAIFixesButton.defaultProps = { + unpressedBoxShadowColor: colors.$color_button_border, + pressedBoxShadowColor: colors.$color_purple, + pressedBackground: colors.$color_pink_dark, + unpressedBackground: colors.$color_button, + pressedIconColor: colors.$color_white, + unpressedIconColor: colors.$color_button_text, + hoverBorderColor: colors.$color_white, +}; + +export default IconAIFixesButton; diff --git a/packages/components/src/IconButtonBase.js b/packages/components/src/IconButtonBase.js new file mode 100644 index 00000000000..340e495aacd --- /dev/null +++ b/packages/components/src/IconButtonBase.js @@ -0,0 +1,31 @@ +import styled from "styled-components"; +import { colors, rgba } from "@yoast/style-guide"; + +const IconButtonBase = styled.button` + align-items: center; + justify-content: center; + box-sizing: border-box; + min-width: 32px; + display: inline-flex; + border: 1px solid ${ colors.$color_button_border }; + background-color: ${ props => props.pressed ? props.pressedBackground : props.unpressedBackground }; + box-shadow: ${ props => props.pressed + ? `inset 0 2px 0 ${ rgba( props.pressedBoxShadowColor, 0.7 ) }` + : `0 1px 0 ${ rgba( props.unpressedBoxShadowColor, 0.7 ) }` }; + border-radius: 3px; + cursor: pointer; + padding: 0; + height: 24px; + + &:hover { + border-color: ${ props => props.hoverBorderColor }; + } + &:disabled { + background-color: ${ props => props.unpressedBackground }; + box-shadow: none; + border: none; + cursor: default; + } +`; + +export default IconButtonBase; diff --git a/packages/components/src/IconButtonToggle.js b/packages/components/src/IconButtonToggle.js index bc6bf13fbe8..ce42c3b5d39 100644 --- a/packages/components/src/IconButtonToggle.js +++ b/packages/components/src/IconButtonToggle.js @@ -1,39 +1,11 @@ import React from "react"; -import styled from "styled-components"; import PropTypes from "prop-types"; - /* Yoast dependencies */ -import { colors, rgba } from "@yoast/style-guide"; - +import { colors } from "@yoast/style-guide"; /* Internal dependencies */ import SvgIcon from "./SvgIcon"; +import IconButtonBase from "./IconButtonBase"; -const IconButtonBase = styled.button` - align-items: center; - justify-content: center; - box-sizing: border-box; - min-width: 32px; - display: inline-flex; - border: 1px solid ${ colors.$color_button_border }; - background-color: ${ props => props.pressed ? props.pressedBackground : props.unpressedBackground }; - box-shadow: ${ props => props.pressed - ? `inset 0 2px 0 ${ rgba( props.pressedBoxShadowColor, 0.7 ) }` - : `0 1px 0 ${ rgba( props.unpressedBoxShadowColor, 0.7 ) }` }; - border-radius: 3px; - cursor: pointer; - padding: 0; - height: ${ props => props.pressed ? "23px" : "24px" }; - - &:hover { - border-color: ${ props => props.hoverBorderColor }; - } - &:disabled { - background-color: ${ props => props.unpressedBackground }; - box-shadow: none; - border: none; - cursor: default; - } -`; /** * Returns the ChangingIconButton component. diff --git a/packages/components/src/IconCTAEditButton.js b/packages/components/src/IconCTAEditButton.js index c591ce70ab1..cdb04292651 100644 --- a/packages/components/src/IconCTAEditButton.js +++ b/packages/components/src/IconCTAEditButton.js @@ -9,16 +9,18 @@ import { colors } from "@yoast/style-guide"; import SvgIcon from "./SvgIcon"; const IconButtonBase = styled.button` + align-items: center; + justify-content: center; box-sizing: border-box; min-width: 32px; - display: inline-block; + display: inline-flex; border: 1px solid ${ colors.$color_button_border }; background-color: ${ props => props.background }; box-shadow: ${ props => props.boxShadowColor }; border-radius: 3px; cursor: pointer; padding: 0; - height: "24px"; + height: 24px; &:hover { border-color: ${ props => props.hoverBorderColor }; } diff --git a/packages/components/src/index.js b/packages/components/src/index.js index c9538b44998..b15c4e05387 100644 --- a/packages/components/src/index.js +++ b/packages/components/src/index.js @@ -49,6 +49,7 @@ export { wrapInHeading, } from "./Collapsible"; +export { default as IconAIFixesButton } from "./IconAIFixesButton"; export { default as Alert } from "./Alert"; export { default as ArticleList } from "./ArticleList"; export { default as Card, FullHeightCard } from "./Card"; @@ -61,6 +62,7 @@ export { default as ErrorBoundary } from "./ErrorBoundary"; export { default as Heading } from "./Heading"; export { default as HelpText } from "./HelpText"; export { default as Icon } from "./Icon"; +export { default as IconButtonBase } from "./IconButtonBase"; export { default as IconButtonToggle } from "./IconButtonToggle.js"; export { default as IconCTAEditButton } from "./IconCTAEditButton.js"; export { default as IFrame } from "./IFrame"; diff --git a/packages/components/tests/IconAIFixesButtonTest.js b/packages/components/tests/IconAIFixesButtonTest.js new file mode 100644 index 00000000000..83d9b0bee13 --- /dev/null +++ b/packages/components/tests/IconAIFixesButtonTest.js @@ -0,0 +1,37 @@ +import React from "react"; +import renderer from "react-test-renderer"; + +import IconAIFixesButton from "../src/IconAIFixesButton"; + +test( "the unpressed IconAIFixesButton matches the snapshot", () => { + const component = renderer.create( + {} } + className={ "yoast-tooltip yoast-tooltip-w" } + /> + ); + + const tree = component.toJSON(); + expect( tree ).toMatchSnapshot(); +} ); + +test( "the pressed IconAIFixesButton matches the snapshot", () => { + const component = renderer.create( + {} } + className={ "yoast-tooltip yoast-tooltip-w" } + /> + ); + + const tree = component.toJSON(); + expect( tree ).toMatchSnapshot(); +} ); + diff --git a/packages/components/tests/__snapshots__/IconAIFixesButtonTest.js.snap b/packages/components/tests/__snapshots__/IconAIFixesButtonTest.js.snap new file mode 100644 index 00000000000..a109f990813 --- /dev/null +++ b/packages/components/tests/__snapshots__/IconAIFixesButtonTest.js.snap @@ -0,0 +1,95 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`the pressed IconAIFixesButton matches the snapshot 1`] = ` +.c0 { + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + -webkit-box-pack: center; + -webkit-justify-content: center; + -ms-flex-pack: center; + justify-content: center; + box-sizing: border-box; + min-width: 32px; + display: -webkit-inline-box; + display: -webkit-inline-flex; + display: -ms-inline-flexbox; + display: inline-flex; + border: 1px solid #ccc; + background-color: #a4286a; + box-shadow: inset 0 2px 0 rgba( 93,35,122,0.7 ); + border-radius: 3px; + cursor: pointer; + padding: 0; + height: 24px; +} + +.c0:hover { + border-color: #fff; +} + +.c0:disabled { + background-color: #f7f7f7; + box-shadow: none; + border: none; + cursor: default; +} + +