mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-07-01 10:02:57 +08:00
Rework the color system around warm neutrals and route hardcoded surfaces through theme tokens for consistency. - Theme tokens (index.css, ThemeContext): warm cream light mode and neutral charcoal dark mode, replacing the pure-white/blue-tinted palette; update PWA theme-color meta - Code blocks: soft grey background in light mode via oneLight/oneDark, and drop the Tailwind Typography <pre> shell that framed the highlighter in a dark box - Dropdowns/panels: convert CommandMenu, Quick Settings, and the JSON response block from hardcoded gray/slate to popover/muted/border tokens - Git panel: Publish button purple -> primary blue - Composer: drop top padding so the input sits flush with the thread
56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { useMemo } from 'react';
|
|
import type { Components } from 'react-markdown';
|
|
import ReactMarkdown from 'react-markdown';
|
|
import rehypeKatex from 'rehype-katex';
|
|
import remarkGfm from 'remark-gfm';
|
|
import remarkMath from 'remark-math';
|
|
import MarkdownCodeBlock from './MarkdownCodeBlock';
|
|
|
|
type MarkdownPreviewProps = {
|
|
content: string;
|
|
};
|
|
|
|
const markdownPreviewComponents: Components = {
|
|
code: MarkdownCodeBlock,
|
|
// MarkdownCodeBlock renders its own highlighted <pre>; passthrough prevents a
|
|
// second Typography-styled <pre> shell from framing it.
|
|
pre: ({ children }) => <>{children}</>,
|
|
blockquote: ({ children }) => (
|
|
<blockquote className="my-2 border-l-4 border-gray-300 pl-4 italic text-gray-600 dark:border-gray-600 dark:text-gray-400">
|
|
{children}
|
|
</blockquote>
|
|
),
|
|
a: ({ href, children }) => (
|
|
<a href={href} className="text-blue-600 hover:underline dark:text-blue-400" target="_blank" rel="noopener noreferrer">
|
|
{children}
|
|
</a>
|
|
),
|
|
table: ({ children }) => (
|
|
<div className="my-2 overflow-x-auto">
|
|
<table className="min-w-full border-collapse border border-gray-200 dark:border-gray-700">{children}</table>
|
|
</div>
|
|
),
|
|
thead: ({ children }) => <thead className="bg-gray-50 dark:bg-gray-800">{children}</thead>,
|
|
th: ({ children }) => (
|
|
<th className="border border-gray-200 px-3 py-2 text-left text-sm font-semibold dark:border-gray-700">{children}</th>
|
|
),
|
|
td: ({ children }) => (
|
|
<td className="border border-gray-200 px-3 py-2 align-top text-sm dark:border-gray-700">{children}</td>
|
|
),
|
|
};
|
|
|
|
export default function MarkdownPreview({ content }: MarkdownPreviewProps) {
|
|
const remarkPlugins = useMemo(() => [remarkGfm, remarkMath], []);
|
|
const rehypePlugins = useMemo(() => [rehypeKatex], []);
|
|
|
|
return (
|
|
<ReactMarkdown
|
|
remarkPlugins={remarkPlugins}
|
|
rehypePlugins={rehypePlugins}
|
|
components={markdownPreviewComponents}
|
|
>
|
|
{content}
|
|
</ReactMarkdown>
|
|
);
|
|
}
|