Snapkit
This section explores how to create a custom user interface using snap-kit and DevRev.
Understanding the structure
The snap-kit JSON has a top-level structure with object
, body
, type
, and snap_kit_body
fields. The snap_kit_body
field contains information regarding snap-kit’s structure.
For example:
Snap-kit body
The snap_kit_body
field has the following properties:
snap_in_id
: A unique identifier for the snap-kit.snap_in_action_name
: The name of the action this snap-kit represents.body
: An object that holds the actual snap-kit content in the form ofsnaps
.
For example:
Body
The body
field contains an array of snaps
. Each snap can have a type
, and depending on the type, it has different properties.
Snaps
The following snap types are supported:
Base types
User interface elements
Form elements
- Checkboxes
- Input
- List Input
- Static Select
- Multi Static Select
- Radio Buttons
- Toggle Button
- Upload Input
Layout elements
Data pickers
Action payloads
Snap-kit generates payloads when a user interacts with an actionable snap. The payload is sent to the backend and can be used to perform actions. The following snaps generate payloads:
- Button
- Checkboxes
- Input and all its types (Plain Text Input, Number Input, Email Input, Rich Text Input)
- List Input and all its types (String List Input, Number List Input, Email List Input)
- Static Select
- Multi Static Select
- Radio Buttons
- Toggle Button
- Upload Input
- Form
- Part Picker
- Tag Picker
- User Picker
Base Payload
All actionable snaps share the same base payload structure. The base payload has the following structure:
Base Types
Many elements share the same base properties. The base types these elements inherit from are described below.
User interface elements
Table
A table element used to present JSON structured data.
Properties
rows
(required): The values to be displayed in the table. The data should be provided as a JSON object, where each cell is a plaintext SnapKit component.columns
(required): Columns are defined as an array of objects, where each object has two parameters: an optional header and a required field key, which defines which field from rows is shown in the defined column. If a key is not used, it means that the associated data from rows will not be displayed in the table. The order of keys also defines the order in which values from rows are shown in the table.
Inherited properties
Inherited from Snap:
type
(required): The type of the element, should be set to"table"
.block_id
(optional): A unique identifier for the snap. If not provided, a random ID is generated.
Example
Table
A table element used to present JSON structured data.
Properties
rows
(required): The values to be displayed in the table. The data should be provided as a JSON object, where each cell is a plaintext SnapKit component.columns
(required): Columns are defined as an array of objects, where each object has two parameters: an optional header and a required field key, which defines which field from rows is shown in the defined column. If a key is not used, it means that the associated data from rows will not be displayed in the table. The order of keys also defines the order in which values from rows are shown in the table.
Inherited properties
Inherited from Snap:
type
(required): The type of the element, should be set to"table"
.block_id
(optional): A unique identifier for the snap. If not provided, a random ID is generated.