From a5c2b38ba758d851c546daa5b4e73f005d4d4495 Mon Sep 17 00:00:00 2001 From: oleeh-shd Date: Fri, 11 Aug 2023 16:50:21 +0300 Subject: [PATCH] added skeleton where needed --- .../verse/[verseNumber]/verse-page.tsx | 27 ++++++++++-- components/Home/VerseOfDay.tsx | 42 ++++++++++++------- components/Shared/Skeleton.tsx | 15 +++++++ components/Verse/Commentary.tsx | 33 ++++++++++----- components/Verse/Translation.tsx | 24 +++++++---- 5 files changed, 103 insertions(+), 38 deletions(-) create mode 100644 components/Shared/Skeleton.tsx diff --git a/app/chapter/[chapterNumber]/verse/[verseNumber]/verse-page.tsx b/app/chapter/[chapterNumber]/verse/[verseNumber]/verse-page.tsx index 077ad62..020bd3b 100644 --- a/app/chapter/[chapterNumber]/verse/[verseNumber]/verse-page.tsx +++ b/app/chapter/[chapterNumber]/verse/[verseNumber]/verse-page.tsx @@ -11,6 +11,7 @@ import { SvgFloralDivider } from "../../../../../components/svgs"; import Translation from "../../../../../components/Verse/Translation"; import Commentary from "../../../../../components/Verse/Commentary"; import PageHeader from "../../../../../components/Headers/PageHeader"; +import { Skeleton } from "../../../../../components/Shared/Skeleton"; type Props = { chapterNumber: string; @@ -107,15 +108,21 @@ export default function VersePage({ chapterNumber, verseNumber }: Props) { > BG {currentVerse?.chapter_number}.{currentVerse?.verse_number} - {devnagari && ( + {devnagari && currentVerse.text ? (

- {currentVerse?.text} + {currentVerse.text}

+ ) : ( +
+ + + +
)} {verseText && (

)} - {synonyms && ( + {synonyms && currentVerse?.word_meanings ? (

- {currentVerse?.word_meanings} + {currentVerse.word_meanings}

+ ) : ( + <> +
+ + +
+
+ + + +
+ )} {(translation || purport) && ( { return (
-

- Verse of the day - BG {dailyVerse?.chapterNumber}. - {dailyVerse?.verseNumber} -

-

- {dailyVerse?.gitaTranslationsByVerseId?.nodes[0]?.description}{" "} -

- + {dailyVerse ? ( + <> +

+ Verse of the day - BG {dailyVerse?.chapterNumber}. + {dailyVerse?.verseNumber} +

+

+ {dailyVerse?.gitaTranslationsByVerseId?.nodes[0]?.description}{" "} +

+ + + ) : ( + <> + + + + + + )}
); diff --git a/components/Shared/Skeleton.tsx b/components/Shared/Skeleton.tsx new file mode 100644 index 0000000..264c574 --- /dev/null +++ b/components/Shared/Skeleton.tsx @@ -0,0 +1,15 @@ +import { FC } from "react"; + +type SkeletonProps = { + height: string; + width: string; + margin: string; +}; + +export const Skeleton: FC = ({ height, width, margin }) => { + return ( +
+ ); +}; diff --git a/components/Verse/Commentary.tsx b/components/Verse/Commentary.tsx index 52be6bc..b02736b 100644 --- a/components/Verse/Commentary.tsx +++ b/components/Verse/Commentary.tsx @@ -1,6 +1,7 @@ import useMyStyles from "../../hooks/useMyStyles"; import classNames from "../../utils/classNames"; import splitIntoParagraphs from "../../utils/splitIntoParagraphs"; +import { Skeleton } from "../Shared/Skeleton"; interface Props { commentaryData: GitaLanguage[] | undefined; @@ -21,17 +22,27 @@ export default function Commentary({ commentaryData }: Props) { > Commentary - {paragraphs?.map((paragraph) => ( -

- {paragraph} -

- ))} + {paragraphs?.[0] ? ( + paragraphs.map((paragraph) => ( +

+ {paragraph} +

+ )) + ) : ( + <> + + + + + + + )}
); } diff --git a/components/Verse/Translation.tsx b/components/Verse/Translation.tsx index 75f04b2..aed8764 100644 --- a/components/Verse/Translation.tsx +++ b/components/Verse/Translation.tsx @@ -1,5 +1,6 @@ import useMyStyles from "../../hooks/useMyStyles"; import classNames from "../../utils/classNames"; +import { Skeleton } from "../Shared/Skeleton"; interface Props { translationData: GitaLanguage[] | undefined; @@ -18,14 +19,21 @@ export default function Translation({ translationData }: Props) { > Translation -

- {translationData ? translationData[0]?.description : ""} -

+ {translationData && translationData[0]?.description ? ( +

+ {translationData[0].description} +

+ ) : ( + <> + + + + )} ); }