Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds card liking button to cards #28

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/app/card-component/card.component.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
<mat-card>
<mat-card-title class="card-word">{{ card.word }}</mat-card-title>
<mat-card-header>
<mat-card-title class="card-word">{{ card.word }}</mat-card-title>
</mat-card-header>
<mat-divider></mat-divider>
<mat-card-content>
<div class="card-synonym card-line" [ngClass]="{'hint-selected': this.selected.indexOf(1) != -1}"><div class="card-desc">Synonym:</div> <div class="card-cont">{{ card.synonym }}</div></div>
<div class="card-antonym card-line" [ngClass]="{'hint-selected': this.selected.indexOf(2) != -1}"><div class="card-desc">Antonym:</div> <div class="card-cont">{{ card.antonym }}</div></div>
<div class="card-general-usage card-line" [ngClass]="{'hint-selected': this.selected.indexOf(3) != -1}"><div class="card-desc">General usage:</div> <div class="card-cont">{{ card.general_sense }}</div></div>
<div class="card-synonym card-line" [ngClass]="{'hint-selected': this.selected.indexOf(1) != -1}"><div class="card-desc">Synonym:</div> <div class="card-cont">{{ card.synonym }}</div></div><br>
<div class="card-antonym card-line" [ngClass]="{'hint-selected': this.selected.indexOf(2) != -1}"><div class="card-desc">Antonym:</div> <div class="card-cont">{{ card.antonym }}</div></div><br>
<div class="card-general-usage card-line" [ngClass]="{'hint-selected': this.selected.indexOf(3) != -1}"><div class="card-desc">General usage:</div> <div class="card-cont">{{ card.general_sense }}</div></div><br>
<div class="card-example-usage card-line" [ngClass]="{'hint-selected': this.selected.indexOf(4) != -1}"><div class="card-desc">Example usage:</div> <div class="card-cont">{{ card.example_usage }}</div></div>
</mat-card-content>
<mat-card-actions align="end">
<button mat-icon-button color="primary" [disabled]="DisableButton" class="card-vote"(click)= "hitUpvote()">
<mat-icon>thumb_up</mat-icon>
</button>
</mat-card-actions>

</mat-card>
11 changes: 3 additions & 8 deletions src/app/card-component/card.component.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
.hint-selected {
background-color: yellow;
}
.card-line {
margin-top: 5px;

}
.card-line { margin-top: 5px; }
.card-desc { float: left; width: 120px; }
.card-cont { margin-left: 120px; }

.card-word, .card-cont {
word-wrap: break-word;
}
.card-vote { bottom: 0; position: absolute;}
.card-word, .card-cont { word-wrap: break-word; }
9 changes: 9 additions & 0 deletions src/app/card-component/card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import {Card} from "../card/card";
})
export class CardComponent implements OnInit {

DisableButton: boolean = false;

constructor() {
}

Expand All @@ -18,4 +20,11 @@ export class CardComponent implements OnInit {
ngOnInit() {
}

hitUpvote(): number {
this.card.likes += 1;
this.DisableButton = true;
console.log(this.card.likes);
return this.card.likes;
}

}
3 changes: 2 additions & 1 deletion src/app/card/card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ export interface Card {
synonym: string,
antonym: string,
general_sense: string,
example_usage: string
example_usage: string,
likes: number;
}
7 changes: 4 additions & 3 deletions src/app/deck/deck.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ export class DeckService {
}

public addNewCard(deckID: string, word: string, synonym: string, antonym: string, general: string, example: string) {
const body : Card = {
const body: Card = {
word: word,
synonym: synonym,
antonym: antonym,
general_sense: general,
example_usage: example
}
example_usage: example,
likes: 0
};
console.log(body);

return this.db.doc('decks/' + deckID).collection('cards').add(body);
Expand Down
3 changes: 2 additions & 1 deletion src/app/new-card-dialog/new-card-dialog.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export class NewCardDialogComponent implements OnInit {
this.newCardSynonym,
this.newCardAntonym,
this.newCardGeneral,
this.newCardExample).then(
this.newCardExample,
).then(
succeeded => {
//this.cardAddSuccess = true;
this.matDialogRef.close(succeeded);
Expand Down