feat: complete dynamic JSON-driven photo tools frontend connected to FastAPI backend
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import React from 'react';
|
||||
|
||||
interface RichTextSectionProps {
|
||||
markdown?: string;
|
||||
}
|
||||
|
||||
export function RichTextSection({ markdown = '' }: RichTextSectionProps) {
|
||||
// Simple, safe markdown to HTML parser for headers, lists, and paragraphs
|
||||
const renderFormatted = (text: string) => {
|
||||
const lines = text.split('\n');
|
||||
return lines.map((line, idx) => {
|
||||
if (line.startsWith('### ')) {
|
||||
return (
|
||||
<h3 key={idx} className="text-xl font-bold text-slate-900 dark:text-white mt-6 mb-3">
|
||||
{line.replace('### ', '')}
|
||||
</h3>
|
||||
);
|
||||
}
|
||||
if (line.startsWith('1. ') || line.startsWith('2. ') || line.startsWith('3. ') || line.startsWith('4. ')) {
|
||||
return (
|
||||
<div key={idx} className="flex items-start space-x-2 my-2 text-sm text-slate-700 dark:text-slate-300">
|
||||
<span className="font-bold text-blue-600">{line.slice(0, 3)}</span>
|
||||
<span>{line.slice(3)}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
if (line.trim().length === 0) {
|
||||
return <div key={idx} className="h-2" />;
|
||||
}
|
||||
return (
|
||||
<p key={idx} className="text-sm text-slate-600 dark:text-slate-400 leading-relaxed my-2">
|
||||
{line}
|
||||
</p>
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<section className="py-12 bg-white dark:bg-slate-900">
|
||||
<div className="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
|
||||
<div className="bg-slate-50 dark:bg-slate-950/60 rounded-3xl p-6 sm:p-10 border border-slate-200 dark:border-slate-800 shadow-sm">
|
||||
{renderFormatted(markdown)}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user