From ddd4fd28f5a3cc882e4632f2563fe9562be811e2 Mon Sep 17 00:00:00 2001 From: Ahmed Ibrahim Date: Thu, 26 Dec 2024 14:01:29 +0200 Subject: [PATCH] refactor(nova): improve topics layout --- apps/nova/src/components/Tutors/Content.tsx | 27 ++--------------- packages/assets/assets/notification-2.svg | 8 +++++ packages/assets/package.json | 1 + .../src/components/TutorCard/TutorCardV1.tsx | 29 +++++++++++++------ 4 files changed, 32 insertions(+), 33 deletions(-) create mode 100644 packages/assets/assets/notification-2.svg diff --git a/apps/nova/src/components/Tutors/Content.tsx b/apps/nova/src/components/Tutors/Content.tsx index 6225ba9c..93f0cfef 100644 --- a/apps/nova/src/components/Tutors/Content.tsx +++ b/apps/nova/src/components/Tutors/Content.tsx @@ -8,7 +8,7 @@ import { motion } from "framer-motion"; import React, { useCallback, useState } from "react"; import { InView } from "react-intersection-observer"; import MoreTutorsSoon from "@litespace/assets/MoreTutorsSoon"; -import Notification from "@litespace/assets/Notification"; +import Notification2 from "@litespace/assets/Notification2"; import { Typography } from "@litespace/luna/Typography"; import { useFormatMessage } from "@litespace/luna/hooks/intl"; import { Button, ButtonSize } from "@litespace/luna/Button"; @@ -16,21 +16,6 @@ import { useToast } from "@litespace/luna/Toast"; type Tutor = Element; -const topics = [ - "hobbies", - "travel", - "books", - "food", - "family", - "health", - "career", - "culture", - "holidays", - "work", - "favourite subjects", - "current events", -]; - const Content: React.FC<{ tutors: ITutor.FindOnboardedTutorsApiResponse["list"] | null; loading: boolean; @@ -75,7 +60,7 @@ const Content: React.FC<{ onBook={() => openBookingDialog(tutor)} profileUrl={profileUrl} imageUrl={tutor.image ? asFullAssetUrl(tutor.image) : null} - topics={topics} + topics={tutor.topics} /> ); @@ -127,13 +112,7 @@ const Content: React.FC<{ > {intl("tutors.coming.set-notifications")} - + diff --git a/packages/assets/assets/notification-2.svg b/packages/assets/assets/notification-2.svg new file mode 100644 index 00000000..697ae4b5 --- /dev/null +++ b/packages/assets/assets/notification-2.svg @@ -0,0 +1,8 @@ + + + + \ No newline at end of file diff --git a/packages/assets/package.json b/packages/assets/package.json index 26a3aa77..cf987d51 100644 --- a/packages/assets/package.json +++ b/packages/assets/package.json @@ -77,6 +77,7 @@ "./MoreTutorsSoon": "./dist/MoreTutorsSoon.tsx", "./More": "./dist/More.tsx", "./NewTutor": "./dist/NewTutor.tsx", + "./Notification2": "./dist/Notification2.tsx", "./Notification": "./dist/Notification.tsx", "./Paperclip": "./dist/Paperclip.tsx", "./Pause": "./dist/Pause.tsx", diff --git a/packages/luna/src/components/TutorCard/TutorCardV1.tsx b/packages/luna/src/components/TutorCard/TutorCardV1.tsx index 40373859..d0e1f027 100644 --- a/packages/luna/src/components/TutorCard/TutorCardV1.tsx +++ b/packages/luna/src/components/TutorCard/TutorCardV1.tsx @@ -17,6 +17,9 @@ import React, { useMemo } from "react"; import { Link } from "react-router-dom"; import { Tooltip } from "@/components/Tooltip"; +const FRESH_TUTOR_MAX_TOPIC_COUNT = 7; +const TUTOR_MAX_TOPIC_COUNT = 3; + export const TutorCardV1: React.FC = ({ id, name, @@ -30,22 +33,22 @@ export const TutorCardV1: React.FC = ({ onBook, }) => { const intl = useFormatMessage(); - const isNewTutor = useMemo( + const isFreshTutor = useMemo( () => !studentCount && !lessonCount && !rating, [lessonCount, rating, studentCount] ); const remainingTopicsCount = useMemo(() => { - // 3 is the number of the topics presented in one line - // 6 is the number of the topics presented in two lines - const displayedCount = !isNewTutor ? 3 : 6; + const displayedCount = !isFreshTutor + ? FRESH_TUTOR_MAX_TOPIC_COUNT + : TUTOR_MAX_TOPIC_COUNT; const totalTopics = topics.length; const remainingTopicsCount = totalTopics < displayedCount ? 0 : totalTopics - displayedCount; return remainingTopicsCount; - }, [isNewTutor, topics]); + }, [isFreshTutor, topics]); return (
= ({ - {!isNewTutor ? ( + {!isFreshTutor ? (
{studentCount ? (
@@ -159,15 +162,23 @@ export const TutorCardV1: React.FC = ({ ) : null} {!isEmpty(topics) && topics.join("").length > 0 ? ( -
+
{topics.map((topic, idx) => { - if ((isNewTutor && idx < 6) || (!isNewTutor && idx < 3)) + if ( + (isFreshTutor && idx < FRESH_TUTOR_MAX_TOPIC_COUNT) || + (!isFreshTutor && idx < TUTOR_MAX_TOPIC_COUNT) + ) return ( {topic}} > -
+