diff --git a/components/bl-list-component/README.md b/components/bl-list-component/README.md new file mode 100644 index 000000000..d7a22c2ac --- /dev/null +++ b/components/bl-list-component/README.md @@ -0,0 +1,57 @@ +# List + +List is the component that can be used in Backendless [UI-Builder](https://backendless.com/developers/#ui-builder). It allows you to add a standard list to your application. Select the type of list (ordered/unordered) and specify the data that will be displayed inside the list. +More information about list you can find [here](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/li). + +

+ main thumbnail +

+ +## Properties + +| Property | Type | Default value | Logic | Data Binding | UI Setting | Description | +|-----------------------------|----------------------------------------------|----------------|-----------------|--------------|------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| Type
`type` | *Select*
[Unordered:`ul`, Ordered:`ol`] | Unordered:`ul` | Type Logic | NO | YES | Controls the type of list(ul/ol). | +| List Items
`listItems` | *JSON* | | ListItems Logic | YES | YES | Specifies a JSON array containing data of the list items. Watch [Codeless Examples](#Examples). Signature of items list: `[ ]`. Signature of item: `{ content: String, children: [ ], type: String }`. | + +## Events + +| Name | Triggers | Context Blocks | +|--------------------------|----------------------------------------------------|---------------------------------| +| On Click List Item Event | Triggered when the user click any item of the list | `{event: Object, item: Object}` | + +## Styles + +**Theme** +```` +@bl-customComponent-list-theme: @themePrimary; +@bl-customComponent-list-themeTextColor: @appTextColor; +```` + +**Dimensions** +``` +@bl-customComponent-list-margin: 5px; +@bl-customComponent-list-item-fontSize: 1rem; +@bl-customComponent-list-item-line-height: 1.3; +@bl-customComponent-list-item-padding: 3px; +``` + +**Other** +``` +@bl-customComponent-list-item-cursor: pointer; +``` + +## Examples + +Below is a Codeless Example highlighting how to use the List component: + +![list data example](example-images/list-data-example.png) +![list data example view](example-images/list-data-example-view.png) + +
+Try yourself + +``` +CoffeeTeagreenwhite with flowers and citrus fruitsblack "Earl Grey"olWatercarbonatednon-carbonated +``` +
diff --git a/components/bl-list-component/component.json b/components/bl-list-component/component.json new file mode 100644 index 000000000..7add222a0 --- /dev/null +++ b/components/bl-list-component/component.json @@ -0,0 +1,66 @@ +{ + "id": "c_f95c74e56529269bdafe747715db7bbe", + "name": "List", + "description": "The List component allows the user to add a standard list to an application.", + "showInToolbox": true, + "faIcon": "list", + "mainJS": "dist/index.js", + "type": "custom", + "category": "Custom Components", + "properties": [ + { + "type": "select", + "name": "type", + "label": "Type", + "showInSettings": true, + "defaultValue": "ul", + "hasLogicHandler": false, + "handlerId": "typeLogic", + "options": [ + { + "value": "ul", + "label": "Unordered" + }, + { + "value": "ol", + "label": "Ordered" + } + ], + "handlerLabel": "Type Logic", + "settingTooltip": "Select a list type" + }, + { + "type": "json", + "name": "listItems", + "showInSettings": true, + "hasLogicHandler": true, + "handlerId": "listItemsLogic", + "handlerLabel": "List Items Logic", + "dataBinding": true, + "defaultValue": "[{\n \"content\": \"first item\"\n},\n {\n \"content\": \"second item\",\n \"children\": [{\n \"content\": \"second item first subitem\"\n },\n {\n \"content\": \"second item second subitem\"\n },\n {\n \"content\": \"second item third subitem\"\n }],\n \"type\": \"ol\"\n },\n {\n \"content\": \"third item\",\n \"children\": [{\n \"content\": \"third item first subitem\"\n },\n {\n \"content\": \"third item second subitem\"\n }]\n }]", + "handlerDescription": "Specifies a JSON array containing data of the list items. Signature of items list: [ ]. Signature of item: { content: String, children: [ ], type: String }.", + "label": "List Items", + "settingTooltip": "List Items Data" + } + ], + "eventHandlers": [ + { + "name": "onItemClick", + "label": "On Click List Item Event", + "contextBlocks": [ + { + "id": "event", + "label": "Click Event" + }, + { + "id": "item", + "label": "List Item" + } + ], + "handlerDescription": "This event is fired when the user clicks the mouse or taps the item of the list." + } + ], + "actions": [], + "settings": [], + "pods": {} +} diff --git a/components/bl-list-component/example-images/list-data-example-view.png b/components/bl-list-component/example-images/list-data-example-view.png new file mode 100644 index 000000000..e4e22d1c6 Binary files /dev/null and b/components/bl-list-component/example-images/list-data-example-view.png differ diff --git a/components/bl-list-component/example-images/list-data-example.png b/components/bl-list-component/example-images/list-data-example.png new file mode 100644 index 000000000..9c4d90fae Binary files /dev/null and b/components/bl-list-component/example-images/list-data-example.png differ diff --git a/components/bl-list-component/preview.html b/components/bl-list-component/preview.html new file mode 100644 index 000000000..4109f52e9 --- /dev/null +++ b/components/bl-list-component/preview.html @@ -0,0 +1 @@ +
  • unordered lists ( ul ) - the list items are marked with bullets
  • ordered lists ( ol ) - the list items are marked with numbers or letters
diff --git a/components/bl-list-component/src/index.js b/components/bl-list-component/src/index.js new file mode 100644 index 000000000..3ce7b6d1e --- /dev/null +++ b/components/bl-list-component/src/index.js @@ -0,0 +1,24 @@ +import { List } from './list'; + +const { cn } = BackendlessUI.CSSUtils; + +export default function ListComponent({ component, elRef, eventHandlers }) { + const { classList, style, display, type, listItems } = component; + + const items = listItems || []; + + const onItemClick = (event, item) => { + event.stopPropagation(); + eventHandlers.onItemClick({ event, item }); + }; + + if (!display) { + return null; + } + + return ( +
+ +
+ ); +} diff --git a/components/bl-list-component/src/list.js b/components/bl-list-component/src/list.js new file mode 100644 index 000000000..64b333941 --- /dev/null +++ b/components/bl-list-component/src/list.js @@ -0,0 +1,23 @@ +export function List({ type, items, onItemClick }) { + const ListElement = type === 'ol' ? 'ol' : 'ul'; + + return ( + + { items.map((item, i) => ( + + )) } + + ); +} + +function Item({ key, item, listType, onClick }) { + return ( +
  • onClick(e, item) }> + { item.content } + + { item.children && ( + + )} +
  • + ); +} diff --git a/components/bl-list-component/styles/index.less b/components/bl-list-component/styles/index.less new file mode 100644 index 000000000..5621a87bf --- /dev/null +++ b/components/bl-list-component/styles/index.less @@ -0,0 +1,24 @@ +@bl-customComponent-list-theme: @themePrimary; +@bl-customComponent-list-themeTextColor: @appTextColor; + +@bl-customComponent-list-margin: 5px; +@bl-customComponent-list-item-fontSize: 1rem; +@bl-customComponent-list-item-line-height: 1.3; +@bl-customComponent-list-item-padding: 3px; + +@bl-customComponent-list-item-cursor: pointer; + +.bl-customComponent-list { + color: @bl-customComponent-list-themeTextColor; + + .list { + margin: @bl-customComponent-list-margin; + } + + .list__item { + font-size: @bl-customComponent-list-item-fontSize; + padding: @bl-customComponent-list-item-padding; + line-height: @bl-customComponent-list-item-line-height; + cursor: @bl-customComponent-list-item-cursor; + } +} diff --git a/components/bl-list-component/thumbnail.png b/components/bl-list-component/thumbnail.png new file mode 100644 index 000000000..f9b889242 Binary files /dev/null and b/components/bl-list-component/thumbnail.png differ