Skip to content

Commit e949585

Browse files
author
Juarez Mota
committed
feat: apply colour palette to 3 tier designable banner
1 parent f9bfc9c commit e949585

File tree

3 files changed

+118
-75
lines changed

3 files changed

+118
-75
lines changed

dotcom-rendering/src/components/marketing/banners/designableBanner/DesignableBanner.tsx

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import type {
4747
BannerTemplateSettings,
4848
ChoiceCardSettings,
4949
CtaSettings,
50-
CtaStateSettings,
5150
} from './settings';
5251
import { buttonStyles, buttonThemes } from './styles/buttonStyles';
5352
import { templateSpacing } from './styles/templateStyles';
@@ -92,6 +91,9 @@ const buildChoiceCardSettings = (
9291
buttonSelectColour,
9392
buttonSelectTextColour,
9493
buttonSelectBorderColour,
94+
buttonSelectMarkerColour,
95+
pillTextColour,
96+
pillBackgroundColour,
9597
} = design.visual;
9698
return {
9799
buttonColour: buttonColour
@@ -112,6 +114,15 @@ const buildChoiceCardSettings = (
112114
buttonSelectBorderColour: buttonSelectBorderColour
113115
? hexColourToString(buttonSelectBorderColour)
114116
: undefined,
117+
buttonSelectMarkerColour: buttonSelectMarkerColour
118+
? hexColourToString(buttonSelectMarkerColour)
119+
: undefined,
120+
pillTextColour: pillTextColour
121+
? hexColourToString(pillTextColour)
122+
: undefined,
123+
pillBackgroundColour: pillBackgroundColour
124+
? hexColourToString(pillBackgroundColour)
125+
: undefined,
115126
};
116127
}
117128
return undefined;
@@ -195,15 +206,6 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({
195206
? 'main-image'
196207
: '.';
197208

198-
// TODO: I assume we're planning on making this adjustable in RRCP in future.
199-
const choiceCardButtonCtaStateSettings: CtaStateSettings = {
200-
backgroundColour: palette.brandAlt[400],
201-
textColour: 'inherit',
202-
};
203-
const choiceCardButtonSettings: CtaSettings = {
204-
default: choiceCardButtonCtaStateSettings,
205-
};
206-
207209
const templateSettings: BannerTemplateSettings = {
208210
containerSettings: {
209211
backgroundColour: hexColourToString(basic.background),
@@ -431,8 +433,10 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({
431433
onClick={() =>
432434
handleSetIsCollapsed(!isCollapsed)
433435
}
434-
cssOverrides={styles.iconOverrides}
435-
priority="tertiary"
436+
cssOverrides={styles.iconOverrides(
437+
templateSettings.closeButtonSettings,
438+
)}
439+
priority="secondary"
436440
icon={
437441
isCollapsed ? (
438442
<SvgChevronUpSingle />
@@ -442,14 +446,8 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({
442446
}
443447
size="small"
444448
theme={buttonThemes(
445-
{
446-
default: {
447-
backgroundColour:
448-
palette.brand[400],
449-
textColour: 'inherit',
450-
},
451-
},
452-
'tertiary',
449+
templateSettings.closeButtonSettings,
450+
'secondary',
453451
)}
454452
hideLabel={true}
455453
/>
@@ -478,6 +476,7 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({
478476
choices={choiceCards}
479477
id={'banner'}
480478
submitComponentEvent={submitComponentEvent}
479+
choiceCardSettings={choiceCardSettings}
481480
/>
482481
)}
483482
<div css={styles.ctaContainer(isCollapsed)}>
@@ -493,9 +492,9 @@ const DesignableBanner: ReactComponent<BannerRenderProps> = ({
493492
})}
494493
onClick={onCtaClick}
495494
priority="primary"
496-
cssOverrides={styles.linkButtonStyles}
495+
cssOverrides={[styles.linkButtonStyles]}
497496
theme={buttonThemes(
498-
choiceCardButtonSettings,
497+
templateSettings.primaryCtaSettings,
499498
'primary',
500499
)}
501500
icon={<SvgArrowRightStraight />}
@@ -1036,10 +1035,11 @@ const styles = {
10361035
margin-top: ${space[1]}px;
10371036
}
10381037
`,
1039-
iconOverrides: css`
1040-
background-color: ${palette.brand[400]};
1038+
iconOverrides: (ctaSettings?: CtaSettings) => css`
1039+
background-color: ${ctaSettings?.default.backgroundColour ??
1040+
palette.brand[400]};
10411041
path {
1042-
fill: white;
1042+
fill: ${ctaSettings?.default.textColour ?? 'white'};
10431043
}
10441044
margin-top: ${space[1]}px;
10451045
margin-right: ${space[1]}px;

dotcom-rendering/src/components/marketing/banners/designableBanner/settings.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ export interface ChoiceCardSettings {
4343
buttonSelectColour?: string;
4444
buttonSelectTextColour?: string;
4545
buttonSelectBorderColour?: string;
46+
buttonSelectMarkerColour?: string;
47+
pillTextColour?: string;
48+
pillBackgroundColour?: string;
4649
}
4750

4851
export interface BannerTemplateSettings {

dotcom-rendering/src/components/marketing/shared/ThreeTierChoiceCards.tsx

Lines changed: 90 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,7 @@ import type { Dispatch, SetStateAction } from 'react';
2323
import { useEffect } from 'react';
2424
import sanitise from 'sanitize-html';
2525
import { useIsInView } from '../../../lib/useIsInView';
26-
27-
const supportTierChoiceCardStyles = (selected: boolean) => css`
28-
display: block;
29-
border: ${selected
30-
? `2px solid ${palette.brand['500']}`
31-
: `1px solid ${palette.neutral[46]}`};
32-
background-color: ${palette.neutral[100]};
33-
border-radius: 10px;
34-
padding: ${selected
35-
? `6px ${space[5]}px 10px ${space[5]}px`
36-
: `6px ${space[5]}px`};
37-
`;
26+
import type { ChoiceCardSettings } from '../banners/designableBanner/settings';
3827

3928
const benefitsStyles = css`
4029
${textSans15};
@@ -60,8 +49,8 @@ const benefitsStyles = css`
6049
}
6150
`;
6251

63-
const benefitsLabelStyles = css`
64-
color: ${palette.neutral[0]};
52+
const benefitsLabelStyles = (customColor?: string) => css`
53+
color: ${customColor ?? palette.neutral[0]};
6554
${textSans15};
6655
6756
strong {
@@ -82,45 +71,23 @@ const supportingTextStyles = css`
8271
margin-top: ${space[4]}px;
8372
`;
8473

85-
const pillStyles = (pill: NonNullable<ChoiceCard['pill']>) => css`
86-
border-radius: 4px;
87-
padding: ${space[1]}px ${space[2]}px;
88-
background-color: ${pill.backgroundColour
89-
? hexColourToString(pill.backgroundColour as HexColour)
90-
: palette.brandAlt[400]};
91-
${textSansBold14};
92-
color: ${pill.textColour
93-
? hexColourToString(pill.textColour as HexColour)
94-
: palette.neutral[7]};
95-
position: absolute;
96-
top: -${space[2]}px;
97-
${until.phablet} {
98-
right: ${space[3]}px;
99-
}
100-
right: ${space[5]}px;
101-
`;
102-
103-
const customRadioTheme: ThemeRadio = {
104-
...themeRadio,
105-
borderSelected: palette.brandAlt[400],
106-
borderUnselected: palette.neutral[46],
107-
borderHover: palette.brandAlt[400],
108-
fillSelected: palette.brand[400],
109-
};
110-
11174
const SupportingBenefits = ({
11275
benefitsLabel,
11376
benefits,
77+
choiceCardSettings,
11478
}: {
11579
benefitsLabel?: string;
11680
benefits: ChoiceCard['benefits'];
81+
choiceCardSettings?: ChoiceCardSettings;
11782
}) => {
11883
const showTicks = benefits.length > 1;
11984
return (
12085
<div css={supportingTextStyles}>
12186
{!!benefitsLabel && (
12287
<span
123-
css={benefitsLabelStyles}
88+
css={benefitsLabelStyles(
89+
choiceCardSettings?.buttonSelectTextColour,
90+
)}
12491
dangerouslySetInnerHTML={{
12592
__html: sanitise(benefitsLabel),
12693
}}
@@ -129,8 +96,20 @@ const SupportingBenefits = ({
12996
<ul css={benefitsStyles}>
13097
{benefits.map((benefit) => (
13198
<li key={benefit.copy}>
132-
{showTicks && <SvgTickRound size="xsmall" />}
99+
{showTicks && (
100+
<SvgTickRound
101+
size="xsmall"
102+
theme={{
103+
fill:
104+
choiceCardSettings?.buttonSelectMarkerColour ??
105+
palette.brand[400],
106+
}}
107+
/>
108+
)}
133109
<span
110+
css={benefitsLabelStyles(
111+
choiceCardSettings?.buttonSelectTextColour,
112+
)}
134113
dangerouslySetInnerHTML={{
135114
__html: sanitise(benefit.copy),
136115
}}
@@ -142,20 +121,13 @@ const SupportingBenefits = ({
142121
);
143122
};
144123

145-
const ChoiceCardPill = ({
146-
pill,
147-
}: {
148-
pill: NonNullable<ChoiceCard['pill']>;
149-
}) => {
150-
return <div css={pillStyles(pill)}>{pill.copy}</div>;
151-
};
152-
153124
type ThreeTierChoiceCardsProps = {
154125
selectedChoiceCard: ChoiceCard;
155126
setSelectedChoiceCard: Dispatch<SetStateAction<ChoiceCard | undefined>>;
156127
choices: ChoiceCard[];
157128
id: 'epic' | 'banner'; // uniquely identify this choice cards component to avoid conflicting with others
158129
submitComponentEvent?: (componentEvent: ComponentEvent) => void;
130+
choiceCardSettings?: ChoiceCardSettings;
159131
};
160132

161133
export const ThreeTierChoiceCards = ({
@@ -164,12 +136,77 @@ export const ThreeTierChoiceCards = ({
164136
choices,
165137
id,
166138
submitComponentEvent,
139+
choiceCardSettings,
167140
}: ThreeTierChoiceCardsProps) => {
168141
const [hasBeenSeen, setNode] = useIsInView({
169142
debounce: true,
170143
threshold: 0,
171144
});
172145

146+
const supportTierChoiceCardStyles = (selected: boolean) => css`
147+
display: block;
148+
border: ${selected
149+
? `2px solid ${
150+
choiceCardSettings?.buttonSelectBorderColour ??
151+
palette.brand['500']
152+
}`
153+
: `1px solid ${
154+
choiceCardSettings?.buttonBorderColour ??
155+
palette.neutral[46]
156+
}`};
157+
background-color: ${selected
158+
? choiceCardSettings?.buttonSelectColour ?? palette.neutral[100]
159+
: choiceCardSettings?.buttonColour ?? palette.neutral[100]};
160+
color: ${selected
161+
? choiceCardSettings?.buttonSelectTextColour ?? 'inherit'
162+
: choiceCardSettings?.buttonTextColour ?? 'inherit'};
163+
border-radius: 10px;
164+
padding: ${selected
165+
? `6px ${space[5]}px 10px ${space[5]}px`
166+
: `6px ${space[5]}px`};
167+
`;
168+
169+
const customRadioTheme: ThemeRadio = {
170+
...themeRadio,
171+
borderSelected:
172+
choiceCardSettings?.buttonSelectBorderColour ??
173+
palette.brandAlt[400],
174+
borderUnselected:
175+
choiceCardSettings?.buttonBorderColour ?? palette.neutral[46],
176+
borderHover:
177+
choiceCardSettings?.buttonSelectBorderColour ??
178+
palette.brandAlt[400],
179+
fillSelected:
180+
choiceCardSettings?.buttonSelectMarkerColour ?? palette.brand[400],
181+
};
182+
183+
const pillStyles = (pill: NonNullable<ChoiceCard['pill']>) => css`
184+
border-radius: 4px;
185+
padding: ${space[1]}px ${space[2]}px;
186+
background-color: ${pill.backgroundColour
187+
? hexColourToString(pill.backgroundColour as HexColour)
188+
: choiceCardSettings?.pillBackgroundColour ??
189+
palette.brandAlt[400]};
190+
${textSansBold14};
191+
color: ${pill.textColour
192+
? hexColourToString(pill.textColour as HexColour)
193+
: choiceCardSettings?.pillTextColour ?? palette.neutral[7]};
194+
position: absolute;
195+
top: -${space[2]}px;
196+
${until.phablet} {
197+
right: ${space[3]}px;
198+
}
199+
right: ${space[5]}px;
200+
`;
201+
202+
const ChoiceCardPill = ({
203+
pill,
204+
}: {
205+
pill: NonNullable<ChoiceCard['pill']>;
206+
}) => {
207+
return <div css={pillStyles(pill)}>{pill.copy}</div>;
208+
};
209+
173210
useEffect(() => {
174211
if (submitComponentEvent) {
175212
void submitComponentEvent({
@@ -277,6 +314,9 @@ export const ThreeTierChoiceCards = ({
277314
| undefined
278315
}
279316
benefits={benefits}
317+
choiceCardSettings={
318+
choiceCardSettings
319+
}
280320
/>
281321
)
282322
}

0 commit comments

Comments
 (0)