Skip to content

Commit e563a2c

Browse files
SaraVieiraCompuIves
authored andcommitted
fix readability issues with white themes (codesandbox#1706)
* fix readibility issues with white themes * fix github * remove duplicate * revert terminal changes * fix icons * fix flicker * fix lint * Update packages/app/src/app/pages/Sandbox/Editor/utils/get-vscode-theme.js Co-Authored-By: SaraVieira <[email protected]> * Update packages/app/src/app/pages/Sandbox/Editor/utils/get-vscode-theme.js Co-Authored-By: SaraVieira <[email protected]>
1 parent eea4e56 commit e563a2c

File tree

10 files changed

+34
-15
lines changed

10 files changed

+34
-15
lines changed

packages/app/src/app/components/Alert/elements.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const Title = styled.div`
1313
justify-content: center;
1414
font-weight: 500;
1515
font-size: 1.125rem;
16-
color: rgba(255, 255, 255, 0.9);
1716
margin-top: 0 !important;
1817
margin-bottom: 1rem;
1918
text-transform: uppercase;

packages/app/src/app/components/Alert/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import React from 'react';
33
import { Button } from '@codesandbox/common/lib/components/Button';
44
import { Container, Title, Text, Buttons } from './elements';
55

6-
function Alert({ title, body, onCancel, onDelete }) {
6+
function Alert({ title, body, onCancel, onDelete, ...props }) {
77
return (
8-
<Container>
8+
<Container {...props}>
99
<Title>{title}</Title>
1010
<Text>{body}</Text>
1111
<Buttons>

packages/app/src/app/components/CodeEditor/VSCode/Configuration/elements.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import styled, { css } from 'styled-components';
22

33
export const Container = styled.div`
44
padding: 1rem;
5-
color: rgba(255, 255, 255, 0.8);
5+
color: ${props => props.theme['sideBar.foreground'] || 'inherit'};
66
box-sizing: border-box;
77
max-height: 100%;
88
overflow: auto;
@@ -12,7 +12,7 @@ export const Title = styled.h1`
1212
display: inline-block;
1313
font-weight: 600;
1414
font-size: 1.25rem;
15-
color: rgba(255, 255, 255, 0.8);
15+
color: ${props => props.theme['sideBar.foreground'] || 'inherit'};
1616
text-transform: uppercase;
1717
margin-top: 0;
1818
margin-bottom: 0;
@@ -23,7 +23,5 @@ export const Title = styled.h1`
2323
export const Description = styled.p`
2424
font-size: 1;
2525
line-height: 1.4;
26-
27-
color: ${props =>
28-
props.theme.light ? 'rgba(0, 0, 0, 0.7)' : 'rgba(255, 255, 255, 0.7)'};
26+
color: ${props => props.theme['sideBar.foreground'] || 'inherit'};
2927
`;

packages/app/src/app/components/CodeEditor/VSCode/MonacoReactComponent.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ class MonacoEditor extends React.PureComponent {
8585
r('vs/platform/instantiation/common/instantiation'),
8686
];
8787

88-
document.getElementById('root').className += ' monaco-shell vs-dark';
89-
9088
const container = document.createElement('div');
9189
const part = document.createElement('div');
9290
container.appendChild(part);
@@ -174,6 +172,7 @@ class MonacoEditor extends React.PureComponent {
174172

175173
// After initializing monaco editor
176174
this.editorDidMount(editorApi, context.monaco);
175+
document.getElementById('root').className += ` monaco-shell`;
177176
});
178177
}
179178
);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ type XTermTheme = {
5353
export default function getTerminalTheme(theme: VSTheme): XTermTheme {
5454
return {
5555
background:
56-
theme.vscodeTheme.colors['panel.background'] || theme.background2(),
56+
theme.vscodeTheme.colors['terminal.background'] || theme.background2(),
5757
black: theme.vscodeTheme.colors['terminal.ansiBlack'],
5858
blue: theme.vscodeTheme.colors['terminal.ansiBlue'],
5959
brightBlack: theme.vscodeTheme.colors['terminal.ansiBrightBlack'],
@@ -74,5 +74,7 @@ export default function getTerminalTheme(theme: VSTheme): XTermTheme {
7474
white: theme.vscodeTheme.colors['terminal.ansiWhite'],
7575
yellow: theme.vscodeTheme.colors['terminal.ansiYellow'],
7676
selection: theme.vscodeTheme.colors['terminal.selectionBackground'],
77+
cursor: theme.vscodeTheme.colors['terminalCursor.foreground'],
78+
cursorAccent: theme.vscodeTheme.colors['terminalCursor.background'],
7779
};
7880
}

packages/app/src/app/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
height="0" width="0" style="display:none;visibility:hidden"></iframe>
8383
</noscript>
8484
<!-- End Google Tag Manager (noscript) -->
85-
<div class="vs-dark" id="root">
85+
<div id="root">
8686
</div>
8787
</body>
8888
</html>

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,14 @@ class DirectoryEntry extends React.Component {
311311
width={400}
312312
>
313313
<Alert
314+
css={`
315+
background-color: ${props =>
316+
props.theme['sideBar.background'] || 'auto'};
317+
color: ${props =>
318+
props.theme.light
319+
? 'rgba(0,0,0,0.9)'
320+
: 'rgba(255,255,255,0.9)'};
321+
`}
314322
title="Delete File"
315323
body={
316324
<span>

packages/app/src/app/pages/Sandbox/Editor/Workspace/Git/Changes/elements.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const Entry = styled(EntryContainer)`
1111
display: flex;
1212
align-items: center;
1313
line-height: 1;
14-
14+
color: ${props => props.theme.vscodeTheme.colors['editor.foreground']};
1515
${({ hideColor }) =>
1616
hideColor &&
1717
css`

packages/app/src/app/pages/Sandbox/Editor/utils/get-vscode-theme.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,22 @@ const findTheme = async (themeName, customTheme) => {
9797
};
9898
};
9999

100+
const classnames = {
101+
dark: 'vs-dark',
102+
light: 'vs',
103+
hc: 'hc-black',
104+
};
105+
100106
export default async function getTheme(themeName, customTheme) {
101107
const foundTheme = await findTheme(themeName, customTheme);
102108
// Explicitly check for dark as that is the default
103109
const isLight = foundTheme.type !== 'dark' && foundTheme.type !== 'hc';
110+
// We need to set this so VSCode knows that the last known theme is the right one. This prevents
111+
// flickering for light themes.
112+
document.body.classList.remove('vs');
113+
document.body.classList.remove('vs-dark');
114+
document.body.classList.remove('hc-black');
115+
document.body.classList.add(classnames[foundTheme.type] || 'vs');
104116

105117
const colors = {
106118
...(isLight ? vs : vsDark),

packages/common/src/templates/configuration/elements.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,16 @@ export const ConfigName = styled.span`
2525
flex: 1;
2626
font-weight: 400;
2727
28-
color: rgba(255, 255, 255, 0.8);
28+
color: ${props => props.theme['sideBar.foreground'] || 'inherit'};
2929
`;
3030

3131
export const ConfigValue = styled.div``;
3232

3333
export const ConfigDescription = styled.div`
3434
margin-top: 0.25rem;
3535
font-weight: 500;
36-
color: rgba(255, 255, 255, 0.5);
36+
color: ${props => props.theme['sideBar.foreground'] || 'inherit'};
37+
opacity: 0.8;
3738
font-size: 0.875rem;
3839
max-width: 75%;
3940
`;

0 commit comments

Comments
 (0)