File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {useEffect, useState} from 'react';
1212import { LogoMark } from './LogoMark' ;
1313import VersionSelector from './VersionSelector' ;
1414import { Search } from './search/Search' ;
15+ import { TopBanner } from './TopBanner'
1516
1617function GitHubIcon ( props : React . ComponentPropsWithoutRef < 'svg' > ) {
1718 return (
@@ -110,13 +111,14 @@ export function Layout({children}: {children: React.ReactNode}) {
110111 < Header />
111112
112113 { /* Cody docs banner */ }
113- { /* { isCodyDocs && !isopenCtxDocs && <TopBanner
114+ { isCodyDocs && ! isopenCtxDocs && < TopBanner
114115 text = "NEW: Introducing chat and search in a single input with Sourcegraph 6.0."
115116 link = "https://sourcegraph.com/blog/combining-chat-and-search"
116117 linkText = "Read here"
117118 textColor = "#ffffff"
118119 backgroundColor = "#F34E3F"
119- />} */ }
120+ opacity = '0.75'
121+ /> }
120122
121123 { /* Openctx docs banner */ }
122124 { /* {isopenCtxDocs && <TopBanner
Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ interface TopBannerProps {
99 backgroundColor ?: string ;
1010 textColor ?: string ;
1111 linkText ?: string ;
12+ opacity ?: string ;
13+ }
14+
15+ const hexToRgb = ( hex : string ) => {
16+ hex = hex . replace ( / ^ # / , '' ) ;
17+ const r = parseInt ( hex . slice ( 0 , 2 ) , 16 ) ;
18+ const g = parseInt ( hex . slice ( 2 , 4 ) , 16 ) ;
19+ const b = parseInt ( hex . slice ( 4 , 6 ) , 16 ) ;
20+
21+ return `${ r } , ${ g } , ${ b } ` ;
1222}
1323
1424export function TopBanner ( {
@@ -17,14 +27,15 @@ export function TopBanner({
1727 backgroundColor = "#F34E3F" ,
1828 textColor = "white" ,
1929 linkText = 'new docs' ,
30+ opacity = '1'
2031} : TopBannerProps ) {
2132 const [ isVisible , setIsVisible ] = useState ( true ) ;
2233
2334 if ( ! isVisible ) return null ;
2435
2536 return (
2637 < div
27- style = { { backgroundColor, color : textColor } }
38+ style = { { backgroundColor : `rgba( ${ hexToRgb ( backgroundColor ) } , ${ opacity } )` , color : textColor } }
2839 className = "fixed top-0 z-[100] min-h-[42px] w-full flex items-center justify-center px-4 py-2 md:py-0 md:h-[42px]"
2940 >
3041 < div className = "flex items-center gap-2 text-xs sm:text-sm max-w-[90%] md:max-w-none text-center" >
You can’t perform that action at this time.
0 commit comments