StatusIndicator

new StatusIndicator(options) → {Class}

A statusIndicator component .

Parameters:
NameTypeDescription
optionsobject

The options for the component.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes for the component.

customClassesArray

An array of additional classes for the component.

hasDotboolean

Whether or not to include the svg dot.

idstring

Id for the component, auto generated if not passed.

isStaticboolean

Whether or not the indicator should be active (button) or static (span).

labelstring

Status indicator label.

pillboolean

Whether or not to apply fully rounded "pill" css to the indicator.

renderedstring

Is the component already rendered in the dom, eg by php?

renderOnInitstring

Render the component on init of the class?

sizestring

Size of the component.

spacingstring

Spacing for the component.

statusstring

Type of indicator: active, inactive, or error.

targetstring

The target to render to. Any valid css selector string.

targetPositionstring

The insert position for the component relative to the target.

themestring

Theme for the component, primary or cosmos.

Since
  • 1.1.16
Returns:

The class instance.

Type: 
Class
Example
import StatusIndicator from '@gravityforms/components/html/admin/elements/StatusIndicator';

function Example() {
     const statusIndicatorInstance = new StatusIndicator( {
         id: 'example-statusIndicator',
         renderOnInit: false,
         target: '#example-target',
         targetPosition: 'beforeend',
         theme: 'cosmos',
     } );

     // Some time later we can render it. This is only done if we set renderOnInit to false.
     // If true it will render on initialization.
     statusIndicatorInstance.init();
}

Methods

(static) init() → {void}

Initialize the component.

Since
  • 1.1.16
Returns:
Type: 
void

(static) render() → {void}

Renders the component into the dom.

Since
  • 1.1.16
Returns:
Type: 
void

(static) statusIndicatorTemplate(options) → {string}

Generates the markup for a statusIndicator in the admin.

Parameters:
NameTypeDescription
optionsobject

The options for the component template.

Properties
NameTypeDescription
customAttributesobject

Any custom attributes.

customClassesArray

An array of additional classes for the toggle.

hasDotboolean

Whether or not to include the svg dot.

idstring

Id for the statusIndicator, auto generated if not passed.

isStaticboolean

Whether or not the indicator should be active (button) or static (span).

labelstring

Status indicator label.

sizestring

The size of the component.

pillboolean

Whether or not to apply fully rounded "pill" css to the indicator.

spacingstring | number | Array | object

The spacing for the component, string, number, object or array.

statusstring

Type of indicator: active, inactive, or error.

themestring

Theme for the toggle, primary or cosmos.

Since
  • 1.1.16
Returns:
Type: 
string
Example
import { statusIndicatorTemplate } from '@gravityforms/components/html/admin/elements/StatusIndicator';

function Example() {
     const statusIndicatorTemplateHTML = statusIndicatorTemplateTemplate( options );
     document.body.insertAdjacentHTML( 'beforeend', statusIndicatorTemplateHTML );
}