-
Notifications
You must be signed in to change notification settings - Fork 7
MARKET-1557 List Component #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
71c071e
d89e697
4a56f91
13cba78
73c8ed4
217c5f1
a2946e7
d733da6
65cfa59
8c664c0
a436837
f82cdde
7c7e957
bad8f87
2ea85f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| # 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. | ||
|
|
||
| <p align="center"> | ||
| <img src="./thumbnail.png" alt="main thumbnail" width="643"/> | ||
| </p> | ||
|
|
||
| Additional properties allow customizing the font size, background color, text color, padding and behavior of the component. Refer to the Properties section below. | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Configuration | ||
|
|
||
| The configuration can be done in the UI Builder or using the Codeless Logic. You need to select the type of list (ordered/unordered) and specify the data that will be displayed inside the list. | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Properties | ||
|
|
||
| | Property | Type | Default value | Logic | Data Binding | UI Setting | Description | | ||
| |--------------------------|------------|---------------|--------------------|--------------|------------|-------------------------------------------------------------------| | ||
| | Type | *Select* | `"Unordered"` | Type Logic | NO | YES | Controls the type of list(ul/ol). | | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| | List Items | *JSON* | | ListItems Logic | YES | NO | Specifies a JSON array containing data for the list items. Watch [Codeless Examples] #codeless-examples). | | ||
|
||
| | Background | *Color* | | | NO | YES | Controls the background color of the main block. | | ||
| | Width | *Text* | | | NO | YES | Controls the width of the main block. | | ||
| | Color | *Color* | | | NO | YES | Controls the color of the list items. | | ||
| | Font Size | *Text* | | | NO | YES | Controls the font size of the list items. | | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ## Events | ||
|
|
||
| | Name | Triggers | Context Blocks | | ||
| |---------------------------|--------------------------------------------------------|----------------| | ||
| | On Click List Item | when the user click any item of the list | `List Item` | | ||
|
|
||
| ## Styles | ||
|
|
||
| **Theme** | ||
| ```` | ||
| @bl-customComponent-list-theme: @themePrimary; | ||
| @bl-customComponent-list-themeTextColor: @appTextColor; | ||
| ```` | ||
|
|
||
| **Dimensions** | ||
| ``` | ||
| @bl-customComponent-list-item-size: 20px; | ||
| ``` | ||
|
|
||
| **Colors** | ||
| ```` | ||
| @bl-customComponent-list-item-hover-background-color: if(@isLightTheme, rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.04)); | ||
| ```` | ||
|
|
||
| ## Codeless Examples | ||
|
|
||
| Below is a Codeless Example highlighting how to use the List component: | ||
|
|
||
|  | ||
|  | ||
v-excelsior marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| { | ||
| "id": "c_f95c74e56529269bdafe747715db7bbe", | ||
| "name": "List", | ||
| "description": "The List component allows the user to add a standard list to an application.", | ||
| "showInToolbox": true, | ||
| "faIcon": "pencil-ruler", | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "mainJS": "dist/index.js", | ||
| "type": "custom", | ||
| "category": "Custom Components", | ||
| "properties": [ | ||
| { | ||
| "type": "select", | ||
v-excelsior marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "name": "type", | ||
| "label": "Type", | ||
| "showInSettings": true, | ||
| "defaultValue": "ul", | ||
| "hasLogicHandler": false, | ||
| "handlerId": "typeLogic", | ||
| "options": [ | ||
| { | ||
| "value": "ul", | ||
| "label": "Unordered" | ||
| }, | ||
| { | ||
| "value": "ol", | ||
| "label": "Ordered" | ||
| } | ||
| ], | ||
| "handlerLabel": "Type Logic" | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }, | ||
| { | ||
| "type": "json", | ||
| "name": "listItems", | ||
| "showInSettings": false, | ||
Valodya marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| "hasLogicHandler": true, | ||
| "handlerId": "listItemsLogic", | ||
| "handlerLabel": "List Items Logic", | ||
| "dataBinding": true | ||
| }, | ||
| { | ||
| "type": "color", | ||
| "name": "backgroundColor", | ||
| "label": "Background", | ||
| "showInSettings": true, | ||
| "hasLogicHandler": false, | ||
| "handlerId": "backgroundColorLogic" | ||
| }, | ||
| { | ||
| "type": "text", | ||
| "name": "width", | ||
| "label": "Width", | ||
| "showInSettings": true, | ||
| "hasLogicHandler": false, | ||
| "handlerId": "widthLogic" | ||
| }, | ||
| { | ||
| "type": "color", | ||
| "name": "color", | ||
| "label": "Color", | ||
| "showInSettings": true, | ||
| "hasLogicHandler": false, | ||
| "handlerId": "colorLogic" | ||
| }, | ||
| { | ||
| "type": "text", | ||
| "name": "fontSize", | ||
| "label": "Font Size", | ||
| "showInSettings": true, | ||
| "hasLogicHandler": false, | ||
| "handlerId": "fontSizeLogic" | ||
| } | ||
| ], | ||
| "eventHandlers": [ | ||
| { | ||
| "name": "onClickListItem", | ||
| "label": "On Click List Item Event", | ||
| "contextBlocks": [ | ||
| { | ||
| "id": "item", | ||
| "label": "List Item" | ||
| } | ||
| ] | ||
| } | ||
| ], | ||
| "actions": [], | ||
| "settings": [], | ||
| "pods": {} | ||
| } | ||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,19 @@ | ||||||||||
| import { List } from './list'; | ||||||||||
|
|
||||||||||
| export default function ListComponent ({ | ||||||||||
| component, eventHandlers | ||||||||||
| }) { | ||||||||||
|
||||||||||
| export default function ListComponent ({ | |
| component, eventHandlers | |
| }) { | |
| export default function ListComponent ({ component, eventHandlers }) { |
Also, did you setup eslint and editorconfig in your IDE?
https://github.com/Backendless/eslint-config
https://github.com/v-excelsior/editor-config/blob/main/.editorconfig
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be moved out from the component. You don't need to create cn every render
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| style.width = width; | |
| style.backgroundColor = backgroundColor; | |
| const styles = useMemo(()=> ({...style, width, backgroundColor}), [style, width, backgroundColor]) |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| <List component={component} | |
| eventHandlers={eventHandlers}/> | |
| <List component={component} eventHandlers={eventHandlers}/> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| import { List } from './list'; | ||
|
|
||
| export function ListContent({ | ||
|
||
| component, eventHandlers, child}) { | ||
|
|
||
| const { color, fontSize, listItems, type} = component; | ||
|
|
||
| const itemStyles = { | ||
| color : color, | ||
| fontSize: fontSize | ||
| }; | ||
|
||
|
|
||
| const onItemClick = (key) => { | ||
| eventHandlers.onClickListItem({item: key}); | ||
| } | ||
|
|
||
| const getItems = (items) => { | ||
|
||
| return (items || []).map((item, i) => { | ||
| if (item.child && item.child.length !== 0) { | ||
|
||
| return ( | ||
| <li key={i.toString()} | ||
|
||
| className="list__item" | ||
| style = {itemStyles} | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
|
||
| onItemClick(item.item); | ||
| }} | ||
| > | ||
| {item.item} | ||
| <List component={component} | ||
| child={item.child} | ||
| eventHandlers={eventHandlers}/> | ||
| </li> | ||
| ) | ||
| } else { | ||
| return ( | ||
| <li key={i.toString()} | ||
| className="list__item" | ||
| style = {itemStyles} | ||
|
||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| onItemClick(item.item); | ||
| }} | ||
| > | ||
| {item.item} | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </li> | ||
| ) | ||
| } | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| }); | ||
| } | ||
|
|
||
| return (getItems(child || listItems)) | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { ListContent } from './list-content'; | ||
|
|
||
| export function List ({ | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| component, eventHandlers, child | ||
| }) { | ||
|
|
||
| const listType = (type) => { | ||
| if(type && type === 'ol') { | ||
|
||
| return ( | ||
| <ol className="list"> | ||
| <ListContent | ||
| component={component} | ||
| child={child} | ||
| eventHandlers={eventHandlers} /> | ||
| </ol> | ||
| ) | ||
| } else { | ||
| return ( | ||
| <ul className="list"> | ||
| <ListContent | ||
| component={component} | ||
| child={child} | ||
| eventHandlers={eventHandlers} /> | ||
| </ul> | ||
| ) | ||
| } | ||
| }; | ||
|
|
||
| return (listType(component.type)) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| @bl-customComponent-list-theme: @themePrimary; | ||
| @bl-customComponent-list-themeTextColor: @appTextColor; | ||
|
|
||
| @bl-customComponent-list-item-hover-background-color: if(@isLightTheme, rgba(0, 0, 0, 0.04), rgba(255, 255, 255, 0.04)); | ||
|
|
||
| @bl-customComponent-list-item-size: 20px; | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .bl-customComponent-list { | ||
| color: @bl-customComponent-list-themeTextColor; | ||
| user-select: none; | ||
v-excelsior marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| .list { | ||
| margin: @bl-customComponent-list-item-size; | ||
| } | ||
|
|
||
| .list__item { | ||
| padding: @bl-customComponent-list-item-size / 2; | ||
| line-height: 1.3; | ||
| cursor: pointer; | ||
|
|
||
| &:hover { | ||
| background-color: @bl-customComponent-list-item-hover-background-color; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.