Skip to content
Open
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
3 changes: 3 additions & 0 deletions composites/Plugin/SnippetEditor/components/SnippetEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ class SnippetEditor extends React.Component {
data,
titleLengthProgress,
descriptionLengthProgress,
replacementVariablesExplanation,
} = this.props;
const replacementVariables = this.decodeSeparatorVariable( this.props.replacementVariables );
const { activeField, hoveredField, isOpen } = this.state;
Expand All @@ -130,6 +131,7 @@ class SnippetEditor extends React.Component {
onChange={ this.handleChange }
onFocus={ this.setFieldFocus }
replacementVariables={ replacementVariables }
replacementVariablesExplanation={ replacementVariablesExplanation }
titleLengthProgress={ titleLengthProgress }
descriptionLengthProgress={ descriptionLengthProgress }
/>
Expand Down Expand Up @@ -404,6 +406,7 @@ SnippetEditor.propTypes = {
mapDataToPreview: PropTypes.func,
keyword: PropTypes.string,
locale: PropTypes.string,
replacementVariablesExplanation: PropTypes.string,
};

SnippetEditor.defaultProps = {
Expand Down
14 changes: 12 additions & 2 deletions composites/Plugin/SnippetEditor/components/SnippetEditorFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ const InputContainerDescription = InputContainer.extend`
`;

const FormSection = styled.div`
margin: 32px 0;
margin: 32px 0 0;
`;

const StyledEditor = styled.section`
padding: 10px 20px 20px 20px;
padding: 10px 20px 0 20px;
`;

const SimulatedLabel = styled.div`
Expand All @@ -107,6 +107,11 @@ const SimulatedLabel = styled.div`
font-family: Arial, Roboto-Regular, HelveticaNeue, sans-serif;
`;

const ReplacementVariableExplanation = styled.p`
margin: 16px 0;
font-size: 13px;
`;

class SnippetEditorFields extends React.Component {
/**
* Constructs the snippet editor fields.
Expand Down Expand Up @@ -208,6 +213,7 @@ class SnippetEditorFields extends React.Component {
activeField,
hoveredField,
replacementVariables,
replacementVariablesExplanation,
titleLengthProgress,
descriptionLengthProgress,
onFocus,
Expand Down Expand Up @@ -293,6 +299,7 @@ class SnippetEditorFields extends React.Component {
value={ descriptionLengthProgress.actual }
progressColor={ this.getProgressColor( descriptionLengthProgress.score ) }
/>
<ReplacementVariableExplanation>{ replacementVariablesExplanation }</ReplacementVariableExplanation>
</FormSection>
</StyledEditor>
);
Expand Down Expand Up @@ -331,6 +338,7 @@ SnippetEditorFields.propTypes = {
hoveredField: PropTypes.oneOf( [ "title", "slug", "description" ] ),
titleLengthProgress: lengthProgressShape,
descriptionLengthProgress: lengthProgressShape,
replacementVariablesExplanation: PropTypes.string,
};

SnippetEditorFields.defaultProps = {
Expand All @@ -346,6 +354,8 @@ SnippetEditorFields.defaultProps = {
actual: 0,
score: 0,
},
replacementVariablesExplanation: __( "Type '%' to add snippet variables. " +
"See the 'Help' tab on this page to see all available variables.", "yoast-components" ),
};

export default SnippetEditorFields;
Loading