Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/simplajs/simpla-element-behavior
Polymer behavior that connects an element to Simpla's API
https://github.com/simplajs/simpla-element-behavior
behavior polymer simpla web-components
Last synced: about 2 months ago
JSON representation
Polymer behavior that connects an element to Simpla's API
- Host: GitHub
- URL: https://github.com/simplajs/simpla-element-behavior
- Owner: simplajs
- License: mit
- Created: 2017-04-16T22:49:15.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-12-01T03:02:02.000Z (about 7 years ago)
- Last Synced: 2024-11-10T14:48:02.804Z (2 months ago)
- Topics: behavior, polymer, simpla, web-components
- Language: HTML
- Size: 119 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Simpla Element Behavior
![Version][bower-badge] [![Build status][travis-badge]][travis-url] ![Size][size-badge] [![Published][webcomponents-badge]][webcomponents-url]This Polymer behavior sets up everything you need to connect your element to Simpla's API. It handles setting and getting data, keeping in sync with state, and reacting to changes in content.
## Installation & usage
Install simpla-element-behavior with Bower (Yarn support coming soon)
```sh
$ bower install simpla-element-behavior --save
```Import into your element
```html
```
And include the behavior by adding `SimplaBehaviors.Element(config)` in your behaviors array with the configuration options for your element (see full options below)
```js
const SIMPLA_CONFIG = {
type: 'Text',
dataProperties: [ 'value' ]
};Polymer({
is: 'my-element',...
behaviors: [ SimplaBehaviors.Element(SIMPLA_CONFIG) ]
});
```## Configuration
Property | Type | Description
---------------- | -------- | ------------
`type` | `String` | Type of content created by this element (read more about [Simpla's content model](https://www.simpla.io/docs/guides/content-model))
`dataProperties` | `Array` | The properties you wish to sync to Simpla's API
`getCallback` | `String` | Override the default method used to set properties on your element from Simpla, specified as the name of a method available on your element
`setCallback` | `String` | Override the default method used to set data to Simpla's buffer, specified as the name of a method available on your elementThe `setCallback` method expects you to return the values you wish to set to Simpla every time your `dataProperties` change. If you return `null` or `undefined` the buffer is not updated.
## Properties
This behavior adds the following properties to your element. Any property can be overriden by adding your own property definition of the same name in the main `Polymer` constructor
Property | Type | Description
---------- | --------- | ------------
`path` | `String` | Content path where the element will store its data on Simpla's API, set by the user
`editable` | `Boolean` | Whether the element should be editable, synced to Simpla's `'editable'` state
`readonly` | `Boolean` | Whether an element should be able to go editable
`loaded` | `Boolean` | Whether a new path's data has been set on the element## Contributing
If you find any issues with simpla-element-behavior please report them! If you'd like to see a new feature in supported file an issue or let us know in Simpla's public [Slack group](https://slack.simpla.io). We also happily accept PRs.
***
MIT © Simpla
[bower-badge]: https://img.shields.io/bower/v/simpla-element-behavior.svg
[bowerlicense-badge]: https://img.shields.io/bower/l/simpla-element-behavior.svg
[travis-badge]: https://img.shields.io/travis/SimplaElements/simpla-element-behavior.svg
[travis-url]: https://travis-ci.org/SimplaElements/simpla-element-behavior
[bowerdeps-badge]: https://img.shields.io/gemnasium/SimplaElements/simpla-element-behavior.svg
[bowerdeps-url]: https://gemnasium.com/bower/simpla-element-behavior
[size-badge]: https://badges.herokuapp.com/size/github/SimplaElements/simpla-element-behavior/master/simpla-element-behavior.html?gzip=true
[webcomponents-badge]: https://img.shields.io/badge/webcomponents.org-published-blue.svg
[webcomponents-url]: https://www.webcomponents.org/element/SimplaElements/simpla-element-behavior.svg