-
Notifications
You must be signed in to change notification settings - Fork 84
BuildFire Drawer Component
This sdk documentation is deprecated and will not be updated. Check out our new docs at https://sdk.buildfire.com/docs/drawer/
The drawer component provides a contextual modal that slides up from the bottom of the app. It will appear above any plugins, along with a backdrop that will dismiss the modal.
This component supports multiple tabs, which can be populated with either fully custom markup, or a list of actions.
The drawer component supports the following methods.
This component only works on the widget. Include the following in the index.html:
<script src="../../../scripts/buildfire/components/drawer/drawer.js"></script>This method takes an options object and builds the drawer UI. The callback will be executed with information on actions taken by the user.
-
header- String, optional
- This can be text or stringified HTML
- Renders as a header for the drawer
-
content- String, optional.
- This can be text or stringified HTML
- Renders as the body of the drawer
-
listItems- Array, optional
- Renders as the body of the drawer
- When an item is clicked, the callback executes with that item's data
- See How to Use List Items
-
tabs- Array, optional
- Renders as the body of the drawer
- Supports both
contentandlistItems - See How to Use Tabs
-
error- Returns any errors that occur
-
result-
id- Boolean. Returns id of the listItem selected.
-
This method takes an options object and builds the drawer UI. Only supports header, content, and listItems. The callback will be executed with information on actions taken by the user.
-
header- String, optional
- This can be text or stringified HTML
- Renders as a header for the drawer
-
content- String, optional.
- This can be text or stringified HTML
- Renders as the body of the drawer
-
listItems- Array, optional
- Renders as the body of the drawer
- When an item is clicked, the callback executes with that item's data
- See How to Use List Items
-
error- Returns any errors that occur
-
result-
id- Boolean. Returns id of the listItem selected.
-
This method takes an options object and builds the drawer UI. Only supports header, content, and tabs. The callback will be executed with information on actions taken by the user.
-
header- String, optional
- This can be text or stringified HTML
- Renders as a header for the drawer
-
content- String, optional.
- This can be text or stringified HTML
- Renders as the body of the drawer
-
tabs- Array, optional
- Renders as the body of the drawer
- Supports both
contentandlistItems - See How to Use Tabs
-
error- Returns any errors that occur
-
result-
id- Boolean. Returns id of the listItem selected.
-
This method closes the drawer UI. The callback will be executed when the drawer closes.
listItems is an array of actions presented to the user. Each item has the following structure:
-
item-
id- String, required
- Unique ID to differentiate actions taken by the user
-
text- String, required
- Text presented to the user
-
icon- String, optional
- Icon that renders alongside the item
-
When an action is clicked, its data is passed to the callback.
tabs is an array of tab data used to render multiple tabs in the drawer. Tabs can either be content or listItems. Both options act identically to their counterparts above.
- tab
-
header- String, required.
- Appears as the tab header
-
content- String, optional.
- Rich content to render in the tab
-
-
listItems- Array, optional.
- List of actions (see above)
const options = {
header: `
<div class="avatar">
<img src="${imageUrl}" onerror="this.src=window._appRoot+'media/avatar.png'" />
</div>
`,
tabs: [{
text: `<span class="glyphicon glyphicon-user"></span>`,
listItems: [{
id: 'profile',
icon: 'glyphicon glyphicon-circle-arrow-right',
text: 'Open Profile',
},
{
id: 'delete',
icon: 'glyphicon glyphicon-remove-circle',
text: 'delete`,
}]
},
{
text: `<span class="glyphicon glyphicon-tags"></span>`
content: `<div>Rich HTML here</div>`
}]
};
const callback = (error, result) => {
if (error) return console.error(error);
switch (result.id) {
//...
}
};
buildfire.components.drawer.openBottomDrawer(options, callback);