diff --git a/client/branded/src/components/panel/TabbedPanelContent.fixtures.ts b/client/branded/src/components/panel/TabbedPanelContent.fixtures.ts index b9560854dd90..1c1a4d94fe4e 100644 --- a/client/branded/src/components/panel/TabbedPanelContent.fixtures.ts +++ b/client/branded/src/components/panel/TabbedPanelContent.fixtures.ts @@ -25,7 +25,6 @@ export const panels: Panel[] = [ export const panelProps: React.ComponentPropsWithoutRef = { repoName: 'git://github.com/foo/bar', fetchHighlightedFileLineRanges: () => of([]), - isLightTheme: true, platformContext: {} as any, settingsCascade: { subjects: null, final: null }, telemetryService: NOOP_TELEMETRY_SERVICE, diff --git a/client/branded/src/components/panel/TabbedPanelContent.tsx b/client/branded/src/components/panel/TabbedPanelContent.tsx index c474bfaa9b4c..5ac9685c3aff 100644 --- a/client/branded/src/components/panel/TabbedPanelContent.tsx +++ b/client/branded/src/components/panel/TabbedPanelContent.tsx @@ -10,7 +10,6 @@ import { FetchFileParameters } from '@sourcegraph/shared/src/backend/file' import { PlatformContextProps } from '@sourcegraph/shared/src/platform/context' import { SettingsCascadeProps } from '@sourcegraph/shared/src/settings/settings' import { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService' -import { ThemeProps } from '@sourcegraph/shared/src/theme' import { Button, useObservable, @@ -29,7 +28,7 @@ import { EmptyPanelView } from './views/EmptyPanelView' import styles from './TabbedPanelContent.module.scss' -interface TabbedPanelContentProps extends PlatformContextProps, SettingsCascadeProps, TelemetryProps, ThemeProps { +interface TabbedPanelContentProps extends PlatformContextProps, SettingsCascadeProps, TelemetryProps { repoName?: string fetchHighlightedFileLineRanges: (parameters: FetchFileParameters, force?: boolean) => Observable } diff --git a/client/branded/src/search-ui/input/CodeMirrorQueryInput.tsx b/client/branded/src/search-ui/input/CodeMirrorQueryInput.tsx index de5f24d4c016..2bf417801f15 100644 --- a/client/branded/src/search-ui/input/CodeMirrorQueryInput.tsx +++ b/client/branded/src/search-ui/input/CodeMirrorQueryInput.tsx @@ -28,7 +28,7 @@ import { Filter } from '@sourcegraph/shared/src/search/query/token' import { appendContextFilter } from '@sourcegraph/shared/src/search/query/transformer' import { fetchStreamSuggestions as defaultFetchStreamSuggestions } from '@sourcegraph/shared/src/search/suggestions' import { RecentSearch } from '@sourcegraph/shared/src/settings/temporary/recentSearches' -import { ThemeProps } from '@sourcegraph/shared/src/theme' +import { useIsLightTheme } from '@sourcegraph/shared/src/theme' import { isInputElement } from '@sourcegraph/shared/src/util/dom' import { createDefaultSuggestions, singleLine } from './codemirror' @@ -93,7 +93,6 @@ export const CodeMirrorMonacoFacade: React.FunctionComponent void // Whether comments are parsed and highlighted @@ -327,12 +325,14 @@ interface CodeMirrorQueryInputProps extends ThemeProps, SearchPatternTypeProps { * theming, syntax highlighting and token info. */ export const CodeMirrorQueryInput: React.FunctionComponent = React.memo( - ({ isLightTheme, onEditorCreated, patternType, interpretComments, value, className, extensions = EMPTY }) => { + ({ onEditorCreated, patternType, interpretComments, value, className, extensions = EMPTY }) => { // This is using state instead of a ref because `useRef` doesn't cause a // re-render when the ref is attached, but we need that so that // `useCodeMirror` is called again and the editor is actually created. // See https://reactjs.org/docs/hooks-faq.html#how-can-i-measure-a-dom-node const [container, setContainer] = useState(null) + const isLightTheme = useIsLightTheme() + const externalExtensions = useMemo(() => new Compartment(), []) const themeExtension = useMemo(() => new Compartment(), []) diff --git a/client/branded/src/search-ui/input/QueryInput.ts b/client/branded/src/search-ui/input/QueryInput.ts index ebee7199af8c..c3b559fdfa66 100644 --- a/client/branded/src/search-ui/input/QueryInput.ts +++ b/client/branded/src/search-ui/input/QueryInput.ts @@ -5,7 +5,6 @@ import { SearchPatternTypeProps, } from '@sourcegraph/shared/src/search' import { fetchStreamSuggestions as defaultFetchStreamSuggestions } from '@sourcegraph/shared/src/search/suggestions' -import { ThemeProps } from '@sourcegraph/shared/src/theme' import { IEditor } from './LazyQueryInput' @@ -13,8 +12,7 @@ import { IEditor } from './LazyQueryInput' * Props that the Monaco and CodeMirror implementation have in common. */ export interface QueryInputProps - extends ThemeProps, - Pick, + extends Pick, SearchPatternTypeProps, Pick { isSourcegraphDotCom: boolean // Needed for query suggestions to give different options on dotcom; see SOURCEGRAPH_DOT_COM_REPO_COMPLETION diff --git a/client/branded/src/search-ui/input/SearchBox.story.tsx b/client/branded/src/search-ui/input/SearchBox.story.tsx index 79e0a32adbba..26b19c630193 100644 --- a/client/branded/src/search-ui/input/SearchBox.story.tsx +++ b/client/branded/src/search-ui/input/SearchBox.story.tsx @@ -28,7 +28,6 @@ const defaultProps: SearchBoxProps = { final: null, subjects: null, }, - isLightTheme: false, globbing: false, queryState: { query: 'hello repo:test' }, isSourcegraphDotCom: false, @@ -57,40 +56,27 @@ export const SearchBoxStory: Story = () => (

Default

- +

Regexp enabled

- +

Structural enabled

- +

Case sensitivity enabled

- +

With search contexts

- +

With search contexts, user context selected

@@ -98,7 +84,6 @@ export const SearchBoxStory: Story = () => (
@@ -108,7 +93,6 @@ export const SearchBoxStory: Story = () => ( diff --git a/client/branded/src/search-ui/input/SearchBox.tsx b/client/branded/src/search-ui/input/SearchBox.tsx index f7784ae055f2..949110d178b3 100644 --- a/client/branded/src/search-ui/input/SearchBox.tsx +++ b/client/branded/src/search-ui/input/SearchBox.tsx @@ -11,7 +11,6 @@ import { fetchStreamSuggestions as defaultFetchStreamSuggestions } from '@source import { RecentSearch } from '@sourcegraph/shared/src/settings/temporary/recentSearches' import { useTemporarySetting } from '@sourcegraph/shared/src/settings/temporary/useTemporarySetting' import { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService' -import { ThemeProps } from '@sourcegraph/shared/src/theme' import { IEditor, LazyQueryInput, LazyQueryInputProps } from './LazyQueryInput' import { SearchButton } from './SearchButton' @@ -24,7 +23,6 @@ import styles from './SearchBox.module.scss' export interface SearchBoxProps extends Omit, - ThemeProps, SearchContextInputProps, TelemetryProps, PlatformContextProps<'requestGraphQL'>, @@ -185,7 +183,6 @@ export const SearchBox: FC = props => { fetchStreamSuggestions={props.fetchStreamSuggestions} globbing={props.globbing} interpretComments={props.interpretComments} - isLightTheme={props.isLightTheme} isSourcegraphDotCom={props.isSourcegraphDotCom} onChange={props.onChange} onCompletionItemSelected={props.onCompletionItemSelected} diff --git a/client/branded/src/search-ui/results/NoResultsPage.tsx b/client/branded/src/search-ui/results/NoResultsPage.tsx index baf449cd1b52..f3a233801c06 100644 --- a/client/branded/src/search-ui/results/NoResultsPage.tsx +++ b/client/branded/src/search-ui/results/NoResultsPage.tsx @@ -7,7 +7,6 @@ import { QueryState, SearchContextProps } from '@sourcegraph/shared/src/search' import { NoResultsSectionID as SectionID } from '@sourcegraph/shared/src/settings/temporary/searchSidebar' import { useTemporarySetting } from '@sourcegraph/shared/src/settings/temporary/useTemporarySetting' import { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService' -import { ThemeProps } from '@sourcegraph/shared/src/theme' import { Button, Link, Icon, H3, Text, H2 } from '@sourcegraph/wildcard' import { QueryExamples } from '../components/QueryExamples' @@ -44,7 +43,7 @@ const Container: React.FunctionComponent ) -interface NoResultsPageProps extends ThemeProps, TelemetryProps, Pick { +interface NoResultsPageProps extends TelemetryProps, Pick { isSourcegraphDotCom: boolean showSearchContext: boolean /** Available to web app through JS Context */ @@ -56,7 +55,6 @@ interface NoResultsPageProps extends ThemeProps, TelemetryProps, Pick> = ({ searchContextsEnabled, - isLightTheme, telemetryService, isSourcegraphDotCom, showSearchContext, diff --git a/client/branded/src/search-ui/results/StreamingSearchResultsList.tsx b/client/branded/src/search-ui/results/StreamingSearchResultsList.tsx index fae873247bd9..022d41ffa8ea 100644 --- a/client/branded/src/search-ui/results/StreamingSearchResultsList.tsx +++ b/client/branded/src/search-ui/results/StreamingSearchResultsList.tsx @@ -19,7 +19,6 @@ import { } from '@sourcegraph/shared/src/search/stream' import { SettingsCascadeProps } from '@sourcegraph/shared/src/settings/settings' import { TelemetryProps } from '@sourcegraph/shared/src/telemetry/telemetryService' -import { ThemeProps } from '@sourcegraph/shared/src/theme' import { CommitSearchResult } from '../components/CommitSearchResult' import { FileContentSearchResult } from '../components/FileContentSearchResult' @@ -37,8 +36,7 @@ import resultContainerStyles from '../components/ResultContainer.module.scss' import styles from './StreamingSearchResultsList.module.scss' export interface StreamingSearchResultsListProps - extends ThemeProps, - SettingsCascadeProps, + extends SettingsCascadeProps, TelemetryProps, Pick, PlatformContextProps<'requestGraphQL'> { @@ -85,7 +83,6 @@ export const StreamingSearchResultsList: React.FunctionComponent< fetchHighlightedFileLineRanges, settingsCascade, telemetryService, - isLightTheme, isSourcegraphDotCom, searchContextsEnabled, assetsRoot, @@ -287,7 +284,6 @@ export const StreamingSearchResultsList: React.FunctionComponent< JSX.Element | null) + children: JSX.Element | null | ((props: { isLightTheme: boolean }) => JSX.Element | null) }): JSX.Element | null { const darkThemeMediaList = useMemo(() => window.matchMedia('(prefers-color-scheme: dark)'), []) const [isLightTheme, setIsLightTheme] = useState(!darkThemeMediaList.matches) diff --git a/client/browser/src/browser-extension/after-install-page/AfterInstallPageContent.tsx b/client/browser/src/browser-extension/after-install-page/AfterInstallPageContent.tsx index 86df8591f56f..406905f4bf70 100644 --- a/client/browser/src/browser-extension/after-install-page/AfterInstallPageContent.tsx +++ b/client/browser/src/browser-extension/after-install-page/AfterInstallPageContent.tsx @@ -5,18 +5,18 @@ import classNames from 'classnames' import { SourcegraphLogo } from '@sourcegraph/branded/src/components/SourcegraphLogo' import { PhabricatorIcon } from '@sourcegraph/shared/src/components/icons' -import { ThemeProps } from '@sourcegraph/shared/src/theme' import { Link, Icon, Code, H1, H2, H3, Text } from '@sourcegraph/wildcard' import { getPlatformName } from '../../shared/util/context' import styles from './AfterInstallPageContent.module.scss' -const Video: React.FunctionComponent< - React.PropsWithChildren< - { name: string } & Pick, 'width' | 'height'> & ThemeProps - > -> = ({ name, isLightTheme, width, height }) => { +interface VideoProps extends Pick, 'width' | 'height'> { + name: string + isLightTheme: boolean +} + +const Video: React.FC = ({ name, isLightTheme, width, height }) => { const suffix = isLightTheme ? 'Light' : 'Dark' return (