Compare commits

..

No commits in common. "1f5f87999b2dbd87f005d54c79351466bdf5e301" and "cde76e6205397ba9e41d7b25215c96229da47a62" have entirely different histories.

5 changed files with 15 additions and 29 deletions

View File

@ -1,5 +1,5 @@
{ {
"name": "study-card-tool", "name": "flash-card-app",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"scripts": { "scripts": {

View File

@ -7,13 +7,10 @@
<meta name="keywords" content="vocabulary,practice,tool" /> <meta name="keywords" content="vocabulary,practice,tool" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#2f4f4f" /> <meta name="theme-color" content="#2f4f4f" />
<meta <meta name="description" content="Practice vocabulary using flash cards" />
name="description"
content="Practice vocabulary through repetition with study cards"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" /> <link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> <link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Study Card Tool</title> <title>React App</title>
</head> </head>
<body> <body>
<noscript>You need to enable JavaScript to run this app.</noscript> <noscript>You need to enable JavaScript to run this app.</noscript>

View File

@ -1,7 +1,7 @@
{ {
"short_name": "Study Card Tool", "short_name": "Flash Card App",
"name": "Study Card Tool", "name": "Flash Card App",
"description": "Practice vocabulary through repetition with study cards", "description": "Practice vocabulary using flash cards",
"icons": [ "icons": [
{ {
"src": "favicon.ico", "src": "favicon.ico",

View File

@ -13,7 +13,7 @@ export function AddExpressionView() {
const [error, setError] = useState<any>(undefined); const [error, setError] = useState<any>(undefined);
return ( return (
<form className="page-with-bottom-navigation"> <div className="page-with-bottom-navigation">
<section className="padding-small scroll"> <section className="padding-small scroll">
<div className="padding-small"> <div className="padding-small">
{error ? <p className="text-error">{error.message}</p> : null} {error ? <p className="text-error">{error.message}</p> : null}
@ -49,10 +49,8 @@ export function AddExpressionView() {
<button <button
className="navigation-item bottom text-navigation grow" className="navigation-item bottom text-navigation grow"
type="submit" type="submit"
value="submit"
disabled={prompt === ""} disabled={prompt === ""}
onClick={async (event) => { onClick={async () => {
event.preventDefault();
try { try {
// `https://en.wiktionary.org/w/api.php?action=parse&format=json&prop=text&page=${query}`; // `https://en.wiktionary.org/w/api.php?action=parse&format=json&prop=text&page=${query}`;
const url = URL.format({ const url = URL.format({
@ -69,15 +67,9 @@ export function AddExpressionView() {
}); });
const result = await fetch(url); const result = await fetch(url);
const data = await result.json(); const data = await result.json();
const expressionData = parseWiktionaryData( setExpression(
prompt, parseWiktionaryData(prompt, data.parse?.text?.["*"] || "")
data.parse?.text?.["*"] || ""
); );
if (!expressionData)
throw new Error(
`Unable to find expression "${prompt}" on Wiktionary in the given language`
);
setExpression(expressionData);
} catch (error) { } catch (error) {
setError(error); setError(error);
} }
@ -91,7 +83,6 @@ export function AddExpressionView() {
className="navigation-item bottom text-navigation grow" className="navigation-item bottom text-navigation grow"
type="button" type="button"
onClick={() => { onClick={() => {
setPrompt("");
setExpression(null); setExpression(null);
setSubmitStatus(undefined); setSubmitStatus(undefined);
setError(undefined); setError(undefined);
@ -113,14 +104,12 @@ export function AddExpressionView() {
expression_set_id: 1, expression_set_id: 1,
category_ids: [], category_ids: [],
}); });
setExpression(null);
setSubmitStatus(`Card "${expression.prompt}" saved`); setSubmitStatus(`Card "${expression.prompt}" saved`);
setError(undefined); setError(undefined);
} catch (error) { } catch (error) {
setSubmitStatus(undefined); setSubmitStatus(undefined);
setError(error); setError(error);
} finally {
setPrompt("");
setExpression(null);
} }
}} }}
> >
@ -129,6 +118,6 @@ export function AddExpressionView() {
</> </>
)} )}
</section> </section>
</form> </div>
); );
} }

View File

@ -1,7 +1,7 @@
export function HomeView() { export function HomeView() {
return ( return (
<div className="page-with-padding content-text scroll"> <div className="page-with-padding content-text scroll">
<h1 className="text-title margin-title">Study Card Tool</h1> <h1 className="text-title margin-title">Flash Card App</h1>
<p className="text-details margin-paragraph"> <p className="text-details margin-paragraph">
A handy tool for vocabulary practice through repetition. Go to{" "} A handy tool for vocabulary practice through repetition. Go to{" "}
<i>settings -&gt; create card</i> to start adding words for practicing. <i>settings -&gt; create card</i> to start adding words for practicing.
@ -46,7 +46,7 @@ export function HomeView() {
. .
</p> </p>
<p className="text-details margin-paragraph"> <p className="text-details margin-paragraph">
The content for the study cards generated is dual-licensed under{" "} The content for the flash cards generated is dual-licensed under{" "}
<a <a
className="link" className="link"
target="_blank" target="_blank"
@ -93,7 +93,7 @@ export function HomeView() {
<h2 className="text-title margin-title">Support the app</h2> <h2 className="text-title margin-title">Support the app</h2>
<p className="text-details margin-paragraph"> <p className="text-details margin-paragraph">
This app would not exist if it was not for Wiktionary and the Wikimedia This app would not exist if it was not for Wiktionary and the Wikimedia
foundation. If you want to support anyone consider donating to the{" "} foundation. If you want to support anyone, consider donating to the{" "}
<a <a
className="link" className="link"
target="_blank" target="_blank"