Skip to content

Commit b6e07de

Browse files
committed
[B] Ensure preview attrs are shown for feature
1 parent 9dbb023 commit b6e07de

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

client/src/backend/containers/features/Detail.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,8 @@ class FeatureDetailContainer extends PureComponent {
113113
previewableFeature(props) {
114114
const { session } = props;
115115
if (!session) return null;
116-
const { source, dirty } = session;
117-
const previewAttributes = {
118-
...source.attributes,
119-
...dirty.attributes
120-
};
121-
const preview = { ...source, attributes: previewAttributes };
122-
return preview;
116+
const { dirty } = session;
117+
return dirty.attributes;
123118
}
124119

125120
isNew(props) {
@@ -214,7 +209,11 @@ class FeatureDetailContainer extends PureComponent {
214209
label={t("records.features.preview.section_title")}
215210
instructions={t("records.features.preview.instructions")}
216211
>
217-
<FrontendLayout.Splash feature={previewFeature} preview />
212+
<FrontendLayout.Splash
213+
feature={feature}
214+
preview
215+
previewAttrs={previewFeature}
216+
/>
218217
</Form.FieldGroup>
219218
) : null}
220219
{this.renderRoutes()}

client/src/backend/containers/features/Properties.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,20 +88,20 @@ class FeaturesPropertiesContainer extends PureComponent {
8888
}
8989
]}
9090
/>
91-
<Form.TextInput
91+
<Form.ColorInput
9292
label={t("records.features.background_label")}
9393
name="attributes[backgroundColor]"
94-
placeholder="#000000"
94+
defaultValue="#000000"
9595
/>
96-
<Form.TextInput
96+
<Form.ColorInput
9797
label={t("records.features.foreground_label")}
9898
name="attributes[foregroundColor]"
99-
placeholder="#000000"
99+
defaultValue="#000000"
100100
/>
101-
<Form.TextInput
101+
<Form.ColorInput
102102
label={t("records.features.header_color_label")}
103103
name="attributes[headerColor]"
104-
placeholder="#000000"
104+
defaultValue="#000000"
105105
/>
106106
<Form.Upload
107107
layout="landscape"

client/src/config/app/locale/en-US/json/backend/records.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"no_title": "Untitled #{{position}}",
114114
"unauthorized_create": "You are not allowed to create features.",
115115
"unauthorized_update": "You are not allowed to update features.",
116-
"instructions": "This is an approximate preview of your feature. Foreground, background, and markdown will not be displayed until the feature is saved."
116+
"instructions": "This is an approximate preview of your feature. Foreground and background images, and parsed markdown will not be displayed until the feature is saved."
117117
},
118118
"untitled_record": "Untitled #{{number}}",
119119
"new_header": "New Feature",

client/src/frontend/components/layout/Splash/index.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Link } from "react-router-dom";
66
import * as Styled from "./styles";
77

88
export default function Splash(props) {
9-
const { preview, feature, authenticated } = props;
9+
const { preview, feature, authenticated, previewAttrs } = props;
1010
const {
1111
style: mode,
1212
backgroundColor,
@@ -28,6 +28,21 @@ export default function Splash(props) {
2828
includeSignUp
2929
} = feature.attributes;
3030

31+
const renderedHeader = () => {
32+
if (preview && previewAttrs?.header) return previewAttrs.header;
33+
return headerFormatted || header;
34+
};
35+
36+
const renderedSubheader = () => {
37+
if (preview && previewAttrs?.subheader) return previewAttrs.subheader;
38+
return subheaderFormatted || subheader;
39+
};
40+
41+
const renderedBody = () => {
42+
if (preview && previewAttrs?.body) return previewAttrs.body;
43+
return bodyFormatted || body;
44+
};
45+
3146
return (
3247
<Styled.Wrapper
3348
$preview={preview}
@@ -40,20 +55,20 @@ export default function Splash(props) {
4055
<Styled.Heading
4156
$color={headerColor}
4257
dangerouslySetInnerHTML={{
43-
__html: headerFormatted || header
58+
__html: renderedHeader()
4459
}}
4560
/>
4661
{(subheaderFormatted || subheader) && (
4762
<Styled.Subheading
4863
$color={headerColor}
4964
dangerouslySetInnerHTML={{
50-
__html: subheaderFormatted || subheader
65+
__html: renderedSubheader()
5166
}}
5267
/>
5368
)}
5469
<Styled.Body
5570
$color={foregroundColor}
56-
dangerouslySetInnerHTML={{ __html: bodyFormatted || body }}
71+
dangerouslySetInnerHTML={{ __html: renderedBody() }}
5772
/>
5873
<Styled.Buttons>
5974
{linkText && linkUrl ? (

0 commit comments

Comments
 (0)