gender on nouns in selector

This commit is contained in:
lingdocs 2021-10-21 07:11:43 -04:00
parent c30ff70340
commit a97b85863e
1 changed files with 28 additions and 24 deletions

View File

@ -10,7 +10,7 @@ import {
ButtonSelect, ButtonSelect,
Types as T, Types as T,
} from "@lingdocs/pashto-inflector"; } from "@lingdocs/pashto-inflector";
import { isPluralEntry } from "../../lib/type-predicates"; import { isFemNoun, isMascNoun, isPluralEntry } from "../../lib/type-predicates";
import Select from "react-select"; import Select from "react-select";
const zIndexProps = { const zIndexProps = {
@ -111,8 +111,22 @@ export function SubjectSelector({ state, dispatch }: {
placeholder={options.find(o => o.value === subject?.ts.toString())?.label} placeholder={options.find(o => o.value === subject?.ts.toString())?.label}
{...zIndexProps} {...zIndexProps}
/> />
<div className="d-flex flex-row justify-content-center"> <div className="d-flex flex-row justify-content-center mt-3">
{state.subjectType !== "participle" && <div className={state.subjectType === "unisexNoun" ? "mr-2" : ""}> {state.subjectType !== "participle" && <>
<div className="mr-2">
<ButtonSelect
small
options={[
...(state.subjectType === "unisexNoun" || ("noun" && isMascNoun(state.subjectsSelected[state.subjectType])))
? [{ label: "Masc.", value: "masc" }] : [],
...(state.subjectType === "unisexNoun" || ("noun" && isFemNoun(state.subjectsSelected[state.subjectType])))
? [{ label: "Fem.", value: "fem" }] : [],
]}
value={state.subjectType === "noun" ? (isMascNoun(state.subjectsSelected[state.subjectType]) ? "masc" : "fem") : state.subjectsSelected.info.gender}
handleChange={state.subjectType === "noun" ? p => null : (p) => dispatch({ type: "setSubjectGender", payload: p as T.Gender })}
/>
</div>
<div className="ml-2">
<ButtonSelect <ButtonSelect
small small
options={[ options={[
@ -122,18 +136,8 @@ export function SubjectSelector({ state, dispatch }: {
value={(state.subjectsSelected.info.plural || pluralNounSelected) ? "plural" : "singular"} value={(state.subjectsSelected.info.plural || pluralNounSelected) ? "plural" : "singular"}
handleChange={(p) => dispatch({ type: "setSubjectPlural", payload: p === "plural" ? true : false })} handleChange={(p) => dispatch({ type: "setSubjectPlural", payload: p === "plural" ? true : false })}
/> />
</div>} </div>
{state.subjectType === "unisexNoun" && <div className="ml-2"> </>}
<ButtonSelect
small
options={[
{ label: "Masc.", value: "masc" },
{ label: "Fem.", value: "fem" },
]}
value={state.subjectsSelected.info.gender}
handleChange={(p) => dispatch({ type: "setSubjectGender", payload: p as T.Gender })}
/>
</div>}
</div> </div>
</> </>
} }