Skip to content

Commit d16e0a7

Browse files
authored
Merge pull request #1487 from CodeForAfrica/fix/testimonial-background-color
Configurable background and text colour for ContentOverview and Testimonial
2 parents 81b614c + 14f50dc commit d16e0a7

6 files changed

Lines changed: 51 additions & 17 deletions

File tree

apps/trustlab/src/components/ContentOverview/ContentOverview.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,23 @@ const itemValueSx = {
8787
};
8888

8989
const ContentOverview = forwardRef(function ContentOverview(props, ref) {
90-
const { card, content, date, location, title } = props;
90+
const {
91+
card,
92+
content,
93+
date,
94+
location,
95+
title,
96+
backgroundColor = "#fff",
97+
textColor = "#000",
98+
} = props;
9199

92100
if (!(content && card)) {
93101
return null;
94102
}
95103
const { cardType, items, richContent, title: cardTitle } = card;
96104
const hasLocationOrDate = location?.length || date?.length;
97105
return (
98-
<Box sx={{ backgroundColor: "common.white" }} ref={ref}>
106+
<Box sx={{ backgroundColor, color: textColor }} ref={ref}>
99107
<Section sx={{ py: 5, px: { xs: 2.5, sm: 0 } }}>
100108
<Grid container spacing={4} alignItems="flex-start">
101109
<Grid
@@ -113,7 +121,11 @@ const ContentOverview = forwardRef(function ContentOverview(props, ref) {
113121
) : null}
114122
{hasLocationOrDate ? (
115123
<Grid>
116-
<LocationAndDate date={date} location={location} />
124+
<LocationAndDate
125+
color={textColor}
126+
date={date}
127+
location={location}
128+
/>
117129
</Grid>
118130
) : null}
119131
<Grid>
@@ -123,12 +135,13 @@ const ContentOverview = forwardRef(function ContentOverview(props, ref) {
123135
"h1, h2, h3, h4, h5, h6": {
124136
...headingSx,
125137
mb: 1,
138+
color: textColor,
126139
},
127140
p: { mb: 2 },
128141
}}
129142
TypographyProps={{
130143
gutterBottom: true,
131-
sx: bodySx,
144+
sx: { ...bodySx, color: textColor },
132145
}}
133146
/>
134147
</Grid>

apps/trustlab/src/components/ContentOverview/ContentOverview.snap.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
exports[`<ContentOverview /> renders items without labels 1`] = `
44
<div>
55
<div
6-
class="MuiBox-root css-1k9ek97"
6+
class="MuiBox-root css-jvd2ob"
77
>
88
<div
99
class="MuiContainer-root MuiContainer-maxWidthLg MuiContainer-fixed MuiContainer-disableGutters css-j09c23-MuiContainer-root"
@@ -18,7 +18,7 @@ exports[`<ContentOverview /> renders items without labels 1`] = `
1818
class="MuiGrid2-root MuiGrid2-direction-xs-row css-1fzlhpv-MuiGrid2-root"
1919
>
2020
<div
21-
class="MuiBox-root css-e71fug"
21+
class="MuiBox-root css-1wrl852"
2222
/>
2323
</div>
2424
</div>
@@ -75,7 +75,7 @@ exports[`<ContentOverview /> renders items without labels 1`] = `
7575
exports[`<ContentOverview /> renders richtext card type 1`] = `
7676
<div>
7777
<div
78-
class="MuiBox-root css-1k9ek97"
78+
class="MuiBox-root css-jvd2ob"
7979
>
8080
<div
8181
class="MuiContainer-root MuiContainer-maxWidthLg MuiContainer-fixed MuiContainer-disableGutters css-j09c23-MuiContainer-root"
@@ -90,7 +90,7 @@ exports[`<ContentOverview /> renders richtext card type 1`] = `
9090
class="MuiGrid2-root MuiGrid2-direction-xs-row css-1fzlhpv-MuiGrid2-root"
9191
>
9292
<div
93-
class="MuiBox-root css-e71fug"
93+
class="MuiBox-root css-1wrl852"
9494
/>
9595
</div>
9696
</div>
@@ -119,7 +119,7 @@ exports[`<ContentOverview /> renders richtext card type 1`] = `
119119
exports[`<ContentOverview /> renders unchanged 1`] = `
120120
<div>
121121
<div
122-
class="MuiBox-root css-1k9ek97"
122+
class="MuiBox-root css-jvd2ob"
123123
>
124124
<div
125125
class="MuiContainer-root MuiContainer-maxWidthLg MuiContainer-fixed MuiContainer-disableGutters css-j09c23-MuiContainer-root"
@@ -134,7 +134,7 @@ exports[`<ContentOverview /> renders unchanged 1`] = `
134134
class="MuiGrid2-root MuiGrid2-direction-xs-row css-1fzlhpv-MuiGrid2-root"
135135
>
136136
<div
137-
class="MuiBox-root css-e71fug"
137+
class="MuiBox-root css-1wrl852"
138138
/>
139139
</div>
140140
</div>
@@ -248,7 +248,7 @@ exports[`<ContentOverview /> renders unchanged 1`] = `
248248
exports[`<ContentOverview /> renders with linked item 1`] = `
249249
<div>
250250
<div
251-
class="MuiBox-root css-1k9ek97"
251+
class="MuiBox-root css-jvd2ob"
252252
>
253253
<div
254254
class="MuiContainer-root MuiContainer-maxWidthLg MuiContainer-fixed MuiContainer-disableGutters css-j09c23-MuiContainer-root"
@@ -263,7 +263,7 @@ exports[`<ContentOverview /> renders with linked item 1`] = `
263263
class="MuiGrid2-root MuiGrid2-direction-xs-row css-1fzlhpv-MuiGrid2-root"
264264
>
265265
<div
266-
class="MuiBox-root css-e71fug"
266+
class="MuiBox-root css-1wrl852"
267267
/>
268268
</div>
269269
</div>

apps/trustlab/src/components/LocationAndDate/LocationAndDate.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { RichTypography } from "@commons-ui/next";
22
import { Divider, Stack } from "@mui/material";
33

4-
function LocationAndDate({ DividerProps, date, location, sx }) {
4+
function LocationAndDate({ DividerProps, color, date, location, sx }) {
55
// if both location and date are not present, return null
66
if (!(date?.length || location?.length)) {
77
return null;
@@ -14,14 +14,14 @@ function LocationAndDate({ DividerProps, date, location, sx }) {
1414
orientation="vertical"
1515
flexItem
1616
variant="middle"
17-
sx={{ backgroundColor: "text.primary" }}
17+
sx={{ backgroundColor: color ?? "text.primary" }}
1818
{...DividerProps}
1919
/>
2020
);
2121
}
2222
return (
2323
<Stack direction="row" divider={divider} spacing={1} sx={sx}>
24-
<RichTypography variant="p2" sx={{ color: "common.black" }}>
24+
<RichTypography variant="p2" sx={{ color: color ?? "common.black" }}>
2525
{location}
2626
</RichTypography>
2727
<RichTypography variant="p2" sx={{ color: "#828499" }}>

apps/trustlab/src/components/Testimonial/Testimonial.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,15 @@ import { Box, Grid2 as Grid, Typography } from "@mui/material";
55
import { forwardRef } from "react";
66

77
const Testimonial = forwardRef(function Testimonial(props, ref) {
8-
const { title, description, image, signatureIcon, sx } = props;
8+
const {
9+
title,
10+
description,
11+
image,
12+
signatureIcon,
13+
backgroundColor = "#fff",
14+
textColor = "#000",
15+
sx,
16+
} = props;
917

1018
if (!(description && image?.src && image.width && image.height)) {
1119
return null;
@@ -22,7 +30,8 @@ const Testimonial = forwardRef(function Testimonial(props, ref) {
2230
ref={ref}
2331
sx={[
2432
{
25-
backgroundColor: "#fff",
33+
backgroundColor,
34+
color: textColor,
2635
py: 2,
2736
},
2837
...(Array.isArray(sx) ? sx : [sx]),

apps/trustlab/src/payload/blocks/ContentOverview.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { link, richText } from "@commons-ui/payload/fields";
22

3+
import colorSettingsField from "../fields/colorSettingsField";
4+
35
const ContentOverview = {
46
slug: "content-overview",
57
imageURL: "/images/cms/blocks/content-overview.png",
@@ -12,6 +14,10 @@ const ContentOverview = {
1214
localized: true,
1315
},
1416
richText({ name: "content", required: true, localized: true }),
17+
colorSettingsField({
18+
backgroundOverrides: { defaultValue: "#fff" },
19+
textOverrides: { defaultValue: "#000" },
20+
}),
1521
{
1622
name: "card",
1723
type: "group",

apps/trustlab/src/payload/blocks/Testimonial.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { richText } from "@commons-ui/payload/fields";
22

3+
import colorSettingsField from "../fields/colorSettingsField";
4+
35
const Testimonial = {
46
slug: "testimonial",
57
labels: { singular: "Testimonial", plural: "Testimonials" },
@@ -17,6 +19,10 @@ const Testimonial = {
1719
required: true,
1820
localized: true,
1921
}),
22+
colorSettingsField({
23+
backgroundOverrides: { defaultValue: "#fff" },
24+
textOverrides: { defaultValue: "#000" },
25+
}),
2026
{
2127
name: "image",
2228
type: "upload",

0 commit comments

Comments
 (0)