plugin-ui-launcher.fixture.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { useState } from "react";
  2. import { createRoot } from "react-dom/client";
  3. import { PluginUiToolCallView } from "@/plugin-ui/components/PluginUiToolCallBlock.js";
  4. import { ZCodeIntlProvider, useZCodeIntl } from "@/i18n/IntlProvider.js";
  5. import "@/styles.css";
  6. const params = new URLSearchParams(location.search);
  7. document.documentElement.className = `${params.get("theme")} theme-zai-${params.get("theme")}`;
  8. function Fixture() {
  9. const [opened, setOpened] = useState(false);
  10. const { intl } = useZCodeIntl();
  11. const label = (id: string) => intl.formatMessage({ id });
  12. return (
  13. <main className="min-h-screen bg-background p-4 text-foreground">
  14. <div className="mx-auto max-w-2xl">
  15. <PluginUiToolCallView
  16. supported
  17. fallback={null}
  18. preferredDisplayMode="fullscreen"
  19. sidePaneActive={opened}
  20. inlineAllowed={false}
  21. pluginId="pdf@zcode-plugins-official"
  22. pluginName={
  23. params.get("long")
  24. ? "PDF — Research document with a very long descriptive title"
  25. : "PDF"
  26. }
  27. host={{
  28. pageKey: "fixture",
  29. handle: null,
  30. phase: "running",
  31. height: 240,
  32. error: null,
  33. reload() {},
  34. }}
  35. prefersBorder
  36. superseded={false}
  37. pinLabel={label("pluginUi.pin")}
  38. unpinLabel={label("pluginUi.unpin")}
  39. loadingLabel={label("pluginUi.loading")}
  40. errorLabel={label("pluginUi.loadFailed")}
  41. retryLabel={label("pluginUi.retry")}
  42. openedLabel={label("pluginUi.openedInSidePane")}
  43. openLabel={label("pluginUi.openInSidePane")}
  44. openButtonLabel={label("pluginUi.open")}
  45. onWidthChange={() => {}}
  46. onOpenSidePane={() => setOpened(true)}
  47. />
  48. </div>
  49. </main>
  50. );
  51. }
  52. createRoot(document.getElementById("root")!).render(
  53. <ZCodeIntlProvider initialLocale={params.get("locale") === "zh-CN" ? "zh-CN" : "en-US"}>
  54. <Fixture />
  55. </ZCodeIntlProvider>,
  56. );