Skip to content

Commit

Permalink
fix(browser-repl): use an error background color that makes syntax hi…
Browse files Browse the repository at this point in the history
…ghlighting legible COMPASS-8308 (#2307)

* fix error formatting

* more color
  • Loading branch information
djechlin-mongodb authored Dec 20, 2024
1 parent 62aebdf commit 0919d39
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/browser-repl/src/components/shell-output-line.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ const shellOutputLine = css({
});

const shellOutputLineError = css({
backgroundColor: palette.red.light2,
color: palette.red.dark3,
backgroundColor: 'inherit',
color: palette.red.light1,
});

const shellOutputLineIcon = css({
Expand Down
19 changes: 16 additions & 3 deletions packages/browser-repl/src/components/types/error-output.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { isShouldReportAsBugError } from '@mongosh/errors';
import { css, cx, palette } from '@mongodb-js/compass-components';

import { SimpleTypeOutput } from './simple-type-output';
import { Expandable } from '../utils/expandable';
Expand All @@ -10,6 +11,18 @@ interface ErrorOutputProps {
value: any;
}

const errInfoCss = css({
'&&': {
borderLeft: '3px solid',
paddingLeft: '0px',
borderColor: palette.red.light1,
},
});

const messageCss = css({
color: palette.white,
});

export class ErrorOutput extends Component<ErrorOutputProps> {
static propTypes = {
value: PropTypes.any,
Expand All @@ -30,7 +43,7 @@ export class ErrorOutput extends Component<ErrorOutputProps> {
>
{formattedName || 'Error'}:
</a>{' '}
{message}
<span className={messageCss}>{message}</span>
</pre>
</div>
);
Expand Down Expand Up @@ -87,11 +100,11 @@ export class ErrorOutput extends Component<ErrorOutputProps> {
return (
<div>
{this.renderCollapsed(toggle)}
<div>
<div className={messageCss}>
{this.formatErrorBugReportInfo()}
{this.formatErrorInfo()}
{this.formatErrorResult()}
<pre>{this.formatStack()}</pre>
<pre className={errInfoCss}>{this.formatStack()}</pre>
</div>
</div>
);
Expand Down

0 comments on commit 0919d39

Please sign in to comment.