From c8b2c9ea638231dd179e1a893931323a2eb38be9 Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Sun, 18 May 2025 23:49:02 -0700 Subject: [PATCH] improvement(subdomain): added header links --- .../[subdomain]/components/chat-client.tsx | 169 ++++++++++++++++-- .../components/header-links/header-links.tsx | 28 +++ apps/sim/public/icon.svg | 8 + 3 files changed, 193 insertions(+), 12 deletions(-) create mode 100644 apps/sim/app/chat/[subdomain]/components/components/header-links/header-links.tsx create mode 100644 apps/sim/public/icon.svg diff --git a/apps/sim/app/chat/[subdomain]/components/chat-client.tsx b/apps/sim/app/chat/[subdomain]/components/chat-client.tsx index 4206decf46..2dcedb18e5 100644 --- a/apps/sim/app/chat/[subdomain]/components/chat-client.tsx +++ b/apps/sim/app/chat/[subdomain]/components/chat-client.tsx @@ -15,6 +15,8 @@ import { Input } from '@/components/ui/input' import { OTPInputForm } from '@/components/ui/input-otp-form' import { ScrollArea } from '@/components/ui/scroll-area' import { cn } from '@/lib/utils' +import { getFormattedGitHubStars } from '@/app/(landing)/actions/github' +import HeaderLinks from './components/header-links/header-links' import MarkdownRenderer from './components/markdown-renderer/markdown-renderer' // Define message type @@ -96,6 +98,7 @@ export default function ChatClient({ subdomain }: { subdomain: string }) { const messagesEndRef = useRef(null) const messagesContainerRef = useRef(null) const inputRef = useRef(null) + const [starCount, setStarCount] = useState('3.4k') // Authentication state const [authRequired, setAuthRequired] = useState<'password' | 'email' | null>(null) @@ -163,6 +166,15 @@ export default function ChatClient({ subdomain }: { subdomain: string }) { // Fetch chat config on mount useEffect(() => { fetchChatConfig() + + // Fetch GitHub stars + getFormattedGitHubStars() + .then((formattedStars) => { + setStarCount(formattedStars) + }) + .catch((err) => { + console.error('Failed to fetch GitHub stars:', err) + }) }, [subdomain]) // Handle keyboard input for message sending @@ -514,6 +526,49 @@ export default function ChatClient({ subdomain }: { subdomain: string }) { return (
+

Error

{error}

@@ -530,6 +585,49 @@ export default function ChatClient({ subdomain }: { subdomain: string }) { return (
+

{title}

@@ -744,18 +842,65 @@ export default function ChatClient({ subdomain }: { subdomain: string }) { } `} - {/* Header with title */} -

-

- {chatConfig.customizations?.headerText || chatConfig.title || 'Chat'} -

- {chatConfig.customizations?.logoUrl && ( - {`${chatConfig.title} - )} + {/* Header with title and links */} +
+
+ {chatConfig?.customizations?.logoUrl && ( + {`${chatConfig?.title + )} +

+ {chatConfig?.customizations?.headerText || chatConfig?.title || 'Chat'} +

+
+
+ + {!chatConfig?.customizations?.logoUrl && ( + + + + + + + + + + + )} +
{/* Messages container */} diff --git a/apps/sim/app/chat/[subdomain]/components/components/header-links/header-links.tsx b/apps/sim/app/chat/[subdomain]/components/components/header-links/header-links.tsx new file mode 100644 index 0000000000..761b09901a --- /dev/null +++ b/apps/sim/app/chat/[subdomain]/components/components/header-links/header-links.tsx @@ -0,0 +1,28 @@ +'use client' + +import { motion } from 'framer-motion' +import { GithubIcon } from '@/components/icons' + +interface HeaderLinksProps { + stars: string +} + +export default function HeaderLinks({ stars }: HeaderLinksProps) { + return ( +
+ + + {stars} + +
+ ) +} diff --git a/apps/sim/public/icon.svg b/apps/sim/public/icon.svg new file mode 100644 index 0000000000..f0ad55ac97 --- /dev/null +++ b/apps/sim/public/icon.svg @@ -0,0 +1,8 @@ + + + + + + + +