Skip to content

Commit a758bab

Browse files
MichaelDeBoeychristianalfoni
authored andcommitted
🔨 Switch VSCodePlaceholder to use useOvermind (codesandbox#3118)
* 🔨 Switch VSCodePlaceholder to use useOvermind * Fix types
1 parent cbfb0ba commit a758bab

File tree

10 files changed

+75
-231
lines changed

10 files changed

+75
-231
lines changed

‎packages/app/src/app/pages/common/Modals/PreferencesModal/Appearance/index.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { FunctionComponent } from 'react';
22

33
import { PreferenceContainer, SubContainer, Title } from '../elements';
4-
import VSCodePlaceholder from '../VSCodePlaceholder';
4+
import { VSCodePlaceholder } from '../VSCodePlaceholder';
55

66
import { EditorTheme } from './EditorTheme';
77

‎packages/app/src/app/pages/common/Modals/PreferencesModal/EditorPageSettings/EditorSettings/index.tsx‎

Lines changed: 3 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ import {
77
PreferenceContainer,
88
PaddedPreference,
99
SubDescription,
10-
Rule,
1110
} from '../../elements';
12-
import VSCodePlaceholder from '../../VSCodePlaceholder';
11+
import { VSCodePlaceholder } from '../../VSCodePlaceholder';
1312

1413
const isSafari: boolean = /^((?!chrome|android).)*safari/i.test(
1514
navigator.userAgent
@@ -36,50 +35,8 @@ export const EditorSettings: React.FC = () => {
3635
<Title>Editor</Title>
3736

3837
<SubContainer>
39-
<VSCodePlaceholder>
40-
<PreferenceContainer>
41-
<PaddedPreference
42-
title="Use CodeMirror"
43-
type="boolean"
44-
{...bindValue('codeMirror')}
45-
/>
46-
<SubDescription>
47-
Use CodeMirror instead of Monaco editor.
48-
</SubDescription>
49-
<Rule />
50-
<PaddedPreference
51-
title="Automatic Type Acquisition"
52-
type="boolean"
53-
{...bindValue('autoDownloadTypes')}
54-
/>
55-
<SubDescription>
56-
Automatically download type definitions for dependencies.
57-
</SubDescription>
58-
<Rule />
59-
<PaddedPreference
60-
title="ESLint"
61-
type="boolean"
62-
tooltip="Made possible by ESLint"
63-
{...bindValue('lintEnabled')}
64-
/>
65-
<SubDescription>
66-
Whether linting as you type should be enabled.
67-
</SubDescription>
68-
<Rule />
69-
<VSCodePlaceholder hideTitle>
70-
<PaddedPreference
71-
title="Prettify On Save"
72-
type="boolean"
73-
tooltip="Made possible by Prettier"
74-
{...bindValue('prettifyOnSaveEnabled')}
75-
/>
76-
<SubDescription>
77-
Format all code on save with prettier.
78-
</SubDescription>
79-
<Rule />
80-
</VSCodePlaceholder>
81-
</PreferenceContainer>
82-
</VSCodePlaceholder>
38+
<VSCodePlaceholder />
39+
8340
{/* {Vim mode does not work on FF or Safari */}
8441
<PreferenceContainer disabled={isSafari || isFF}>
8542
<PaddedPreference

‎packages/app/src/app/pages/common/Modals/PreferencesModal/KeyMapping/elements.js‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎packages/app/src/app/pages/common/Modals/PreferencesModal/KeyMapping/index.js‎

Lines changed: 0 additions & 117 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import React, { FunctionComponent } from 'react';
2+
3+
import { VSCodePlaceholder } from '../VSCodePlaceholder';
4+
5+
export const KeyMapping: FunctionComponent = () => <VSCodePlaceholder />;

‎packages/app/src/app/pages/common/Modals/PreferencesModal/VSCodePlaceholder.tsx‎

Lines changed: 0 additions & 51 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import styled from 'styled-components';
2+
3+
export const Container = styled.div`
4+
margin-top: 1rem;
5+
`;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Button } from '@codesandbox/common/lib/components/Button';
2+
import React, { FunctionComponent } from 'react';
3+
4+
import { useOvermind } from 'app/overmind';
5+
6+
import { Container } from './elements';
7+
8+
export const OpenVSCodeSettingsButton: FunctionComponent = () => {
9+
const {
10+
actions: { modalClosed },
11+
effects: { vscode },
12+
} = useOvermind();
13+
14+
const openCommand = () => {
15+
vscode
16+
.runCommand('workbench.action.openSettings2')
17+
.then(() => modalClosed());
18+
};
19+
20+
return (
21+
<Container>
22+
<Button onClick={openCommand} small>
23+
Open VSCode Settings
24+
</Button>
25+
</Container>
26+
);
27+
};
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import styled from 'styled-components';
2+
3+
export const Container = styled.div`
4+
font-size: 0.875rem;
5+
font-style: italic;
6+
color: rgba(255, 255, 255, 0.5);
7+
line-height: 1.4;
8+
font-weight: 500;
9+
margin-bottom: 1.5rem;
10+
`;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { editorUrl } from '@codesandbox/common/lib/utils/url-generator';
2+
import React, { FunctionComponent } from 'react';
3+
import { Route } from 'react-router-dom';
4+
5+
import { Container } from './elements';
6+
import { OpenVSCodeSettingsButton } from './OpenVSCodeSettingsButton';
7+
8+
type Props = {
9+
hideTitle?: boolean;
10+
};
11+
export const VSCodePlaceholder: FunctionComponent<Props> = ({
12+
hideTitle = false,
13+
}) =>
14+
hideTitle ? null : (
15+
<Container>
16+
Some options are disabled because they are handled by VSCode. You can open
17+
the settings of VSCode by pressing {"'"}
18+
CTRL/CMD + ,{"'"}.
19+
<Route
20+
path={editorUrl()}
21+
render={({ match }) => match && <OpenVSCodeSettingsButton />}
22+
/>
23+
</Container>
24+
);

0 commit comments

Comments
 (0)