Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit e7a9c17

Browse files
committed
fix theming for github.com
Uses the latest CSS classes that GitHub.com uses, which fixes the theming.
1 parent cc0d8af commit e7a9c17

File tree

6 files changed

+51
-45
lines changed

6 files changed

+51
-45
lines changed

client/browser/src/shared/code-hosts/github/codeHost.module.scss

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
:root {
44
// Map out CSS variables to the theme-aware GitHub ones
55
// Latest variable, backwards compat (GitHub Enterprise) fallback, last-resort fallback to Sourcegraph color (in case GitHub changes its variables again)
6-
--body-bg: var(--color-canvas-default, var(--color-bg-canvas, var(--white)));
7-
--border-color: var(--color-border-default, var(--color-border-primary, var(--secondary)));
6+
--body-bg: var(--bgColor-default, var(--color-canvas-default, var(--color-bg-canvas, var(--white))));
7+
--border-color: var(--borderColor-default, var(--color-border-default, var(--color-border-primary, var(--secondary))));
88
--secondary: var(--color-btn-bg, var(--color-auto-gray-2), var(--gray-06));
99
}
1010

@@ -18,19 +18,12 @@
1818
}
1919
}
2020

21-
.action-item {
22-
/* Match GitHub's button height even if button only contains icon
23-
* (no text that would push the height) */
24-
height: 28px;
25-
}
26-
2721
.icon {
2822
height: 16px;
2923
width: 16px;
3024
}
3125

3226
.code-view-toolbar {
33-
margin-bottom: -4px;
3427
text-align: right;
3528
}
3629

@@ -44,7 +37,6 @@
4437
.code-view-toolbar-item {
4538
/* The space provides enough margin */
4639
margin-left: 0 !important;
47-
margin-bottom: 4px;
4840
}
4941

5042
.hover-overlay-badge {

client/browser/src/shared/code-hosts/github/codeHost.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ import type { ViewResolver } from '../shared/views'
3232
import { diffDomFunctions, searchCodeSnippetDOMFunctions, singleFileDOMFunctions } from './domFunctions'
3333
import { resolveDiffFileInfo, resolveFileInfo, resolveSnippetFileInfo } from './fileInfo'
3434
import {
35+
getEmbeddedData,
3536
getFileContainers,
36-
parseURL,
3737
getSelectorFor,
3838
isNewGitHubUI,
39-
getEmbeddedData,
39+
parseURL,
4040
windowLocation__testingOnly,
4141
} from './util'
4242

@@ -725,14 +725,14 @@ export const githubCodeHost: GithubCodeHost = {
725725
}),
726726
getViewContextOnSourcegraphMount: createOpenOnSourcegraphIfNotExists,
727727
viewOnSourcegraphButtonClassProps: {
728-
className: 'btn btn-sm tooltipped tooltipped-s',
728+
className: 'Button Button--iconOnly Button--secondary Button--medium AppHeader-button',
729729
iconClassName,
730730
},
731731
check: checkIsGitHub,
732732
codeViewToolbarClassProps: {
733733
className: styles.codeViewToolbar,
734734
listItemClass: classNames(styles.codeViewToolbarItem, 'BtnGroup'),
735-
actionItemClass: classNames('btn btn-sm tooltipped tooltipped-s BtnGroup-item', styles.actionItem),
735+
actionItemClass: 'Button Button--iconOnly Button--secondary Button--medium',
736736
actionItemPressedClass: 'selected',
737737
actionItemIconClass: classNames(styles.icon, 'v-align-text-bottom'),
738738
},
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
.hover-overlay {
22
isolation: isolate;
33
z-index: 2000 !important;
4+
min-width: 20rem !important;
5+
}
6+
7+
.badge-hidden {
8+
display: none !important;
49
}

client/browser/src/shared/code-hosts/shared/codeHost.tsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ import type { Renderer } from 'react-dom'
77
import { createRoot } from 'react-dom/client'
88
import {
99
asyncScheduler,
10+
BehaviorSubject,
1011
combineLatest,
12+
concat,
1113
EMPTY,
1214
from,
15+
fromEvent,
16+
lastValueFrom,
1317
type Observable,
1418
of,
1519
Subject,
1620
Subscription,
17-
type Unsubscribable,
18-
concat,
19-
BehaviorSubject,
20-
fromEvent,
21-
lastValueFrom,
2221
throwError,
22+
type Unsubscribable,
2323
} from 'rxjs'
2424
import {
2525
catchError,
2626
concatAll,
2727
concatMap,
28+
distinctUntilChanged,
2829
filter,
2930
map,
3031
mergeMap,
3132
observeOn,
32-
switchMap,
33-
withLatestFrom,
34-
tap,
35-
startWith,
36-
distinctUntilChanged,
3733
retry,
34+
startWith,
35+
switchMap,
3836
take,
37+
tap,
38+
withLatestFrom,
3939
} from 'rxjs/operators'
4040

4141
import type { HoverMerged } from '@sourcegraph/client-api'
@@ -51,11 +51,11 @@ import {
5151
asError,
5252
asObservable,
5353
isDefined,
54+
isExternalLink,
5455
isInstanceOf,
56+
type LineOrPositionOrRange,
5557
property,
5658
registerHighlightContributions,
57-
isExternalLink,
58-
type LineOrPositionOrRange,
5959
} from '@sourcegraph/common'
6060
import type { WorkspaceRoot } from '@sourcegraph/extension-api-types'
6161
import { gql, isHTTPAuthError } from '@sourcegraph/http-client'
@@ -72,18 +72,18 @@ import {
7272
} from '@sourcegraph/shared/src/hover/HoverOverlay'
7373
import { getModeFromPath } from '@sourcegraph/shared/src/languages'
7474
import type { PlatformContext, URLToFileContext } from '@sourcegraph/shared/src/platform/context'
75-
import { TelemetryV2Props } from '@sourcegraph/shared/src/telemetry'
75+
import { type TelemetryV2Props } from '@sourcegraph/shared/src/telemetry'
7676
import type { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService'
7777
import { createURLWithUTM } from '@sourcegraph/shared/src/tracking/utm'
7878
import {
7979
type FileSpec,
80-
type UIPositionSpec,
80+
makeRepoGitURI,
8181
type RawRepoSpec,
8282
type RepoSpec,
8383
type ResolvedRevisionSpec,
8484
type RevisionSpec,
85+
type UIPositionSpec,
8586
type ViewStateSpec,
86-
makeRepoGitURI,
8787
} from '@sourcegraph/shared/src/util/url'
8888

8989
import { background } from '../../../browser-extension/web-extension-api/runtime'
@@ -95,8 +95,8 @@ import { CodeViewToolbar, type CodeViewToolbarClassProps } from '../../component
9595
import { TrackAnchorClick } from '../../components/TrackAnchorClick'
9696
import { WildcardThemeProvider } from '../../components/WildcardThemeProvider'
9797
import { isExtension, isInPage } from '../../context'
98-
import type { SourcegraphIntegrationURLs, BrowserPlatformContext } from '../../platform/context'
99-
import { resolveRevision, retryWhenCloneInProgressError, resolvePrivateRepo } from '../../repo/backend'
98+
import type { BrowserPlatformContext, SourcegraphIntegrationURLs } from '../../platform/context'
99+
import { resolvePrivateRepo, resolveRevision, retryWhenCloneInProgressError } from '../../repo/backend'
100100
import { ConditionalTelemetryRecorderProvider } from '../../telemetry'
101101
import { ConditionalTelemetryService, EventLogger } from '../../tracking/eventLogger'
102102
import { DEFAULT_SOURCEGRAPH_URL, getPlatformName, isDefaultSourcegraphUrl } from '../../util/context'
@@ -109,16 +109,16 @@ import { type GithubCodeHost, githubCodeHost, isGithubCodeHost } from '../github
109109
import { gitlabCodeHost } from '../gitlab/codeHost'
110110
import { phabricatorCodeHost } from '../phabricator/codeHost'
111111

112-
import { type CodeView, trackCodeViews, fetchFileContentForDiffOrFileInfo } from './codeViews'
112+
import { type CodeView, fetchFileContentForDiffOrFileInfo, trackCodeViews } from './codeViews'
113113
import { NotAuthenticatedError, RepoURLParseError } from './errors'
114114
import { initializeExtensions } from './extensions'
115115
import { SignInButton } from './SignInButton'
116-
import { resolveRepoNamesForDiffOrFileInfo, defaultRevisionToCommitID } from './util/fileInfo'
116+
import { defaultRevisionToCommitID, resolveRepoNamesForDiffOrFileInfo } from './util/fileInfo'
117117
import { lprToSelectionsZeroIndexed } from './util/selections'
118118
import {
119-
type ViewOnSourcegraphButtonClassProps,
120-
ViewOnSourcegraphButton,
121119
ConfigureSourcegraphButton,
120+
ViewOnSourcegraphButton,
121+
type ViewOnSourcegraphButtonClassProps,
122122
} from './ViewOnSourcegraphButton'
123123
import { delayUntilIntersecting, trackViews, type ViewResolver } from './views'
124124

@@ -227,7 +227,6 @@ export interface CodeHost {
227227

228228
/**
229229
* Construct the URL to the specified file.
230-
*
231230
* @param sourcegraphURL The URL of the Sourcegraph instance.
232231
* @param target The target to build a URL for.
233232
* @param context Context information about this invocation.
@@ -474,6 +473,7 @@ function initCodeIntelligence({
474473
<HoverOverlay
475474
{...this.state.hoverOverlayProps}
476475
{...codeHost.hoverOverlayClassProps}
476+
badgeClassName={styles.badgeHidden} // hide badges in browser ext
477477
className={classNames(styles.hoverOverlay, codeHost.hoverOverlayClassProps?.className)}
478478
telemetryService={telemetryService}
479479
telemetryRecorder={telemetryRecorder}
@@ -748,7 +748,7 @@ export async function handleCodeHost({
748748
* active Sourcegraph URL.
749749
* 2. It is a repository not added to the Sourcegraph instance (other than Cloud).
750750
* If the current state is `true`, we can short circuit subsequent requests.
751-
* */
751+
*/
752752
const repoSyncErrors = new BehaviorSubject<boolean>(false)
753753
// Set by `ViewOnSourcegraphButton` (cleans up and sets to `false` whenever it is unmounted).
754754
const setRepoSyncError = repoSyncErrors.next.bind(repoSyncErrors)
@@ -759,7 +759,7 @@ export async function handleCodeHost({
759759
* - repository is not added to other than Cloud Sourcegraph instance.
760760
*
761761
* (no side effects, doesn't notify `repoSyncErrors`)
762-
* */
762+
*/
763763
const checkRepoSyncError = async (error: any): Promise<boolean> =>
764764
isRepoNotFoundErrorLike(error) &&
765765
(isDefaultSourcegraphUrl(sourcegraphURL) ? !!(await codeHost.getContext?.())?.privateRepository : true)

client/browser/src/shared/platform/inlineExtensionsService.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,22 @@ export function getInlineExtensions(assetsURL: string): Observable<ExecutableExt
5151
promises.push(
5252
fetch(manifestURL)
5353
.then(response => checkOk(response).json())
54-
.then(
55-
(manifest: ExtensionManifest): ExecutableExtension => ({
54+
.then((manifest: ExtensionManifest): ExecutableExtension => {
55+
// HACK(sqs): Remove the not-super-useful "Find implementations" action.
56+
try {
57+
if (manifest.contributes?.actions) {
58+
manifest.contributes.actions = []
59+
}
60+
} catch {
61+
/* noop */
62+
}
63+
64+
return {
5665
id: extensionID,
5766
manifest,
5867
scriptURL,
59-
})
60-
)
68+
}
69+
})
6170
)
6271
}
6372

client/build-config/src/esbuild/stylePlugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs'
22
import path from 'path'
33

4-
import { ResolverFactory, CachedInputFileSystem } from 'enhanced-resolve'
4+
import { CachedInputFileSystem, ResolverFactory } from 'enhanced-resolve'
55
import type esbuild from 'esbuild'
66
import postcss from 'postcss'
77
import postcssModules from 'postcss-modules'
@@ -27,7 +27,7 @@ export const stylePlugin: esbuild.Plugin = {
2727

2828
const modulesMap = new Map<string, string>()
2929
const modulesPlugin = postcssModules({
30-
generateScopedName: '[name]__[local]', // omit hash for local dev
30+
generateScopedName: '[name]__[local]___[hash:base64:5]',
3131
localsConvention: 'camelCase',
3232
getJSON: (cssPath, json) => modulesMap.set(cssPath, JSON.stringify(json)),
3333
})
@@ -46,7 +46,7 @@ export const stylePlugin: esbuild.Plugin = {
4646
const isSCSS = inputPath.endsWith('.scss')
4747
const sassResult = isSCSS
4848
? // renderSync is ~20% faster than render with an async callback (because it's blocked on CPU, not IO).
49-
// eslint-disable-next-line no-sync
49+
5050
sass.renderSync({
5151
file: inputPath,
5252
data: inputContents,

0 commit comments

Comments
 (0)