Skip to content

Commit bace307

Browse files
authored
Updated banner opacity (#1195)
<!-- Explain the changes introduced in your PR --> ## Pull Request approval You will need to get your PR approved by at least one member of the Sourcegraph team. For reviews of docs formatting, styles, and component usage, please tag the docs team via the #docs Slack channel.
1 parent 1873707 commit bace307

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/components/Layout.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {useEffect, useState} from 'react';
1212
import {LogoMark} from './LogoMark';
1313
import VersionSelector from './VersionSelector';
1414
import {Search} from './search/Search';
15+
import {TopBanner} from './TopBanner'
1516

1617
function 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

src/components/TopBanner.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff 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

1424
export 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">

0 commit comments

Comments
 (0)