Skip to content

Commit d183cb7

Browse files
authored
Terminal: convert object to dot notation (codesandbox#3582)
1 parent fb28303 commit d183cb7

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

packages/app/src/app/components/Preview/DevTools/Terminal/Shell/Term.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import * as fit from 'xterm/lib/addons/fit/fit';
55

66
import ResizeObserver from 'resize-observer-polyfill';
77

8-
import getTerminalTheme, { VSTheme } from '../terminal-theme';
8+
import getTerminalTheme, {
9+
VSTheme,
10+
flattenTerminalTheme,
11+
} from '../terminal-theme';
912
import { TerminalWithFit } from '../types';
1013

1114
type Props = {
@@ -23,9 +26,14 @@ export class TerminalComponentNoTheme extends React.PureComponent<Props> {
2326
observer: ResizeObserver;
2427

2528
startTerminal = () => {
29+
let theme = this.props.theme;
30+
// @ts-ignore ignore because it shouldnt exist :)
31+
if (this.props.theme.vscodeTheme.colors.terminal) {
32+
theme = flattenTerminalTheme(theme);
33+
}
2634
// @ts-ignore
2735
this.term = new Terminal({
28-
theme: getTerminalTheme(this.props.theme),
36+
theme: getTerminalTheme(theme),
2937
fontFamily: 'Source Code Pro',
3038
fontWeight: 'normal',
3139
fontWeightBold: 'bold',

packages/app/src/app/components/Preview/DevTools/Terminal/terminal-theme.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { ITheme } from 'xterm';
2+
import dot from 'dot-object';
23

34
export type VSTheme = {
45
background2: () => void;
@@ -56,3 +57,11 @@ export default function getTerminalTheme(theme: VSTheme): ITheme {
5657
cursorAccent: theme.vscodeTheme.colors['terminalCursor.background'],
5758
};
5859
}
60+
61+
export const flattenTerminalTheme = theme => ({
62+
...theme,
63+
vscodeTheme: {
64+
...theme.vscodeTheme,
65+
colors: dot.dot(theme.vscodeTheme.colors),
66+
},
67+
});

packages/common/src/themes/codesandbox-black.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ const colors = {
250250
unfocusedInactiveForeground: tokens.grays[400],
251251
},
252252
terminal: {
253-
background: tokens.grays[900],
253+
background: tokens.grays[700],
254254
foreground: tokens.white,
255255
ansiBrightBlack: tokens.blues[700],
256256
ansiBrightRed: tokens.reds[500],

0 commit comments

Comments
 (0)