Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions components/bl-list-component/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 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).

<p align="center">
<img src="./thumbnail.png" alt="main thumbnail" width="780"/>
</p>

## Properties

| Property | Type | Default value | Logic | Data Binding | UI Setting | Description |
|------------|-----------------------------------------------|---------------|-----------------|--------------|------------|--------------------------------------------------------------------------------------------------|
| Type | *Select* <br> `'Unordered'` <br> `'Ordered'` | `Unordered` | Type Logic | NO | YES | Controls the type of list(ul/ol). |
| List Items | *JSON* <br> `[...{content:'', ?children:[]}]` | `[]` | ListItems Logic | YES | NO | Specifies a JSON array containing data of the list items. Watch [Codeless Examples] (#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. |

## 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));
````

## 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)
95 changes: 95 additions & 0 deletions components/bl-list-component/component.json

Large diffs are not rendered by default.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions components/bl-list-component/preview.html

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions components/bl-list-component/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { useMemo } from 'react'

import { List } from './list'

const { cn } = BackendlessUI.CSSUtils

export default function ListComponent ({ component, eventHandlers }) {

const { style, classList, width, backgroundColor } = component

const styles = useMemo(() => ({ style, width, backgroundColor }), [style, width, backgroundColor])

return (
<div className={ cn('bl-customComponent-list', classList) } style={ styles }>
<List as={ component.type } component={ component } eventHandlers={ eventHandlers }/>
</div>
)
}
29 changes: 29 additions & 0 deletions components/bl-list-component/src/list-content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { List } from './list'

export function ListContent({ component, eventHandlers, children }) {

const { color, fontSize, listItems } = component

const onItemClick = (e, key) => {
e.stopPropagation()
eventHandlers.onClickListItem({ item: key })
}

return (children || listItems || []).map((item, i) => (
<li
key={ i }
className="list__item"
style={{ color: color, fontSize: fontSize }}
onClick={ e => onItemClick(e, item) }
>
{ item.content }
{ item.children && (
<List
component={ component }
children={ item.children }
eventHandlers={ eventHandlers }
/>
) }
</li>
))
}
16 changes: 16 additions & 0 deletions components/bl-list-component/src/list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ListContent } from './list-content'

export function List ({ component, eventHandlers, children, as=component.type }) {

const Component = as

return (
<Component className="list">
<ListContent
component={ component }
children={ children }
eventHandlers={ eventHandlers }
/>
</Component>
)
}
25 changes: 25 additions & 0 deletions components/bl-list-component/styles/index.less
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;

.bl-customComponent-list {
color: @bl-customComponent-list-themeTextColor;
user-select: none;

.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;
}
}
}
Binary file added components/bl-list-component/thumbnail.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.