Skip to content

Commit 62c67c5

Browse files
authored
Merge pull request #145 from communitiesuk/feature/masthead-text-colour-prop/|ID2-101
Add text color prop and force color change with css variable
2 parents 948780e + c9c6082 commit 62c67c5

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/lib/components/ui/Masthead.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
imageSrc = homepageIllustration,
1212
imageAlt = "",
1313
backgroundColor = "#1d70b8", // GOV.UK blue by default
14+
textColor = "#FFFFFF",
1415
} = $props<{
1516
title?: string;
1617
description?: string;
@@ -20,12 +21,13 @@
2021
imageSrc?: string;
2122
imageAlt?: string;
2223
backgroundColor?: string;
24+
textColor?: string;
2325
}>();
2426
</script>
2527

2628
<div
2729
class="app-masthead"
28-
style="background-color: {backgroundColor}; border-bottom-color: {backgroundColor};"
30+
style="background-color: {backgroundColor}; border-bottom-color: {backgroundColor}; --masthead-text-color: {textColor};"
2931
>
3032
<div class="govuk-width-container">
3133
<div class="govuk-grid-row">
@@ -250,7 +252,10 @@
250252
251253
/* GOV.UK Typography - Scoped to our component with high specificity */
252254
.app-masthead .govuk-heading-xl.govuk-heading-xl {
253-
color: #ffffff; /* Override to white for masthead */
255+
color: var(
256+
--masthead-text-color,
257+
#ffffff
258+
); /* Override to textColor prop if specified otherwise fall back to white */
254259
font-family: "GDS Transport", arial, sans-serif;
255260
font-weight: 700;
256261
font-size: 2rem;
@@ -267,4 +272,8 @@
267272
margin-bottom: 3.125rem;
268273
}
269274
}
275+
276+
.app-masthead__description {
277+
color: var(--masthead-text-color);
278+
}
270279
</style>

src/wrappers/components/ui/MastheadWrapper.svelte

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@
209209
},
210210
rows: 4,
211211
},
212+
{
213+
name: "textColor",
214+
category: "Visual",
215+
value: "#FFFFFF",
216+
description: {
217+
markdown: true,
218+
arr: ["The text color of the title and description."],
219+
},
220+
},
212221
{
213222
name: "includeButton",
214223
category: "Call to Action",

0 commit comments

Comments
 (0)