Skip to content

Commit

Permalink
Merge pull request #13 from gamer-ai/staging
Browse files Browse the repository at this point in the history
v0.3.1-beta/add-pacing-caret-mode
  • Loading branch information
MUYANGGUO authored Aug 29, 2022
2 parents c5bb049 + 5485cc8 commit 9d026b2
Show file tree
Hide file tree
Showing 8 changed files with 234 additions and 71 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ An elegant typing test tool.

https://github.com/gamer-ai/eletype-frontend/issues


## Community Channel:

Discord: ![Discord](https://img.shields.io/discord/993567075589181621?style=for-the-badge)
Expand All @@ -41,6 +40,9 @@ Discord: ![Discord](https://img.shields.io/discord/993567075589181621?style=for-
- KPM
- Accuracy
- Error analysis (correct/error/missing/extra chars count)
- Pacing Style (word pulse/ character caret):
- Pulse mode: the active word will have an underlien pulse, which helps improve the speed typing habit.
- Caret mode: a pacing caret, advancing character by character, which aligns normal typing habit.

#### 2. Words Card (for English learners)

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eletype",
"version": "0.3.0",
"version": "0.3.1",
"private": true,
"dependencies": {
"@emotion/react": "^11.9.0",
Expand Down
10 changes: 5 additions & 5 deletions src/components/features/Keyboard/DefaultKeyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,23 @@ const DefaultKeyboard = () => {
const [inputChar, setInputChar] = useState("");
const [correctCount, setCorrectCount] = useState(0);
const [incorrectCount, setIncorrectCount] = useState(0);
const accuracy = (correctCount + incorrectCount) === 0 ? 0 : Math.floor(
(correctCount / (correctCount + incorrectCount)) * 100
);
const accuracy =
correctCount + incorrectCount === 0
? 0
: Math.floor((correctCount / (correctCount + incorrectCount)) * 100);
const keys = [..." abcdefghijklmnopqrstuvwxyz "];
const resetStats = () => {
setCorrectCount(0);
setIncorrectCount(0);
};

useEffect(() => {
keyboardRef.current && keyboardRef.current.focus();
});
const handleInputBlur = (event) => {
keyboardRef.current && keyboardRef.current.focus();
};
const handleKeyDown = (event) => {

setInputChar(event.key);
event.preventDefault();
return;
Expand Down
72 changes: 37 additions & 35 deletions src/components/features/TypeBox/Stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,48 @@ import { Box } from "@mui/system";
import { Tooltip } from "@mui/material";
import { CHAR_TOOLTIP_TITLE } from "../../../constants/Constants";

const Stats = ({ status, wpm, countDown, countDownConstant, statsCharCount, rawKeyStrokes}) => {
const Stats = ({
status,
wpm,
countDown,
countDownConstant,
statsCharCount,
rawKeyStrokes,
}) => {
return (
<>
<h3>{countDown} s </h3>
<Box display="flex" flexDirection="row">
<h3>WPM: {Math.round(wpm)}</h3>
{status === "finished" && (
<h4>Accuracy: {Math.round(statsCharCount[0])} %</h4>
)}
{status === "finished" && (
<Tooltip
title={
<span style={{ whiteSpace: "pre-line" }}>
{CHAR_TOOLTIP_TITLE}
</span>
}
>
<h4>
Char:{" "}
<span className="correct-char-stats">{statsCharCount[1]}</span>/
<span className="incorrect-char-stats">
{statsCharCount[2]}
</span>
/<span className="missing-char-stats">{statsCharCount[3]}</span>
/<span className="correct-char-stats">{statsCharCount[4]}</span>
/
<span className="incorrect-char-stats">
{statsCharCount[5]}
</span>
</h4>
</Tooltip>
)}
{status === "finished" && (
<h3>{countDown} s </h3>
<Box display="flex" flexDirection="row">
<h3>WPM: {Math.round(wpm)}</h3>
{status === "finished" && (
<h4>Accuracy: {Math.round(statsCharCount[0])} %</h4>
)}
{status === "finished" && (
<Tooltip
title={
<span style={{ whiteSpace: "pre-line" }}>
{CHAR_TOOLTIP_TITLE}
</span>
}
>
<h4>
Raw KPM: {Math.round((rawKeyStrokes / countDownConstant) * 60.0)}
Char:{" "}
<span className="correct-char-stats">{statsCharCount[1]}</span>/
<span className="incorrect-char-stats">{statsCharCount[2]}</span>/
<span className="missing-char-stats">{statsCharCount[3]}</span>/
<span className="correct-char-stats">{statsCharCount[4]}</span>/
<span className="incorrect-char-stats">{statsCharCount[5]}</span>
</h4>
)}
</Box>
</Tooltip>
)}
{status === "finished" && (
<h4>
Raw KPM: {Math.round((rawKeyStrokes / countDownConstant) * 60.0)}
</h4>
)}
</Box>
</>
);
};

export default Stats;
export default Stats;
Loading

0 comments on commit 9d026b2

Please sign in to comment.