@@ -10,6 +10,7 @@ export function CtaCard({
10
10
buttonText,
11
11
buttonUrl,
12
12
hasBackground,
13
+ hasImage,
13
14
hasSponsorLabel,
14
15
htmlEditor,
15
16
htmlEditorInitialState,
@@ -19,7 +20,8 @@ export function CtaCard({
19
20
updateButtonUrl,
20
21
updateShowButton,
21
22
updateHasBackground,
22
- updateHasSponsorLabel
23
+ updateHasSponsorLabel,
24
+ updateHasImage
23
25
} ) {
24
26
return (
25
27
< >
@@ -32,26 +34,33 @@ export function CtaCard({
32
34
) }
33
35
34
36
< div className = { `flex flex-col gap-5 py-5 ${ hasSponsorLabel || ! hasBackground ? 'border-t border-grey-300 dark:border-grey-800' : '' } ${ hasBackground ? 'mx-5' : 'border-b border-grey-300 dark:border-grey-800' } ` } >
35
- { /* HTML content */ }
36
- < KoenigNestedEditor
37
- autoFocus = { true }
38
- hasSettingsPanel = { true }
39
- initialEditor = { htmlEditor }
40
- initialEditorState = { htmlEditorInitialState }
41
- nodes = 'basic'
42
- placeholderClassName = { `bg-transparent whitespace-normal font-serif text-xl !text-grey-500 !dark:text-grey-800 ` }
43
- placeholderText = "Write something worth clicking..."
44
- textClassName = "w-full bg-transparent whitespace-normal font-serif text-xl text-grey-900 dark:text-grey-200"
45
- >
46
- < ReplacementStringsPlugin />
47
- </ KoenigNestedEditor >
48
-
49
- { /* Button */ }
50
- { ( showButton && ( isEditing || ( buttonText && buttonUrl ) ) ) &&
51
- < div >
52
- < Button color = { 'accent' } dataTestId = "cta-button" placeholder = "Add button text" value = { buttonText } />
37
+ { hasImage && (
38
+ < div className = "flex" >
39
+ < img alt = "Placeholder" className = "h-auto w-full rounded-md" src = "https://images.unsplash.com/photo-1526170375885-4d8ecf77b99f?q=80& w = 3888 & auto = format & fit = crop & ixlib = rb - 4.0 .3 & ixid = M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA % 3 D % 3 D " />
53
40
</ div >
54
- }
41
+ ) }
42
+ < div className = "flex flex-col gap-5" >
43
+ { /* HTML content */ }
44
+ < KoenigNestedEditor
45
+ autoFocus = { true }
46
+ hasSettingsPanel = { true }
47
+ initialEditor = { htmlEditor }
48
+ initialEditorState = { htmlEditorInitialState }
49
+ nodes = 'basic'
50
+ placeholderClassName = { `bg-transparent whitespace-normal font-serif text-xl !text-grey-500 !dark:text-grey-800 ` }
51
+ placeholderText = "Write something worth clicking..."
52
+ textClassName = "w-full bg-transparent whitespace-normal font-serif text-xl text-grey-900 dark:text-grey-200"
53
+ >
54
+ < ReplacementStringsPlugin />
55
+ </ KoenigNestedEditor >
56
+
57
+ { /* Button */ }
58
+ { ( showButton && ( isEditing || ( buttonText && buttonUrl ) ) ) &&
59
+ < div >
60
+ < Button color = { 'accent' } dataTestId = "cta-button" placeholder = "Add button text" value = { buttonText } />
61
+ </ div >
62
+ }
63
+ </ div >
55
64
</ div >
56
65
57
66
{ /* Read-only overlay */ }
@@ -60,17 +69,23 @@ export function CtaCard({
60
69
61
70
{ isEditing && (
62
71
< SettingsPanel >
72
+ { /* Background setting */ }
73
+ < ToggleSetting
74
+ isChecked = { hasBackground }
75
+ label = 'Background'
76
+ onChange = { updateHasBackground }
77
+ />
63
78
{ /* Sponsor label setting */ }
64
79
< ToggleSetting
65
80
isChecked = { hasSponsorLabel }
66
81
label = 'Sponsor label'
67
82
onChange = { updateHasSponsorLabel }
68
83
/>
69
- { /* Background setting */ }
84
+ { /* Image setting */ }
70
85
< ToggleSetting
71
- isChecked = { hasBackground }
72
- label = 'Background '
73
- onChange = { updateHasBackground }
86
+ isChecked = { hasImage }
87
+ label = 'Image '
88
+ onChange = { updateHasImage }
74
89
/>
75
90
{ /* Button settings */ }
76
91
< ToggleSetting
@@ -106,6 +121,7 @@ CtaCard.propTypes = {
106
121
buttonText : PropTypes . string ,
107
122
buttonUrl : PropTypes . string ,
108
123
hasBackground : PropTypes . bool ,
124
+ hasImage : PropTypes . bool ,
109
125
hasSponsorLabel : PropTypes . bool ,
110
126
isEditing : PropTypes . bool ,
111
127
showButton : PropTypes . bool ,
@@ -115,17 +131,20 @@ CtaCard.propTypes = {
115
131
updateButtonUrl : PropTypes . func ,
116
132
updateHasBackground : PropTypes . func ,
117
133
updateHasSponsorLabel : PropTypes . func ,
134
+ updateHasImage : PropTypes . func ,
118
135
updateShowButton : PropTypes . func
119
136
} ;
120
137
121
138
CtaCard . defaultProps = {
122
139
buttonText : '' ,
123
140
buttonUrl : '' ,
124
141
hasBackground : false ,
142
+ hasImage : false ,
125
143
hasSponsorLabel : false ,
126
144
isEditing : false ,
127
145
showButton : false ,
128
146
updateHasBackground : ( ) => { } ,
129
147
updateHasSponsorLabel : ( ) => { } ,
148
+ updateHasImage : ( ) => { } ,
130
149
updateShowButton : ( ) => { }
131
150
} ;
0 commit comments