diff --git a/src/components/equative-explorer/EquativeDisplay.tsx b/src/components/equative-explorer/EquativeDisplay.tsx index e76a7b5..8608ed2 100644 --- a/src/components/equative-explorer/EquativeDisplay.tsx +++ b/src/components/equative-explorer/EquativeDisplay.tsx @@ -13,7 +13,7 @@ import { assembleEquativeOutput, SubjectInput, } from "../../lib/equative-machine"; -import { isNoun, isPluralEntry } from "../../lib/type-predicates"; +import { isNoun, isPluralEntry, isUnisexNoun } from "../../lib/type-predicates"; function EquativeDisplay({ state }: { state: ExplorerState }) { if (state.subjectType === "pronouns") { @@ -27,6 +27,9 @@ function EquativeDisplay({ state }: { state: ExplorerState }) { const subjInput: SubjectInput = isNoun(entry) ? { entry, plural: isPluralEntry(entry) ? true : state.subjectsSelected.info.plural, + ...isUnisexNoun(entry) ? { + gender: state.subjectsSelected.info.gender, + } : {}, } : entry; const eq = assembleEquativeOutput( diff --git a/src/components/equative-explorer/EquativeExplorer.tsx b/src/components/equative-explorer/EquativeExplorer.tsx index 4b8bfcf..708fb94 100644 --- a/src/components/equative-explorer/EquativeExplorer.tsx +++ b/src/components/equative-explorer/EquativeExplorer.tsx @@ -28,6 +28,7 @@ const defaultState: ExplorerState = { subjectsSelected: { noun: defaultNoun, participle: defaultParticiple, + unisexNoun: defaultUnisexNoun, info: { plural: false, gender: "masc", @@ -44,7 +45,7 @@ function EquativeExplorer() { unsafeSetState(newState); } return <> -
+
diff --git a/src/components/equative-explorer/explorer-inputs.ts b/src/components/equative-explorer/explorer-inputs.ts index 256cdb8..68d3282 100644 --- a/src/components/equative-explorer/explorer-inputs.ts +++ b/src/components/equative-explorer/explorer-inputs.ts @@ -7,14 +7,14 @@ import { ParticipleInput, } from "../../lib/equative-machine"; -const unisexNouns = nouns.filter(x => isUnisexNoun(x)) as UnisexNoun[]; -const nonUnisexNouns = nouns.filter(x => !isUnisexNoun(x)) as (MascNoun | FemNoun)[]; +const unisexNouns = sort(nouns.filter(x => isUnisexNoun(x)) as UnisexNoun[]); +const nonUnisexNouns = sort(nouns.filter(x => !isUnisexNoun(x)) as (MascNoun | FemNoun)[]); const inputs = { adjective: sort(adjectives), - unisexNoun: sort(unisexNouns), - noun: sort(nonUnisexNouns), + unisexNoun: unisexNouns, + noun: nonUnisexNouns, // @ts-ignore participle: sort(verbs.map(e => e.entry) as ParticipleInput[]), }; diff --git a/src/components/equative-explorer/explorer-reducer.ts b/src/components/equative-explorer/explorer-reducer.ts index f7b26b9..e248d2c 100644 --- a/src/components/equative-explorer/explorer-reducer.ts +++ b/src/components/equative-explorer/explorer-reducer.ts @@ -41,13 +41,25 @@ export function reducer(state: ExplorerState, action: ExplorerReducerAction): Ex }, }; } + if (action.type === "setSubjectPlural") { + return { + ...state, + subjectsSelected: { + ...state.subjectsSelected, + info: { + ...state.subjectsSelected.info, + plural: action.payload, + }, + }, + }; + } return { ...state, subjectsSelected: { ...state.subjectsSelected, info: { ...state.subjectsSelected.info, - plural: action.payload, + gender: action.payload, }, }, }; diff --git a/src/components/equative-explorer/explorer-selectors.tsx b/src/components/equative-explorer/explorer-selectors.tsx index 93fd5ac..c93f625 100644 --- a/src/components/equative-explorer/explorer-selectors.tsx +++ b/src/components/equative-explorer/explorer-selectors.tsx @@ -8,10 +8,16 @@ import { } from "./explorer-types"; import { ButtonSelect, + Types as T, } from "@lingdocs/pashto-inflector"; import { isPluralEntry } from "../../lib/type-predicates"; import Select from "react-select"; +const zIndexProps = { + menuPortalTarget: document.body, + styles: { menuPortal: (base: any) => ({ ...base, zIndex: 9999 }) }, +}; + export function SubjectSelector({ state, dispatch }: { state: ExplorerState, dispatch: (action: ExplorerReducerAction) => void, @@ -36,7 +42,7 @@ export function SubjectSelector({ state, dispatch }: { ? undefined : state.subjectsSelected[state.subjectType]; return
- +
+
+ + +
o.value === subject?.ts.toString())?.label} + {...zIndexProps} /> - {state.subjectType === "noun" && dispatch({ type: "setSubjectPlural", payload: p === "plural" ? true : false })} - />} +
+ {state.subjectType !== "participle" &&
+ dispatch({ type: "setSubjectPlural", payload: p === "plural" ? true : false })} + /> +
} + {state.subjectType === "unisexNoun" &&
+ dispatch({ type: "setSubjectGender", payload: p as T.Gender })} + /> +
} +
}
; @@ -121,7 +157,7 @@ export function PredicateSelector({ state, dispatch }: { })); const predicate = state.predicatesSelected[state.predicateType]; return
- +
o.value === predicate.ts.toString())?.label} + {...zIndexProps} />
; } diff --git a/src/components/equative-explorer/explorer-types.ts b/src/components/equative-explorer/explorer-types.ts index e427a34..0e66da1 100644 --- a/src/components/equative-explorer/explorer-types.ts +++ b/src/components/equative-explorer/explorer-types.ts @@ -2,7 +2,7 @@ import { Types as T } from "@lingdocs/pashto-inflector"; import { ParticipleInput } from "../../lib/equative-machine"; export type PredicateType = keyof PredicatesSelected; -export type SubjectType = "noun" | "pronouns" | "participle"; +export type SubjectType = "noun" | "pronouns" | "participle" | "unisexNoun"; export type ExplorerState = { subjectType: SubjectType, @@ -17,6 +17,7 @@ type PredicatesSelected = { type SubjectSelected = { noun: Noun, participle: ParticipleInput, + unisexNoun: UnisexNoun, info: { plural: boolean, gender: T.Gender, @@ -33,4 +34,6 @@ export type ExplorerReducerAction = { type: "setSubject", payload: number, } | { type: "setSubjectPlural", payload: boolean, +} | { + type: "setSubjectGender", payload: T.Gender, }; \ No newline at end of file diff --git a/src/content/equatives/equative-explorer.mdx b/src/content/equatives/equative-explorer.mdx index 0d698b2..a1fae47 100644 --- a/src/content/equatives/equative-explorer.mdx +++ b/src/content/equatives/equative-explorer.mdx @@ -4,6 +4,4 @@ title: Equative Explorer 🌎 import EquativeExplorer from "../../components/equative-explorer/EquativeExplorer"; -This is in progress... will be able to explore much more soon. 👷‍♂️ -