refactor Output component to display multiple results
This commit is contained in:
parent
745fd3b899
commit
6f55f0ac39
3 changed files with 30 additions and 4 deletions
|
@ -102,7 +102,7 @@ const PhonoChangeApplier = () => {
|
|||
<Features phones={phones} features={features} dispatch={dispatch}/>
|
||||
<Epochs epochs={epochs} dispatch={dispatch} />
|
||||
<Options options={options} dispatch={dispatch}/>
|
||||
<Output results={results} dispatch={dispatch}/>
|
||||
<Output results={results} options={options} dispatch={dispatch}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -2,13 +2,33 @@ import React from 'react';
|
|||
import './Output.scss';
|
||||
|
||||
const Output = props => {
|
||||
const { results } = props;
|
||||
const { results, options } = props;
|
||||
const renderResults = () => {
|
||||
switch(options.output) {
|
||||
case 'default':
|
||||
return renderDefault();
|
||||
default:
|
||||
return <></>
|
||||
}
|
||||
}
|
||||
|
||||
const renderDefault = () => {
|
||||
return results.map((epoch, i) => {
|
||||
const lexicon = epoch.lexicon.map(lexeme => <span>{lexeme}</span>);
|
||||
return (
|
||||
<div key={`epoch-${i}`} className="Output-epoch">
|
||||
<h5>{epoch.pass}</h5>
|
||||
<p className="lexicon">{lexicon}</p>
|
||||
</div>
|
||||
)
|
||||
})
|
||||
}
|
||||
return (
|
||||
<div className="Output" data-testid="Output">
|
||||
<h3>Results of Run</h3>
|
||||
|
||||
<div data-testid="Output-lexicon">
|
||||
{results && results.length ? results[0].lexicon.map((lexicalItem, i) => <p key={`output-lexical-item-${i}`}>{lexicalItem}</p>) : <></>}
|
||||
<div data-testid="Output-lexicon" className="Output_container">
|
||||
{results && results.length ? renderResults() : <></>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
div.Output-epoch {
|
||||
display: flex;
|
||||
p.lexicon {
|
||||
display: flex;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue