Compare commits
3 Commits
9d52161957
...
146b8126a2
Author | SHA1 | Date | |
---|---|---|---|
|
146b8126a2 | ||
|
cf975330f4 | ||
|
3ec15e30b3 |
@ -21,6 +21,10 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
rules: {
|
rules: {
|
||||||
"arrow-parens": ["error", "always"],
|
"arrow-parens": ["error", "always"],
|
||||||
"indent": ["error", 4]
|
"indent": ["error", 4],
|
||||||
|
"unused-vars": "off",
|
||||||
|
"@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
|
||||||
|
"no-redeclare": "off",
|
||||||
|
"@typescript-eslint/no-redeclare": ["error"]
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
56
src/App.tsx
56
src/App.tsx
@ -12,6 +12,11 @@ enum Conlang {
|
|||||||
Juteyuji = 'juteyuji',
|
Juteyuji = 'juteyuji',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SearchDirection {
|
||||||
|
ToConlang,
|
||||||
|
ToEnglish
|
||||||
|
}
|
||||||
|
|
||||||
const renderConlang = (conlang: Conlang): string => {
|
const renderConlang = (conlang: Conlang): string => {
|
||||||
if (conlang === Conlang.Saimiar) {
|
if (conlang === Conlang.Saimiar) {
|
||||||
return 'Saimiar';
|
return 'Saimiar';
|
||||||
@ -39,20 +44,34 @@ function makeRequest(queryString, jsonHandler) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const Entry = (props) => {
|
interface EntryProps {
|
||||||
|
conlang: Conlang;
|
||||||
|
entry: SaiEntryProps | JutEntryProps;
|
||||||
|
key: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Entry = (props: EntryProps) => {
|
||||||
const {conlang} = props;
|
const {conlang} = props;
|
||||||
if (conlang === Conlang.Saimiar) {
|
if (conlang === Conlang.Saimiar) {
|
||||||
return <SaiEntry entry={ props.entry } />;
|
return <SaiEntry entry={ props.entry as SaiEntryProps } />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conlang === Conlang.Juteyuji) {
|
if (conlang === Conlang.Juteyuji) {
|
||||||
return <JutEntry entry={ props.entry } />;
|
return <JutEntry entry={ props.entry as JutEntryProps } />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div>Conlang { conlang } not yet supported</div>;
|
return <div>Conlang { conlang } not yet supported</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const SaiEntry = (props) => {
|
interface SaiEntryProps {
|
||||||
|
id: number;
|
||||||
|
sai: string;
|
||||||
|
eng: string;
|
||||||
|
syn_category: string;
|
||||||
|
morph_type: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const SaiEntry = (props: {entry: SaiEntryProps}) => {
|
||||||
const {entry} = props;
|
const {entry} = props;
|
||||||
const synCategory = entry.syn_category;
|
const synCategory = entry.syn_category;
|
||||||
const isNominal = synCategory === 'nominal';
|
const isNominal = synCategory === 'nominal';
|
||||||
@ -70,7 +89,15 @@ const SaiEntry = (props) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const JutEntry = (props) => {
|
interface JutEntryProps {
|
||||||
|
id: number;
|
||||||
|
jut: string;
|
||||||
|
eng: string;
|
||||||
|
syn_category: string;
|
||||||
|
gender: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const JutEntry = (props: {entry: JutEntryProps}) => {
|
||||||
const {entry} = props;
|
const {entry} = props;
|
||||||
console.log(props);
|
console.log(props);
|
||||||
|
|
||||||
@ -101,13 +128,20 @@ function formatMorphology(entry) {
|
|||||||
</span>);
|
</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Results = (props) => {
|
interface ResultsProps {
|
||||||
|
searchResults: any;
|
||||||
|
searchTerm: string;
|
||||||
|
conlang: Conlang;
|
||||||
|
direction: SearchDirection;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Results = (props: ResultsProps) => {
|
||||||
const content = () => {
|
const content = () => {
|
||||||
const {conlang} = props;
|
const {conlang} = props;
|
||||||
const num = props.searchResults.length;
|
const num = props.searchResults.length;
|
||||||
|
|
||||||
const renderedName = renderConlang(conlang);
|
const renderedName = renderConlang(conlang);
|
||||||
const searchType = (props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`;
|
const searchType = (props.direction === SearchDirection.ToConlang) ? `English -> ${renderedName}` : `${renderedName} -> English`;
|
||||||
const header = (
|
const header = (
|
||||||
<div className="searchResultHeader" key="header">
|
<div className="searchResultHeader" key="header">
|
||||||
Searched for <b>{ props.searchTerm }</b>, { searchType }, found { num } result(s)
|
Searched for <b>{ props.searchTerm }</b>, { searchType }, found { num } result(s)
|
||||||
@ -154,7 +188,7 @@ class App extends Component {
|
|||||||
const {conlang} = this.state;
|
const {conlang} = this.state;
|
||||||
if (conlang === Conlang.Saimiar) {
|
if (conlang === Conlang.Saimiar) {
|
||||||
this.searchSaimiar(searchTerm);
|
this.searchSaimiar(searchTerm);
|
||||||
} else if (conlang == Conlang.Juteyuji) {
|
} else if (conlang === Conlang.Juteyuji) {
|
||||||
this.searchJuteyuji(searchTerm);
|
this.searchJuteyuji(searchTerm);
|
||||||
} else {
|
} else {
|
||||||
console.error(`Conlang ${conlang} not supported`);
|
console.error(`Conlang ${conlang} not supported`);
|
||||||
@ -167,7 +201,7 @@ class App extends Component {
|
|||||||
this.setState({searchResults: null, searchTerm: null, direction: null});
|
this.setState({searchResults: null, searchTerm: null, direction: null});
|
||||||
} else {
|
} else {
|
||||||
makeRequest(request, (json) => {
|
makeRequest(request, (json) => {
|
||||||
this.setState({searchResults: json, searchTerm, direction: 'toEnglish'});
|
this.setState({searchResults: json, searchTerm, direction: SearchDirection.ToEnglish});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,7 +212,7 @@ class App extends Component {
|
|||||||
this.setState({searchResults: null, searchTerm: null, direction: null});
|
this.setState({searchResults: null, searchTerm: null, direction: null});
|
||||||
} else {
|
} else {
|
||||||
makeRequest(request, (json) => {
|
makeRequest(request, (json) => {
|
||||||
this.setState({searchResults: json, searchTerm, direction: 'toEnglish'});
|
this.setState({searchResults: json, searchTerm, direction: SearchDirection.ToEnglish});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -191,7 +225,7 @@ class App extends Component {
|
|||||||
this.setState({searchResults: null, searchTerm: null});
|
this.setState({searchResults: null, searchTerm: null});
|
||||||
} else {
|
} else {
|
||||||
makeRequest(request, (json) => {
|
makeRequest(request, (json) => {
|
||||||
this.setState({searchResults: json, searchTerm, direction: 'toConlang'});
|
this.setState({searchResults: json, searchTerm, direction: SearchDirection.ToConlang});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user