@@ -29,6 +29,41 @@ const getYouTubeEmbedUrl = (url: string): string => {
2929 return videoId ? `https://www.youtube.com/embed/${ videoId } ` : '' ;
3030} ;
3131
32+ type TextColour = 'white' | 'dark' ;
33+
34+ function generateCTAClasses ( variant : string , textColour : TextColour ) : string {
35+ const baseClasses = 'inline-flex items-center justify-center px-6 py-3 font-semibold rounded-md transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2' ;
36+
37+ switch ( variant ) {
38+ case 'primary' :
39+ if ( textColour === 'white' ) {
40+ return `${ baseClasses } bg-white text-gray-900 hover:bg-gray-100 focus:ring-white` ;
41+ }
42+ return `${ baseClasses } bg-brand-a text-white hover:bg-brand-b focus:ring-brand-a` ;
43+
44+ case 'secondary' :
45+ if ( textColour === 'white' ) {
46+ return `${ baseClasses } bg-white/20 text-white border border-white/40 hover:bg-white/30 focus:ring-white` ;
47+ }
48+ return `${ baseClasses } bg-white text-brand-a border border-brand-a hover:bg-brand-a hover:text-white hover:border-brand-a focus:ring-brand-a` ;
49+
50+ case 'outline' :
51+ if ( textColour === 'white' ) {
52+ return `${ baseClasses } bg-white/10 border-2 border-white text-white hover:bg-white hover:text-gray-900 focus:ring-white` ;
53+ }
54+ return `${ baseClasses } bg-transparent border-2 border-brand-a text-brand-a hover:bg-brand-a hover:text-white focus:ring-brand-a` ;
55+
56+ default :
57+ return baseClasses ;
58+ }
59+ }
60+
61+ const ExternalLinkIcon = ( ) => (
62+ < svg className = "ml-2 w-4 h-4 inline" fill = "none" stroke = "currentColor" viewBox = "0 0 24 24" >
63+ < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = { 2 } d = "M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
64+ </ svg >
65+ ) ;
66+
3267function transformToPublicFormat ( data : IBannerFormData ) {
3368 const processMediaAsset = (
3469 asset : IMediaAsset | File | MediaAssetFileMeta | null | undefined
@@ -154,22 +189,17 @@ export const BannerPreview: React.FC<BannerPreviewProps> = ({ data, className =
154189 ) }
155190
156191 { props . ctaButtons . length > 0 && (
157- < div className = { `flex gap-3 pt-4 ${ ! isSplitLayout ? 'justify-center' : '' } ` } >
192+ < div className = { `flex flex-wrap gap-3 pt-4 ${ ! isSplitLayout ? 'justify-center' : '' } ` } >
158193 { props . ctaButtons . map ( ( btn , index ) => (
159194 < a
160195 key = { index }
161196 href = { btn . url }
162- className = { `px-6 py-3 rounded-md font-medium transition-colors ${
163- btn . variant === 'primary'
164- ? 'bg-brand-d text-white hover:bg-brand-c'
165- : btn . variant === 'secondary'
166- ? 'bg-white text-brand-k hover:bg-gray-100'
167- : 'border-2 border-current hover:bg-white hover:bg-opacity-10'
168- } `}
197+ className = { generateCTAClasses ( btn . variant , props . textColour as TextColour ) }
169198 target = { btn . external ? '_blank' : undefined }
170199 rel = { btn . external ? 'noopener noreferrer' : undefined }
171200 >
172201 { btn . label }
202+ { btn . external && < ExternalLinkIcon /> }
173203 </ a >
174204 ) ) }
175205 </ div >
0 commit comments