better examples

This commit is contained in:
lingdocs 2022-05-09 17:23:55 -05:00
parent 3255b15961
commit 97364b284f
4 changed files with 14 additions and 14 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/pashto-inflector",
"version": "2.5.0",
"version": "2.5.1",
"author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com",

View File

@ -23,25 +23,22 @@ function EnglishContent({ children }: { children: (string | JSX.Element)[] | (st
</div>;
}
function Examples({
children,
ex,
opts,
lineHeight,
}: {
ex?: PsStringWSub | PsStringWSub[] | T.PsJSX | T.PsJSX[],
children: PsStringWSub | PsStringWSub[],
function Examples(props: ({
ex: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[],
} | {
children: T.PsJSX | T.PsJSX[] | PsStringWSub | PsStringWSub[],
}) & {
opts: T.TextOptions,
lineHeight?: 0 | 1 | 2 | 3 | 4,
}) {
const examples = children || ex;
const examples = "children" in props ? props.children : props.ex;
const Example = ({ children: text }: { children: PsStringWSub }) => (
<div className={lineHeight !== undefined ? `mb-${lineHeight}` : `mt-1 mb-3`}>
<div className={props.lineHeight !== undefined ? `mb-${props.lineHeight}` : `mt-1 mb-3`}>
<div>
<Pashto opts={opts}>{text}</Pashto>
<Pashto opts={props.opts}>{text}</Pashto>
</div>
<div>
<Phonetics opts={opts}>{text}</Phonetics>
<Phonetics opts={props.opts}>{text}</Phonetics>
</div>
{text.e && <EnglishContent>
{text.e}
@ -53,9 +50,11 @@ function Examples({
);
return Array.isArray(examples) ?
<div>
{/* @ts-ignore */}
{examples.map((example, i) => <Example key={i}>{example}</Example>)}
</div>
:
// @ts-ignore
<Example>{examples}</Example>;
}

View File

@ -19,7 +19,7 @@ import * as T from "../types";
* @param dealWithString
* @returns
*/
export function psJSXMap(ps: T.PsJSX, target: "p" | "f", dealWithString: (ps: T.PsString) => string): JSX.Element {
export function psJSXMap(ps: T.PsJSX, target: "p" | "f", dealWithString: (ps: T.PsString) => string | JSX.Element): JSX.Element {
const base = ps[target];
const sec = ps[target === "p" ? "f" : "p"];
try {

View File

@ -93,6 +93,7 @@ const equativeBuilders: Record<T.EquativeTense, (p: T.Person, n: boolean) => str
return [
`$SUBJ ${getEnglishConj(p, g.englishEquative.present)}${not(n)} $PRED`,
`$SUBJ tend${isThirdPersonSing(p) ? "s" : ""}${not(n)} to be $PRED`,
`$SUBJ ${n ? "don't " : ""}be $PRED`,
];
},
subjunctive: (p, n) => {