diff --git a/.prettierignore b/.prettierignore
index ee1f78a973c..6fc95863968 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -21,10 +21,11 @@ testdata
doc/
**/.cache
**/__snapshots__
-**/*.html
+**/__fixtures__
client/contrib/GH2SG.bookmarklet.js
docker-images/grafana/jsonnet/*.json
docker-images/grafana/grafonnet-lib/
docker-images/grafana/config/provisioning/dashboards/sourcegraph/
storybook-static/
+browser/code-intel-extensions/
!/.storybook/**
diff --git a/client/branded/src/global-styles/background.scss b/client/branded/src/global-styles/background.scss
new file mode 100644
index 00000000000..0693e661715
--- /dev/null
+++ b/client/branded/src/global-styles/background.scss
@@ -0,0 +1,7 @@
+// Extend Bootstrap's bg-* utilities with classes for our grey/blueish theme-aware background colors.
+
+@for $number from 1 through 3 {
+ .bg-#{$number} {
+ background: var(--color-bg-#{$number});
+ }
+}
diff --git a/client/branded/src/global-styles/colors.scss b/client/branded/src/global-styles/colors.scss
index 22f0795e20e..410a34d8a57 100644
--- a/client/branded/src/global-styles/colors.scss
+++ b/client/branded/src/global-styles/colors.scss
@@ -118,6 +118,8 @@ $body-bg-color-dark: #04070e;
--body-color: #{$body-color-light};
--body-bg: #{$body-bg-color-light};
--color-bg-1: #{$color-light-bg-1};
+ --color-bg-2: #{$color-light-bg-2};
+ --color-bg-3: #{$color-light-bg-3};
--text-muted: #{$color-light-text-2};
--link-color: #{$gray-13};
--link-active-color: #{$gray-18};
@@ -132,6 +134,8 @@ $body-bg-color-dark: #04070e;
--body-color: #{$body-color-dark};
--body-bg: #{$body-bg-color-dark};
--color-bg-1: #{$color-bg-1};
+ --color-bg-2: #{$color-bg-2};
+ --color-bg-3: #{$color-bg-3};
--text-muted: #{$color-text-1};
--link-color: #{$gray-07};
--link-active-color: #{$gray-02};
diff --git a/client/branded/src/global-styles/index.scss b/client/branded/src/global-styles/index.scss
index 3bc6cb70534..37ac8a5fe83 100644
--- a/client/branded/src/global-styles/index.scss
+++ b/client/branded/src/global-styles/index.scss
@@ -133,6 +133,7 @@ $code-bg: var(--body-bg);
@import 'bootstrap/scss/tooltip';
@import 'bootstrap/scss/transitions';
@import '../../../shared/src/global-styles/icons';
+@import './background';
@import './badge';
@import './card';
@import './dropdown';
diff --git a/client/branded/src/global-styles/web-content.scss b/client/branded/src/global-styles/web-content.scss
index 08ae1af9a0e..70dc0938bf9 100644
--- a/client/branded/src/global-styles/web-content.scss
+++ b/client/branded/src/global-styles/web-content.scss
@@ -50,12 +50,6 @@
}
}
- strong {
- .theme-dark & {
- color: $gray-11;
- }
- }
-
.search-keyword {
color: #329af0;
diff --git a/client/browser/config/webpack/base.config.ts b/client/browser/config/webpack/base.config.ts
index 2c154ea13e6..87be65f62e6 100644
--- a/client/browser/config/webpack/base.config.ts
+++ b/client/browser/config/webpack/base.config.ts
@@ -29,8 +29,9 @@ const config: webpack.Configuration = {
backgroundEntry,
'../../src/browser-extension/scripts/backgroundPage.main.ts'
),
- options: buildEntry(extensionEntry, optionsEntry, '../../src/browser-extension/scripts/optionsPage.main.tsx'),
inject: buildEntry(extensionEntry, contentEntry, '../../src/browser-extension/scripts/contentPage.main.ts'),
+ options: buildEntry(extensionEntry, optionsEntry, '../../src/browser-extension/scripts/optionsPage.main.tsx'),
+ 'after-install': path.resolve(__dirname, '../../src/browser-extension/scripts/afterInstallPage.main.tsx'),
// Common native integration entry point (Gitlab, Bitbucket)
integration: buildEntry(pageEntry, '../../src/native-integration/integration.main.ts'),
@@ -39,7 +40,7 @@ const config: webpack.Configuration = {
// Styles
style: path.join(__dirname, '../../src/app.scss'),
- 'options-style': path.join(__dirname, '../../src/options.scss'),
+ 'branded-style': path.join(__dirname, '../../src/branded.scss'),
},
output: {
path: path.join(__dirname, '../../build/dist/js'),
diff --git a/client/browser/package.json b/client/browser/package.json
index 399b895b619..45ac5e4953d 100644
--- a/client/browser/package.json
+++ b/client/browser/package.json
@@ -43,6 +43,9 @@
},
{
"path": "./build/dist/css/style.bundle.css"
+ },
+ {
+ "path": "./build/dist/css/branded-style.bundle.css"
}
]
}
diff --git a/client/browser/scripts/tasks.ts b/client/browser/scripts/tasks.ts
index a9ebee65ea6..9b739c9a3fe 100644
--- a/client/browser/scripts/tasks.ts
+++ b/client/browser/scripts/tasks.ts
@@ -62,16 +62,10 @@ export function copyAssets(): void {
function copyExtensionAssets(toDirectory: string): void {
shelljs.mkdir('-p', `${toDirectory}/js`, `${toDirectory}/css`, `${toDirectory}/img`)
- shelljs.cp('build/dist/js/background.bundle.js', `${toDirectory}/js`)
- shelljs.cp('build/dist/js/inject.bundle.js', `${toDirectory}/js`)
- shelljs.cp('build/dist/js/options.bundle.js', `${toDirectory}/js`)
- shelljs.cp('build/dist/js/extensionHostWorker.bundle.js', `${toDirectory}/js`)
- shelljs.cp('build/dist/css/style.bundle.css', `${toDirectory}/css`)
- shelljs.cp('build/dist/css/options-style.bundle.css', `${toDirectory}/css`)
- shelljs.cp('build/dist/css/options-style.bundle.css', `${toDirectory}/css`)
+ shelljs.cp('build/dist/js/*.bundle.js', `${toDirectory}/js`)
+ shelljs.cp('build/dist/css/*.bundle.css', `${toDirectory}/css`)
shelljs.cp('-R', 'build/dist/img/*', `${toDirectory}/img`)
- shelljs.cp('build/dist/background.html', toDirectory)
- shelljs.cp('build/dist/options.html', toDirectory)
+ shelljs.cp('build/dist/*.html', toDirectory)
}
/**
diff --git a/client/browser/src/branded.scss b/client/browser/src/branded.scss
new file mode 100644
index 00000000000..01033603fac
--- /dev/null
+++ b/client/browser/src/branded.scss
@@ -0,0 +1,7 @@
+// CSS entry point for branded contexts (options menu and after-install page)
+// Bootstrap etc can be used freely here (in opposite to the content page styles in app.scss)
+
+@import '../../branded/src/global-styles/index.scss';
+@import '../../branded/src/components/Toggle';
+@import './browser-extension/options-page/OptionsContainer';
+@import './browser-extension/after-install-page/AfterInstallPageContent';
diff --git a/client/browser/src/browser-extension/ThemeWrapper.tsx b/client/browser/src/browser-extension/ThemeWrapper.tsx
new file mode 100644
index 00000000000..2c1447b858b
--- /dev/null
+++ b/client/browser/src/browser-extension/ThemeWrapper.tsx
@@ -0,0 +1,25 @@
+import React, { useEffect, useMemo, useState } from 'react'
+import { ThemeProps } from '../../../shared/src/theme'
+
+/**
+ * Wrapper for the browser extension that listens to changes of the OS theme.
+ */
+export function ThemeWrapper({
+ children: Children,
+}: {
+ children: (props: ThemeProps) => JSX.Element | null
+}): JSX.Element | null {
+ const darkThemeMediaList = useMemo(() => window.matchMedia('(prefers-color-scheme: dark)'), [])
+ const [isLightTheme, setIsLightTheme] = useState(!darkThemeMediaList.matches)
+
+ useEffect(() => {
+ darkThemeMediaList.addListener(event => setIsLightTheme(!event.matches))
+ }, [darkThemeMediaList])
+
+ useEffect(() => {
+ document.body.classList.toggle('theme-light', isLightTheme)
+ document.body.classList.toggle('theme-dark', !isLightTheme)
+ }, [isLightTheme])
+
+ return
We’ve gathered the most important information that will get your started:
++ Sourcegraph browser extension adds code intelligence to files and diffs on GitHub, GitHub + Enterprise, GitLab, Phabricator, and Bitbucket Server. +
+ {/* Video placeholder */} +
+ Type src
+ space in the address bar of your browser to search for queries on Sourcegraph.
+
+
Your extension needs explicit permissions to your code host:
++ Grant permissions +{' '} + button. +
+ Allow +{' '} + in the permissions request popup. +
By default, the browser extension works only for public code.
++ To use the browser extension with your private repositories, you need to set up a{' '} + private Sourcegraph instance and connect the extension to it. +
+Follow these instructions:
+https://sourcegraph.example.com). +
+ Read the{' '} + + Sourcegraph Documentation + {' '} + to learn more about how we respect your privacy, troubleshooting and extension features. +
+