Skip to content
This repository was archived by the owner on Sep 18, 2024. It is now read-only.

Commit 426cb65

Browse files
committed
chore: checkout
1 parent fc0fadf commit 426cb65

File tree

3 files changed

+44
-8
lines changed

3 files changed

+44
-8
lines changed

bun.lockb

-13 KB
Binary file not shown.

packages/app-akeru/src/app/(dashboard)/threads/features/thread-list/threads-list-item.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ export interface ThreadsListItemProps {
99

1010
const ThreadsListItem = (props: ThreadsListItemProps) => {
1111
return (
12-
<div className="">
13-
<p className="overflow-hidden whitespace-nowrap text-sm">{props.title}</p>
12+
<div
13+
className={`max-w-52 px-2 py-1 duration-200 hover:bg-gray-600/75 hover:text-white ${props.isActive && "bg-gray-600/75 text-white"}`}
14+
>
15+
<p className="overflow-hidden text-ellipsis whitespace-nowrap text-sm ">
16+
{props.title}
17+
</p>
1418
</div>
1519
);
1620
};

packages/app-akeru/src/app/(dashboard)/threads/features/thread-list/threads-list.tsx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,56 @@
1-
import React from "react";
1+
"use client";
2+
import React, { useState, useEffect } from "react";
23
import { THREADS_LIST_MOCK_DATA } from "./test-data";
34
import { ScrollArea } from "@/components/ui/scroll-area";
45
import ThreadsListItem from "./threads-list-item";
56
import { Input } from "@/components/ui/input";
67
import { Search } from "lucide-react";
8+
import { Skeleton } from "@/components/ui/skeleton";
79

810
const ThreadsList = () => {
11+
const [isLoading, setIsLoading] = useState(true);
12+
const [activeId, setActiveId] = useState("");
13+
14+
useEffect(() => {
15+
const fetchData = async () => {
16+
setTimeout(() => {
17+
setIsLoading(false);
18+
}, 2000);
19+
};
20+
fetchData();
21+
}, []);
22+
23+
const handleSetActiveId = (id: string) => {
24+
setActiveId(id);
25+
};
26+
27+
const isActive = (id: string) => id === activeId;
28+
929
return (
1030
<div className="w-64 rounded-md bg-white p-4 shadow-md">
1131
<div className="mb-4 flex flex-col gap-2">
1232
<Input placeholder="Filter your threads..." startIcon={Search} />
1333
</div>
1434
<ScrollArea className="relative h-4/5 overflow-clip">
15-
{/* This is just for the overflow gradient */}
35+
{/* This is just for the overflow gradient */}
1636
<div className="pointer-events-none absolute right-0 top-0 h-4/5 w-8 bg-gradient-to-r from-transparent to-white"></div>
17-
{/* This is just for the overflow gradient */}
37+
{/* This is just for the overflow gradient */}
1838
<div className="flex flex-col gap-4">
19-
{THREADS_LIST_MOCK_DATA.map((thread, key) => {
20-
return <ThreadsListItem key={thread.title + key} {...thread} />;
21-
})}
39+
{isLoading
40+
? Array.from({ length: THREADS_LIST_MOCK_DATA.length }).map(
41+
(_, idx) => <Skeleton key={idx} className="h-8" />,
42+
)
43+
: THREADS_LIST_MOCK_DATA.map((thread, key) => (
44+
<div
45+
key={thread.title + key}
46+
onClick={() => handleSetActiveId(thread.title.toLowerCase())}
47+
>
48+
<ThreadsListItem
49+
isActive={isActive(thread.title.toLowerCase())}
50+
{...thread}
51+
/>
52+
</div>
53+
))}
2254
</div>
2355
</ScrollArea>
2456
</div>

0 commit comments

Comments
 (0)