From a4c48b3cceeb1103d1caed5d7193269a1ccd04a3 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Mon, 13 Sep 2021 00:00:51 -0700 Subject: [PATCH] Move entry components into separate file --- src/App.tsx | 76 +---------------------------------------------- src/Entries.tsx | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+), 75 deletions(-) create mode 100644 src/Entries.tsx diff --git a/src/App.tsx b/src/App.tsx index f88fc67..3f300a3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,8 +1,8 @@ import React, {useState} from 'react'; import './App.scss'; -import {declineSaimiar} from './saimiar_morphology'; import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from './dbtypes'; +import {SaiEntry, JutEntry, ElesuEntry, TukEntry} from './Entries'; const backendUrl = 'https://kucinakobackend.ichigo.everydayimshuflin.com'; @@ -81,80 +81,6 @@ const Entry = (props: EntryProps) => { } }; -const SaiEntry = (props: {entry: SaiEntryProps}) => { - const {entry} = props; - const synCategory = entry.syn_category; - const isNominal = synCategory === 'nominal'; - return ( -
- { entry.sai } - { entry.eng } -
- - { entry.syn_category } - { entry.morph_type ? `\t\t${entry.morph_type}` : null } -
- { isNominal ? formatMorphology(entry) : null } -
-
- ); -}; - -const JutEntry = (props: {entry: JutEntryProps}) => { - const {entry} = props; - - return ( -
- { entry.jut } - { entry.eng } -
- - { entry.syn_category === 'noun' ? entry.gender : null } - -
); -}; - -const ElesuEntry = (props: {entry: ElesuEntryProps}) => { - const {entry} = props; - - return ( -
- { entry.elesu } - { entry.eng } -
- - { entry.syn_category } - -
); -}; - -const TukEntry = (props: {entry: TukEntryProps}) => { - const {entry} = props; - - return ( -
- { entry.tuk } - { entry.eng } -
- - { entry.syn_category } - -
); -}; - -function formatMorphology(entry) { - const decl = declineSaimiar(entry); - if (!decl) { - return ''; - } - - return ( - Abs: {decl.abs}, Erg: {decl.erg}, - Adp: {decl.adp}, - All: {decl.all}, - Loc: {decl.loc}, - Ell: {decl.ell}, - Inst: {decl.inst}, - Rel: {decl.rel} - ); -} - interface ResultsProps { searchResults: Array; searchTerm: string; diff --git a/src/Entries.tsx b/src/Entries.tsx new file mode 100644 index 0000000..9238b8f --- /dev/null +++ b/src/Entries.tsx @@ -0,0 +1,79 @@ +import React from 'react'; +import {declineSaimiar} from './saimiar_morphology'; +import {SaiEntryProps, JutEntryProps, ElesuEntryProps, TukEntryProps} from './dbtypes'; + +const SaiEntry = (props: {entry: SaiEntryProps}) => { + const {entry} = props; + const synCategory = entry.syn_category; + const isNominal = synCategory === 'nominal'; + return ( +
+ { entry.sai } - { entry.eng } +
+ + { entry.syn_category } + { entry.morph_type ? `\t\t${entry.morph_type}` : null } +
+ { isNominal ? formatMorphology(entry) : null } +
+
+ ); +}; + +function formatMorphology(entry) { + const decl = declineSaimiar(entry); + if (!decl) { + return ''; + } + + return ( + Abs: {decl.abs}, Erg: {decl.erg}, + Adp: {decl.adp}, + All: {decl.all}, + Loc: {decl.loc}, + Ell: {decl.ell}, + Inst: {decl.inst}, + Rel: {decl.rel} + ); +} + +const JutEntry = (props: {entry: JutEntryProps}) => { + const {entry} = props; + + return ( +
+ { entry.jut } - { entry.eng } +
+ + { entry.syn_category === 'noun' ? entry.gender : null } + +
); +}; + +const ElesuEntry = (props: {entry: ElesuEntryProps}) => { + const {entry} = props; + + return ( +
+ { entry.elesu } - { entry.eng } +
+ + { entry.syn_category } + +
); +}; + +const TukEntry = (props: {entry: TukEntryProps}) => { + const {entry} = props; + + return ( +
+ { entry.tuk } - { entry.eng } +
+ + { entry.syn_category } + +
); +}; + +export {SaiEntry, ElesuEntry, JutEntry, TukEntry};