Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -41,6 +42,10 @@ const indexFieldsCalloutStyles = css({
marginBottom: spacing[600],
});

const indexFieldsCalloutDarkStyles = css({
border: `1px solid ${palette.gray.base}`,
});

const codeEquivalentToggleLabelStyles = css({
marginRight: spacing[100],
fontWeight: 'normal',
Expand All @@ -51,13 +56,20 @@ 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({
border: `1px solid ${palette.gray.light2}`,
background: palette.gray.light3,
});

const darkModeCoveredQueriesCalloutStyles = css({
border: `1px solid ${palette.gray.dark2}`,
background: palette.black,
});
const buttonContainerStyles = css({
display: 'flex',
justifyContent: 'right',
Expand Down Expand Up @@ -171,6 +183,7 @@ const IndexFlowSection = ({
onErrorEncountered,
onErrorCleared,
}: IndexFlowSectionProps) => {
const darkMode = useDarkMode();
const [isCodeEquivalentToggleChecked, setIsCodeEquivalentToggleChecked] =
useState(false);
const [hasFieldChanges, setHasFieldChanges] = useState(false);
Expand Down Expand Up @@ -266,7 +279,12 @@ const IndexFlowSection = ({
/>
</div>
</div>
<div className={indexFieldsCalloutStyles}>
<div
className={cx(
indexFieldsCalloutStyles,
darkMode && indexFieldsCalloutDarkStyles
)}
>
{isCodeEquivalentToggleChecked ? (
<MDBCodeViewer
dbName={dbName}
Expand Down Expand Up @@ -321,7 +339,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
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
css,
palette,
Link,
useDarkMode,
} from '@mongodb-js/compass-components';
import React from 'react';

Expand All @@ -13,18 +14,23 @@ const headerStyle = css({
paddingBottom: 0,
});

const subtitleStyle = css({
const subtitleLightStyle = css({
color: palette.gray.dark1,
});

const subtitleDarkStyle = css({
color: palette.gray.light1,
});

const CreateIndexModalHeader = () => {
const darkMode = useDarkMode();
return (
<div className={headerStyle}>
<H3 data-testid="create-index-modal-header-title">Create Index</H3>

<Body
data-testid="create-index-modal-header-subtitle"
className={subtitleStyle}
className={darkMode ? subtitleDarkStyle : subtitleLightStyle}
>
The best indexes for your application should consider a number of
factors, such as your data model, and the queries you use most often. To
Expand Down
Loading