Skip to content
This repository was archived by the owner on Oct 4, 2022. It is now read-only.

Commit 7c7d0fd

Browse files
authored
Merge pull request #1114 from Yoast/P3-418-snippet-editor-fields
Allow custom labels to be used in the replacement variable editor
2 parents 10a27ee + ff50174 commit 7c7d0fd

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

packages/replacement-variable-editor/src/SettingsSnippetEditor.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class SettingsSnippetEditor extends React.Component {
122122
descriptionEditorFieldPlaceholder,
123123
hasPaperStyle,
124124
fieldIds,
125+
labels,
125126
} = this.props;
126127

127128
const { activeField, hoveredField } = this.state;
@@ -140,6 +141,7 @@ class SettingsSnippetEditor extends React.Component {
140141
recommendedReplacementVariables={ recommendedReplacementVariables }
141142
containerPadding={ hasPaperStyle ? "0 20px" : "0" }
142143
fieldIds={ fieldIds }
144+
labels={ labels }
143145
/>
144146
</ErrorBoundary>
145147
);
@@ -160,13 +162,18 @@ SettingsSnippetEditor.propTypes = {
160162
title: PropTypes.string.isRequired,
161163
description: PropTypes.string.isRequired,
162164
} ).isRequired,
165+
labels: PropTypes.shape( {
166+
title: PropTypes.string,
167+
description: PropTypes.string,
168+
} ),
163169
};
164170

165171
SettingsSnippetEditor.defaultProps = {
166172
replacementVariables: [],
167173
recommendedReplacementVariables: [],
168174
hasPaperStyle: true,
169-
descriptionEditorFieldPlaceholder: "",
175+
descriptionEditorFieldPlaceholder: null,
176+
labels: {},
170177
};
171178

172179
export default SettingsSnippetEditor;

packages/replacement-variable-editor/src/SettingsSnippetEditorFields.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class SettingsSnippetEditorFields extends React.Component {
124124
},
125125
containerPadding,
126126
fieldIds,
127+
labels,
127128
} = this.props;
128129

129130
return (
@@ -132,7 +133,7 @@ class SettingsSnippetEditorFields extends React.Component {
132133
>
133134
<ReplacementVariableEditor
134135
type="title"
135-
label={ __( "SEO title", "yoast-components" ) }
136+
label={ labels.title || __( "SEO title", "yoast-components" ) }
136137
onFocus={ () => onFocus( "title" ) }
137138
onBlur={ onBlur }
138139
isActive={ activeField === "title" }
@@ -147,7 +148,7 @@ class SettingsSnippetEditorFields extends React.Component {
147148
<ReplacementVariableEditor
148149
type="description"
149150
placeholder={ descriptionEditorFieldPlaceholder }
150-
label={ __( "Meta description", "yoast-components" ) }
151+
label={ labels.description || __( "Meta description", "yoast-components" ) }
151152
onFocus={ () => onFocus( "description" ) }
152153
onBlur={ onBlur }
153154
isActive={ activeField === "description" }
@@ -182,13 +183,19 @@ SettingsSnippetEditorFields.propTypes = {
182183
title: PropTypes.string.isRequired,
183184
description: PropTypes.string.isRequired,
184185
} ).isRequired,
186+
labels: PropTypes.shape( {
187+
title: PropTypes.string,
188+
description: PropTypes.string,
189+
} ),
185190
};
186191

187192
SettingsSnippetEditorFields.defaultProps = {
188193
replacementVariables: [],
189194
onFocus: () => {},
190195
onBlur: () => {},
191196
containerPadding: "0 20px",
197+
descriptionEditorFieldPlaceholder: null,
198+
labels: {},
192199
};
193200

194201
export default SettingsSnippetEditorFields;

0 commit comments

Comments
 (0)