draft-greeting-layout.fixture.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { useState } from "react";
  2. import { createRoot } from "react-dom/client";
  3. import { ConversationDraftEmptyState } from "@/v4/ConversationDraftEmptyState.js";
  4. import { ZCodeIntlProvider, useZCodeIntl } from "@/i18n/IntlProvider.js";
  5. import "@/styles.css";
  6. const params = new URLSearchParams(location.search);
  7. const theme = params.get("theme") ?? "light";
  8. document.documentElement.className = `${theme} theme-zai-${theme}`;
  9. const compact = params.has("compact");
  10. function Fixture() {
  11. const { locale, setLocale } = useZCodeIntl();
  12. const [revision, setRevision] = useState(0);
  13. return (
  14. <main className="min-h-dvh bg-background p-4 text-ui-base text-foreground">
  15. <button onClick={() => setLocale(locale === "zh-CN" ? "en-US" : "zh-CN")}>
  16. Switch language
  17. </button>
  18. <button onClick={() => setRevision(revision + 1)}>Render parent {revision}</button>
  19. <section
  20. data-testid="greeting-column"
  21. className="mt-24"
  22. style={{ width: compact ? "100%" : 672 }}
  23. >
  24. <ConversationDraftEmptyState compactForRemoteControl={compact} />
  25. {/* 只测量标题对下一兄弟节点的位置影响;真实 composer 由桌面 E2E 覆盖。 */}
  26. <input
  27. data-testid="following-input"
  28. aria-label="Message"
  29. className="h-24 w-full rounded-2xl border border-input-border bg-input"
  30. />
  31. </section>
  32. </main>
  33. );
  34. }
  35. createRoot(document.getElementById("root")!).render(
  36. <ZCodeIntlProvider initialLocale={params.get("locale") === "en-US" ? "en-US" : "zh-CN"}>
  37. <Fixture />
  38. </ZCodeIntlProvider>,
  39. );