0.0.4 • Published 3 years ago

@brandfolder/panel v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

panel-ui-sdk

This library was generated with Nx.

Running unit tests

Run nx test panel-ui-sdk to execute the unit tests via Jest.

Manually publish to NPM

  • Bump version in libs/panel-ui-sdk/package.json
  • run npm run build panel-ui-sdk
  • run npm login --auth-type=web
  • use npm credentials from 1password
  • run npm run publish-sdk
  • type in the one time password from 1password

Documentation

Initialization

export interface PanelUISdkParameters {
  anchorElement: HTMLElement; // Used to append the Iframe containing the Panel
  panelUIBaseUrl?: string; // Custom base URL if using a self-hosted version of the Panel
}

Example:

const anchor = window.getElementById('panel-anchor');
const panel = new PanelUISdk({ 
  anchorElement: anchor, 
  panelUIBaseUrl: 'https://custom-panel.com'
});

PanelUISdk.selectAttachments

Opens the Panel on the Org landing page. Allows you to pass in a handler to listen for attachment selection events.

Arguments:

export interface SelectAttachmentProps {
  onSelect: (attachment: AttachmentDto) => void; // Called whenever user selects an attachment
}

Example:

panel.selectAttachments({ 
  onSelect: (attachment) => console.log('Attachment selected: ', attachment) 
});

PanelUISdk.closePanel

Removes the Panel IFrame from the anchor element. All listeners that were registered while the Panel was opened are deleted.

Example:

panel.closePanel()