Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
fontFamilies,
InfoSprinkle,
Tooltip,
useDarkMode,
} from '@mongodb-js/compass-components';
import React, { useState, useCallback, useEffect } from 'react';
import {
Expand Down Expand Up @@ -52,12 +53,18 @@ const coveredQueriesHeaderContainerStyles = css({

const coveredQueriesCalloutStyles = css({
border: `1px solid ${palette.gray.light2}`,
background: palette.gray.light3,
borderRadius: '12px',
padding: spacing[600],
marginBottom: spacing[600],
});

const lightModeCoveredQueriesCalloutStyles = css({
background: palette.gray.light3,
});

const darkModeCoveredQueriesCalloutStyles = css({
background: palette.black,
});
const buttonContainerStyles = css({
display: 'flex',
justifyContent: 'right',
Expand Down Expand Up @@ -171,6 +178,7 @@ const IndexFlowSection = ({
onErrorEncountered,
onErrorCleared,
}: IndexFlowSectionProps) => {
const darkMode = useDarkMode();
const [isCodeEquivalentToggleChecked, setIsCodeEquivalentToggleChecked] =
useState(false);
const [hasFieldChanges, setHasFieldChanges] = useState(false);
Expand Down Expand Up @@ -321,7 +329,14 @@ const IndexFlowSection = ({
</InfoSprinkle>
</div>

<div className={coveredQueriesCalloutStyles}>
<div
className={cx(
coveredQueriesCalloutStyles,
darkMode
? darkModeCoveredQueriesCalloutStyles
: lightModeCoveredQueriesCalloutStyles
)}
>
{/* Covered Queries */}
<Body
className={codeStyles}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
cx,
useFocusRing,
ParagraphSkeleton,
useDarkMode,
} from '@mongodb-js/compass-components';
import type { Document } from 'mongodb';
import React, { useMemo, useCallback } from 'react';
Expand Down Expand Up @@ -62,7 +63,6 @@ const codeEditorContainerStyles = css({
const codeEditorStyles = css({
borderRadius: editorContainerRadius,
'& .cm-editor': {
background: `${palette.white} !important`,
borderRadius: editorContainerRadius,
},
'& .cm-content': {
Expand All @@ -71,12 +71,21 @@ const codeEditorStyles = css({
},
});

const lightModeCodeEditorStyles = css({
'& .cm-editor': {
background: `${palette.white} !important`,
},
});

const indexSuggestionsLoaderStyles = css({
marginBottom: spacing[600],
padding: spacing[600],
borderRadius: editorContainerRadius,
});

const indexSuggestionsLoaderLightStyles = css({
background: palette.gray.light3,
border: `1px solid ${palette.gray.light2}`,
borderRadius: editorContainerRadius,
});

const insightStyles = css({
Expand Down Expand Up @@ -111,6 +120,7 @@ const QueryFlowSection = ({
initialQuery: Document | null;
}) => {
const track = useTelemetry();
const darkMode = useDarkMode();
const [inputQuery, setInputQuery] = React.useState(
initialQuery ? JSON.stringify(initialQuery, null, 2) : ''
);
Expand Down Expand Up @@ -205,7 +215,10 @@ const QueryFlowSection = ({
onChangeText={(text) => handleQueryInputChange(text)}
placeholder="Type a query: { field: 'value' }"
completer={completer}
className={codeEditorStyles}
className={cx(
codeEditorStyles,
!darkMode && lightModeCodeEditorStyles
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, i found it easier to default to the component's existing dark mode styles rather than apply new dark mode styling

)}
/>
</div>

Expand All @@ -230,7 +243,10 @@ const QueryFlowSection = ({
{isFetchingIndexSuggestions ? (
<ParagraphSkeleton
data-testid="query-flow-section-code-loader"
className={indexSuggestionsLoaderStyles}
className={cx(
indexSuggestionsLoaderStyles,
!darkMode && indexSuggestionsLoaderLightStyles
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

)}
/>
) : (
indexSuggestions && (
Expand Down
Loading