From 9a9d92d4da9fce9a3c75471140401806412ef1b0 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 13 Sep 2022 16:54:26 +0400 Subject: [PATCH] better inflections display --- website/package.json | 4 +-- website/src/App.css | 8 ++++++ website/src/components/ExtraEntryInfo.tsx | 35 ++++++++++++----------- website/src/screens/IsolatedEntry.tsx | 25 +++++++++++++++- website/yarn.lock | 8 +++--- 5 files changed, 57 insertions(+), 23 deletions(-) diff --git a/website/package.json b/website/package.json index 08f245f..b09e0be 100644 --- a/website/package.json +++ b/website/package.json @@ -7,7 +7,7 @@ "private": true, "dependencies": { "@fortawesome/fontawesome-free": "^5.15.2", - "@lingdocs/pashto-inflector": "3.8.9", + "@lingdocs/pashto-inflector": "3.9.4", "@testing-library/jest-dom": "^5.11.4", "@testing-library/react": "^11.1.0", "@testing-library/user-event": "^12.1.10", @@ -110,6 +110,6 @@ "user-event": "^4.0.0" }, "peerDependencies": { - "@lingdocs/pashto-inflector": "3.8.9" + "@lingdocs/pashto-inflector": "3.9.4" } } diff --git a/website/src/App.css b/website/src/App.css index 2ca83c8..fbbb983 100644 --- a/website/src/App.css +++ b/website/src/App.css @@ -140,6 +140,14 @@ hr { margin-left: 1rem; } +.inflections-preview-table { + table-layout: fixed; +} + +.inflections-preview-table td { + padding-right: 1rem; +} + kbd { background-color: #eee; border-radius: 3px; diff --git a/website/src/components/ExtraEntryInfo.tsx b/website/src/components/ExtraEntryInfo.tsx index 4d28668..310e931 100644 --- a/website/src/components/ExtraEntryInfo.tsx +++ b/website/src/components/ExtraEntryInfo.tsx @@ -5,14 +5,20 @@ * LICENSE file in the root directory of this source tree. * */ - -import React from "react"; -import { inflectWord, Types, InlinePs } from "@lingdocs/pashto-inflector"; +import { + inflectWord, + Types, + InlinePs, +} from "@lingdocs/pashto-inflector"; +import { isAdjectiveEntry, isNounEntry } from "@lingdocs/pashto-inflector/dist/lib/type-predicates"; const InflectionsInfo = ({ entry, textOptions }: { entry: Types.DictionaryEntry, textOptions: Types.TextOptions, }) => { + if (!isNounEntry(entry) && !isAdjectiveEntry(entry)) { + return null; + } const inf = ((): Types.InflectorOutput | false => { try { return inflectWord(entry); @@ -24,21 +30,11 @@ const InflectionsInfo = ({ entry, textOptions }: { if (!inf) { return null; } - // unisex noun / adjective - if (inf.inflections && "masc" in inf.inflections && "fem" in inf.inflections) { + if (inf.inflections) { + // TODO: would be nice if inflection pattern number was in the inflections object return (
Thank you for your help!
} {inf && <> - {inf.inflections &&