feat(sidebar): узкое меню, субменю историй с hover, эффект text-fade

- Сужено боковое меню (56px), убрана иконка Home
- Субменю историй при наведении: полная высота, на всю ширину, z-9999
- Класс text-fade для плавного обрезания длинного текста
- Убраны скругления в субменю
- Chatwoot, изменения в posts-mcs и прочие обновления

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
home
2026-02-21 16:36:58 +03:00
parent 3fa83bc605
commit 8fc82a3b90
53 changed files with 894 additions and 4015 deletions

View File

@@ -2,14 +2,34 @@ import { searchSearxng, type SearxngSearchResult } from '@/lib/searxng';
import configManager from '@/lib/config';
import { getSearxngURL } from '@/lib/config/serverRegistry';
const GHOST_URL = process.env.GHOST_URL?.trim() ?? '';
const GHOST_CONTENT_API_KEY = process.env.GHOST_CONTENT_API_KEY?.trim() ?? '';
const PLACEHOLDER_IMAGE = 'https://placehold.co/400x225/e5e7eb/6b7280?text=Post';
type Region = 'america' | 'eu' | 'russia' | 'china';
type Topic = 'tech' | 'finance' | 'art' | 'sports' | 'entertainment';
type Topic = 'tech' | 'finance' | 'art' | 'sports' | 'entertainment' | 'gooseek';
interface GhostPost {
title: string;
excerpt?: string | null;
custom_excerpt?: string | null;
meta_description?: string | null;
plaintext?: string | null;
html?: string | null;
feature_image?: string | null;
url: string;
}
function stripHtml(html: string): string {
return html.replace(/<[^>]+>/g, ' ').replace(/\s+/g, ' ').trim();
}
const SOURCES_BY_REGION: Record<
Region,
Record<Topic, { query: string[]; links: string[] }>
> = {
america: {
gooseek: { query: [], links: [] },
tech: {
query: ['technology news', 'latest tech', 'AI', 'science and innovation'],
links: ['techcrunch.com', 'wired.com', 'theverge.com', 'arstechnica.com'],
@@ -32,6 +52,7 @@ const SOURCES_BY_REGION: Record<
},
},
eu: {
gooseek: { query: [], links: [] },
tech: {
query: ['technology news', 'tech', 'AI', 'innovation'],
links: ['techcrunch.com', 'bbc.com', 'theguardian.com', 'reuters.com', 'euronews.com'],
@@ -54,6 +75,7 @@ const SOURCES_BY_REGION: Record<
},
},
russia: {
gooseek: { query: [], links: [] },
tech: {
query: ['technology news', 'tech', 'IT', 'innovation'],
links: ['tass.com', 'ria.ru', 'interfax.com', 'kommersant.ru', 'vedomosti.ru'],
@@ -76,6 +98,7 @@ const SOURCES_BY_REGION: Record<
},
},
china: {
gooseek: { query: [], links: [] },
tech: {
query: ['technology news', 'tech', 'AI', 'innovation'],
links: ['scmp.com', 'xinhuanet.com', 'chinadaily.com.cn', 'reuters.com'],
@@ -137,8 +160,91 @@ const COUNTRY_TO_REGION: Record<string, Region> = {
DK: 'eu',
};
async function fetchDooseekPosts(): Promise<
{ title: string; content: string; url: string; thumbnail: string }[]
> {
if (!GHOST_URL || !GHOST_CONTENT_API_KEY) {
throw new Error(
'Ghost не настроен. Укажите GHOST_URL и GHOST_CONTENT_API_KEY в .env',
);
}
const base = GHOST_URL.replace(/\/$/, '');
const apiUrl = `${base}/ghost/api/content/posts/?key=${GHOST_CONTENT_API_KEY}&limit=50&fields=title,excerpt,custom_excerpt,meta_description,html,feature_image,url&formats=html`;
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 15_000);
try {
const res = await fetch(apiUrl, {
signal: controller.signal,
headers: { Accept: 'application/json' },
});
clearTimeout(timeoutId);
if (!res.ok) {
if (res.status === 401) {
throw new Error(
'Неверный Ghost Content API Key. Получите ключ в Ghost Admin → Settings → Integrations → Add custom integration.',
);
}
throw new Error(`Ghost API: HTTP ${res.status}`);
}
const data = await res.json();
const posts: GhostPost[] = data.posts ?? [];
return posts.map((p) => {
const excerpt =
p.custom_excerpt?.trim() ||
p.meta_description?.trim() ||
p.excerpt?.trim() ||
p.plaintext?.trim() ||
(p.html ? stripHtml(p.html) : '');
const content = excerpt
? excerpt.slice(0, 300) + (excerpt.length > 300 ? '…' : '')
: (p.title ? `${p.title}. Читать далее →` : 'Читать далее →');
return {
title: p.title || 'Без названия',
content,
url: p.url,
thumbnail: p.feature_image?.trim() || PLACEHOLDER_IMAGE,
};
});
} catch (e) {
clearTimeout(timeoutId);
throw e;
}
}
export const GET = async (req: Request) => {
try {
const params = new URL(req.url).searchParams;
const mode: 'normal' | 'preview' =
(params.get('mode') as 'normal' | 'preview') || 'normal';
const topic: Topic = (params.get('topic') as Topic) || 'tech';
if (topic === 'gooseek') {
try {
const blogs = await fetchDooseekPosts();
return Response.json({ blogs }, { status: 200 });
} catch (e) {
const msg =
e instanceof Error ? e.message : String(e);
const isConnect =
msg.includes('ECONNREFUSED') ||
msg.includes('fetch failed') ||
msg.includes('Failed to fetch') ||
msg.includes('AbortError');
return Response.json(
{
message:
!GHOST_URL || !GHOST_CONTENT_API_KEY
? 'Ghost не настроен. Укажите GHOST_URL и GHOST_CONTENT_API_KEY в .env'
: isConnect
? 'Не удалось подключиться к Ghost. Проверьте GHOST_URL и доступность сайта.'
: `Ошибка загрузки постов: ${msg}`,
},
{ status: isConnect ? 503 : 500 },
);
}
}
const searxngURL = getSearxngURL();
if (!searxngURL?.trim()) {
return Response.json(
@@ -149,12 +255,6 @@ export const GET = async (req: Request) => {
{ status: 503 },
);
}
const params = new URL(req.url).searchParams;
const mode: 'normal' | 'preview' =
(params.get('mode') as 'normal' | 'preview') || 'normal';
const topic: Topic = (params.get('topic') as Topic) || 'tech';
const regionParam = params.get('region') as Region | null;
let region: Region = 'america';

View File

@@ -112,7 +112,9 @@ const Page = () => {
throw new Error(data.message || 'Failed to load articles');
}
data.blogs = data.blogs.filter((blog: Discover) => blog.thumbnail);
if (topic !== 'gooseek') {
data.blogs = data.blogs.filter((blog: Discover) => blog.thumbnail);
}
setDiscover(data.blogs);
} catch (err: unknown) {
@@ -131,9 +133,7 @@ const Page = () => {
useEffect(() => {
if (activeTopic === 'gooseek') {
setLoading(false);
setDiscover(null);
setSetupRequired(false);
fetchArticles('gooseek');
return;
}
fetchArticles(activeTopic);
@@ -170,26 +170,95 @@ const Page = () => {
</div>
{loading ? (
<div className="flex flex-row items-center justify-center min-h-screen">
<svg
aria-hidden="true"
className="w-8 h-8 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<div className="flex flex-col gap-4 pb-28 pt-5 lg:pb-8 w-full">
{/* Mobile: SmallNewsCard — rounded-3xl, aspect-video, p-4, h3 mb-2 + p */}
<div className="block lg:hidden">
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
{[1, 2, 3, 4].map((i) => (
<div
key={i}
className="rounded-3xl overflow-hidden bg-light-secondary dark:bg-dark-secondary shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-col"
>
<div className="relative aspect-video overflow-hidden bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="p-4">
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
<div className="h-3 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse mt-1" />
</div>
</div>
))}
</div>
</div>
{/* Desktop: точно как реальный layout — 1st Major isLeft=false (текст слева, картинка справа) */}
<div className="hidden lg:block space-y-0">
{/* 1st MajorNewsCard isLeft=FALSE: content LEFT, image RIGHT */}
<div className="w-full flex flex-row items-stretch gap-6 h-60 py-3">
<div className="flex flex-col justify-center flex-1 py-4 space-y-3">
<div className="h-8 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-4 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
</div>
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0 bg-light-200 dark:bg-dark-200 animate-pulse" />
</div>
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
{/* 3× SmallNewsCard */}
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-4">
{[1, 2, 3].map((i) => (
<div
key={i}
className="rounded-3xl overflow-hidden bg-light-secondary dark:bg-dark-secondary shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-col"
>
<div className="relative aspect-video overflow-hidden bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="p-4">
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
<div className="h-3 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse mt-1" />
</div>
</div>
))}
</div>
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
{/* 2nd MajorNewsCard isLeft=TRUE: image LEFT, content RIGHT */}
<div className="w-full flex flex-row items-stretch gap-6 h-60 py-3">
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0 bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="flex flex-col justify-center flex-1 py-4 space-y-3">
<div className="h-8 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
</div>
</div>
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
{/* 3rd MajorNewsCard isLeft=FALSE: content LEFT, image RIGHT */}
<div className="w-full flex flex-row items-stretch gap-6 h-60 py-3">
<div className="flex flex-col justify-center flex-1 py-4 space-y-3">
<div className="h-8 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
</div>
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0 bg-light-200 dark:bg-dark-200 animate-pulse" />
</div>
<hr className="border-t border-light-200/20 dark:border-dark-200/20 my-3 w-full" />
{/* 3× SmallNewsCard */}
<div className="grid lg:grid-cols-3 sm:grid-cols-2 grid-cols-1 gap-4">
{[1, 2, 3].map((i) => (
<div
key={i}
className="rounded-3xl overflow-hidden bg-light-secondary dark:bg-dark-secondary shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-col"
>
<div className="relative aspect-video overflow-hidden bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="p-4">
<div className="h-4 w-full rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse mb-2" />
<div className="h-3 w-2/3 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200 animate-pulse mt-1" />
</div>
</div>
))}
</div>
</div>
</div>
) : activeTopic === 'gooseek' ? (
<div className="flex flex-col items-center justify-center min-h-[50vh] px-4" />
) : setupRequired ? (
<div className="flex flex-col items-center justify-center min-h-[50vh] gap-4 px-4 text-center">
<div className="rounded-full p-4 bg-[#EA580C]/10 dark:bg-[#EA580C]/5">
@@ -205,7 +274,7 @@ const Page = () => {
</p>
</div>
</div>
) : (
) : discover && discover.length > 0 ? (
<div className="flex flex-col gap-4 pb-28 pt-5 lg:pb-8 w-full">
<div className="block lg:hidden">
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
@@ -342,7 +411,13 @@ const Page = () => {
})()}
</div>
</div>
)}
) : discover && discover.length === 0 ? (
<div className="flex flex-col items-center justify-center min-h-[40vh] px-4 text-center">
<p className="text-black/60 dark:text-white/60 text-sm">
No articles found for this topic.
</p>
</div>
) : null}
</div>
</>
);

View File

@@ -80,6 +80,13 @@
line-clamp: 2;
overflow: hidden;
}
.text-fade {
overflow: hidden;
white-space: nowrap;
mask-image: linear-gradient(to right, black 75%, transparent 100%);
-webkit-mask-image: linear-gradient(to right, black 75%, transparent 100%);
}
}
@media screen and (-webkit-min-device-pixel-ratio: 0) {

View File

@@ -41,11 +41,9 @@ export default function RootLayout({
<ThemeProvider>
<LocalizationProvider>
{setupComplete ? (
<ClientOnly
<ClientOnly
fallback={
<div className="flex min-h-screen items-center justify-center bg-light-primary dark:bg-dark-primary">
<div className="h-8 w-8 animate-spin rounded-full border-2 border-[#EA580C] border-t-transparent" />
</div>
<div className="min-h-screen bg-light-primary dark:bg-dark-primary" />
}
>
<ChatProvider>

View File

@@ -2,7 +2,7 @@ import { Metadata } from 'next';
import React from 'react';
export const metadata: Metadata = {
title: 'Library - GooSeek',
title: 'History - GooSeek',
};
const Layout = ({ children }: { children: React.ReactNode }) => {

View File

@@ -2,9 +2,17 @@
import DeleteChat from '@/components/DeleteChat';
import { formatTimeDifference } from '@/lib/utils';
import { BookOpenText, ClockIcon, FileText, Globe2Icon } from 'lucide-react';
import {
ClockIcon,
FileText,
Globe2Icon,
MessagesSquare,
Search,
Filter,
} from 'lucide-react';
import Link from 'next/link';
import { useEffect, useState } from 'react';
import { useEffect, useMemo, useState } from 'react';
import { useTranslation } from '@/lib/localization/context';
export interface Chat {
id: string;
@@ -14,9 +22,18 @@ export interface Chat {
files: { fileId: string; name: string }[];
}
const SOURCE_KEYS = ['web', 'academic', 'discussions'] as const;
type SourceKey = (typeof SOURCE_KEYS)[number];
type FilesFilter = 'all' | 'with' | 'without';
const Page = () => {
const { t } = useTranslation();
const [chats, setChats] = useState<Chat[]>([]);
const [loading, setLoading] = useState(true);
const [searchQuery, setSearchQuery] = useState('');
const [sourceFilter, setSourceFilter] = useState<SourceKey | 'all'>('all');
const [filesFilter, setFilesFilter] = useState<FilesFilter>('all');
useEffect(() => {
const fetchChats = async () => {
@@ -30,23 +47,41 @@ const Page = () => {
});
const data = await res.json();
setChats(data.chats);
setChats(data.chats ?? []);
setLoading(false);
};
fetchChats();
}, []);
const filteredChats = useMemo(() => {
return chats.filter((chat) => {
const matchesSearch =
!searchQuery.trim() ||
chat.title.toLowerCase().includes(searchQuery.trim().toLowerCase());
const matchesSource =
sourceFilter === 'all' ||
chat.sources.some((s) => s === sourceFilter);
const matchesFiles =
filesFilter === 'all' ||
(filesFilter === 'with' && chat.files.length > 0) ||
(filesFilter === 'without' && chat.files.length === 0);
return matchesSearch && matchesSource && matchesFiles;
});
}, [chats, searchQuery, sourceFilter, filesFilter]);
return (
<div>
<div className="flex flex-col pt-10 border-b border-light-200/20 dark:border-dark-200/20 pb-6 px-2">
<div className="flex flex-col lg:flex-row lg:items-end lg:justify-between gap-3">
<div className="flex items-center justify-center">
<BookOpenText size={45} className="mb-2.5" />
<MessagesSquare size={45} className="mb-2.5" />
<div className="flex flex-col">
<h1 className="text-5xl font-normal p-2 pb-0">
Library
{t('nav.messageHistory')}
</h1>
<div className="px-2 text-sm text-black/60 dark:text-white/60 text-center lg:text-left">
Past chats, sources, and uploads.
@@ -56,38 +91,78 @@ const Page = () => {
<div className="flex items-center justify-center lg:justify-end gap-2 text-xs text-black/60 dark:text-white/60">
<span className="inline-flex items-center gap-1 rounded-full border border-black/20 dark:border-white/20 px-2 py-0.5">
<BookOpenText size={14} />
{loading
? 'Loading…'
<MessagesSquare size={14} />
{loading && chats.length === 0
? ''
: `${chats.length} ${chats.length === 1 ? 'chat' : 'chats'}`}
</span>
</div>
</div>
</div>
{loading ? (
<div className="flex flex-row items-center justify-center min-h-[60vh]">
<svg
aria-hidden="true"
className="w-8 h-8 text-light-200 fill-light-secondary dark:text-[#202020] animate-spin dark:fill-[#ffffff3b]"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100.003 78.2051 78.1951 100.003 50.5908 100C22.9765 99.9972 0.997224 78.018 1 50.4037C1.00281 22.7993 22.8108 0.997224 50.4251 1C78.0395 1.00281 100.018 22.8108 100 50.4251ZM9.08164 50.594C9.06312 73.3997 27.7909 92.1272 50.5966 92.1457C73.4023 92.1642 92.1298 73.4365 92.1483 50.6308C92.1669 27.8251 73.4392 9.0973 50.6335 9.07878C27.8278 9.06026 9.10003 27.787 9.08164 50.594Z"
fill="currentColor"
{(chats.length > 0 || loading) && (
<div className="sticky top-0 z-10 flex flex-row flex-wrap items-center gap-2 pt-4 pb-2 px-2 bg-light-primary dark:bg-dark-primary border-b border-light-200/20 dark:border-dark-200/20">
<div className="relative flex-1 min-w-[140px]">
<Search
size={18}
className="absolute left-3 top-1/2 -translate-y-1/2 text-black/40 dark:text-white/40"
/>
<path
d="M93.9676 39.0409C96.393 38.4037 97.8624 35.9116 96.9801 33.5533C95.1945 28.8227 92.871 24.3692 90.0681 20.348C85.6237 14.1775 79.4473 9.36872 72.0454 6.45794C64.6435 3.54717 56.3134 2.65431 48.3133 3.89319C45.869 4.27179 44.3768 6.77534 45.014 9.20079C45.6512 11.6262 48.1343 13.0956 50.5786 12.717C56.5073 11.8281 62.5542 12.5399 68.0406 14.7911C73.527 17.0422 78.2187 20.7487 81.5841 25.4923C83.7976 28.5886 85.4467 32.059 86.4416 35.7474C87.1273 38.1189 89.5423 39.6781 91.9676 39.0409Z"
fill="currentFill"
<input
type="text"
value={searchQuery}
onChange={(e) => setSearchQuery(e.target.value)}
placeholder={t('app.searchPlaceholder')}
className="w-full pl-10 pr-4 py-2.5 text-sm bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 rounded-xl placeholder:text-black/40 dark:placeholder:text-white/40 text-black dark:text-white focus:outline-none focus:border-light-300 dark:focus:border-dark-300 transition-colors"
/>
</svg>
</div>
<div className="flex flex-wrap items-center gap-2 shrink-0">
<Filter size={16} className="text-black/50 dark:text-white/50" />
<select
value={sourceFilter}
onChange={(e) =>
setSourceFilter(e.target.value as SourceKey | 'all')
}
className="text-xs py-1.5 px-3 rounded-lg bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-[#EA580C]/30"
>
<option value="all">{t('library.filterSourceAll')}</option>
<option value="web">{t('library.filterSourceWeb')}</option>
<option value="academic">{t('library.filterSourceAcademic')}</option>
<option value="discussions">{t('library.filterSourceSocial')}</option>
</select>
<select
value={filesFilter}
onChange={(e) => setFilesFilter(e.target.value as FilesFilter)}
className="text-xs py-1.5 px-3 rounded-lg bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 text-black dark:text-white focus:outline-none focus:ring-2 focus:ring-[#EA580C]/30"
>
<option value="all">{t('library.filterFilesAll')}</option>
<option value="with">{t('library.filterFilesWith')}</option>
<option value="without">{t('library.filterFilesWithout')}</option>
</select>
</div>
</div>
)}
{loading && chats.length === 0 ? (
<div className="pt-6 pb-28 px-2">
<div className="rounded-2xl border border-light-200 dark:border-dark-200 overflow-hidden bg-light-primary dark:bg-dark-primary">
{[1, 2, 3, 4].map((i) => (
<div
key={i}
className="flex flex-col gap-2 p-4 border-b border-light-200 dark:border-dark-200 last:border-b-0"
>
<div className="h-5 w-3/4 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="flex gap-2 mt-2">
<div className="h-4 w-16 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-4 w-24 rounded bg-light-200 dark:bg-dark-200 animate-pulse" />
</div>
</div>
))}
</div>
</div>
) : chats.length === 0 ? (
<div className="flex flex-col items-center justify-center min-h-[70vh] px-2 text-center">
<div className="flex items-center justify-center w-12 h-12 rounded-2xl border border-light-200 dark:border-dark-200 bg-light-secondary dark:bg-dark-secondary">
<BookOpenText className="text-black/70 dark:text-white/70" />
<MessagesSquare className="text-black/70 dark:text-white/70" />
</div>
<p className="mt-2 text-black/70 dark:text-white/70 text-sm">
No chats found.
@@ -99,10 +174,27 @@ const Page = () => {
to see it listed here.
</p>
</div>
) : filteredChats.length === 0 ? (
<div className="flex flex-col items-center justify-center min-h-[50vh] px-2 text-center">
<p className="text-black/70 dark:text-white/70 text-sm">
{t('library.noResults')}
</p>
<button
type="button"
onClick={() => {
setSearchQuery('');
setSourceFilter('all');
setFilesFilter('all');
}}
className="mt-2 text-sm text-[#EA580C] hover:underline"
>
{t('library.clearFilters')}
</button>
</div>
) : (
<div className="pt-6 pb-28 px-2">
<div className="rounded-2xl border border-light-200 dark:border-dark-200 overflow-hidden bg-light-primary dark:bg-dark-primary">
{chats.map((chat, index) => {
{filteredChats.map((chat, index) => {
const sourcesLabel =
chat.sources.length === 0
? null

View File

@@ -7,7 +7,6 @@ import NextError from 'next/error';
import { useChat } from '@/lib/hooks/useChat';
import SettingsButtonMobile from './Settings/SettingsButtonMobile';
import { Block } from '@/lib/types';
import Loader from './ui/Loader';
export interface BaseMessage {
chatId: string;
@@ -69,8 +68,8 @@ const ChatWindow = () => {
</div>
)
) : (
<div className="flex items-center justify-center min-h-screen w-full">
<Loader />
<div className="min-h-screen w-full">
<EmptyChat />
</div>
);
};

View File

@@ -18,11 +18,7 @@ const MajorNewsCard = ({
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0">
<img
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-500"
src={
new URL(item.thumbnail).origin +
new URL(item.thumbnail).pathname +
`?id=${new URL(item.thumbnail).searchParams.get('id')}`
}
src={item.thumbnail}
alt={item.title}
/>
</div>
@@ -52,11 +48,7 @@ const MajorNewsCard = ({
<div className="relative w-80 h-full overflow-hidden rounded-2xl flex-shrink-0">
<img
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-500"
src={
new URL(item.thumbnail).origin +
new URL(item.thumbnail).pathname +
`?id=${new URL(item.thumbnail).searchParams.get('id')}`
}
src={item.thumbnail}
alt={item.title}
/>
</div>

View File

@@ -10,11 +10,7 @@ const SmallNewsCard = ({ item }: { item: Discover }) => (
<div className="relative aspect-video overflow-hidden">
<img
className="object-cover w-full h-full group-hover:scale-105 transition-transform duration-300"
src={
new URL(item.thumbnail).origin +
new URL(item.thumbnail).pathname +
`?id=${new URL(item.thumbnail).searchParams.get('id')}`
}
src={item.thumbnail}
alt={item.title}
/>
</div>

View File

@@ -46,7 +46,7 @@ const EmptyChat = () => {
<SettingsButtonMobile />
</div>
<div className="flex flex-col items-center justify-center min-h-screen max-w-screen-sm mx-auto p-2 space-y-4">
<div className="flex flex-col items-center justify-center w-full space-y-8">
<div className="flex flex-col items-center justify-center w-full space-y-6">
<div className="flex flex-row items-center justify-center -mt-8 mb-2">
<span className="text-4xl sm:text-5xl font-semibold tracking-tight select-none">
{['G', 'o', 'o', 'S', 'e', 'e', 'k'].map((letter, i) => (
@@ -54,7 +54,7 @@ const EmptyChat = () => {
key={i}
className="inline-block"
style={{
color: ['#6B7280', '#EA580C', '#9CA3AF', '#4B5563', '#EA580C', '#A8A29E', '#57534E'][i],
color: ['#4285F4', '#FC3F1D', '#34A853', '#FBBC05', '#FC3F1D', '#4285F4', '#34A853'][i],
}}
>
{letter}
@@ -65,22 +65,22 @@ const EmptyChat = () => {
<h2 className="text-black/70 dark:text-white/70 text-3xl font-medium">
{t('empty.subtitle')}
</h2>
{(showWeather || showNews) && (
<div className="flex flex-row flex-wrap w-full gap-2 sm:gap-3 justify-center items-stretch">
{showWeather && (
<div className="flex-1 min-w-[120px] shrink-0">
<WeatherWidget />
</div>
)}
{showNews && (
<div className="flex-1 min-w-[120px] shrink-0">
<NewsArticleWidget />
</div>
)}
</div>
)}
<EmptyChatMessageInput />
</div>
{(showWeather || showNews) && (
<div className="flex flex-col w-full gap-4 mt-2 sm:flex-row sm:justify-center">
{showWeather && (
<div className="flex-1 w-full">
<WeatherWidget />
</div>
)}
{showNews && (
<div className="flex-1 w-full">
<NewsArticleWidget />
</div>
)}
</div>
)}
</div>
</div>
);

View File

@@ -1,6 +1,6 @@
const Layout = ({ children }: { children: React.ReactNode }) => {
return (
<main className="lg:pl-20 bg-light-primary dark:bg-dark-primary min-h-screen">
<main className="lg:pl-16 bg-light-primary dark:bg-dark-primary min-h-screen">
<div className="max-w-screen-lg lg:mx-auto mx-4">{children}</div>
</main>
);

View File

@@ -179,7 +179,7 @@ const MessageBox = ({
(b) => b.type === 'research' && b.data.subSteps.length > 0,
) && (
<div className="flex items-center gap-2 p-3 rounded-lg bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200">
<Disc3 className="w-4 h-4 text-black dark:text-white animate-spin" />
<Disc3 className="w-4 h-4 text-black dark:text-white" />
<span className="text-sm text-black/70 dark:text-white/70">
{t('chat.brainstorming')}
</span>
@@ -191,13 +191,7 @@ const MessageBox = ({
<div className="flex flex-col space-y-2">
{sources.length > 0 && (
<div className="flex flex-row items-center space-x-2">
<Disc3
className={cn(
'text-black dark:text-white',
isLast && loading ? 'animate-spin' : 'animate-none',
)}
size={20}
/>
<Disc3 className="text-black dark:text-white" size={20} />
<h3 className="text-black dark:text-white font-medium text-xl">
{t('chat.answer')}
</h3>

View File

@@ -9,7 +9,6 @@ import {
CopyPlus,
File,
Link,
LoaderCircle,
Paperclip,
Plus,
Trash,
@@ -56,8 +55,8 @@ const Attach = () => {
};
return loading ? (
<div className="active:border-none hover:bg-light-200 hover:dark:bg-dark-200 p-2 rounded-lg focus:outline-none text-black/50 dark:text-white/50 transition duration-200">
<LoaderCircle size={16} className="text-[#EA580C] animate-spin" />
<div className="active:border-none p-2 rounded-lg focus:outline-none text-black/50 dark:text-white/50 transition duration-200 text-xs">
<span className="text-[#EA580C]">Uploading</span>
</div>
) : files.length > 0 ? (
<Popover className="relative w-full max-w-[15rem] md:max-w-md lg:max-w-lg">
@@ -72,7 +71,7 @@ const Attach = () => {
<AnimatePresence>
{open && (
<PopoverPanel
className="absolute z-10 w-64 md:w-[350px] right-0"
className="absolute z-10 w-64 md:w-[350px] right-0 bottom-full mb-2"
static
>
<motion.div
@@ -80,7 +79,7 @@ const Attach = () => {
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
transition={{ duration: 0.1, ease: 'easeOut' }}
className="origin-top-right bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
className="origin-bottom-right bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
>
<div className="flex flex-row items-center justify-between px-3 py-2">
<h4 className="text-black/70 dark:text-white/70 text-sm">

View File

@@ -4,7 +4,7 @@ import {
PopoverPanel,
Transition,
} from '@headlessui/react';
import { File, LoaderCircle, Paperclip, Plus, Trash } from 'lucide-react';
import { File, Paperclip, Plus, Trash } from 'lucide-react';
import { Fragment, useRef, useState } from 'react';
import { useChat } from '@/lib/hooks/useChat';
import { AnimatePresence } from 'motion/react';
@@ -47,8 +47,8 @@ const AttachSmall = () => {
};
return loading ? (
<div className="flex flex-row items-center justify-between space-x-1 p-1 ">
<LoaderCircle size={20} className="text-[#EA580C] animate-spin" />
<div className="flex flex-row items-center justify-between space-x-1 p-1 text-xs text-[#EA580C]">
Uploading
</div>
) : files.length > 0 ? (
<Popover className="max-w-[15rem] md:max-w-md lg:max-w-lg">
@@ -63,7 +63,7 @@ const AttachSmall = () => {
<AnimatePresence>
{open && (
<PopoverPanel
className="absolute z-10 w-64 md:w-[350px] bottom-14"
className="absolute z-10 w-64 md:w-[350px] right-0 bottom-full mb-2"
static
>
<motion.div
@@ -71,7 +71,7 @@ const AttachSmall = () => {
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
transition={{ duration: 0.1, ease: 'easeOut' }}
className="origin-bottom-left bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
className="origin-bottom-right bg-light-primary dark:bg-dark-primary border rounded-md border-light-200 dark:border-dark-200 w-full max-h-[200px] md:max-h-none overflow-y-auto flex flex-col"
>
<div className="flex flex-row items-center justify-between px-3 py-2">
<h4 className="text-black/70 dark:text-white/70 font-medium text-sm">

View File

@@ -1,6 +1,6 @@
'use client';
import { Cpu, Loader2, Search } from 'lucide-react';
import { Cpu, Search } from 'lucide-react';
import { cn } from '@/lib/utils';
import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react';
import { useEffect, useMemo, useState } from 'react';
@@ -90,7 +90,7 @@ const ModelSelector = () => {
<AnimatePresence>
{open && (
<PopoverPanel
className="absolute z-10 w-[230px] sm:w-[270px] md:w-[300px] right-0"
className="absolute z-10 w-[230px] sm:w-[270px] md:w-[300px] right-0 bottom-full mb-2"
static
>
<motion.div
@@ -98,7 +98,7 @@ const ModelSelector = () => {
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
transition={{ duration: 0.1, ease: 'easeOut' }}
className="origin-top-right bg-light-primary dark:bg-dark-primary max-h-[300px] sm:max-w-none border rounded-lg border-light-200 dark:border-dark-200 w-full flex flex-col shadow-lg overflow-hidden"
className="origin-bottom-right bg-light-primary dark:bg-dark-primary max-h-[300px] sm:max-w-none border rounded-lg border-light-200 dark:border-dark-200 w-full flex flex-col shadow-lg overflow-hidden"
>
<div className="p-2 border-b border-light-200 dark:border-dark-200">
<div className="relative">
@@ -118,11 +118,13 @@ const ModelSelector = () => {
<div className="max-h-[320px] overflow-y-auto">
{isLoading ? (
<div className="flex items-center justify-center py-16">
<Loader2
className="animate-spin text-black/40 dark:text-white/40"
size={24}
/>
<div className="flex flex-col gap-2 py-16 px-4">
{[1, 2, 3, 4].map((i) => (
<div
key={i}
className="h-10 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse"
/>
))}
</div>
) : filteredProviders.length === 0 ? (
<div className="text-center py-16 px-4 text-black/60 dark:text-white/60 text-sm">

View File

@@ -64,7 +64,7 @@ const Optimization = () => {
<AnimatePresence>
{open && (
<PopoverPanel
className="absolute z-10 w-64 md:w-[250px] left-0"
className="absolute z-10 w-64 md:w-[250px] left-0 bottom-full mb-2"
static
>
<motion.div
@@ -72,7 +72,7 @@ const Optimization = () => {
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
transition={{ duration: 0.1, ease: 'easeOut' }}
className="origin-top-left flex flex-col space-y-2 bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-2 max-h-[200px] md:max-h-none overflow-y-auto"
className="origin-bottom-left flex flex-col space-y-2 bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-2 max-h-[200px] md:max-h-none overflow-y-auto"
>
{OptimizationModes.map((mode, i) => (
<PopoverButton

View File

@@ -44,14 +44,14 @@ const Sources = () => {
{open && (
<PopoverPanel
static
className="absolute z-10 w-64 md:w-[225px] right-0"
className="absolute z-10 w-64 md:w-[225px] right-0 bottom-full mb-2"
>
<motion.div
initial={{ opacity: 0, scale: 0.9 }}
animate={{ opacity: 1, scale: 1 }}
exit={{ opacity: 0, scale: 0.9 }}
transition={{ duration: 0.1, ease: 'easeOut' }}
className="origin-top-right flex flex-col bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-1 max-h-[200px] md:max-h-none overflow-y-auto shadow-lg"
className="origin-bottom-right flex flex-col bg-light-primary dark:bg-dark-primary border rounded-lg border-light-200 dark:border-dark-200 w-full p-1 max-h-[200px] md:max-h-none overflow-y-auto shadow-lg"
>
{sourcesList.map((source, i) => (
<div

View File

@@ -27,13 +27,13 @@ const NewsArticleWidget = () => {
}, []);
return (
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-stretch w-full h-24 min-h-[96px] max-h-[96px] p-0 overflow-hidden">
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-stretch w-full h-20 min-h-[80px] max-h-[80px] p-0 overflow-hidden">
{loading ? (
<div className="animate-pulse flex flex-row items-stretch w-full h-full">
<div className="w-24 min-w-24 max-w-24 h-full bg-light-200 dark:bg-dark-200" />
<div className="flex flex-col justify-center flex-1 px-3 py-2 gap-2">
<div className="h-4 w-3/4 rounded bg-light-200 dark:bg-dark-200" />
<div className="h-3 w-1/2 rounded bg-light-200 dark:bg-dark-200" />
<div className="w-20 min-w-20 max-w-20 h-full bg-light-200 dark:bg-dark-200" />
<div className="flex flex-col justify-center flex-1 px-2.5 py-1.5 gap-1">
<div className="h-3 w-full max-w-[80%] rounded bg-light-200 dark:bg-dark-200" />
<div className="h-3 w-16 rounded bg-light-200 dark:bg-dark-200" />
</div>
</div>
) : error ? (
@@ -43,7 +43,7 @@ const NewsArticleWidget = () => {
href={`/?q=${encodeURIComponent(`Summary: ${article.url}`)}&title=${encodeURIComponent(article.title)}`}
className="flex flex-row items-stretch w-full h-full relative overflow-hidden group"
>
<div className="relative w-24 min-w-24 max-w-24 h-full overflow-hidden">
<div className="relative w-20 min-w-20 max-w-20 h-full overflow-hidden">
<img
className="object-cover w-full h-full bg-light-200 dark:bg-dark-200 group-hover:scale-110 transition-transform duration-300"
src={
@@ -54,11 +54,11 @@ const NewsArticleWidget = () => {
alt={article.title}
/>
</div>
<div className="flex flex-col justify-center flex-1 px-3 py-2">
<div className="font-semibold text-xs text-black dark:text-white leading-tight line-clamp-2 mb-1">
<div className="flex flex-col justify-center flex-1 px-2.5 py-1.5 min-w-0">
<div className="font-semibold text-[11px] text-black dark:text-white leading-tight line-clamp-2 mb-0.5">
{article.title}
</div>
<p className="text-black/60 dark:text-white/60 text-[10px] leading-relaxed line-clamp-2">
<p className="text-black/60 dark:text-white/60 text-[9px] leading-relaxed line-clamp-2">
{article.content}
</p>
</div>

View File

@@ -1,5 +1,5 @@
import { Dialog, DialogPanel } from '@headlessui/react';
import { Loader2, Plus } from 'lucide-react';
import { Plus } from 'lucide-react';
import { useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import { ConfigModelProvider } from '@/lib/config/types';
@@ -142,11 +142,7 @@ const AddModel = ({
disabled={loading}
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
>
{loading ? (
<Loader2 className="animate-spin" size={16} />
) : (
'Add Model'
)}
{loading ? 'Adding…' : 'Add Model'}
</button>
</div>
</form>

View File

@@ -4,7 +4,7 @@ import {
DialogPanel,
DialogTitle,
} from '@headlessui/react';
import { Loader2, Plus } from 'lucide-react';
import { Plus } from 'lucide-react';
import { useMemo, useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import {
@@ -196,11 +196,7 @@ const AddProvider = ({
disabled={loading}
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
>
{loading ? (
<Loader2 className="animate-spin" size={16} />
) : (
'Add Connection'
)}
{loading ? 'Adding…' : 'Add Connection'}
</button>
</div>
</form>

View File

@@ -1,5 +1,5 @@
import { Dialog, DialogPanel } from '@headlessui/react';
import { Loader2, Trash2 } from 'lucide-react';
import { Trash2 } from 'lucide-react';
import { useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import { ConfigModelProvider } from '@/lib/config/types';
@@ -100,11 +100,7 @@ const DeleteProvider = ({
onClick={handleDelete}
className="px-4 py-2 rounded-lg text-sm bg-red-500 text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
>
{loading ? (
<Loader2 className="animate-spin" size={16} />
) : (
'Delete'
)}
{loading ? 'Deleting…' : 'Delete'}
</button>
</div>
</DialogPanel>

View File

@@ -1,5 +1,5 @@
import { Dialog, DialogPanel } from '@headlessui/react';
import { Loader2, Pencil } from 'lucide-react';
import { Pencil } from 'lucide-react';
import { useEffect, useState } from 'react';
import { AnimatePresence, motion } from 'framer-motion';
import {
@@ -168,11 +168,7 @@ const UpdateProvider = ({
disabled={loading}
className="px-4 py-2 rounded-lg text-[13px] bg-[#EA580C] text-white font-medium disabled:opacity-85 hover:opacity-85 active:scale-95 transition duration-200"
>
{loading ? (
<Loader2 className="animate-spin" size={16} />
) : (
'Update Connection'
)}
{loading ? 'Updating…' : 'Update Connection'}
</button>
</div>
</form>

View File

@@ -12,7 +12,6 @@ import Preferences from './Sections/Preferences';
import { motion } from 'framer-motion';
import { useEffect, useState } from 'react';
import { toast } from 'sonner';
import Loader from '../ui/Loader';
import { cn } from '@/lib/utils';
import Models from './Sections/Models/Section';
import SearchSection from './Sections/Search';
@@ -121,8 +120,22 @@ const SettingsDialogue = ({
>
<DialogPanel className="space-y-4 border border-light-200 dark:border-dark-200 bg-light-primary dark:bg-dark-primary backdrop-blur-lg rounded-xl h-[calc(100vh-2%)] w-[calc(100vw-2%)] md:h-[calc(100vh-7%)] md:w-[calc(100vw-7%)] lg:h-[calc(100vh-20%)] lg:w-[calc(100vw-30%)] overflow-hidden flex flex-col">
{isLoading ? (
<div className="flex items-center justify-center h-full w-full">
<Loader />
<div className="flex flex-col gap-3 p-6 h-full w-full overflow-y-auto">
<div className="h-8 w-48 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="flex gap-4 mt-4">
<div className="w-48 space-y-2">
{[1, 2, 3, 4].map((i) => (
<div
key={i}
className="h-10 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse"
/>
))}
</div>
<div className="flex-1 space-y-4">
<div className="h-24 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse" />
<div className="h-32 rounded-lg bg-light-200 dark:bg-dark-200 animate-pulse" />
</div>
</div>
</div>
) : (
<div className="flex flex-1 inset-0 h-full overflow-hidden">

View File

@@ -9,7 +9,6 @@ import { useState } from 'react';
import Select from '../ui/Select';
import { toast } from 'sonner';
import { useTheme } from 'next-themes';
import { Loader2 } from 'lucide-react';
import { Switch } from '@headlessui/react';
const emitClientConfigChanged = () => {
@@ -160,11 +159,6 @@ const SettingsInput = ({
type="text"
disabled={loading}
/>
{loading && (
<span className="pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-black/40 dark:text-white/40">
<Loader2 className="h-4 w-4 animate-spin" />
</span>
)}
</div>
</div>
</section>
@@ -237,11 +231,6 @@ const SettingsTextarea = ({
rows={4}
disabled={loading}
/>
{loading && (
<span className="pointer-events-none absolute right-3 translate-y-3 text-black/40 dark:text-white/40">
<Loader2 className="h-4 w-4 animate-spin" />
</span>
)}
</div>
</div>
</section>

View File

@@ -2,108 +2,244 @@
import { cn } from '@/lib/utils';
import {
BookOpenText,
Home,
Search,
SquarePen,
Settings,
MessagesSquare,
Plus,
ArrowLeft,
Search,
} from 'lucide-react';
import Link from 'next/link';
import { useSelectedLayoutSegments } from 'next/navigation';
import React, { useState, type ReactNode } from 'react';
import React, { useEffect, useRef, useState, type ReactNode } from 'react';
import { createPortal } from 'react-dom';
import { useTranslation } from '@/lib/localization/context';
import Layout from './Layout';
import {
Description,
Dialog,
DialogPanel,
DialogTitle,
} from '@headlessui/react';
import SettingsButton from './Settings/SettingsButton';
interface ChatItem {
id: string;
title: string;
createdAt: string;
}
const VerticalIconContainer = ({ children }: { children: ReactNode }) => {
return <div className="flex flex-col items-center w-full">{children}</div>;
};
interface HistorySubmenuProps {
onMouseEnter: () => void;
onMouseLeave: () => void;
}
const HistorySubmenu = ({ onMouseEnter, onMouseLeave }: HistorySubmenuProps) => {
const { t } = useTranslation();
const [chats, setChats] = useState<ChatItem[]>([]);
const [loading, setLoading] = useState(true);
useEffect(() => {
const fetchChats = async () => {
try {
const res = await fetch('/api/chats');
const data = await res.json();
setChats((data.chats ?? []).reverse());
} catch {
setChats([]);
} finally {
setLoading(false);
}
};
fetchChats();
}, []);
return (
<div
className="min-w-[180px] w-56 h-screen overflow-y-auto bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 shadow-xl py-2 z-[9999]"
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
>
{loading ? (
<div className="px-4 py-3 text-sm text-black/60 dark:text-white/60">
{t('common.loading')}
</div>
) : chats.length === 0 ? (
<div className="px-4 py-3 text-sm text-black/60 dark:text-white/60">
</div>
) : (
<nav className="flex flex-col">
{chats.map((chat) => (
<Link
key={chat.id}
href={`/c/${chat.id}`}
className="px-4 py-2.5 text-sm text-black dark:text-white hover:bg-light-200 dark:hover:bg-dark-200 text-fade block transition-colors"
title={chat.title}
>
{chat.title}
</Link>
))}
</nav>
)}
</div>
);
};
const Sidebar = ({ children }: { children: React.ReactNode }) => {
const segments = useSelectedLayoutSegments();
const [isOpen, setIsOpen] = useState<boolean>(true);
const { t } = useTranslation();
const [historyOpen, setHistoryOpen] = useState(false);
const historyRef = useRef<HTMLDivElement>(null);
const hideTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const [submenuStyle, setSubmenuStyle] = useState({ top: 0, left: 0 });
const navLinks = [
{
icon: Home,
href: '/',
active: segments.length === 0 || segments.includes('c'),
label: t('nav.home'),
},
{
icon: Search,
href: '/discover',
active: segments.includes('discover'),
label: t('nav.discover'),
},
{
icon: BookOpenText,
href: '/library',
active: segments.includes('library'),
label: t('nav.library'),
},
];
const discoverLink = {
icon: Search,
href: '/discover',
active: segments.includes('discover'),
label: t('nav.discover'),
};
const libraryLink = {
icon: MessagesSquare,
href: '/library',
active: segments.includes('library'),
label: t('nav.messageHistory'),
};
const navLinks = [discoverLink, libraryLink];
const handleHistoryMouseEnter = () => {
if (hideTimeoutRef.current) {
clearTimeout(hideTimeoutRef.current);
hideTimeoutRef.current = null;
}
if (historyRef.current) {
const rect = historyRef.current.getBoundingClientRect();
setSubmenuStyle({ top: 0, left: rect.right + 4 });
}
setHistoryOpen(true);
};
const handleHistoryMouseLeave = () => {
hideTimeoutRef.current = setTimeout(() => setHistoryOpen(false), 150);
};
const cancelHide = () => {
if (hideTimeoutRef.current) {
clearTimeout(hideTimeoutRef.current);
hideTimeoutRef.current = null;
}
};
useEffect(() => {
return () => {
if (hideTimeoutRef.current) clearTimeout(hideTimeoutRef.current);
};
}, []);
return (
<div>
<div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-[72px] lg:flex-col border-r border-light-200 dark:border-dark-200">
<div className="flex grow flex-col items-center justify-between gap-y-5 overflow-y-auto bg-light-secondary dark:bg-dark-secondary px-2 py-8 shadow-sm shadow-light-200/10 dark:shadow-black/25">
<div className="hidden lg:fixed lg:inset-y-0 lg:z-50 lg:flex lg:w-[56px] lg:flex-col border-r border-light-200 dark:border-dark-200">
<div className="flex grow flex-col items-center justify-start gap-y-1 overflow-y-auto bg-light-secondary dark:bg-dark-secondary px-2 py-6 shadow-sm shadow-light-200/10 dark:shadow-black/25">
<a
className="p-2.5 rounded-full bg-light-200 text-black/70 dark:bg-dark-200 dark:text-white/70 hover:opacity-70 hover:scale-105 tansition duration-200"
className="p-2.5 rounded-full bg-light-200 text-black/70 dark:bg-dark-200 dark:text-white/70 hover:opacity-70 hover:scale-105 transition duration-200 cursor-pointer"
href="/"
>
<Plus size={19} className="cursor-pointer" />
</a>
<VerticalIconContainer>
{navLinks.map((link, i) => (
<Link
href={discoverLink.href}
className={cn(
'relative flex flex-col items-center justify-center space-y-0.5 cursor-pointer w-full py-2 rounded-lg',
discoverLink.active
? 'text-black/70 dark:text-white/70'
: 'text-black/60 dark:text-white/60',
)}
>
<div
className={cn(
discoverLink.active && 'bg-light-200 dark:bg-dark-200',
'group rounded-lg hover:bg-light-200 hover:dark:bg-dark-200 transition duration-200',
)}
>
<discoverLink.icon
size={25}
className={cn(
!discoverLink.active && 'group-hover:scale-105',
'transition duration:200 m-1.5',
)}
/>
</div>
<p
className={cn(
discoverLink.active
? 'text-black/80 dark:text-white/80'
: 'text-black/60 dark:text-white/60',
'text-[10px] text-fade',
)}
>
{discoverLink.label}
</p>
</Link>
<div
ref={historyRef}
className="relative w-full"
onMouseEnter={handleHistoryMouseEnter}
onMouseLeave={handleHistoryMouseLeave}
>
<Link
key={i}
href={link.href}
href={libraryLink.href}
className={cn(
'relative flex flex-col items-center justify-center space-y-0.5 cursor-pointer w-full py-2 rounded-lg',
link.active
? 'text-black/70 dark:text-white/70 '
libraryLink.active
? 'text-black/70 dark:text-white/70'
: 'text-black/60 dark:text-white/60',
)}
>
<div
className={cn(
link.active && 'bg-light-200 dark:bg-dark-200',
libraryLink.active && 'bg-light-200 dark:bg-dark-200',
'group rounded-lg hover:bg-light-200 hover:dark:bg-dark-200 transition duration-200',
)}
>
<link.icon
<libraryLink.icon
size={25}
className={cn(
!link.active && 'group-hover:scale-105',
!libraryLink.active && 'group-hover:scale-105',
'transition duration:200 m-1.5',
)}
/>
</div>
<p
className={cn(
link.active
libraryLink.active
? 'text-black/80 dark:text-white/80'
: 'text-black/60 dark:text-white/60',
'text-[10px]',
'text-[10px] text-fade',
)}
>
{link.label}
{libraryLink.label}
</p>
</Link>
))}
{historyOpen &&
typeof document !== 'undefined' &&
createPortal(
<div
style={{ top: submenuStyle.top, left: submenuStyle.left }}
className="fixed z-[9999]"
>
<HistorySubmenu
onMouseEnter={cancelHide}
onMouseLeave={handleHistoryMouseLeave}
/>
</div>,
document.body,
)}
</div>
</VerticalIconContainer>
<SettingsButton />
<div className="mt-auto pt-4">
<SettingsButton />
</div>
</div>
</div>
@@ -123,7 +259,7 @@ const Sidebar = ({ children }: { children: React.ReactNode }) => {
<div className="absolute top-0 -mt-4 h-1 w-full rounded-b-lg bg-black dark:bg-white" />
)}
<link.icon />
<p className="text-xs">{link.label}</p>
<p className="text-xs text-fade min-w-0">{link.label}</p>
</Link>
))}
</div>

View File

@@ -158,16 +158,16 @@ const WeatherWidget = () => {
}, []);
return (
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-center w-full h-24 min-h-[96px] max-h-[96px] px-3 py-2 gap-3">
<div className="bg-light-secondary dark:bg-dark-secondary rounded-2xl border border-light-200 dark:border-dark-200 shadow-sm shadow-light-200/10 dark:shadow-black/25 flex flex-row items-center w-full h-20 min-h-[80px] max-h-[80px] px-2.5 py-1.5 gap-2">
{error ? (
<div className="flex items-center justify-center w-full h-full text-xs text-black/50 dark:text-white/50">
Weather unavailable
</div>
) : loading ? (
<>
<div className="flex flex-col items-center justify-center w-16 min-w-16 max-w-16 h-full animate-pulse">
<div className="h-10 w-10 rounded-full bg-light-200 dark:bg-dark-200 mb-2" />
<div className="h-4 w-10 rounded bg-light-200 dark:bg-dark-200" />
<div className="flex flex-col items-center justify-center w-12 min-w-12 max-w-12 h-full animate-pulse">
<div className="h-8 w-8 rounded-full bg-light-200 dark:bg-dark-200 mb-1" />
<div className="h-3 w-8 rounded bg-light-200 dark:bg-dark-200" />
</div>
<div className="flex flex-col justify-between flex-1 h-full py-1 animate-pulse">
<div className="flex flex-row items-center justify-between">
@@ -183,30 +183,30 @@ const WeatherWidget = () => {
</>
) : (
<>
<div className="flex flex-col items-center justify-center w-16 min-w-16 max-w-16 h-full">
<div className="flex flex-col items-center justify-center w-12 min-w-12 max-w-12 h-full">
<img
src={`/weather-ico/${data.icon}.svg`}
alt={data.condition}
className="h-10 w-auto"
className="h-8 w-auto"
/>
<span className="text-base font-semibold text-black dark:text-white">
<span className="text-sm font-semibold text-black dark:text-white">
{data.temperature}°{data.temperatureUnit}
</span>
</div>
<div className="flex flex-col justify-between flex-1 h-full py-2">
<div className="flex flex-col justify-between flex-1 h-full py-1">
<div className="flex flex-row items-center justify-between">
<span className="text-sm font-semibold text-black dark:text-white">
<span className="text-xs font-semibold text-black dark:text-white truncate">
{data.location}
</span>
<span className="flex items-center text-xs text-black/60 dark:text-white/60 font-medium">
<Wind className="w-3 h-3 mr-1" />
<span className="flex items-center text-[10px] text-black/60 dark:text-white/60 font-medium shrink-0">
<Wind className="w-2.5 h-2.5 mr-0.5" />
{data.windSpeed} {data.windSpeedUnit}
</span>
</div>
<span className="text-xs text-black/50 dark:text-white/50 italic">
<span className="text-[10px] text-black/50 dark:text-white/50 italic truncate">
{data.condition}
</span>
<div className="flex flex-row justify-between w-full mt-auto pt-2 border-t border-light-200/50 dark:border-dark-200/50 text-xs text-black/50 dark:text-white/50 font-medium">
<div className="flex flex-row justify-between w-full mt-auto pt-1 border-t border-light-200/50 dark:border-dark-200/50 text-[10px] text-black/50 dark:text-white/50 font-medium">
<span>Humidity {data.humidity}%</span>
<span className="font-semibold text-black/70 dark:text-white/70">
Now

View File

@@ -1,5 +1,5 @@
import { cn } from '@/lib/utils';
import { Loader2, ChevronDown } from 'lucide-react';
import { ChevronDown } from 'lucide-react';
import { SelectHTMLAttributes, forwardRef } from 'react';
interface SelectProps extends SelectHTMLAttributes<HTMLSelectElement> {
@@ -34,11 +34,7 @@ export const Select = forwardRef<HTMLSelectElement, SelectProps>(
})}
</select>
<span className="pointer-events-none absolute right-3 flex h-4 w-4 items-center justify-center text-black/50 dark:text-white/60">
{loading ? (
<Loader2 className="h-4 w-4 animate-spin" />
) : (
<ChevronDown className="h-4 w-4" />
)}
<ChevronDown className="h-4 w-4" />
</span>
</div>
);

View File

@@ -47,6 +47,7 @@ const defaultTranslations: Translations = {
'nav.home': 'Home',
'nav.discover': 'Discover',
'nav.library': 'Library',
'nav.messageHistory': 'History',
'chat.related': 'Follow-up questions',
'chat.searchImages': 'Search images',
'chat.searchVideos': 'Search videos',
@@ -75,6 +76,15 @@ const defaultTranslations: Translations = {
'chat.source': 'source',
'chat.document': 'document',
'chat.documents': 'documents',
'library.filterSourceAll': 'All sources',
'library.filterSourceWeb': 'Web',
'library.filterSourceAcademic': 'Academic',
'library.filterSourceSocial': 'Social',
'library.filterFilesAll': 'All',
'library.filterFilesWith': 'With files',
'library.filterFilesWithout': 'No files',
'library.noResults': 'No chats match your filters.',
'library.clearFilters': 'Clear filters',
};
const LocalizationContext = createContext<LocalizationContextValue | null>(null);

View File

@@ -26,6 +26,7 @@ export const embeddedTranslations: Record<
'nav.home': 'Home',
'nav.discover': 'Discover',
'nav.library': 'Library',
'nav.messageHistory': 'History',
'chat.related': 'Follow-up questions',
'chat.searchImages': 'Search images',
'chat.searchVideos': 'Search videos',
@@ -54,6 +55,15 @@ export const embeddedTranslations: Record<
'chat.source': 'source',
'chat.document': 'document',
'chat.documents': 'documents',
'library.filterSourceAll': 'All sources',
'library.filterSourceWeb': 'Web',
'library.filterSourceAcademic': 'Academic',
'library.filterSourceSocial': 'Social',
'library.filterFilesAll': 'All',
'library.filterFilesWith': 'With files',
'library.filterFilesWithout': 'No files',
'library.noResults': 'No chats match your filters.',
'library.clearFilters': 'Clear filters',
},
ru: {
'app.title': 'GooSeek',
@@ -74,6 +84,7 @@ export const embeddedTranslations: Record<
'nav.home': 'Главная',
'nav.discover': 'Обзор',
'nav.library': 'Библиотека',
'nav.messageHistory': 'История',
'chat.related': 'Что ещё спросить',
'chat.searchImages': 'Поиск изображений',
'chat.searchVideos': 'Поиск видео',
@@ -102,6 +113,15 @@ export const embeddedTranslations: Record<
'chat.source': 'источнику',
'chat.documents': 'документов',
'chat.document': 'документу',
'library.filterSourceAll': 'Все источники',
'library.filterSourceWeb': 'Веб',
'library.filterSourceAcademic': 'Академия',
'library.filterSourceSocial': 'Соцсети',
'library.filterFilesAll': 'Все',
'library.filterFilesWith': 'С файлами',
'library.filterFilesWithout': 'Без файлов',
'library.noResults': 'Нет чатов по вашим фильтрам.',
'library.clearFilters': 'Сбросить фильтры',
},
de: {
'app.title': 'GooSeek',
@@ -122,6 +142,7 @@ export const embeddedTranslations: Record<
'nav.home': 'Start',
'nav.discover': 'Entdecken',
'nav.library': 'Bibliothek',
'nav.messageHistory': 'Verlauf',
'chat.related': 'Weitere Fragen',
'chat.searchImages': 'Bilder suchen',
'chat.searchVideos': 'Videos suchen',
@@ -150,6 +171,15 @@ export const embeddedTranslations: Record<
'chat.source': 'Quelle',
'chat.document': 'Dokument',
'chat.documents': 'Dokumente',
'library.filterSourceAll': 'Alle Quellen',
'library.filterSourceWeb': 'Web',
'library.filterSourceAcademic': 'Akademisch',
'library.filterSourceSocial': 'Sozial',
'library.filterFilesAll': 'Alle',
'library.filterFilesWith': 'Mit Dateien',
'library.filterFilesWithout': 'Ohne Dateien',
'library.noResults': 'Keine Chats entsprechen Ihren Filtern.',
'library.clearFilters': 'Filter zurücksetzen',
},
fr: {
'app.title': 'GooSeek',
@@ -170,6 +200,7 @@ export const embeddedTranslations: Record<
'nav.home': 'Accueil',
'nav.discover': 'Découvrir',
'nav.library': 'Bibliothèque',
'nav.messageHistory': 'Historique',
'chat.related': 'Questions de suivi',
'chat.searchImages': 'Rechercher des images',
'chat.searchVideos': 'Rechercher des vidéos',
@@ -198,6 +229,15 @@ export const embeddedTranslations: Record<
'chat.source': 'source',
'chat.document': 'document',
'chat.documents': 'documents',
'library.filterSourceAll': 'Toutes les sources',
'library.filterSourceWeb': 'Web',
'library.filterSourceAcademic': 'Académique',
'library.filterSourceSocial': 'Réseaux',
'library.filterFilesAll': 'Tous',
'library.filterFilesWith': 'Avec fichiers',
'library.filterFilesWithout': 'Sans fichiers',
'library.noResults': 'Aucun chat ne correspond à vos filtres.',
'library.clearFilters': 'Effacer les filtres',
},
es: {
'app.title': 'GooSeek',
@@ -218,6 +258,7 @@ export const embeddedTranslations: Record<
'nav.home': 'Inicio',
'nav.discover': 'Descubrir',
'nav.library': 'Biblioteca',
'nav.messageHistory': 'Historial',
'chat.related': 'Preguntas de seguimiento',
'chat.searchImages': 'Buscar imágenes',
'chat.searchVideos': 'Buscar videos',
@@ -246,6 +287,15 @@ export const embeddedTranslations: Record<
'chat.source': 'fuente',
'chat.document': 'documento',
'chat.documents': 'documentos',
'library.filterSourceAll': 'Todas las fuentes',
'library.filterSourceWeb': 'Web',
'library.filterSourceAcademic': 'Académico',
'library.filterSourceSocial': 'Social',
'library.filterFilesAll': 'Todos',
'library.filterFilesWith': 'Con archivos',
'library.filterFilesWithout': 'Sin archivos',
'library.noResults': 'Ningún chat coincide con sus filtros.',
'library.clearFilters': 'Borrar filtros',
},
uk: {
'app.title': 'GooSeek',
@@ -266,6 +316,7 @@ export const embeddedTranslations: Record<
'nav.home': 'Головна',
'nav.discover': 'Огляд',
'nav.library': 'Бібліотека',
'nav.messageHistory': 'Історія',
'chat.related': 'Що ще запитати',
'chat.searchImages': 'Пошук зображень',
'chat.searchVideos': 'Пошук відео',
@@ -294,6 +345,15 @@ export const embeddedTranslations: Record<
'chat.source': 'джерелу',
'chat.document': 'документу',
'chat.documents': 'документів',
'library.filterSourceAll': 'Усі джерела',
'library.filterSourceWeb': 'Веб',
'library.filterSourceAcademic': 'Академія',
'library.filterSourceSocial': 'Соцмережі',
'library.filterFilesAll': 'Усі',
'library.filterFilesWith': 'З файлами',
'library.filterFilesWithout': 'Без файлів',
'library.noResults': 'Немає чатів за вашими фільтрами.',
'library.clearFilters': 'Скинути фільтри',
},
};