diff --git a/ui/app/globals.css b/ui/app/globals.css index f75daca..5aa0fd8 100644 --- a/ui/app/globals.css +++ b/ui/app/globals.css @@ -10,4 +10,12 @@ .overflow-hidden-scrollable::-webkit-scrollbar { display: none; } + .line-clamp-3-5 { + display: -webkit-box; + -webkit-line-clamp: 4; + -webkit-box-orient: vertical; + overflow: hidden; + } + } + diff --git a/ui/components/ContextItem.tsx b/ui/components/ContextItem.tsx index 03f25b1..f05b28e 100644 --- a/ui/components/ContextItem.tsx +++ b/ui/components/ContextItem.tsx @@ -1,7 +1,6 @@ import React from "react"; import Image from "next/image"; import { ReactMarkdown } from "@/components/Markdown"; - interface ContextItemProperties { item: { name: string; @@ -22,49 +21,60 @@ interface ContextItemProperties { }; }; } - const ContextItem: React.FC = ({ item }) => { return ( -
-

{item.name}

- {item.image && ( - {item.name} - )} -
- -
- +
- Read more - -
-
- {item.provider[0].image && ( - {`${item.provider[0].name} + {/* div for image if the link does not exist use the placeholder image */} + {!item.image && ( + {"placeholder"} )} - {item.provider[0].name} + {item.image && {item.name}}
-
- {new Date(item.datePublished).toLocaleDateString()} +
+ {/* div for other text info */} +
+

{item.name}

+
+ + {/* Content container with controlled overflow */} +
+ +
+ + {/* Absolute positioned provider info */} +
+
+ {/*
*/} + {item.provider[0].image && ( + {`${item.provider[0].name} + )} + {item.provider[0].name} + + {new Date(item.datePublished).toLocaleDateString()} + +
-
+ ); }; diff --git a/ui/components/ExpandableItems.tsx b/ui/components/ExpandableItems.tsx new file mode 100644 index 0000000..783d26c --- /dev/null +++ b/ui/components/ExpandableItems.tsx @@ -0,0 +1,62 @@ +"use client"; +import React, { useState } from "react"; +import ContextItem from "./ContextItem"; + +interface ContextItemType { + name: string; + url: string; + description: string; + provider: { + name: string; + image?: { + thumbnail: { + contentUrl: string; + }; + }; + }[]; + datePublished: string; + image?: { + contentUrl: string; + thumbnail: { + contentUrl: string; + width: number; + height: number; + }; + }; + article?: string; + score?: number; +} + +interface ExpandableItemsProperties { + context: ContextItemType[]; +} + +const ExpandableItems: React.FC = ({ context }) => { + const [expanded, setExpanded] = useState(false); + + const handleShowMore = () => { + setExpanded(!expanded); + }; + + return ( +
+ +
+ +
+ {expanded && + context.slice(1).map((item, index) => ( +
+ +
+ ))} +
+ ); +}; + +export default ExpandableItems; diff --git a/ui/components/NewsDetail.tsx b/ui/components/NewsDetail.tsx index ffa482d..be6173e 100644 --- a/ui/components/NewsDetail.tsx +++ b/ui/components/NewsDetail.tsx @@ -1,6 +1,6 @@ import React from "react"; import ContextItem from "./ContextItem"; - +import ExpandableItems from "./ExpandableItems"; interface ContextItemType { name: string; url: string; @@ -47,9 +47,7 @@ const NewsDetail: React.FC = ({ news }) => {

{section.content}

Related Context:

- {section.context.map((item, index_) => ( - - ))} +
))}