better UI for inflection pattern notice w link to the grammar - still would be better to include the pattern in the inflections object and display this in the inflections table

This commit is contained in:
adueck 2022-09-25 17:22:33 +04:00
parent cecd3e56a8
commit 28e96b2b71
1 changed files with 28 additions and 5 deletions

View File

@ -226,13 +226,19 @@ function IsolatedEntry({ state, dictionary, isolateEntry }: {
}
{editSubmitted && <p>Thank you for your help!</p>}
{inf && <>
{inf.inflections && <div>
<div>Inflection pattern {humanReadableInflectionPattern(getInflectionPattern(
{inf.inflections && (() => {
const pattern = getInflectionPattern(
// @ts-ignore
entry
), textOptions)}</div>
<InflectionsTable inf={inf.inflections} textOptions={textOptions} />
</div>}
);
return <div>
<a href={`https://grammar.lingdocs.com/inflection/inflection-patterns/${inflectionSubUrl(pattern)}`} rel="noreferrer" target="_blank">
<div className="badge bg-light mb-2">Inflection pattern {humanReadableInflectionPattern(pattern, textOptions)}
</div>
</a>
<InflectionsTable inf={inf.inflections} textOptions={textOptions} />
</div>;
})()}
{"plural" in inf && inf.plural !== undefined && <div>
<h5>Plural</h5>
<InflectionsTable inf={inf.plural} textOptions={textOptions} />
@ -284,4 +290,21 @@ function explodeEntry(entry: T.DictionaryEntry): T.DictionaryEntry {
};
}
function inflectionSubUrl(pattern: T.InflectionPattern): string {
return pattern === 0
? ""
: pattern === 1
? "#1-basic"
: pattern === 2
? "#2-words-ending-in-an-unstressed-ی---ey"
: pattern === 3
? "#3-words-ending-in-a-stressed-ی---éy"
: pattern === 4
? "#4-words-with-the-pashtoon-pattern"
: pattern === 5
? "#5-shorter-words-that-squish"
// : pattern === 6
: "#6-inanimate-feminine-nouns-ending-in-ي---ee"
}
export default IsolatedEntry;