Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
fix: mobile swipecards based UI - more requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrijaned committed Nov 9, 2019
1 parent 23ce694 commit 7c5607d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 53 deletions.
5 changes: 2 additions & 3 deletions web/css/review-form.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@
.master-root {
margin: 20px auto;
position: relative;
height: calc(6rem + 120px + 2em);
width: calc(380px + 2em);
height: calc(6rem + 2em);
width: calc(250px + 2em);
overflow: hidden;
border: 1px solid #e5e5e5;
}
Expand All @@ -135,7 +135,6 @@
background: #F8F3F3;
height: 6rem;
width: 250px;
margin: 0 auto;
transition: box-shadow .3s;
box-shadow: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
cursor: pointer;
Expand Down
92 changes: 42 additions & 50 deletions web/src/components/review-form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const PAGE_SIZE = 5;
const DEFAULT_STATE = {
page: 0,
};
let mobileUI = true;
let mobileUI = false;

export default class ReviewForm extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -102,48 +102,37 @@ export default class ReviewForm extends React.Component {
const curSentences = this.props.sentences.slice(offset, offset + PAGE_SIZE);

if (mobileUI) {
let message = (<p>Swipe right to approve sentencee, swipe left to reject it.</p>);
let message = (<p>You have not reviewed any sentences yet!</p>);
if (this.state.page !== 0) {
message = (<p>You have succesfully reviewed your {this.state.page * PAGE_SIZE}th sentence!</p>)
message = (<p>You have successfully reviewed your {this.state.page * PAGE_SIZE}th sentence!</p>)
}

return (
<form id="review-form" onSubmit={this.onSubmit}>
<p>Swipe right to approve sentence, swipe left to reject it.</p>
{message}
<Cards onEnd={() => {
if (this.state.page === this.getLastPage()) {
this.onSubmit({preventDefault: ()=>{}});
} else {
this.setPage(this.state.page + 1);
this.cardsRef.current.setState({index: -1});//cardsRef.state.index modified due to Cards' inner card removal handling.
}
}} className="master-root" ref={this.cardsRef}>
{curSentences.map((sentence, i) => (
<Card
key={offset + i}
onSwipeLeft={() => this.reviewSentence(offset + i, false)}
onSwipeRight={() => this.reviewSentence(offset + i, true)}
>
<div className="card-sentence-box">
{sentence.sentence || sentence}
</div>
</Card>
))}
</Cards>
<section className="review-footer">
<section id="confirm-buttons" className="divCenter">
{ this.state.pendingSentences ?
<SpinnerButton></SpinnerButton> :
<button type="submit">Finish Review</button>
<Cards onEnd={() => {
if (this.state.page === this.getLastPage()) {
this.onSubmit({preventDefault: ()=>{}});
} else {
this.setPage(this.state.page + 1);
this.cardsRef.current.setState({index: -1});//cardsRef.state.index modified due to Cards' inner card removal handling.
}

{ this.state.pendingSentences && (
<div>
<p className="loadingText">Reviews are being uploaded. This can take several minutes depending on the number of sentences added.
Please don't close this website.</p>
</div>
)}
</section>
}} className="master-root" ref={this.cardsRef}>
{curSentences.map((sentence, i) => (
<Card
key={offset + i}
onSwipeLeft={() => this.reviewSentence(offset + i, false)}
onSwipeRight={() => this.reviewSentence(offset + i, true)}
>
<div className="card-sentence-box">
{sentence.sentence || sentence}
</div>
</Card>
))}
</Cards>
<section className="review-footer">
<ConfirmButtons pendingSentences={this.state.pendingSentences}/>
</section>
</form>
);
Expand Down Expand Up @@ -178,20 +167,7 @@ export default class ReviewForm extends React.Component {
)) }

<section className="review-footer">
<section id="confirm-buttons" className="divCenter">
{ this.state.pendingSentences ?
<SpinnerButton></SpinnerButton> :
<button type="submit">Finish Review</button>
}

{ this.state.pendingSentences && (
<div>
<p className="loadingText">Reviews are being uploaded. This can take several minutes depending on the number of sentences added.
Please don't close this website.</p>
</div>
)}
</section>

<ConfirmButtons pendingSentences={this.state.pendingSentences}/>
<Pager page={this.state.page} lastPage={this.getLastPage()}
onPage={this.setPage} />
</section>
Expand Down Expand Up @@ -225,3 +201,19 @@ const Pager = (props) => (
))
}</section>
);

const ConfirmButtons = (props) => (
<section id="confirm-buttons" className="divCenter">
{ props.pendingSentences ?
<SpinnerButton></SpinnerButton> :
<button type="submit">Finish Review</button>
}

{ props.pendingSentences && (
<div>
<p className="loadingText">Reviews are being uploaded. This can take several minutes depending on the number of sentences added.
Please don&apos;t close this website.</p>
</div>
)}
</section>
);

0 comments on commit 7c5607d

Please sign in to comment.