2026-03-28 18:03:46 +08:00
|
|
|
import { useState } from "react";
|
2026-03-28 15:08:05 +08:00
|
|
|
import { ProgressBar, Label } from "@heroui/react";
|
2026-03-25 09:14:24 +08:00
|
|
|
import Card from "./components/Card";
|
2026-03-27 20:30:49 +08:00
|
|
|
import Guodegang from "./components/Guodegang";
|
2026-03-28 18:03:46 +08:00
|
|
|
import Mermaid from "./components/Mermaid";
|
2026-03-28 15:08:05 +08:00
|
|
|
import Topic from "./components/Topic";
|
2026-03-24 11:59:20 +08:00
|
|
|
|
2026-03-23 22:33:30 +08:00
|
|
|
function App() {
|
2026-03-28 15:08:05 +08:00
|
|
|
const [topic, setTopic] = useState('');
|
|
|
|
|
const [cardLoaded, setCardLoaded] = useState(false);
|
|
|
|
|
const [guodegangLoaded, setGuodegangLoaded] = useState(false);
|
2026-03-28 18:03:46 +08:00
|
|
|
const [mermaidLoaded, setMermaidLoaded] = useState(false);
|
2026-03-28 15:08:05 +08:00
|
|
|
|
|
|
|
|
const progress = (() => {
|
|
|
|
|
if (!topic) return 0;
|
2026-03-28 18:03:46 +08:00
|
|
|
if (cardLoaded && guodegangLoaded && mermaidLoaded) return 100;
|
|
|
|
|
if (cardLoaded && guodegangLoaded) return 67;
|
|
|
|
|
if (cardLoaded && mermaidLoaded) return 67;
|
|
|
|
|
if (guodegangLoaded && mermaidLoaded) return 67;
|
|
|
|
|
if (cardLoaded || guodegangLoaded || mermaidLoaded) return 33;
|
2026-03-28 15:08:05 +08:00
|
|
|
return 10;
|
|
|
|
|
})();
|
|
|
|
|
|
2026-03-23 22:33:30 +08:00
|
|
|
return (
|
2026-03-28 15:08:05 +08:00
|
|
|
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '20px' }}>
|
|
|
|
|
<Topic onTopicSubmit={setTopic}/>
|
|
|
|
|
{topic && (
|
|
|
|
|
<div className="w-64">
|
|
|
|
|
<ProgressBar value={progress} color="accent">
|
|
|
|
|
<Label>Data Loading</Label>
|
|
|
|
|
<ProgressBar.Output />
|
|
|
|
|
<ProgressBar.Track>
|
|
|
|
|
<ProgressBar.Fill />
|
|
|
|
|
</ProgressBar.Track>
|
|
|
|
|
</ProgressBar>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
2026-03-28 18:03:46 +08:00
|
|
|
<div style={{ display: 'grid', gap: '10px' }}>
|
2026-03-28 15:08:05 +08:00
|
|
|
<Card topic={topic} onLoaded={setCardLoaded} />
|
|
|
|
|
<Guodegang topic={topic} onLoaded={setGuodegangLoaded} />
|
2026-03-28 18:03:46 +08:00
|
|
|
<Mermaid topic={topic} onLoaded={setMermaidLoaded} />
|
2026-03-28 15:08:05 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-03-25 09:14:24 +08:00
|
|
|
);
|
2026-03-23 22:33:30 +08:00
|
|
|
}
|
|
|
|
|
|
2026-03-25 09:14:24 +08:00
|
|
|
export default App;
|