File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ export interface AnnouncementBannerProps extends VariantProps<typeof bannerVaria
3131 message : ReactNode ;
3232 ctaHref ?: string ;
3333 ctaLabel ?: string ;
34+ ctaExternal ?: boolean ;
3435 className ?: string ;
3536 dismissible ?: boolean ; // future enhancement
3637}
@@ -41,10 +42,30 @@ export function AnnouncementBanner({
4142 message,
4243 ctaHref,
4344 ctaLabel = 'Learn more' ,
45+ ctaExternal = false ,
4446 className,
4547 variant,
4648 size,
4749} : AnnouncementBannerProps ) {
50+ const ctaClassName =
51+ 'inline-flex shrink-0 items-center gap-1 underline underline-offset-4 decoration-white/40 hover:decoration-white transition-colors group' ;
52+ const ctaArrow = (
53+ < svg
54+ xmlns = "http://www.w3.org/2000/svg"
55+ viewBox = "0 0 24 24"
56+ fill = "none"
57+ stroke = "currentColor"
58+ strokeWidth = "2"
59+ strokeLinecap = "round"
60+ strokeLinejoin = "round"
61+ className = "h-4 w-4 group-hover:translate-x-1 transition-transform"
62+ aria-hidden = "true"
63+ >
64+ < path d = "M5 12h14" />
65+ < path d = "m12 5 7 7-7 7" />
66+ </ svg >
67+ ) ;
68+
4869 return (
4970 < div className = { cn ( bannerVariants ( { variant, size } ) , className ) } >
5071 < div className = "absolute inset-0 pointer-events-none select-none overflow-hidden" aria-hidden >
@@ -63,27 +84,18 @@ export function AnnouncementBanner({
6384 </ span >
6485 ) }
6586 < span className = "min-w-0 text-balance" > { message } </ span >
66- { ctaHref && (
67- < Link
68- href = { ctaHref }
69- className = "inline-flex shrink-0 items-center gap-1 underline underline-offset-4 decoration-white/40 hover:decoration-white transition-colors group"
70- >
71- { ctaLabel }
72- < svg
73- xmlns = "http://www.w3.org/2000/svg"
74- viewBox = "0 0 24 24"
75- fill = "none"
76- stroke = "currentColor"
77- strokeWidth = "2"
78- strokeLinecap = "round"
79- strokeLinejoin = "round"
80- className = "h-4 w-4 group-hover:translate-x-1 transition-transform"
81- >
82- < path d = "M5 12h14" />
83- < path d = "m12 5 7 7-7 7" />
84- </ svg >
85- </ Link >
86- ) }
87+ { ctaHref &&
88+ ( ctaExternal ? (
89+ < a href = { ctaHref } target = "_blank" rel = "noreferrer" className = { ctaClassName } >
90+ { ctaLabel }
91+ { ctaArrow }
92+ </ a >
93+ ) : (
94+ < Link href = { ctaHref } className = { ctaClassName } >
95+ { ctaLabel }
96+ { ctaArrow }
97+ </ Link >
98+ ) ) }
8799 </ div >
88100 </ div >
89101 ) ;
You can’t perform that action at this time.
0 commit comments