From f0f66f7056de48e535ba5344c1930bca6986385a Mon Sep 17 00:00:00 2001 From: kj1352 Date: Mon, 25 Jan 2021 07:20:21 +0530 Subject: [PATCH] Partial commit --- Swiper cards for quiz --- src/app/quiz/quiz.page.html | 2 +- src/app/quiz/quiz.page.ts | 13 ++++---- .../swipe-cards/swipe-cards.component.html | 16 ++++++++-- .../swipe-cards/swipe-cards.component.scss | 30 +++++++++++++++++++ .../quiz/swipe-cards/swipe-cards.component.ts | 14 +++++---- 5 files changed, 60 insertions(+), 15 deletions(-) diff --git a/src/app/quiz/quiz.page.html b/src/app/quiz/quiz.page.html index 2d256e0..8228fdf 100644 --- a/src/app/quiz/quiz.page.html +++ b/src/app/quiz/quiz.page.html @@ -24,7 +24,7 @@
  • - +
  • diff --git a/src/app/quiz/quiz.page.ts b/src/app/quiz/quiz.page.ts index ee12e0a..9918e41 100644 --- a/src/app/quiz/quiz.page.ts +++ b/src/app/quiz/quiz.page.ts @@ -7,18 +7,18 @@ import * as faker from 'faker'; styleUrls: ['./quiz.page.scss'], }) export class QuizPage implements OnInit { - secondsPerQuestion: number = 30; - selectedQuestion: number = 0; + secondsPerQuestion: number; + selectedQuestion: number = 1; questions: Array<{ type: 'MCQ' | 'CARD', - question: string, + question: string | Array, choices?: Array<{ value: string, text: string, }>, correctAnswer?: string, - secondsAllotted?: number + secondsAllotted: number }>; constructor() { } @@ -50,16 +50,19 @@ export class QuizPage implements OnInit { secondsAllotted: 50 }, { type: 'CARD', - question: faker.lorem.sentence(), + question: [faker.lorem.sentence(), faker.lorem.sentence(), faker.lorem.sentence(), faker.lorem.sentence()], secondsAllotted: 50 }]; + this.secondsPerQuestion = this.questions[this.selectedQuestion].secondsAllotted; + } nextQuestion() { if (this.selectedQuestion < this.questions.length - 1) { this.selectedQuestion += 1; + this.secondsPerQuestion = this.questions[this.selectedQuestion].secondsAllotted; } } diff --git a/src/app/quiz/swipe-cards/swipe-cards.component.html b/src/app/quiz/swipe-cards/swipe-cards.component.html index 92c8e43..fc069e1 100644 --- a/src/app/quiz/swipe-cards/swipe-cards.component.html +++ b/src/app/quiz/swipe-cards/swipe-cards.component.html @@ -1,3 +1,13 @@ -

    - swipe-cards works! -

    +
    + +

    + {{ question }} +

    + +
    + + +
    +
    +
    \ No newline at end of file diff --git a/src/app/quiz/swipe-cards/swipe-cards.component.scss b/src/app/quiz/swipe-cards/swipe-cards.component.scss index e69de29..4a41486 100644 --- a/src/app/quiz/swipe-cards/swipe-cards.component.scss +++ b/src/app/quiz/swipe-cards/swipe-cards.component.scss @@ -0,0 +1,30 @@ +@import '../../colors'; + +.container { + position: relative; + z-index: 0; + display: flex; + align-items: center; + justify-content: center; + height: 60vh; +} + + +ion-card { + margin: 0; + padding: 15px; + + display: inline-block; + width: 100%; + height: 300px; + background: #FFFFFF; + border-radius: 20px; + box-shadow: 0px 0px 15px -2px $dark-blue; + overflow: hidden; + position: absolute; + will-change: transform; + transition: all 0.3s ease-in-out; + cursor: -webkit-grab; + cursor: -moz-grab; + cursor: grab; +} \ No newline at end of file diff --git a/src/app/quiz/swipe-cards/swipe-cards.component.ts b/src/app/quiz/swipe-cards/swipe-cards.component.ts index 69685b6..d104392 100644 --- a/src/app/quiz/swipe-cards/swipe-cards.component.ts +++ b/src/app/quiz/swipe-cards/swipe-cards.component.ts @@ -1,14 +1,16 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, OnInit, Input, ViewChildren, QueryList, ElementRef } from '@angular/core'; @Component({ - selector: 'app-swipe-cards', - templateUrl: './swipe-cards.component.html', - styleUrls: ['./swipe-cards.component.scss'], + selector: 'app-swipe-cards', + templateUrl: './swipe-cards.component.html', + styleUrls: ['./swipe-cards.component.scss'], }) export class SwipeCardsComponent implements OnInit { + @ViewChildren('tinderCard') tinderCards: QueryList; + @Input() questions: Array; - constructor() { } + constructor() { } - ngOnInit() {} + ngOnInit() {} }