Compare commits
No commits in common. "146b8126a2d987717fd0c279ca9d377f8f13d497" and "9d5216195784c8a892c5c54357fc2e73014b4fdf" have entirely different histories.
146b8126a2
...
9d52161957
@ -21,10 +21,6 @@ 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,11 +12,6 @@ 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';
|
||||||
@ -44,34 +39,20 @@ function makeRequest(queryString, jsonHandler) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
interface EntryProps {
|
const Entry = (props) => {
|
||||||
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 as SaiEntryProps } />;
|
return <SaiEntry entry={ props.entry } />;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (conlang === Conlang.Juteyuji) {
|
if (conlang === Conlang.Juteyuji) {
|
||||||
return <JutEntry entry={ props.entry as JutEntryProps } />;
|
return <JutEntry entry={ props.entry } />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div>Conlang { conlang } not yet supported</div>;
|
return <div>Conlang { conlang } not yet supported</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface SaiEntryProps {
|
const SaiEntry = (props) => {
|
||||||
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';
|
||||||
@ -89,15 +70,7 @@ const SaiEntry = (props: {entry: SaiEntryProps}) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
interface JutEntryProps {
|
const JutEntry = (props) => {
|
||||||
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);
|
||||||
|
|
||||||
@ -128,20 +101,13 @@ function formatMorphology(entry) {
|
|||||||
</span>);
|
</span>);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ResultsProps {
|
const Results = (props) => {
|
||||||
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 === SearchDirection.ToConlang) ? `English -> ${renderedName}` : `${renderedName} -> English`;
|
const searchType = (props.direction === '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)
|
||||||
@ -188,7 +154,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`);
|
||||||
@ -201,7 +167,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: SearchDirection.ToEnglish});
|
this.setState({searchResults: json, searchTerm, direction: 'toEnglish'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -212,7 +178,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: SearchDirection.ToEnglish});
|
this.setState({searchResults: json, searchTerm, direction: 'toEnglish'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -225,7 +191,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: SearchDirection.ToConlang});
|
this.setState({searchResults: json, searchTerm, direction: 'toConlang'});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user