App.jsx improvements
This commit is contained in:
parent
e8c53cda2f
commit
0d5e2c90a2
46
src/App.jsx
46
src/App.jsx
@ -32,20 +32,19 @@ function renderConlangName(name) {
|
||||
}
|
||||
}
|
||||
|
||||
function Entry(props) {
|
||||
const Entry = (props) => {
|
||||
const {conlang} = props;
|
||||
if (conlang === 'saimiar') {
|
||||
return <SaiEntry entry={ props.entry } />;
|
||||
}
|
||||
|
||||
return <div>Unknown entry type for { conlang }</div>;
|
||||
}
|
||||
};
|
||||
|
||||
function SaiEntry(props) {
|
||||
const SaiEntry = (props) => {
|
||||
const {entry} = props;
|
||||
const synCategory = entry.syn_category;
|
||||
const isNominal = synCategory === 'nominal';
|
||||
console.log(isNominal);
|
||||
return (
|
||||
<div className="searchResult" key={ entry.id }>
|
||||
<b>{ entry.sai }</b> - { entry.eng }
|
||||
@ -58,7 +57,7 @@ function SaiEntry(props) {
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
function formatMorphology(entry) {
|
||||
const decl = declineSaimiar(entry);
|
||||
@ -77,36 +76,29 @@ function formatMorphology(entry) {
|
||||
</span>);
|
||||
}
|
||||
|
||||
class Results extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.content = this.content.bind(this);
|
||||
}
|
||||
|
||||
content() {
|
||||
const {conlang} = this.props;
|
||||
const num = this.props.searchResults.length;
|
||||
const Results = (props) => {
|
||||
const content = () => {
|
||||
const {conlang} = props;
|
||||
const num = props.searchResults.length;
|
||||
const renderedName = renderConlangName(conlang);
|
||||
const searchType = (this.props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`;
|
||||
const searchType = (props.direction === 'toConlang') ? `English -> ${renderedName}` : `${renderedName} -> English`;
|
||||
const header = (
|
||||
<div className="searchResultHeader" key="header">
|
||||
Searched for <b>{ this.props.searchTerm }</b>, { searchType }, found { num } result(s)
|
||||
Searched for <b>{ props.searchTerm }</b>, { searchType }, found { num } result(s)
|
||||
</div>);
|
||||
const entries = this.props.searchResults.map(
|
||||
const entries = props.searchResults.map(
|
||||
(entry, _idx) => <Entry entry={ entry } key= { entry.id } conlang={ conlang } />,
|
||||
);
|
||||
return [header].concat(entries);
|
||||
}
|
||||
};
|
||||
|
||||
render() {
|
||||
const results = this.props.searchResults;
|
||||
return (
|
||||
<div className="results">
|
||||
{ results ? this.content() : 'No search' }
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
const results = props.searchResults;
|
||||
return (
|
||||
<div className="results">
|
||||
{ results ? content() : 'No search' }
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
class App extends Component {
|
||||
constructor(props) {
|
||||
|
Loading…
Reference in New Issue
Block a user