mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-21 18:55:16 +02:00
feat: Added active highlighting to chats and notes
This commit is contained in:
parent
a956b5ff87
commit
71b8860d20
4 changed files with 17 additions and 3 deletions
|
|
@ -310,6 +310,7 @@ export function AllChatsSidebar({ open, onOpenChange, searchSpaceId }: AllChatsS
|
||||||
const isDeleting = deletingThreadId === thread.id;
|
const isDeleting = deletingThreadId === thread.id;
|
||||||
const isArchiving = archivingThreadId === thread.id;
|
const isArchiving = archivingThreadId === thread.id;
|
||||||
const isBusy = isDeleting || isArchiving;
|
const isBusy = isDeleting || isArchiving;
|
||||||
|
const isActive = currentChatId === thread.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -318,6 +319,7 @@ export function AllChatsSidebar({ open, onOpenChange, searchSpaceId }: AllChatsS
|
||||||
"group flex items-center gap-2 rounded-md px-2 py-1.5 text-sm",
|
"group flex items-center gap-2 rounded-md px-2 py-1.5 text-sm",
|
||||||
"hover:bg-accent hover:text-accent-foreground",
|
"hover:bg-accent hover:text-accent-foreground",
|
||||||
"transition-colors cursor-pointer",
|
"transition-colors cursor-pointer",
|
||||||
|
isActive && "bg-accent text-accent-foreground font-medium",
|
||||||
isBusy && "opacity-50 pointer-events-none"
|
isBusy && "opacity-50 pointer-events-none"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||||
import { format } from "date-fns";
|
import { format } from "date-fns";
|
||||||
import { FileText, Loader2, MoreHorizontal, Plus, Search, Trash2, X } from "lucide-react";
|
import { FileText, Loader2, MoreHorizontal, Plus, Search, Trash2, X } from "lucide-react";
|
||||||
import { AnimatePresence, motion } from "motion/react";
|
import { AnimatePresence, motion } from "motion/react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useParams, useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { createPortal } from "react-dom";
|
import { createPortal } from "react-dom";
|
||||||
|
|
@ -37,7 +37,11 @@ export function AllNotesSidebar({
|
||||||
}: AllNotesSidebarProps) {
|
}: AllNotesSidebarProps) {
|
||||||
const t = useTranslations("sidebar");
|
const t = useTranslations("sidebar");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const params = useParams();
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
// Get the current note ID from URL to highlight the open note
|
||||||
|
const currentNoteId = params.note_id ? Number(params.note_id) : null;
|
||||||
const [deletingNoteId, setDeletingNoteId] = useState<number | null>(null);
|
const [deletingNoteId, setDeletingNoteId] = useState<number | null>(null);
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
const [searchQuery, setSearchQuery] = useState("");
|
||||||
const [mounted, setMounted] = useState(false);
|
const [mounted, setMounted] = useState(false);
|
||||||
|
|
@ -260,6 +264,7 @@ export function AllNotesSidebar({
|
||||||
<div className="space-y-1">
|
<div className="space-y-1">
|
||||||
{notes.map((note) => {
|
{notes.map((note) => {
|
||||||
const isDeleting = deletingNoteId === note.id;
|
const isDeleting = deletingNoteId === note.id;
|
||||||
|
const isActive = currentNoteId === note.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -268,6 +273,7 @@ export function AllNotesSidebar({
|
||||||
"group flex items-center gap-2 rounded-md px-2 py-1.5 text-sm",
|
"group flex items-center gap-2 rounded-md px-2 py-1.5 text-sm",
|
||||||
"hover:bg-accent hover:text-accent-foreground",
|
"hover:bg-accent hover:text-accent-foreground",
|
||||||
"transition-colors cursor-pointer",
|
"transition-colors cursor-pointer",
|
||||||
|
isActive && "bg-accent text-accent-foreground font-medium",
|
||||||
isDeleting && "opacity-50 pointer-events-none"
|
isDeleting && "opacity-50 pointer-events-none"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
Trash2,
|
Trash2,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
@ -71,6 +71,7 @@ export function NavChats({
|
||||||
}: NavChatsProps) {
|
}: NavChatsProps) {
|
||||||
const t = useTranslations("sidebar");
|
const t = useTranslations("sidebar");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const [isDeleting, setIsDeleting] = useState<number | null>(null);
|
const [isDeleting, setIsDeleting] = useState<number | null>(null);
|
||||||
const [isOpen, setIsOpen] = useState(defaultOpen);
|
const [isOpen, setIsOpen] = useState(defaultOpen);
|
||||||
|
|
@ -142,6 +143,7 @@ export function NavChats({
|
||||||
<SidebarMenu>
|
<SidebarMenu>
|
||||||
{chats.map((chat) => {
|
{chats.map((chat) => {
|
||||||
const isDeletingChat = isDeleting === chat.id;
|
const isDeletingChat = isDeleting === chat.id;
|
||||||
|
const isActive = pathname === chat.url;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarMenuItem key={chat.id || chat.name} className="group/chat">
|
<SidebarMenuItem key={chat.id || chat.name} className="group/chat">
|
||||||
|
|
@ -151,6 +153,7 @@ export function NavChats({
|
||||||
disabled={isDeletingChat}
|
disabled={isDeletingChat}
|
||||||
className={cn(
|
className={cn(
|
||||||
"pr-8", // Make room for the action button
|
"pr-8", // Make room for the action button
|
||||||
|
isActive && "bg-sidebar-accent text-sidebar-accent-foreground font-medium",
|
||||||
isDeletingChat && "opacity-50"
|
isDeletingChat && "opacity-50"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
Plus,
|
Plus,
|
||||||
Trash2,
|
Trash2,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useRouter } from "next/navigation";
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { useCallback, useEffect, useState } from "react";
|
import { useCallback, useEffect, useState } from "react";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
|
|
@ -72,6 +72,7 @@ export function NavNotes({
|
||||||
}: NavNotesProps) {
|
}: NavNotesProps) {
|
||||||
const t = useTranslations("sidebar");
|
const t = useTranslations("sidebar");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const pathname = usePathname();
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
const [isDeleting, setIsDeleting] = useState<number | null>(null);
|
const [isDeleting, setIsDeleting] = useState<number | null>(null);
|
||||||
const [isOpen, setIsOpen] = useState(defaultOpen);
|
const [isOpen, setIsOpen] = useState(defaultOpen);
|
||||||
|
|
@ -157,6 +158,7 @@ export function NavNotes({
|
||||||
{notes.length > 0 ? (
|
{notes.length > 0 ? (
|
||||||
notes.map((note) => {
|
notes.map((note) => {
|
||||||
const isDeletingNote = isDeleting === note.id;
|
const isDeletingNote = isDeleting === note.id;
|
||||||
|
const isActive = pathname === note.url;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarMenuItem key={note.id || note.name} className="group/note">
|
<SidebarMenuItem key={note.id || note.name} className="group/note">
|
||||||
|
|
@ -166,6 +168,7 @@ export function NavNotes({
|
||||||
disabled={isDeletingNote}
|
disabled={isDeletingNote}
|
||||||
className={cn(
|
className={cn(
|
||||||
"pr-8", // Make room for the action button
|
"pr-8", // Make room for the action button
|
||||||
|
isActive && "bg-sidebar-accent text-sidebar-accent-foreground font-medium",
|
||||||
isDeletingNote && "opacity-50"
|
isDeletingNote && "opacity-50"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue