1.1.0 • Published 6 years ago

flow-app-component v1.1.0

Weekly downloads
3
License
Apache-2.0
Repository
github
Last release
6 years ago

Flow Component SDK

Component SDK for Flow.

Install SDK

npm install flow-app-component --save

Import into your React project

import AppComponent from 'flow-app-component';

Basic Example

LinkButton.jsx

import React from 'react';

import AppComponent from 'flow-app-component';

class LinkButtonComponent extends AppComponent {
    constructor() {
        super();
        this.state = {
            properties: [
                {
                    categoryName: 'General',
                    categoryDescription: 'Basic settings for link button.',
                    properties: [
                        {
                            id: 'text',
                            name: 'Link Button',
                            type: 'text',
                            options: {},
                            data: null,
                        },
                        {
                            id: 'page',
                            name: 'Select Page',
                            type: 'select-page',
                            options: {},
                            data: null,
                        },
                    ],
                },
            ],
            iconUrl: 'src/assets/images/link-button-component.svg',
        };
    }

    renderContent() {
        const buttonStyle = {};
        const elemProps = this.getElementProps();
        elemProps.style = Object.assign(this.getDefaultStyle(), buttonStyle);
        return (
          <button {...elemProps}>
            <a>
              {
                  this.getPropertyData('text') || 'Default Button Text'
              }
            </a>
          </button>
        );
    }
}


export default LinkButtonComponent;

App.jsx

import React, { Component } from 'react';

import LinkButton from './path/to/LinkButton.jsx';

class App extends Component {
    constructor() {
        super();
        this.state = {
            propertyData: [
                {
                    properties: [
                        {
                            id: 'text',
                            name: 'Link Button',
                            type: 'text',
                            options: {},
                            data: null,
                        },
                        {
                            id: 'page',
                            name: 'Select Page',
                            type: 'select-page',
                            options: {},
                            data: null,
                        },
                    ],
                },
            ],
        };
    }

    render() {
        return <LinkButton propertyData={this.state.propertyData} />;
    }
}

export default App;

The Schema of a Component

Every component is associated with a set of properties that follow a schema. These properties define how the component is rendered.

Components

The following is the explanation of the terms you'll see for a component.

TermDescriptionType
iconUrlThe URL of the icon to show in the Component panelString
nameThe name of the componentString
componentTypeThe type of the component to renderString
categoryThe category of the component (used for the Component panel sorting)String
parentThe ID of the parent componentString
showOnComponentsPanelShould the component be shown on the Component Panel?Boolean
isDeleteableCan the component be deleted?Boolean
isValuableIs the component valuable (prompt before deleting)?Boolean
allowsChildrenDoes the component allow children?Boolean
allowedChildTypesAllowed types of children{ number: Number, types: String[] }[]
allowedParentTypesAllowed types of parentsString[]
propertiesAll the properties for the componentProperty

Properties

The following is the schema for the a Property.

Property NameDescriptionType
idThe unique ID of the property, used to set and get the valueString
nameName of the propertyString
typeThe type of the propertyString
multiIf the property should accept an array of valuesBoolean
dataThe data stored for the propertyAny
renderOnPropsPanelShould the property render on the properties panelBoolean

The "type" of the property can be any one of the following:

TypeDescription
textA text input
booleanA true/false input
descriptionA long text input
numberA number input
colorA color picker input
dropdownA dropdown with options to select
toggleA toggle input
imageAn image input
componentRenders the renderOnPropertiesPanel() of a component
select-pageA page selector
tablesA CloudBoost table selector
select-columnsA column selector for a CloudBoost table
queryA query component for the columns
graphA graph selector

Available Components

TypeDescription
textA simple text
imageAn image upload
linkA link with a href property
listA list of items to display
spaceA space component to display space in the view
appThe parent of all pages
pageThe parent of all components
directoryA "category" component for the pages of an app
navA Navigation Bar
navItemFirst child of nav
subNavItemChild of NavItem
mapA Google Maps component
videoA video display component
searchA search component. Hooked to one of the CloudBoost tables
containerAn empty container for components.
inputA text input component
toggleA boolean or yes/no component
radioA Radio component
checkboxA Checkbox component
formA form component, holds all the inputs, checkboxes, radios and toggles
loaderA loading component
dropdownA dropdown component

Component Specific Properties

Some properties are specific to certain component. The following table lists such properties.

app
Property IDProperty TypeDescription
home-pageselect-pageThe first page to open when the app is opened
not-found-pageselect-pageThe page to use for a 404 response
error-pageselect-pageThe page to use for an error response
allowed-rolesdropdownThe allowed roles for the app, others can't access the page
directory
Property IDProperty TypeDescription
allowed-rolesdropdownAllowed roles for the directory. All child pages will be affected.
page
Property IDProperty TypeDescription
allowed-rolesdropdownAllowed roles specific to a page