Skip to content

Commit e3ef5a0

Browse files
authored
Change Editor Theme (#18)
- Change default theme to solarized_light - Move themes and keyboardhandlers to editor types
1 parent 7cc7f6f commit e3ef5a0

File tree

11 files changed

+67
-38
lines changed

11 files changed

+67
-38
lines changed

__tests__/app/containers/EditorSettings.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ describe('EditorSettings Container', () => {
3434
},
3535
});
3636

37-
expect(wrapper.find('select.theme-control').props().value).toBe('twilight');
37+
expect(wrapper.find('select.theme-control').props().value).toBe('solarized_light');
3838
wrapper.find('select.theme-control').simulate('change', { target: { value: 'github' } });
3939
expect(wrapper.find('select.theme-control').props().value).toBe('github');
4040
});

__tests__/app/containers/__snapshots__/Editor.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ State PlayerCode::Update(State state) {
139139
isLoggedIn={false}
140140
keyboardHandler="default"
141141
save={[Function]}
142-
theme="twilight"
142+
theme="solarized_light"
143143
updateCode={[Function]}
144144
viewOnly={false}
145145
/>

__tests__/app/containers/__snapshots__/EditorSettings.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports[`EditorSettings Container Should render EditorSettings 1`] = `
1010
enableSnippets={true}
1111
fontSize={16}
1212
keyboardHandler="default"
13-
theme="twilight"
13+
theme="solarized_light"
1414
toggleBasicAutoCompletion={[Function]}
1515
toggleSnippets={[Function]}
1616
>
@@ -208,7 +208,7 @@ exports[`EditorSettings Container Should render EditorSettings 1`] = `
208208
<select
209209
className="form-control theme-control"
210210
onChange={[Function]}
211-
value="twilight"
211+
value="solarized_light"
212212
>
213213
<option
214214
key="monokai"

src/app/components/SideBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ import {
1313
} from '@fortawesome/free-solid-svg-icons';
1414
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
1515
import { SidePanelTab } from 'app/reducers/Dashboard';
16+
import { Routes } from 'app/routes';
1617
import * as styles from 'app/styles/Sidebar.module.css';
1718
import * as SideBarInterfaces from 'app/types/SideBar';
1819
import classnames from 'classnames';
1920
import * as React from 'react';
2021
import { Button, ButtonGroup } from 'react-bootstrap';
21-
import { Routes } from 'app/routes';
2222

2323
export class Sidebar extends React.Component<SideBarInterfaces.Props, {}> {
2424
public render() {

src/app/components/UserProfileModal/EditPassword.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class EditPassword extends React.Component<EditPasswordInterfaces.Props,
3535
<div className="col mb-3">
3636
<div className="input-group">
3737
<label className="labeltext">Old Password</label>
38-
<div className={classnames('input-group-prepend', styles['inputGroup'])}>
38+
<div className={classnames('input-group-prepend', styles.inputGroup)}>
3939
<input
4040
type="password"
4141
className={classnames('form-control', styles1['login-input'])}
@@ -57,7 +57,7 @@ export class EditPassword extends React.Component<EditPasswordInterfaces.Props,
5757
<div className="col mb-3">
5858
<div className="input-group">
5959
<label className="labeltext">New Password</label>
60-
<div className={classnames('input-group-prepend', styles['inputGroup'])}>
60+
<div className={classnames('input-group-prepend', styles.inputGroup)}>
6161
<input
6262
type="password"
6363
className={classnames('form-control', styles1['login-input'])}
@@ -79,7 +79,7 @@ export class EditPassword extends React.Component<EditPasswordInterfaces.Props,
7979
<div className="col mb-3">
8080
<div className="input-group">
8181
<label className="labeltext">Confirm Password</label>
82-
<div className={classnames('input-group-prepend', styles['passwordInput'])}>
82+
<div className={classnames('input-group-prepend', styles.passwordInput)}>
8383
<input
8484
type="password"
8585
className={classnames('form-control', styles1['login-input'])}

src/app/components/UserProfileModal/EditProfile.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as styles1 from 'app/styles/Authentication.module.css';
2-
import * as styles from 'app/styles/UserProfileModal.module.css';
32
import 'app/styles/Flags.css';
3+
import * as styles from 'app/styles/UserProfileModal.module.css';
44
import { Avatar } from 'app/types/Authentication/Register';
55
import { InputName } from 'app/types/UserProfileModal';
66
import * as EditProfileInterfaces from 'app/types/UserProfileModal/EditProfile';
@@ -138,8 +138,8 @@ export class EditProfile extends React.Component<EditProfileInterfaces.Props, {}
138138
<div className="form-row">
139139
<div className="col text-center mb-2">
140140
<div className={styles.inputGroup}>
141-
{userDetails.errorMessage != '' ? (
142-
<div className={classnames(styles1['login-error'], styles['UsernameError'])}>
141+
{userDetails.errorMessage !== '' ? (
142+
<div className={classnames(styles1['login-error'], styles.UsernameError)}>
143143
{userDetails.errorMessage}
144144
</div>
145145
) : null}
@@ -149,8 +149,8 @@ export class EditProfile extends React.Component<EditProfileInterfaces.Props, {}
149149
style={{
150150
backgroundColor: 'rgb(70, 48, 235)',
151151
borderColor: 'rgb(70, 48, 235)',
152-
width: '100%',
153152
margin: '0px',
153+
width: '100%',
154154
}}
155155
disabled={
156156
currentAvatar === userDetails.avatar &&

src/app/components/UserProfileModal/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ export class UserProfileModal extends React.Component<
8181
<a
8282
className={
8383
this.state.isPasswordPage
84-
? classnames('labeltext', styles['loginPageLink'])
85-
: classnames('labeltext', styles['passwordPageLink'])
84+
? classnames('labeltext', styles.loginPageLink)
85+
: classnames('labeltext', styles.passwordPageLink)
8686
}
8787
onClick={() => {
8888
this.setState((prevState) => ({

src/app/components/code/Editor.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,11 @@ import 'brace/ext/searchbox';
88
import 'brace/mode/c_cpp';
99
import 'brace/snippets/c_cpp';
1010

11-
export const themes = [
12-
'monokai',
13-
'github',
14-
'tomorrow',
15-
'kuroir',
16-
'twilight',
17-
'xcode',
18-
'textmate',
19-
'solarized_dark',
20-
'solarized_light',
21-
'terminal',
22-
'chaos',
23-
'chrome',
24-
'eclipse',
25-
'dracula',
26-
];
27-
28-
export const keyboardHandlers = ['emacs', 'vim', 'default'];
29-
30-
themes.forEach((theme) => {
11+
EditorInterfaces.themes.forEach((theme) => {
3112
require(`brace/theme/${theme}`);
3213
});
3314

34-
keyboardHandlers.forEach((keyboardHandler) => {
15+
EditorInterfaces.keyboardHandlers.forEach((keyboardHandler) => {
3516
if (keyboardHandler !== 'default') {
3617
require(`brace/keybinding/${keyboardHandler}`);
3718
}

src/app/components/code/EditorSettings.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { keyboardHandlers, themes } from 'app/components/code/Editor';
21
import * as styles from 'app/styles/EditorSettings.module.css';
2+
import { keyboardHandlers, themes } from 'app/types/code/Editor';
33
import * as EditorSettingsInterfaces from 'app/types/code/EditorSettings';
44
import classnames from 'classnames';
55
import * as React from 'react';

src/app/reducers/code/Editor.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { EditorSettingsActions } from 'app/actions';
22
import * as EditorInterfaces from 'app/types/code/Editor';
3+
import {
4+
EditorThemeTypes,
5+
KeyboardHandler,
6+
keyboardHandlers,
7+
themes,
8+
} from 'app/types/code/Editor.ts';
39

410
const editorStoreIntialState: EditorInterfaces.EditorStoreState = {
511
editorOptions: {
612
enableBasicAutoCompletion: true,
713
enableSnippets: true,
814
fontSize: 16,
9-
keyboardHandler: 'default',
10-
theme: 'twilight',
15+
keyboardHandler: keyboardHandlers[KeyboardHandler.DEFAULT],
16+
theme: themes[EditorThemeTypes.SOLARIZED_LIGHT],
1117
},
1218
};
1319

src/app/types/code/Editor.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,48 @@ const actions = {
1212
updateCode: CodeActions.updateCode,
1313
};
1414

15+
export const keyboardHandlers = ['emacs', 'vim', 'default'];
16+
17+
export enum KeyboardHandler {
18+
EMACS,
19+
VIM,
20+
DEFAULT,
21+
}
22+
23+
export const themes = [
24+
'monokai',
25+
'github',
26+
'tomorrow',
27+
'kuroir',
28+
'twilight',
29+
'xcode',
30+
'textmate',
31+
'solarized_dark',
32+
'solarized_light',
33+
'terminal',
34+
'chaos',
35+
'chrome',
36+
'eclipse',
37+
'dracula',
38+
];
39+
40+
export enum EditorThemeTypes {
41+
MONOKAI,
42+
GITHUB,
43+
TOMORROW,
44+
KUROIR,
45+
TWILIGHT,
46+
XCODE,
47+
TEXTMATE,
48+
SOLARIZED_DARK,
49+
SOLARIZED_LIGHT,
50+
TERMINAL,
51+
CHAOS,
52+
CHROME,
53+
ECLIPSE,
54+
DRACULA,
55+
}
56+
1557
export interface State {
1658
code: string;
1759
}

0 commit comments

Comments
 (0)