@@ -23,18 +23,7 @@ import type { Dispatch, SetStateAction } from 'react';
2323import { useEffect } from 'react' ;
2424import sanitise from 'sanitize-html' ;
2525import { 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
3928const 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- to p: ${ 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-
11174const 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-
153124type 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
161133export 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+ dis play: block;
148+ bor der: ${ 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+ bor der- 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+ bor der- 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+ to p: - ${ 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