-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backport vscode-v1.64.x] fix: added extension banner to web (#6777)
This PR introduces a banner to push users to the editor extensions, only on the web. Once dismissed, it never returns. ![CleanShot 2025-01-22 at 16 00 49@2x](https://github.com/user-attachments/assets/34cac620-8a9a-47e6-b68f-81fa51d1467d) ## Test plan Tested locally, visually. <br> Backport e099407 from #6757 Co-authored-by: Taiyab Raja <taiyab.raja@gmail.com>
- Loading branch information
1 parent
be2a19f
commit 74b5eaa
Showing
6 changed files
with
124 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
vscode/webviews/components/ExtensionPromotionalBanner.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.banner { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: space-between; | ||
padding: 0.5rem 1rem; | ||
background: var(--vscode-editor-background); | ||
border: 1px solid var(--vscode-widget-border); | ||
margin: 0 auto; | ||
border-radius: 6px; | ||
|
||
h3 { | ||
margin: 0; | ||
font-size: 0.875rem; | ||
color: var(--vscode-editor-foreground); | ||
font-weight: 500; | ||
} | ||
} | ||
|
||
.download-button { | ||
display: flex; | ||
align-items: center; | ||
padding: 0.25rem 0.75rem; | ||
font-weight: 500; | ||
background: var(--vscode-button-secondaryBackground); | ||
color: var(--vscode-editor-foreground); | ||
text-decoration: none; | ||
border-radius: 4px; | ||
height: 32px; | ||
} | ||
|
||
.download-button:hover { | ||
background: var(--vscode-button-hoverBackground); | ||
color: var(--vscode-editor-foreground); | ||
} | ||
|
||
.banner { | ||
position: relative; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import type { CodyIDE } from '@sourcegraph/cody-shared' | ||
import { useState } from 'react' | ||
import styles from './ExtensionPromotionalBanner.module.css' | ||
|
||
const BANNER_DISMISSED_KEY = 'cody-extension-banner-dismissed' | ||
|
||
export const ExtensionPromotionalBanner: React.FC<{ IDE: CodyIDE }> = ({ IDE }) => { | ||
const [isVisible, setIsVisible] = useState(() => { | ||
// Initialize state from localStorage | ||
return localStorage.getItem(BANNER_DISMISSED_KEY) !== 'true' | ||
}) | ||
const [isClosing, setIsClosing] = useState(false) | ||
|
||
const handleDismiss = () => { | ||
setIsClosing(true) | ||
// Wait for animation to complete before hiding | ||
setTimeout(() => { | ||
setIsVisible(false) | ||
// Save dismissed state to localStorage | ||
localStorage.setItem(BANNER_DISMISSED_KEY, 'true') | ||
}, 300) | ||
} | ||
|
||
if (!isVisible) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div | ||
className={`${styles.banner} ${ | ||
isClosing ? styles.slideOut : styles.slideIn | ||
} tw-flex tw-items-center tw-w-full tw-max-w-[640px] tw-mb-16 tw-mt-4 tw-shadow tw-relative`} | ||
> | ||
<div className="tw-flex tw-flex-row tw-gap-6 tw-items-start tw-py-2"> | ||
<div className="tw-flex tw-flex-col tw-max-w-[360px] tw-gap-1"> | ||
<h3>Get Sourcegraph for your favorite editor</h3> | ||
<p className="tw-leading-tight"> | ||
Download the extension to get the power of Sourcegraph right where you code | ||
</p> | ||
</div> | ||
</div> | ||
<div className="tw-flex tw-gap-8 tw-mx-4"> | ||
<div className="tw-flex tw-gap-8"> | ||
<img | ||
alt="VS Code" | ||
src="https://storage.googleapis.com/sourcegraph-assets/ideIcons/ideIconVsCode.svg" | ||
width="24" | ||
height="24" | ||
/> | ||
<img | ||
alt="All JetBrains IDEs" | ||
src="https://storage.googleapis.com/sourcegraph-assets/ideIcons/ideIconJetBrains.svg" | ||
width="24" | ||
height="24" | ||
/> | ||
</div> | ||
<a | ||
href="https://sourcegraph.com/docs/cody" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className={styles.downloadButton} | ||
> | ||
Download | ||
</a> | ||
<button | ||
className="tw-text-muted-foreground hover:tw-text-foreground" | ||
onClick={handleDismiss} | ||
aria-label="Close banner" | ||
type="button" | ||
> | ||
✕ | ||
</button> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters