added subtext option to examples

This commit is contained in:
Bill D 2021-04-15 16:53:18 +03:00
parent cd636fffb5
commit e64f79e8b3
2 changed files with 13 additions and 6 deletions

View File

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

View File

@ -10,17 +10,19 @@ import Pashto from "./Pashto";
import Phonetics from "./Phonetics"; import Phonetics from "./Phonetics";
import * as T from "../types"; import * as T from "../types";
export default function({ type PsStringWSub = T.PsString & { sub?: any };
function Examples({
children, children,
ex, ex,
opts, opts,
}: { }: {
ex?: T.PsString | T.PsString[], ex?: PsStringWSub | PsStringWSub[],
children: T.PsString | T.PsString[], children: PsStringWSub | PsStringWSub[],
opts: T.TextOptions, opts: T.TextOptions,
}) { }) {
const examples = children || ex; const examples = children || ex;
const Example = ({ children: text }: { children: T.PsString }) => ( const Example = ({ children: text }: { children: PsStringWSub }) => (
<div className="mt-1 mb-3"> <div className="mt-1 mb-3">
<div> <div>
<Pashto opts={opts}>{text}</Pashto> <Pashto opts={opts}>{text}</Pashto>
@ -31,6 +33,9 @@ export default function({
{text.e && <div className="text-muted"> {text.e && <div className="text-muted">
{text.e} {text.e}
</div>} </div>}
{text.sub && <div className="small text-muted">
{text.sub}
</div>}
</div> </div>
); );
return Array.isArray(examples) ? return Array.isArray(examples) ?
@ -40,3 +45,5 @@ export default function({
: :
<Example>{examples}</Example>; <Example>{examples}</Example>;
} }
export default Examples;