fixed speed
This commit is contained in:
parent
7561dd5279
commit
a9e17553b0
|
@ -24,7 +24,8 @@ function Sidebar({ content, navOpen, setNavOpen, pathname }) {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<aside className={classNames(
|
<aside
|
||||||
|
className={classNames(
|
||||||
"side-nav col-3 col-lg-2 p-0 bg-light",
|
"side-nav col-3 col-lg-2 p-0 bg-light",
|
||||||
{ "side-nav-closed": !navOpen }
|
{ "side-nav-closed": !navOpen }
|
||||||
)}>
|
)}>
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import {
|
import { comparePs } from "../../lib/game-utils";
|
||||||
comparePs,
|
|
||||||
} from "../../lib/game-utils";
|
|
||||||
import genderColors from "../../lib/gender-colors";
|
import genderColors from "../../lib/gender-colors";
|
||||||
import GameCore from "../GameCore";
|
import GameCore from "../GameCore";
|
||||||
import {
|
import {
|
||||||
|
@ -17,20 +15,34 @@ import { nouns } from "../../words/words";
|
||||||
import { intoPatterns } from "../../lib/categorize";
|
import { intoPatterns } from "../../lib/categorize";
|
||||||
|
|
||||||
const unisexNouns = nouns.filter(tp.isUnisexNounEntry);
|
const unisexNouns = nouns.filter(tp.isUnisexNounEntry);
|
||||||
type NType = "pattern1" | "pattern2" | "pattern3" | "pattern4" | "pattern5" | "other";
|
type NType =
|
||||||
|
| "pattern1"
|
||||||
|
| "pattern2"
|
||||||
|
| "pattern3"
|
||||||
|
| "pattern4"
|
||||||
|
| "pattern5"
|
||||||
|
| "other";
|
||||||
// TODO: make pattern types as overlay types
|
// TODO: make pattern types as overlay types
|
||||||
const types = intoPatterns(unisexNouns);
|
const types = intoPatterns(unisexNouns);
|
||||||
const genders: T.Gender[] = ["masc", "fem"];
|
const genders: T.Gender[] = ["masc", "fem"];
|
||||||
|
|
||||||
const amount = 20;
|
const amount = 14;
|
||||||
|
|
||||||
type Question = { entry: T.DictionaryEntry, gender: T.Gender };
|
type Question = { entry: T.DictionaryEntry; gender: T.Gender };
|
||||||
|
|
||||||
export default function UnisexNounGame({ id, link, inChapter }: { inChapter: boolean, id: string, link: string }) {
|
export default function UnisexNounGame({
|
||||||
|
id,
|
||||||
|
link,
|
||||||
|
inChapter,
|
||||||
|
}: {
|
||||||
|
inChapter: boolean;
|
||||||
|
id: string;
|
||||||
|
link: string;
|
||||||
|
}) {
|
||||||
let pool = { ...types };
|
let pool = { ...types };
|
||||||
function getQuestion(): Question {
|
function getQuestion(): Question {
|
||||||
const keys = Object.keys(types) as NType[];
|
const keys = Object.keys(types) as NType[];
|
||||||
let type: NType
|
let type: NType;
|
||||||
do {
|
do {
|
||||||
type = randFromArray(keys);
|
type = randFromArray(keys);
|
||||||
} while (!pool[type].length);
|
} while (!pool[type].length);
|
||||||
|
@ -61,9 +73,11 @@ export default function UnisexNounGame({ id, link, inChapter }: { inChapter: boo
|
||||||
if (!inflections.masc || !inflections.fem) {
|
if (!inflections.masc || !inflections.fem) {
|
||||||
return <div>WORD ERROR</div>;
|
return <div>WORD ERROR</div>;
|
||||||
}
|
}
|
||||||
const handleInput = ({ target: { value }}: React.ChangeEvent<HTMLInputElement>) => {
|
const handleInput = ({
|
||||||
|
target: { value },
|
||||||
|
}: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
setAnswer(value);
|
setAnswer(value);
|
||||||
}
|
};
|
||||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
|
@ -73,18 +87,40 @@ export default function UnisexNounGame({ id, link, inChapter }: { inChapter: boo
|
||||||
setAnswer("");
|
setAnswer("");
|
||||||
}
|
}
|
||||||
callback(correct);
|
callback(correct);
|
||||||
}
|
};
|
||||||
|
|
||||||
return <div>
|
return (
|
||||||
<div className="pt-2 pb-1 mb-2" style={{ maxWidth: "300px", margin: "0 auto", backgroundColor: genderColors[question.gender === "masc" ? "m" : "f"]}}>
|
<div>
|
||||||
<Examples opts={opts}>{[
|
<div
|
||||||
|
className="pt-2 pb-1 mb-2"
|
||||||
|
style={{
|
||||||
|
maxWidth: "300px",
|
||||||
|
margin: "0 auto",
|
||||||
|
backgroundColor:
|
||||||
|
genderColors[question.gender === "masc" ? "m" : "f"],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Examples opts={opts}>
|
||||||
|
{[
|
||||||
{
|
{
|
||||||
...inflections[question.gender][0][0],
|
...inflections[question.gender][0][0],
|
||||||
e: firstVariation(question.entry.e),
|
e: firstVariation(question.entry.e),
|
||||||
}
|
},
|
||||||
]}</Examples>
|
]}
|
||||||
|
</Examples>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
Is {givenGender}. Make it{" "}
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
background:
|
||||||
|
genderColors[requiredGender === "masculine" ? "m" : "f"],
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{requiredGender}
|
||||||
|
</span>
|
||||||
|
.
|
||||||
</div>
|
</div>
|
||||||
<div>Is {givenGender}. Make it <span style={{ background: genderColors[requiredGender === "masculine" ? "m" : "f"]}}>{requiredGender}</span>.</div>
|
|
||||||
<form onSubmit={handleSubmit}>
|
<form onSubmit={handleSubmit}>
|
||||||
<div className="my-3" style={{ maxWidth: "200px", margin: "0 auto" }}>
|
<div className="my-3" style={{ maxWidth: "200px", margin: "0 auto" }}>
|
||||||
<input
|
<input
|
||||||
|
@ -102,14 +138,16 @@ export default function UnisexNounGame({ id, link, inChapter }: { inChapter: boo
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Instructions() {
|
function Instructions() {
|
||||||
return <div>
|
return (
|
||||||
|
<div>
|
||||||
<h5>Change the gender of a given noun</h5>
|
<h5>Change the gender of a given noun</h5>
|
||||||
</div>
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function DisplayCorrectAnswer({ question }: { question: Question }) {
|
function DisplayCorrectAnswer({ question }: { question: Question }) {
|
||||||
|
@ -118,15 +156,20 @@ export default function UnisexNounGame({ id, link, inChapter }: { inChapter: boo
|
||||||
const { inflections } = infOut;
|
const { inflections } = infOut;
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const correctAnswer = inflections[flipGender(question.gender)][0];
|
const correctAnswer = inflections[flipGender(question.gender)][0];
|
||||||
return <div>
|
return (
|
||||||
{correctAnswer.length > 1 && <div className="text-muted">One of the following:</div>}
|
<div>
|
||||||
|
{correctAnswer.length > 1 && (
|
||||||
|
<div className="text-muted">One of the following:</div>
|
||||||
|
)}
|
||||||
{correctAnswer.map((ps: any) => (
|
{correctAnswer.map((ps: any) => (
|
||||||
<Examples opts={opts}>{ps}</Examples>
|
<Examples opts={opts}>{ps}</Examples>
|
||||||
))}
|
))}
|
||||||
</div>;
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <GameCore
|
return (
|
||||||
|
<GameCore
|
||||||
inChapter={inChapter}
|
inChapter={inChapter}
|
||||||
studyLink={link}
|
studyLink={link}
|
||||||
getQuestion={getQuestion}
|
getQuestion={getQuestion}
|
||||||
|
@ -134,10 +177,11 @@ export default function UnisexNounGame({ id, link, inChapter }: { inChapter: boo
|
||||||
Display={Display}
|
Display={Display}
|
||||||
DisplayCorrectAnswer={DisplayCorrectAnswer}
|
DisplayCorrectAnswer={DisplayCorrectAnswer}
|
||||||
amount={amount}
|
amount={amount}
|
||||||
timeLimit={130}
|
timeLimit={175}
|
||||||
Instructions={Instructions}
|
Instructions={Instructions}
|
||||||
/>
|
/>
|
||||||
};
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function flipGender(g: T.Gender): T.Gender {
|
function flipGender(g: T.Gender): T.Gender {
|
||||||
return g === "masc" ? "fem" : "masc";
|
return g === "masc" ? "fem" : "masc";
|
||||||
|
|
Loading…
Reference in New Issue