You need to sign in or sign up before continuing.

Add config file to store some const values

parent d5e9eb40
import React, { Component } from 'react'; import React, { Component } from 'react';
import $ from 'jquery'; import $ from 'jquery';
import TypoModal from '../Modal/' import TypoModal from '../Modal/';
import {i18n} from '../Localization' import {i18n} from '../Localization';
import {config} from '../config';
class App extends Component { class App extends Component {
...@@ -13,9 +15,6 @@ class App extends Component { ...@@ -13,9 +15,6 @@ class App extends Component {
correctionMode: false correctionMode: false
} }
this.minSelectionLength = 4;
this.maxSelectionLength = 50;
this.typo = ""; this.typo = "";
this.registerHandlers(); this.registerHandlers();
...@@ -33,11 +32,11 @@ class App extends Component { ...@@ -33,11 +32,11 @@ class App extends Component {
$(document).keydown(event => { $(document).keydown(event => {
if (event.ctrlKey && event.keyCode === 13) { if (event.ctrlKey && event.keyCode === 13) {
const selection = this.getSelectedText(); const selection = this.getSelectedText();
if (selection.length < this.minSelectionLength || if (selection.length < config.minTypoLength ||
selection.length > this.maxSelectionLength) selection.length > config.maxTypoLength)
{ {
alert(i18n.formatString(i18n.errorSelectionLength, alert(i18n.formatString(i18n.errorSelectionLength,
this.minSelectionLength, this.maxSelectionLength)); config.minTypoLength, config.maxTypoLength));
return; return;
} }
...@@ -56,7 +55,9 @@ class App extends Component { ...@@ -56,7 +55,9 @@ class App extends Component {
if (!this.state.correctionMode) return null; if (!this.state.correctionMode) return null;
return ( return (
<TypoModal text={this.typo} closeCallback={this.modalClosedCallback} show={this.state.correctionMode}/> <TypoModal text={this.typo}
closeCallback={this.modalClosedCallback}
show={this.state.correctionMode}/>
); );
} }
......
export const config = {
maxTypoLength: 50,
minTypoLength: 2,
maxCorrectLength: 100,
minCorrectLength: 1,
};
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment