diff --git a/apps/class-solid/src/components/ShareButton.tsx b/apps/class-solid/src/components/ShareButton.tsx index 8816f0c..c5295fc 100644 --- a/apps/class-solid/src/components/ShareButton.tsx +++ b/apps/class-solid/src/components/ShareButton.tsx @@ -19,6 +19,66 @@ import { showToast } from "./ui/toast"; const MAX_SHAREABLE_LINK_LENGTH = 32_000; +function ShareStateAsFile({ state }: { state: string }) { + const downloadUrl = createMemo(() => { + return URL.createObjectURL( + new Blob([decodeURI(state)], { + type: "application/json", + }), + ); + }); + onCleanup(() => { + URL.revokeObjectURL(downloadUrl()); + }); + + const filename = createMemo(() => { + const names = experiments.map((e) => e.config.reference.name).join("-"); + return `class-${names.slice(0, 120)}.json`; + }); + + return ( + <> +

+ Alternatively you can create your own shareable link by hosting the + state remotely: +

+
    +
  1. + + Download state + {" "} + as file +
  2. +
  3. + Upload the state file to some static hosting service like your own web + server or an AWS S3 bucket. +
  4. +
  5. + Open the CLASS web application with + "https://classmodel.github.io/class-web?s=<your remote url>". +
  6. +
+

+ Make sure the CLASS web application is{" "} + + allowed to download from remote location + + . +

+ + ); +} + export function ShareButton() { const [open, setOpen] = createSignal(false); const [isCopied, setIsCopied] = createSignal(false); @@ -36,21 +96,6 @@ export function ShareButton() { const url = `${window.location.origin}${basePath}#${encodedAppState()}`; return url; }); - const downloadUrl = createMemo(() => { - return URL.createObjectURL( - new Blob([decodeURI(encodedAppState())], { - type: "application/json", - }), - ); - }); - onCleanup(() => { - URL.revokeObjectURL(downloadUrl()); - }); - - const filename = createMemo(() => { - const names = experiments.map((e) => e.config.reference.name).join("-"); - return `class-${names.slice(0, 120)}.json`; - }); async function copyToClipboard() { try { @@ -93,44 +138,7 @@ export function ShareButton() { Cannot embed application state in shareable link, it is too large.

-

- Alternatively you can create your own shareable link by hosting - the state remotely: -

-
    -
  1. - - Download state - {" "} - as file -
  2. -
  3. - Upload the state file to some static hosting service like your - own web server or an AWS S3 bucket. -
  4. -
  5. - Open the CLASS web application with - "https://classmodel.github.io/class-web?s=<your remote - url>". -
  6. -
-

- Make sure the CLASS web application is{" "} - - allowed to download from remote location - - . -

+ } > @@ -177,6 +185,7 @@ export function ShareButton() { +