BusinessDrawer.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use client";
  2. import { X } from "lucide-react";
  3. import type { BusinessSection } from "@/lib/flow-ledger/business";
  4. export type BusinessDrawerState = {
  5. title: string;
  6. sections: BusinessSection[];
  7. } | null;
  8. export function BusinessDrawer({ drawer, onClose }: { drawer: BusinessDrawerState; onClose: () => void }) {
  9. return (
  10. <>
  11. <button
  12. className={`drawer-overlay ${drawer ? "open" : ""}`}
  13. type="button"
  14. aria-label="关闭抽屉"
  15. onClick={onClose}
  16. />
  17. <aside className={`drawer ${drawer ? "open" : ""}`} aria-hidden={!drawer}>
  18. <header>
  19. <h2>{drawer?.title || "详情"}</h2>
  20. <button className="drawer-close" type="button" aria-label="关闭" onClick={onClose}>
  21. <X size={17} />
  22. </button>
  23. </header>
  24. <div className="drawer-content business-drawer-content">
  25. {drawer?.sections.map((section) => (
  26. <section className={`drawer-section ${section.tone || "neutral"}`} key={section.label}>
  27. <h3>{section.label}</h3>
  28. {section.value ? <p>{section.value}</p> : null}
  29. {section.items?.length ? (
  30. <ul>
  31. {section.items.map((item) => (
  32. <li key={item}>{item}</li>
  33. ))}
  34. </ul>
  35. ) : null}
  36. </section>
  37. ))}
  38. </div>
  39. </aside>
  40. </>
  41. );
  42. }