Created
January 30, 2021 04:31
-
-
Save syamjayaraj/460215f1532e62fef849498688c92c8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import { Modal, Button } from "react-bootstrap"; | |
import { PieChart } from "react-minimal-pie-chart"; | |
function Question(props) { | |
let { correct, incorrect, testAgain } = props; | |
let correctPercentage = (correct / 10) * 100; | |
let incorrectPercentage = 100 - correctPercentage; | |
return ( | |
<Modal show={true} onHide={testAgain} animation={false}> | |
<Modal.Header> | |
<Modal.Title>Your luck: {correctPercentage}%</Modal.Title> | |
</Modal.Header> | |
<Modal.Body> | |
<PieChart | |
data={[ | |
{ | |
title: "Correct", | |
value: correctPercentage, | |
color: "#38bb38", | |
}, | |
{ | |
title: "Incorrect", | |
value: incorrectPercentage, | |
color: "#e24646", | |
}, | |
]} | |
/> | |
<div className="numbers-container"> | |
<div className="numbers"> | |
<div className="number correct">{correct}</div> | |
<div className="number incorrect">{incorrect}</div> | |
</div> | |
</div> | |
</Modal.Body> | |
<Modal.Footer> | |
<Button variant="primary" onClick={testAgain}> | |
Test again | |
</Button> | |
</Modal.Footer> | |
</Modal> | |
); | |
} | |
export default Question; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment