Skip to content

Commit 0eb9c08

Browse files
Merge pull request #1 from SolaceLabs/rohan/AI-492/more-fixes
AI-492: More UI/UX improvements
2 parents 33ea2ec + c2fe408 commit 0eb9c08

File tree

5 files changed

+108
-33
lines changed

5 files changed

+108
-33
lines changed

src/solace_ai_connector_web/frontend/app/components/CustomMarkdown.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,31 @@ interface CustomMarkdownProps {
77
}
88

99
export const CustomMarkdown = ({ children, className = '' }: CustomMarkdownProps) => {
10-
const processedContent = children.replace(/\n\s*\n/g, '\n');
10+
// Check if content appears to be HTML
11+
const containsHtml = (content: string) => {
12+
// Look for HTML document patterns or HTML tags
13+
const htmlPatterns = [
14+
/<!DOCTYPE\s+html>/i,
15+
/<html[\s>]/i,
16+
/<head[\s>]/i,
17+
/<body[\s>]/i,
18+
/<\/[a-z]+>/i,
19+
];
20+
21+
return htmlPatterns.some(pattern => pattern.test(content));
22+
};
23+
24+
let processedContent = children.replace(/\n\s*\n/g, '\n');
25+
26+
// If content seems to be HTML and not already in a code block
27+
if (containsHtml(processedContent) && !processedContent.includes('```')) {
28+
// Escape < and > characters to prevent HTML rendering
29+
processedContent = processedContent
30+
.replace(/</g, '&lt;')
31+
.replace(/>/g, '&gt;');
32+
33+
}
34+
1135
const htmlContent = marked(processedContent) as string;
1236

1337
return (

src/solace_ai_connector_web/frontend/app/components/PreviewFileContent/CsvPreview.tsx

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@ export const CsvPreview: React.FC<CsvPreviewProps> = ({ content, isExpanded }) =
2424
}
2525

2626
return (
27-
<div className="overflow-x-auto">
28-
<table className="min-w-full text-xs md:text-sm dark:text-gray-200">
29-
<tbody>
30-
{rows.map((row, i) => (
31-
<tr
32-
key={i}
33-
className={`
34-
${i === 0 ? 'bg-gray-100 dark:bg-gray-700 font-medium' : ''}
35-
${i % 2 === 1 ? 'bg-gray-50 dark:bg-gray-800' : ''}
36-
`}
37-
>
38-
{row.map((cell, j) => (
39-
<td
40-
key={j}
41-
className="border border-gray-200 dark:border-gray-600 p-2 truncate max-w-[200px] dark:text-white"
42-
title={cell}
43-
>
44-
{cell}
45-
</td>
46-
))}
47-
</tr>
48-
))}
49-
</tbody>
50-
</table>
27+
<div className="overflow-x-auto scrollbar-themed">
28+
<table className="min-w-full text-xs md:text-sm dark:text-gray-200">
29+
<tbody>
30+
{rows.map((row, i) => (
31+
<tr
32+
key={i}
33+
className={`
34+
${i === 0 ? 'bg-gray-100 dark:bg-gray-700 font-medium' : ''}
35+
${i % 2 === 1 ? 'bg-gray-50 dark:bg-gray-800' : ''}
36+
`}
37+
>
38+
{row.map((cell, j) => (
39+
<td
40+
key={j}
41+
className="border border-gray-200 dark:border-gray-600 p-2 truncate max-w-[200px] dark:text-white"
42+
title={cell}
43+
>
44+
{cell}
45+
</td>
46+
))}
47+
</tr>
48+
))}
49+
</tbody>
50+
</table>
5151
</div>
5252
);
5353
};

src/solace_ai_connector_web/frontend/app/components/PreviewFileContent/PreviewContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const PreviewContent: React.FC<PreviewContentProps> = ({ file, className,
121121
</div>
122122

123123
{/* Content container */}
124-
<div className={`p-3 ${
124+
<div className={`p-3 scrollbar-themed ${
125125
isExpanded ? 'overflow-auto max-h-[500px]' : 'overflow-hidden'
126126
}`}>
127127
{isCsv ? (

src/solace_ai_connector_web/frontend/app/routes/auth-callback.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,17 @@ export default function AuthCallback() {
66
const [searchParams] = useSearchParams();
77
const [token, setToken] = useState<string | null>(null);
88
const [error, setError] = useState<string | null>(null);
9+
const [isDarkMode, setIsDarkMode] = useState(false);
910
const { configServerUrl } = useConfig();
1011

12+
useEffect(() => {
13+
// Check if dark mode is enabled
14+
const isDark = document.documentElement.classList.contains('dark') ||
15+
localStorage.getItem('theme') === 'dark' ||
16+
(!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: dark)').matches);
17+
setIsDarkMode(isDark);
18+
}, []);
19+
1120
useEffect(() => {
1221
const exchangeCode = async () => {
1322
const tempCode = searchParams.get('temp_code');
@@ -45,16 +54,15 @@ export default function AuthCallback() {
4554
if (error) {
4655
return (
4756
<div className="text-red-500">
48-
<h2>Error</h2>
49-
<p>{error}</p>
57+
<h2 className={isDarkMode ? "text-white" : "text-black"}>Error</h2>
58+
<p className={isDarkMode ? "text-red-400" : "text-red-500"}>{error}</p>
5059
</div>
5160
);
5261
}
53-
5462
if (token) {
5563
return (
5664
<div className="space-y-4">
57-
<h2 className="text-2xl">Successfully Authenticated!</h2>
65+
<h2 className={`text-2xl ${isDarkMode ? "text-white" : "text-black"}`}>Successfully Authenticated!</h2>
5866
<button
5967
onClick={() => window.location.href = '/'}
6068
className="bg-solace-green text-white px-6 py-2 rounded shadow hover:bg-solace-dark-green"
@@ -64,12 +72,11 @@ export default function AuthCallback() {
6472
</div>
6573
);
6674
}
67-
68-
return <div>Processing authentication...</div>;
75+
return <div className={isDarkMode ? "text-white" : "text-black"}>Processing authentication...</div>;
6976
};
7077

7178
return (
72-
<div className="min-h-screen bg-white dark:bg-gray-900 flex items-center justify-center">
79+
<div className={`min-h-screen flex items-center justify-center ${isDarkMode ? "bg-gray-900" : "bg-white"}`}>
7380
<div className="text-center p-8 max-w-lg">
7481
{renderContent()}
7582
</div>

src/solace_ai_connector_web/frontend/app/tailwind.css

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,47 @@
5555
opacity: 0;
5656
transition: opacity 300ms ease-in-out;
5757
}
58+
59+
/* Custom scrollbar styling */
60+
.scrollbar-themed {
61+
&::-webkit-scrollbar {
62+
width: 8px;
63+
height: 8px;
64+
}
65+
66+
&::-webkit-scrollbar-track {
67+
background: #f1f1f1;
68+
}
69+
70+
&::-webkit-scrollbar-thumb {
71+
background: #888;
72+
border-radius: 4px;
73+
}
74+
75+
&::-webkit-scrollbar-thumb:hover {
76+
background: #555;
77+
}
78+
79+
/* For dark mode */
80+
.dark & {
81+
&::-webkit-scrollbar-track {
82+
background: #2d3748;
83+
}
84+
85+
&::-webkit-scrollbar-thumb {
86+
background: #4a5568;
87+
}
88+
89+
&::-webkit-scrollbar-thumb:hover {
90+
background: #718096;
91+
}
92+
}
93+
94+
/* For Firefox */
95+
scrollbar-width: thin;
96+
scrollbar-color: #888 #f1f1f1;
97+
98+
.dark & {
99+
scrollbar-color: #4a5568 #2d3748;
100+
}
101+
}

0 commit comments

Comments
 (0)