17
17
*/
18
18
import { surfaceHighlightDay } from '@skyscanner/bpk-foundations-web/tokens/base.es6' ;
19
19
20
+ import InfoIcon from '../../bpk-component-icon/sm/information-circle' ;
21
+ import BpkPopover from '../../bpk-component-popover/src/BpkPopover' ;
20
22
import BpkText , { TEXT_STYLES } from '../../bpk-component-text/src/BpkText' ;
21
23
import { cssModules } from '../../bpk-react-utils' ;
22
24
25
+ import type { Placement } from '@floating-ui/react' ;
26
+
23
27
import STYLES from './BpkInsetBanner.module.scss' ;
24
28
25
29
const getClassName = cssModules ( STYLES ) ;
@@ -37,9 +41,16 @@ export type Props = {
37
41
link ?: string ;
38
42
linkText ?: string ;
39
43
} ;
40
- // [TO-DO] In future iteration we will add a button to CTA section with popover functionality
41
44
callToAction ?: {
42
45
text ?: string ;
46
+ popoverMessage ?: string ;
47
+ popoverPlacement ?: Placement ;
48
+ buttonCloseLabel ?: string ;
49
+ buttonA11yLabel ?: string ;
50
+ popverLabel ?: string ;
51
+ popoverId ?: string ;
52
+ labelTitle ?: boolean ;
53
+ closeBtnIcon ?: boolean ;
43
54
} ;
44
55
logo ?: string ;
45
56
subheadline ?: string ;
@@ -86,13 +97,69 @@ const BpkInsetBanner = ({
86
97
< BpkText textStyle = { TEXT_STYLES . caption } > { subheadline } </ BpkText >
87
98
</ div >
88
99
</ div >
89
- < div className = { getClassName ( 'bpk-inset-banner--cta-container' ) } >
90
- { callToAction ?. text && (
100
+ { callToAction && callToAction . popoverMessage && (
101
+ < div
102
+ role = "presentation"
103
+ className = { getClassName ( 'bpk-inset-banner--cta-container' ) }
104
+ onClick = { ( e ) => {
105
+ // Do not propagate the click on the trigger OR popover content up the DOM tree.
106
+ e . stopPropagation ( ) ;
107
+ e . preventDefault ( ) ;
108
+ } }
109
+ >
110
+ < BpkPopover
111
+ id = { callToAction ?. popoverId || '' }
112
+ label = { callToAction ?. popverLabel || '' }
113
+ placement = { callToAction ?. popoverPlacement || 'bottom' }
114
+ onClose = { ( e : {
115
+ stopPropagation : ( ) => void ;
116
+ preventDefault : ( ) => void ;
117
+ } ) => {
118
+ e . stopPropagation ( ) ;
119
+ e . preventDefault ( ) ;
120
+ } }
121
+ closeButtonText = { callToAction ?. buttonCloseLabel }
122
+ closeButtonIcon = { callToAction ?. closeBtnIcon }
123
+ labelAsTitle = { callToAction ?. labelTitle }
124
+ target = {
125
+ < button
126
+ aria-label = { callToAction ?. buttonA11yLabel }
127
+ className = { getClassName ( 'bpk-inset-banner--cta-button' ) }
128
+ data-testid = "adInfoBtn"
129
+ aria-hidden = "false"
130
+ type = "button"
131
+ >
132
+ < div
133
+ className = { getClassName ( 'bpk-inset-banner--cta-content' ) }
134
+ >
135
+ { callToAction ?. text && (
136
+ < BpkText textStyle = { TEXT_STYLES . caption } >
137
+ { callToAction . text }
138
+ </ BpkText >
139
+ ) }
140
+
141
+ < div
142
+ className = { getClassName (
143
+ 'bpk-inset-banner--cta-info-icon' ,
144
+ ) }
145
+ >
146
+ < InfoIcon />
147
+ </ div >
148
+ </ div >
149
+ </ button >
150
+ }
151
+ >
152
+ < BpkText tagName = "p" > { callToAction ?. popoverMessage } </ BpkText >
153
+ </ BpkPopover >
154
+ </ div >
155
+ ) }
156
+ { callToAction && ! callToAction . popoverMessage && callToAction . text && (
157
+ < div className = { getClassName ( 'bpk-inset-banner--cta-text' ) } >
91
158
< BpkText textStyle = { TEXT_STYLES . caption } >
92
159
{ callToAction . text }
93
160
</ BpkText >
94
- ) }
95
- </ div >
161
+ </ div >
162
+ ) }
96
163
</ div >
97
164
{ body && (
98
165
< div className = { getClassName ( 'bpk-inset-banner-body-container' ) } >
0 commit comments