Skip to content

Change Editor Theme #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion __tests__/app/containers/EditorSettings.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('EditorSettings Container', () => {
},
});

expect(wrapper.find('select.theme-control').props().value).toBe('twilight');
expect(wrapper.find('select.theme-control').props().value).toBe('solarized_light');
wrapper.find('select.theme-control').simulate('change', { target: { value: 'github' } });
expect(wrapper.find('select.theme-control').props().value).toBe('github');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ State PlayerCode::Update(State state) {
isLoggedIn={false}
keyboardHandler="default"
save={[Function]}
theme="twilight"
theme="solarized_light"
updateCode={[Function]}
viewOnly={false}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ exports[`EditorSettings Container Should render EditorSettings 1`] = `
enableSnippets={true}
fontSize={16}
keyboardHandler="default"
theme="twilight"
theme="solarized_light"
toggleBasicAutoCompletion={[Function]}
toggleSnippets={[Function]}
>
Expand Down Expand Up @@ -208,7 +208,7 @@ exports[`EditorSettings Container Should render EditorSettings 1`] = `
<select
className="form-control theme-control"
onChange={[Function]}
value="twilight"
value="solarized_light"
>
<option
key="monokai"
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ import {
} from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { SidePanelTab } from 'app/reducers/Dashboard';
import { Routes } from 'app/routes';
import * as styles from 'app/styles/Sidebar.module.css';
import * as SideBarInterfaces from 'app/types/SideBar';
import classnames from 'classnames';
import * as React from 'react';
import { Button, ButtonGroup } from 'react-bootstrap';
import { Routes } from 'app/routes';

export class Sidebar extends React.Component<SideBarInterfaces.Props, {}> {
public render() {
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/UserProfileModal/EditPassword.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class EditPassword extends React.Component<EditPasswordInterfaces.Props,
<div className="col mb-3">
<div className="input-group">
<label className="labeltext">Old Password</label>
<div className={classnames('input-group-prepend', styles['inputGroup'])}>
<div className={classnames('input-group-prepend', styles.inputGroup)}>
<input
type="password"
className={classnames('form-control', styles1['login-input'])}
Expand All @@ -57,7 +57,7 @@ export class EditPassword extends React.Component<EditPasswordInterfaces.Props,
<div className="col mb-3">
<div className="input-group">
<label className="labeltext">New Password</label>
<div className={classnames('input-group-prepend', styles['inputGroup'])}>
<div className={classnames('input-group-prepend', styles.inputGroup)}>
<input
type="password"
className={classnames('form-control', styles1['login-input'])}
Expand All @@ -79,7 +79,7 @@ export class EditPassword extends React.Component<EditPasswordInterfaces.Props,
<div className="col mb-3">
<div className="input-group">
<label className="labeltext">Confirm Password</label>
<div className={classnames('input-group-prepend', styles['passwordInput'])}>
<div className={classnames('input-group-prepend', styles.passwordInput)}>
<input
type="password"
className={classnames('form-control', styles1['login-input'])}
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/UserProfileModal/EditProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as styles1 from 'app/styles/Authentication.module.css';
import * as styles from 'app/styles/UserProfileModal.module.css';
import 'app/styles/Flags.css';
import * as styles from 'app/styles/UserProfileModal.module.css';
import { Avatar } from 'app/types/Authentication/Register';
import { InputName } from 'app/types/UserProfileModal';
import * as EditProfileInterfaces from 'app/types/UserProfileModal/EditProfile';
Expand Down Expand Up @@ -138,8 +138,8 @@ export class EditProfile extends React.Component<EditProfileInterfaces.Props, {}
<div className="form-row">
<div className="col text-center mb-2">
<div className={styles.inputGroup}>
{userDetails.errorMessage != '' ? (
<div className={classnames(styles1['login-error'], styles['UsernameError'])}>
{userDetails.errorMessage !== '' ? (
<div className={classnames(styles1['login-error'], styles.UsernameError)}>
{userDetails.errorMessage}
</div>
) : null}
Expand All @@ -149,8 +149,8 @@ export class EditProfile extends React.Component<EditProfileInterfaces.Props, {}
style={{
backgroundColor: 'rgb(70, 48, 235)',
borderColor: 'rgb(70, 48, 235)',
width: '100%',
margin: '0px',
width: '100%',
}}
disabled={
currentAvatar === userDetails.avatar &&
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/UserProfileModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export class UserProfileModal extends React.Component<
<a
className={
this.state.isPasswordPage
? classnames('labeltext', styles['loginPageLink'])
: classnames('labeltext', styles['passwordPageLink'])
? classnames('labeltext', styles.loginPageLink)
: classnames('labeltext', styles.passwordPageLink)
}
onClick={() => {
this.setState((prevState) => ({
Expand Down
23 changes: 2 additions & 21 deletions src/app/components/code/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,11 @@ import 'brace/ext/searchbox';
import 'brace/mode/c_cpp';
import 'brace/snippets/c_cpp';

export const themes = [
'monokai',
'github',
'tomorrow',
'kuroir',
'twilight',
'xcode',
'textmate',
'solarized_dark',
'solarized_light',
'terminal',
'chaos',
'chrome',
'eclipse',
'dracula',
];

export const keyboardHandlers = ['emacs', 'vim', 'default'];

themes.forEach((theme) => {
EditorInterfaces.themes.forEach((theme) => {
require(`brace/theme/${theme}`);
});

keyboardHandlers.forEach((keyboardHandler) => {
EditorInterfaces.keyboardHandlers.forEach((keyboardHandler) => {
if (keyboardHandler !== 'default') {
require(`brace/keybinding/${keyboardHandler}`);
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/code/EditorSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { keyboardHandlers, themes } from 'app/components/code/Editor';
import * as styles from 'app/styles/EditorSettings.module.css';
import { keyboardHandlers, themes } from 'app/types/code/Editor';
import * as EditorSettingsInterfaces from 'app/types/code/EditorSettings';
import classnames from 'classnames';
import * as React from 'react';
Expand Down
10 changes: 8 additions & 2 deletions src/app/reducers/code/Editor.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { EditorSettingsActions } from 'app/actions';
import * as EditorInterfaces from 'app/types/code/Editor';
import {
EditorThemeTypes,
KeyboardHandler,
keyboardHandlers,
themes,
} from 'app/types/code/Editor.ts';

const editorStoreIntialState: EditorInterfaces.EditorStoreState = {
editorOptions: {
enableBasicAutoCompletion: true,
enableSnippets: true,
fontSize: 16,
keyboardHandler: 'default',
theme: 'twilight',
keyboardHandler: keyboardHandlers[KeyboardHandler.DEFAULT],
theme: themes[EditorThemeTypes.SOLARIZED_LIGHT],
},
};

Expand Down
42 changes: 42 additions & 0 deletions src/app/types/code/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,48 @@ const actions = {
updateCode: CodeActions.updateCode,
};

export const keyboardHandlers = ['emacs', 'vim', 'default'];

export enum KeyboardHandler {
EMACS,
VIM,
DEFAULT,
}

export const themes = [
'monokai',
'github',
'tomorrow',
'kuroir',
'twilight',
'xcode',
'textmate',
'solarized_dark',
'solarized_light',
'terminal',
'chaos',
'chrome',
'eclipse',
'dracula',
];

export enum EditorThemeTypes {
MONOKAI,
GITHUB,
TOMORROW,
KUROIR,
TWILIGHT,
XCODE,
TEXTMATE,
SOLARIZED_DARK,
SOLARIZED_LIGHT,
TERMINAL,
CHAOS,
CHROME,
ECLIPSE,
DRACULA,
}

export interface State {
code: string;
}
Expand Down