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';
12
12
import { LogoMark } from './LogoMark' ;
13
13
import VersionSelector from './VersionSelector' ;
14
14
import { Search } from './search/Search' ;
15
+ import { TopBanner } from './TopBanner'
15
16
16
17
function GitHubIcon ( props : React . ComponentPropsWithoutRef < 'svg' > ) {
17
18
return (
@@ -110,13 +111,14 @@ export function Layout({children}: {children: React.ReactNode}) {
110
111
< Header />
111
112
112
113
{ /* Cody docs banner */ }
113
- { /* { isCodyDocs && !isopenCtxDocs && <TopBanner
114
+ { isCodyDocs && ! isopenCtxDocs && < TopBanner
114
115
text = "NEW: Introducing chat and search in a single input with Sourcegraph 6.0."
115
116
link = "https://sourcegraph.com/blog/combining-chat-and-search"
116
117
linkText = "Read here"
117
118
textColor = "#ffffff"
118
119
backgroundColor = "#F34E3F"
119
- />} */ }
120
+ opacity = '0.75'
121
+ /> }
120
122
121
123
{ /* Openctx docs banner */ }
122
124
{ /* {isopenCtxDocs && <TopBanner
Original file line number Diff line number Diff line change @@ -9,6 +9,16 @@ interface TopBannerProps {
9
9
backgroundColor ?: string ;
10
10
textColor ?: string ;
11
11
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 } ` ;
12
22
}
13
23
14
24
export function TopBanner ( {
@@ -17,14 +27,15 @@ export function TopBanner({
17
27
backgroundColor = "#F34E3F" ,
18
28
textColor = "white" ,
19
29
linkText = 'new docs' ,
30
+ opacity = '1'
20
31
} : TopBannerProps ) {
21
32
const [ isVisible , setIsVisible ] = useState ( true ) ;
22
33
23
34
if ( ! isVisible ) return null ;
24
35
25
36
return (
26
37
< div
27
- style = { { backgroundColor, color : textColor } }
38
+ style = { { backgroundColor : `rgba( ${ hexToRgb ( backgroundColor ) } , ${ opacity } )` , color : textColor } }
28
39
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]"
29
40
>
30
41
< 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