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};