Design system

Widget access dialog

Generates a link to a widget's latest output, for use outside Petavue.

import { WidgetAccessDialog } from "@/ui";

WidgetAccessDialog matches the Figma Widget Access component. It opens from a dashboard widget's menu. It walks through four states: Generate, Generating, Copy Link and Copied. It is a Small Dialog with no icon and no footer.

Try it

Generate a link, copy it, then open Additional information to see the API key. Copied changes back to Copy Link after two seconds.

const [link, setLink] = useState(null);
const [generating, setGenerating] = useState(false);

<WidgetAccessDialog
  link={link}
  generating={generating}
  onGenerate={async () => { setGenerating(true); setLink(await createLink()); setGenerating(false); }}
  apiKey={user.apiKey}
  docsHref="/docs/widget-links"
  onOpenProfile={() => navigate("/profile")}
  onClose={close}
/>

States

Figma statePropsButton
Generateno linkprimary "Generate Link" with a link icon
GeneratinggeneratingPrimary 300, "Generating Link" with a Spinner, not clickable
Copy LinklinkLink field, then primary "Copy Link"
Copiedafter a click on Copy Link"Copied" with a check, for two seconds

Once there is a link, the Additional information box appears below it. Closed, it shows one line. Open, it explains the file formats and the API key, and shows the key masked, with buttons to reveal and copy it.

Anatomy

PartSpec
PanelSmall Dialog, 460px, no icon, no footer
Body12px text, 0 12px 16px padding, 16px gaps
Link fieldGrey 50 fill, 0.5px Grey 200 border, 8px radius, 12px Grey 600 text cut with an ellipsis
ButtonsFull-width Medium Buttons, 10px below the field
Additional information1px Grey 100 border, 6px radius, 8px padding, 12px Grey 600 text. File types in JetBrains Mono on Grey 50

Props

PropTypeDefaultNotes
linkstring | nullnullSet it once generated.
generatingbooleanfalse
onGeneratefunction
apiKeystringShown masked. Leave it out to hide the key row.
docsHrefstring"Know more" link. Leave it out to hide it.
onOpenProfilefunctionThe Profile link.
onClosefunction

Accessibility

  • The Additional information toggle is a button with aria-expanded.
  • The reveal and copy buttons for the key are labelled "Show API key" and "Copy API key".
  • The Copy Link button is aria-live, so screen readers hear "Copied".

On this page