Skip to content

Instantly share code, notes, and snippets.

@syamjayaraj
Created January 30, 2021 04:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save syamjayaraj/460215f1532e62fef849498688c92c8b to your computer and use it in GitHub Desktop.
Save syamjayaraj/460215f1532e62fef849498688c92c8b to your computer and use it in GitHub Desktop.
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